/*
 * break.beat — the home screen.
 *
 * The 3D world is one small canvas scaled up with nearest-neighbour (see js/scene.js).
 * Everything you can click is ordinary HTML laid over it: menu.js moves the disc
 * button and the menu links every frame so they sit on top of their 3D discs.
 * Without JS the menu is a plain list of links.
 */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.world {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* ---- corners ---------------------------------------------------------------- */

.watermark {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  top: max(16px, env(safe-area-inset-top));
  width: 64px;
  height: auto;
  opacity: 0.32;
  pointer-events: none;
}
:root[data-theme="dark"] .watermark { filter: invert(1) hue-rotate(180deg); opacity: 0.4; }

.hud-top {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 3;
}
.clock {
  font: 12px/1 var(--px);
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

/* ---- the big disc ------------------------------------------------------------ */

.disc {
  position: absolute;
  left: 0;
  top: 0;
  width: 200px;
  height: 200px;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  z-index: 1;
}
.disc img { display: none; }
.disc:focus-visible { outline: 2px dashed var(--accent); outline-offset: 6px; }
.booted .disc { cursor: grab; }
.dragging .disc { cursor: grabbing; }

/* ---- the menu ring ------------------------------------------------------------ */

.js .ring .item {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--d, 48px);
  height: var(--d, 48px);
  margin: calc(var(--d, 48px) / -2) 0 0 calc(var(--d, 48px) / -2);
  border-radius: 50%;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  outline: none;
  z-index: 2;
}
.js .ring .item.on { visibility: visible; }

.item .hit { position: absolute; inset: 0; border-radius: 50%; }
.item:focus-visible .hit { outline: 2px dashed var(--item, var(--accent)); outline-offset: 3px; }

.js .item .label {
  position: absolute;
  left: 50%;
  top: calc(100% + 5px);
  transform: translateX(-50%);
  padding: 4px 7px 3px;
  font: 400 var(--label-size, 13px)/1 var(--px);
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: var(--shadow);
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.leaving .item { pointer-events: none; }
.leaving .item .label { opacity: 0; transition: opacity 0.2s; }
.js .item.is-focus .label {
  color: #fff;
  background: var(--item, var(--accent));
  border-color: var(--item, var(--accent));
}
/* blinking selection cursor */
.js .item.is-focus .label::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%;
  margin-top: -4px;
  border: 4px solid transparent;
  border-left: 5px solid var(--item, var(--accent));
  animation: blink 0.8s steps(2, start) infinite;
}

.info {
  position: absolute;
  left: 50%;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 10px));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 12px/1.2 var(--px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  pointer-events: none;
}
.info.blink { animation: blink 1.1s steps(2, start) infinite; color: var(--ink); }

.hints {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: none;
  font: 10px/1 var(--px);
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 0.6s 0.8s;
  pointer-events: none;
}
.hints kbd {
  display: inline-block;
  margin: 0 3px 0 10px;
  padding: 3px 4px 2px;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
}
.hints kbd:first-child { margin-left: 0; }
@media (pointer: fine) and (min-width: 1000px) {
  .hints { display: block; }
  .booted .hints { opacity: 1; }
}

/* ---- music player (right edge; docks to the bottom on phones) ----------------- */

.player {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  top: 50%;
  z-index: 3;
  width: 150px;
  padding: 10px;
  display: grid;
  gap: 9px;
  font-family: var(--px);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translate(calc(100% + 48px), -50%);
  transition: transform 0.7s cubic-bezier(0.2, 0.9, 0.25, 1.1);
}
.player-on .player { transform: translate(0, -50%); }

