/* VIZ. Dark on purpose and not as a preference: the canvas is the content, and
   a bright page around it drags the eye off the one thing that is moving.
   Colours here are the same ramp theme.js draws with. */

:root {
  --bg: #0b0d18;
  --panel: #12152400;
  --panel-solid: #141829;
  --line: rgba(233, 230, 242, 0.12);
  --ink: #e9e6f2;
  --dim: rgba(233, 230, 242, 0.55);
  --accent: #764ed6;
  --accent-hot: #e64894;
  --bad: #ff8a9b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute is only a UA-stylesheet `display: none`, so ANY author
   rule that sets display beats it -- and `.row { display: flex }` below does
   exactly that. Without this line the transport bar renders on first load with
   nothing loaded, seek at zero and a Play button that does nothing. It is the
   whole reason `hidden` has a reputation for not working. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  font:
    15px/1.55 system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  min-height: 100vh;
  padding: 0 20px 40px;
}

/* --------------------------------------------------------------------- bar */

.bar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 2px 16px;
  flex-wrap: wrap;
}

.bar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.22em;
  font-weight: 600;
  background: linear-gradient(92deg, var(--accent), var(--accent-hot) 70%, #ffe2a8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tag {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
}

.home {
  margin-left: auto;
  color: var(--dim);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px solid transparent;
}

.home:hover {
  color: var(--ink);
  border-bottom-color: var(--line);
}

main {
  max-width: 1100px;
  margin: 0 auto;
}

/* ------------------------------------------------------------------- stage */

.stage-wrap {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* The canvas has an explicit CSS height because its pixel grid is set FROM the
   measured box. Left to size itself it would be 150px tall (the replaced-element
   default), and the picture would be a letterbox slot. */
#stage {
  display: block;
  width: 100%;
  height: min(58vh, 460px);
}

/* Fullscreen gives the wrapper the whole screen; the canvas has to be told to
   take it, or it keeps the 460px cap and floats in a black field. */
.stage-wrap:fullscreen {
  border: 0;
  border-radius: 0;
}

.stage-wrap:fullscreen #stage {
  height: 100vh;
}

.overlay {
  position: absolute;
  inset: 10px 10px auto 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none; /* the canvas keeps the space; only controls take clicks */
}

.overlay > * {
  pointer-events: auto;
}

.tabs {
  display: flex;
  gap: 4px;
  background: rgba(11, 13, 24, 0.66);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  backdrop-filter: blur(6px);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-pressed='true'] {
  background: linear-gradient(100deg, var(--accent), var(--accent-hot));
  color: #fff;
}

.gainbox {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(11, 13, 24, 0.66);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  backdrop-filter: blur(6px);
}

.mini {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.mini:hover {
  color: var(--ink);
  background: rgba(233, 230, 242, 0.08);
}

/* Wide enough for "auto ×128" without the row twitching as the number grows. */
.mini.wide {
  min-width: 8ch;
  font:
    11px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}

.mini.wide[aria-pressed='true'] {
  color: var(--ink);
}

.ghost {
  margin-left: auto;
  appearance: none;
  background: rgba(11, 13, 24, 0.66);
  border: 1px solid var(--line);
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.ghost:hover {
  color: var(--ink);
}

.hint {
  margin: 10px 2px 18px;
  color: var(--dim);
  font-size: 13px;
}

/* ------------------------------------------------------------------- panel */

.panel {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.panel.over {
  border-color: var(--accent-hot);
  background: #1a1730;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.transport {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

button {
  appearance: none;
  border: 1px solid var(--line);
  background: #1b1f33;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 8px 15px;
  border-radius: 8px;
  cursor: pointer;
}

button:hover {
  border-color: rgba(233, 230, 242, 0.3);
}

button.primary[aria-pressed='true'] {
  background: linear-gradient(100deg, var(--accent), var(--accent-hot));
  border-color: transparent;
  color: #fff;
}

.src {
  margin-left: auto;
  color: var(--dim);
  font-size: 13px;
}

.src strong {
  color: var(--ink);
  font-weight: 500;
  /* A long filename should not push the buttons around. */
  display: inline-block;
  max-width: 34ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

#seek {
  flex: 1 1 220px;
  min-width: 140px;
}

input[type='range'] {
  accent-color: var(--accent-hot);
  height: 22px;
}

.time {
  color: var(--dim);
  font:
    12px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  min-width: 11ch;
  text-align: right;
}

.vol {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
  font-size: 12px;
}

.vol input {
  width: 90px;
}

.status {
  margin: 14px 0 0;
  color: var(--dim);
  font-size: 13px;
}

.status.bad {
  color: var(--bad);
}

/* -------------------------------------------------------------------- note */

.note {
  margin-top: 22px;
  color: var(--dim);
  font-size: 13px;
  max-width: 66ch;
}

.note strong {
  color: var(--ink);
}

.keys {
  margin-top: 10px;
}

kbd {
  font:
    11px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink);
}

@media (max-width: 620px) {
  .src {
    margin-left: 0;
    width: 100%;
  }
  .overlay {
    flex-wrap: wrap;
  }
}

/* An animated visualiser is the definition of motion, so honour the setting
   where it is cheap to: the idle line and the tab transitions stop. The canvas
   itself only moves while sound is playing, which is a deliberate act. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
