/* Waxwing — a printed-matter music player.
 *
 * The visual world is a broadsheet, not a dashboard: warm paper, one ink, a
 * spot colour lifted from the cover, hard rules instead of shadows, and the
 * one flourish a print shop earns — the title overprinted twice, slightly out
 * of register. No glass, no purple gradient, no rounded card grid.
 */

:root {
  --paper: #ece4d3;
  --paper-2: #e2d8c2;
  --ink: #17130f;
  --ink-2: #57503f;
  --ink-3: #6e6656;
  --accent: #b3410a;
  --ghost: #0f4c5c;
  --rule: 1px solid var(--ink);
  --rule-2: 2px solid var(--ink);
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --sheet: 82rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  /* The grain overlay is positioned against the body, so it has to be a
     containing block — otherwise `inset: 0` means the viewport, not the page. */
  position: relative;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Film grain over everything. SVG turbulence, so there is no image request. */
.grain {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0.42;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* ── masthead ──────────────────────────────────────────────────────────── */

.masthead { border-bottom: var(--rule-2); }

.masthead-rule {
  max-width: var(--sheet);
  margin: 0 auto;
  padding: 1.1rem 1.5rem 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.wordmark {
  margin: 0;
  font-size: clamp(2rem, 5.4vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.92;
  text-transform: uppercase;
}

.wordmark-stop { color: var(--accent); }

.edition {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.edition-sep { color: var(--ink-3); padding: 0 0.4em; }

/* ── sheet ─────────────────────────────────────────────────────────────── */

.sheet {
  max-width: var(--sheet);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr) minmax(15rem, 20rem);
  align-items: stretch;
}

.col-title {
  margin: 0;
  padding: 0.9rem 0 0.45rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  border-bottom: var(--rule-2);
}

/* ── rail ──────────────────────────────────────────────────────────────── */

.rail { padding-right: 1.5rem; }

.queue { padding-left: 1.5rem; }

/* Columns stretch to the tallest, and their foot block is pushed to the
   bottom, so the sheet reads as one grid rather than three unrelated stacks. */
.rail, .queue { display: flex; flex-direction: column; }

.results, .library { margin-bottom: 1.4rem; }

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: var(--rule);
  margin-top: 0.9rem;
}

.tab {
  appearance: none;
  border: 0;
  border-right: var(--rule);
  background: transparent;
  padding: 0.5rem 0.2rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
}

.tab:last-child { border-right: 0; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.tab:hover:not([aria-selected="true"]) { background: var(--paper-2); }

.search { display: flex; margin-top: 0.9rem; }

.search input {
  flex: 1;
  min-width: 0;
  border: var(--rule);
  border-right: 0;
  background: rgb(255 255 255 / 0.42);
  padding: 0.55rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink);
}

.search input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.source-note {
  margin: 0.6rem 0 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--ink-2);
  min-height: 2.4em;
}

.results-status {
  margin: 0.9rem 0 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.results { list-style: none; margin: 0; padding: 0; }

.result {
  width: 100%;
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.55rem 0.2rem;
  border: 0;
  border-bottom: var(--rule);
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.result:hover { background: rgb(255 255 255 / 0.55); }
.result:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.result-index {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-3);
}

.result-title {
  display: block;
  font-size: 0.9rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-artist {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-badge {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: var(--rule);
  padding: 0.1rem 0.35rem;
  color: var(--ink-2);
  white-space: nowrap;
}

.result-badge[data-mode="html5"] { background: var(--ink); color: var(--paper); }

.results-empty {
  padding: 1rem 0.2rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-3);
  border-bottom: var(--rule);
}

/* ── stage ─────────────────────────────────────────────────────────────── */

.stage {
  border-left: var(--rule);
  border-right: var(--rule);
  padding: 1.2rem 1.5rem 2rem;
  min-height: 30rem;
}

.plate {
  position: relative;
  width: min(100%, 20rem);
  margin: 0 0 1.4rem;
}

.plate-offset {
  position: absolute;
  inset: 0;
  transform: translate(9px, 9px);
  background: var(--accent);
  z-index: 0;
}

.art {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--paper-2);
  border: var(--rule-2);
}

.track-title {
  position: relative;
  margin: 0;
  font-size: clamp(1.9rem, 4.4vw, 3.1rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.02;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

/* The overprint: the same words a third of a centimetre out of register. */
.title-ghost {
  position: absolute;
  inset: 0;
  color: var(--ghost);
  mix-blend-mode: multiply;
  opacity: 0.75;
  transform: translate(-0.045em, 0.035em);
  pointer-events: none;
}

.title-ink { position: relative; }

.track-sub {
  margin: 0.55rem 0 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  max-width: 46ch;
}

.lyrics {
  margin: 1.1rem 0 0;
  max-height: 8.5rem;
  overflow: auto;
  border-top: var(--rule);
  border-bottom: var(--rule);
  padding: 0.5rem 0;
}

.lyrics-lines { list-style: none; margin: 0; padding: 0; }

.lyrics-lines li {
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.7;
  color: var(--ink-3);
  transition: color 120ms ease-out;
}

.lyrics-lines li.is-active { color: var(--accent); font-weight: 700; }

.viz-strip {
  margin: 1.1rem 0 0;
  border-top: var(--rule);
  border-bottom: var(--rule);
  padding: 0.35rem 0;
}

#visualizer { display: block; width: 100%; height: 5.5rem; }

.scrub {
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.time {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.time:last-child { text-align: right; }

.transport {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.transport-gap { flex: 1; }

.btn {
  appearance: none;
  border: var(--rule);
  background: transparent;
  color: var(--ink);
  padding: 0.5rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn:hover { background: var(--paper-2); }
.btn:active { transform: translate(1px, 1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: var(--ink-2); }

.btn-transport {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  display: grid;
  place-items: center;
  position: relative;
}

.btn-transport svg {
  width: 1.05rem; height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: bevel;
  stroke-linecap: square;
}

.btn-transport[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.btn-play {
  width: 3.6rem;
  height: 3.6rem;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

.btn-play:hover { background: var(--ink); border-color: var(--ink); }

.btn-play svg { width: 1.4rem; height: 1.4rem; fill: currentColor; stroke: none; }
.btn-play .icon-pause { display: none; }
body.is-playing .btn-play .icon-play { display: none; }
body.is-playing .btn-play .icon-pause { display: block; }

.repeat-badge {
  position: absolute;
  top: -0.4rem; right: -0.4rem;
  background: var(--accent);
  color: var(--paper);
  font-size: 0.55rem;
  line-height: 1;
  padding: 0.2rem 0.28rem;
}

.volume-row {
  display: grid;
  grid-template-columns: 2.6rem 1fr auto;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

/* Square, ink, no pill — a fader from a mixing desk, not a pill. */
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 1.4rem;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--ink);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 0.85rem; height: 1.1rem;
  margin-top: -0.45rem;
  background: var(--accent);
  border: var(--rule);
  border-radius: 0;
}

input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--ink);
}

input[type="range"]::-moz-range-thumb {
  width: 0.85rem; height: 1.1rem;
  background: var(--accent);
  border: var(--rule);
  border-radius: 0;
}

input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="range"]:disabled { opacity: 0.3; cursor: default; }

.eq-panel {
  margin-top: 1rem;
  border: var(--rule-2);
  padding: 0.8rem 0.9rem 1rem;
  background: rgb(255 255 255 / 0.35);
}

.eq-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.eq-head h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.btn-small { padding: 0.3rem 0.55rem; font-size: 0.64rem; }

.eq-presets { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.7rem 0 0.9rem; }

.chip {
  appearance: none;
  border: var(--rule);
  background: transparent;
  padding: 0.28rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.chip:hover { background: var(--ink); color: var(--paper); }
.chip.is-active { background: var(--ink); color: var(--paper); }

/* A rack, not ten vertical faders: five columns of horizontal sliders, each
   labelled with its centre frequency and its current gain. */
.eq-bands {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem 1rem;
}

.eq-band {
  display: grid;
  gap: 0.2rem;
  align-content: start;
}

.eq-band-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink-2);
}

.eq-band input { height: 1.2rem; }

.eq-note {
  margin: 0.8rem 0 0;
  font-family: var(--mono);
  font-size: 0.66rem;
  line-height: 1.5;
  color: var(--ink-3);
}

/* ── queue ─────────────────────────────────────────────────────────────── */

.queue-tools { display: flex; gap: 0.5rem; margin-top: 0.9rem; }

.queue-count {
  margin: 0.9rem 0 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.library { list-style: none; margin: 0; padding: 0; }

.library-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.65rem 0.35rem;
  border: 0;
  border-bottom: var(--rule);
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.library-item:hover { background: rgb(255 255 255 / 0.55); }
.library-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.library-item[aria-current="true"] { background: var(--ink); color: var(--paper); }
.library-item[aria-current="true"] .library-artist,
.library-item[aria-current="true"] .library-index { color: var(--paper); }

.library-index {
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--ink-3);
}

.library-title {
  display: block;
  font-size: 0.88rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-artist {
  display: block;
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-meta {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: right;
}

.empty { margin-top: 1.4rem; border: var(--rule); padding: 0.9rem 1rem; }

.empty-rule { height: 0.4rem; background: var(--accent); margin: 0 0 0.7rem; }

.empty p { margin: 0 0 0.5rem; font-size: 0.9rem; }

.empty-sub {
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.empty code { font-size: 0.66rem; background: var(--paper-2); padding: 0.05rem 0.25rem; }

/* ── supporting blocks ─────────────────────────────────────────────────── */

.rail-foot, .queue-foot {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: var(--rule);
}

.rail-foot h3, .queue-foot h3 {
  margin: 0 0 0.55rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.keys { list-style: none; margin: 0; padding: 0; }

.keys li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.22rem 0;
  border-bottom: 1px dotted var(--ink-3);
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-2);
}

.keys kbd {
  font: inherit;
  color: var(--ink);
  background: var(--paper-2);
  padding: 0.05rem 0.3rem;
  white-space: nowrap;
}

.notes { margin: 0; padding: 0; list-style: none; }

.notes li {
  position: relative;
  padding: 0 0 0.6rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.notes li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 0.4rem;
  height: 2px;
  background: var(--accent);
}

/* ── colophon / toast ──────────────────────────────────────────────────── */

.colophon {
  max-width: var(--sheet);
  margin: 0 auto;
  padding: 1.2rem 1.5rem 3rem;
}

.colophon p {
  margin: 0;
  padding-top: 0.8rem;
  border-top: var(--rule-2);
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--ink);
  color: var(--paper);
  border: var(--rule-2);
  padding: 0.6rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  max-width: min(90vw, 40rem);
}

body.is-dragging .sheet { outline: 3px solid var(--accent); outline-offset: -0.6rem; }

/* ── responsive ────────────────────────────────────────────────────────── */

@media (max-width: 62rem) {
  .sheet { grid-template-columns: minmax(14rem, 1fr) minmax(0, 1.6fr); }
  .queue { grid-column: 1 / -1; border-left: 0; border-top: var(--rule-2); margin-top: 1.5rem; padding-left: 0; }
  .stage { border-right: 0; }
}

@media (max-width: 44rem) {
  .sheet { grid-template-columns: 1fr; }
  .rail { padding-right: 0; }
  .stage { border-left: 0; border-top: var(--rule-2); padding: 1.2rem 0 2rem; min-height: 0; }
  .eq-bands { grid-template-columns: repeat(5, 1fr); }
  .masthead-rule { padding: 0.9rem 1rem 0.7rem; }
  .sheet { padding: 0 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lyrics-lines li { transition: none; }
  .btn:active { transform: none; }
}