.np { display: grid; gap: 4px; min-width: 0; }
.np-k { font-size: 9px; letter-spacing: 0.16em; color: var(--accent); }
.np-title {
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.np-artist { font-size: 10px; color: var(--ink-soft); }
.eq {
  width: 100%;
  aspect-ratio: 15 / 4;
  height: auto;
  image-rendering: pixelated;
}
.ctl { display: flex; justify-content: space-between; gap: 6px; }
.ctl .icon-btn { width: 38px; height: 32px; box-shadow: none; }
.ctl .play { flex: 1; }
.play .i-pause { display: none; }
.play[aria-pressed="true"] .i-play { display: none; }
.play[aria-pressed="true"] .i-pause { display: block; }
.player.waiting .play { animation: blink 1.1s steps(2, start) infinite; }

/* volume: mute beside two sliders, music and SFX */
.vol { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; row-gap: 6px; align-items: center; }
.vol .mute { grid-row: 1 / 3; width: 32px; height: 100%; min-height: 32px; box-shadow: none; }
.mute .i-off, .mute[aria-pressed="true"] .i-on { display: none; }
.mute[aria-pressed="true"] .i-off { display: block; }
.mute[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.vol-row { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 6px; }
.vol-k { font-size: 8px; letter-spacing: 0.1em; color: var(--ink-soft); }
.vol input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.vol input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--panel-edge); }
.vol input[type="range"]::-moz-range-track { height: 4px; background: var(--panel-edge); }
.vol input[type="range"]::-moz-range-progress { height: 4px; background: var(--accent); }
.vol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 14px;
  margin-top: -5px;
  background: var(--accent);
  border: 0;
  border-radius: 0;
}
.vol input[type="range"]::-moz-range-thumb { width: 8px; height: 14px; background: var(--accent); border: 0; border-radius: 0; }
.vol input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.player.muted .vol-row { opacity: 0.45; }

@media (max-width: 700px), (max-aspect-ratio: 1/1) {
  .player {
    top: auto;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    padding: 8px 8px 8px 12px;
    grid-template-columns: 1fr auto;
    align-items: center;
    transform: translateY(calc(100% + 48px));
  }
  .player-on .player { transform: none; }
  .np { grid-template-columns: auto 1fr; column-gap: 8px; }
  .np-k { grid-column: 1 / -1; }
  .np-artist { align-self: end; }
  .eq { display: none; }
  .ctl .icon-btn { width: 40px; height: 36px; }
  .ctl .play { flex: none; }
  /* phones: the volume row runs along the bottom of the docked player */
  .vol { grid-column: 1 / -1; grid-template-columns: auto 1fr 1fr; grid-template-rows: auto; column-gap: 10px; }
  .vol .mute { grid-row: auto; width: 40px; height: 32px; }
  .info { white-space: normal; text-align: center; width: max-content; line-height: 1.5; }
  .player-on .info { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 120px); }
}

/* ---- transitions ---------------------------------------------------------------- */

.flash, .fade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}
.flash { background: var(--flash); }
.flash.go { animation: flash 0.55s ease-out; }
.fade { background: var(--bg-top); transition: opacity 0.45s ease-in 0.12s; }
.leaving .fade { opacity: 1; }

@keyframes flash { from { opacity: 0.9; } to { opacity: 0; } }
@keyframes blink { to { visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  .flash.go { animation: none; }
  .info.blink, .js .item.is-focus .label::before, .player.waiting .play { animation: none; }
}

/* ---- no WebGL: a flat disc stands in, the menu still works --------------------- */

.no-gl .disc {
  background: radial-gradient(circle, var(--accent) 0 66%, transparent 67%);
  box-shadow: var(--shadow);
}
.no-gl .disc img { display: block; width: 100%; height: 100%; animation: spin 10s linear infinite; }
.no-gl .item .hit { background: var(--item, var(--accent)); box-shadow: var(--shadow); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- no JS: a plain list ------------------------------------------------------------ */

html:not(.js) .stage { display: grid; place-items: center; touch-action: auto; }
html:not(.js) .world,
html:not(.js) .disc,
html:not(.js) .player,
html:not(.js) .info,
html:not(.js) .hints,
html:not(.js) .hud-top { display: none; }
html:not(.js) .ring { display: grid; gap: 12px; text-align: center; }
html:not(.js) .ring .item { font: 18px var(--px); text-decoration: none; }
html:not(.js) .ring .item:hover { color: var(--accent); }

/* ---- Orbitron weights: disc labels and the track title bold, small labels medium ------- */

.ring .item .label, .np-title { font-weight: 700; }
.clock, .info, .np-k, .vol-k { font-weight: 500; }
