/*
 * Deep Cuts — "the back of the sleeve".
 * The page reads like the reverse of an LP: a catalogue number, a numbered tracklist with dotted
 * leaders to the running times, and fine print at the foot (℗ year). Light mode is a cool card
 * stock, dark mode a matte black sleeve; the one accent is the label's ultramarine.
 */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('../fonts/archivo-latin-wdth-normal.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Courier Prime';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/courier-prime-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Courier Prime';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/courier-prime-latin-700-normal.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --bg: #e6e5e0;
  --card: #efeeea;
  --raise: #dddcd6;
  --ink: #141414;
  --muted: #575550;
  --faint: #b9b7b0;
  --rule: #cfcdc6;
  --accent: #2337c6;
  --good: #1f6b3a;
  --shadow: rgba(20, 20, 20, 0.08);

  --sans: 'Archivo', 'Helvetica Neue', Arial, system-ui, sans-serif;
  --type: 'Courier Prime', 'Courier New', ui-monospace, monospace;

  --measure: 34rem;
  --gutter: clamp(1rem, 5vw, 1.75rem);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121212;
    --card: #1a1a19;
    --raise: #242422;
    --ink: #ecebe6;
    --muted: #a3a19a;
    --faint: #44433f;
    --rule: #2e2e2b;
    --accent: #9aa6ff;
    --good: #8fd1a4;
    --shadow: rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

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

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--bg);
  z-index: 30;
}
.skip:focus {
  top: 1rem;
}

/* Author display rules must never beat the hidden attribute. */
[hidden] {
  display: none !important;
}

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

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) var(--gutter) 0.5rem;
}

/* The wordmark is set the way sleeves set band names: extra-wide, heavy, tightly tracked. */
.wordmark {
  font: 800 1.35rem/1 var(--sans);
  font-stretch: 125%;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-decoration: none;
}

.bar-actions {
  display: flex;
  gap: 0.25rem;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    color 160ms var(--ease),
    background 160ms var(--ease);
}
.icon-btn:hover {
  color: var(--ink);
  background: var(--raise);
}
.icon-btn svg {
  width: 1.375rem;
  height: 1.375rem;
}

/* ----------------------------------------------------------------- main column */

main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 1rem var(--gutter) 2.5rem;
}

/* ----------------------------------------------------------------- the sleeve */

.sleeve {
  padding: 1.25rem 1.25rem 1rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--shadow);
}

/* The catalogue line: "DC-018 · STEREO · SUNDAY 1 NOVEMBER". */
.cat {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--ink);
  font: 700 0.75rem/1.3 var(--type);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cat span:last-child {
  color: var(--muted);
  font-weight: 400;
  text-align: right;
}

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

/* One printed line: number, title, a dotted leader, the running time. */
.trk {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0;
}
.trk-n {
  font: 400 0.875rem/1 var(--type);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.trk-title {
  display: flex;
  align-items: baseline;
  min-width: 0;
  font: 500 clamp(1.05rem, 4.6vw, 1.25rem) / 1.3 var(--sans);
  letter-spacing: -0.005em;
}
.trk-title span {
  overflow-wrap: anywhere;
}
.trk-title::after {
  content: '';
  flex: 1;
  min-width: 1.5rem;
  margin: 0 0 0.3em 0.5rem;
  border-bottom: 2px dotted var(--faint);
}
.trk-time {
  font: 400 0.875rem/1 var(--type);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* The biggest hit, once it plays: the one line printed bold. */
.trk--hit .trk-title {
  font-weight: 750;
}

/* Tracks still to come: the groove is cut but nothing's printed on it yet. */
.trk--locked .trk-n,
.trk--locked .trk-time {
  color: var(--faint);
}
.trk--locked .trk-n::before,
.trk--locked .trk-time::before {
  content: attr(data-mark);
}
/* A locked line keeps a played line's height, so nothing below shifts when a track drops in. */
.trk--locked .trk-title {
  min-height: 1.3em;
  align-items: center;
}
.trk--locked .trk-title::before {
  content: '';
  display: block;
  width: var(--w, 50%);
  height: 0.5em;
  border-radius: 2px;
  background: var(--raise);
}
.trk--locked .trk-title::after {
  border-bottom-color: transparent;
}

/* A track that just played drops in from above, like the needle settling into a groove. */
.trk--new {
  animation: drop 520ms var(--ease) both;
}
@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-0.6rem);
  }
}

/* Fine print at the foot of the sleeve: ℗ year once it's earned. */
.fine {
  display: flex;
  justify-content: space-between;
  margin: 0.9rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule);
  font: 400 0.75rem/1.4 var(--type);
  letter-spacing: 0.04em;
  color: var(--muted);
}
.fine b {
  color: var(--ink);
}
.fine-genre {
  color: var(--ink);
  text-align: right;
  text-transform: uppercase;
}

/* ----------------------------------------------------------------- status + guess */

.status {
  margin: 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--card);
}
.status:empty {
  display: none;
}
.status .btn {
  display: flex;
  width: fit-content;
  margin-top: 0.75rem;
}

/* The desk: errors, then the result once the game ends (before the guesses that led to it),
   then the guess box and history. */
.desk {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.combo {
  position: relative;
}

.combo input {
  width: 100%;
  height: 3.5rem;
  padding: 0 3.75rem 0 1.1rem;
  border: 1px solid var(--faint);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  font: 400 1.0625rem/1 var(--sans);
  transition: border-color 160ms var(--ease);
}
.combo input::placeholder {
  color: var(--muted);
}
.combo input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.combo input:disabled {
  opacity: 0.6;
}

.guess-go {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  display: grid;
  place-items: center;
  width: 2.7rem;
  height: 2.7rem;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--card);
  cursor: pointer;
}
.guess-go:disabled {
  opacity: 0.35;
  cursor: default;
}
.guess-go svg {
  width: 1.25rem;
  height: 1.25rem;
}

.options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 5;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border: 1px solid var(--faint);
  border-radius: 4px;
  background: var(--card);
  box-shadow: 0 18px 40px var(--shadow);
  max-height: min(22rem, 50vh);
  overflow-y: auto;
}
.options li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.1rem 1rem;
  padding: 0.55rem 0.7rem;
  border-radius: 3px;
  cursor: pointer;
}
.options li[aria-selected='true'] {
  background: var(--raise);
}
.opt-title {
  font-weight: 600;
}
.opt-artist {
  grid-column: 1;
  font-size: 0.875rem;
  color: var(--muted);
}
.opt-year {
  grid-row: 1;
  grid-column: 2;
  font: 400 0.8125rem/1.6 var(--type);
  color: var(--muted);
}

.guess-count {
  margin: 0.6rem 0 0;
  font: 400 0.8125rem/1.4 var(--type);
  color: var(--muted);
}

/* Guesses are filed below like catalogue cards. */
.guesses {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}
/* One line per guess, newest first: album and artist on the left, the verdicts on the right. */
.guess {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--rule);
}
.guess-head {
  min-width: 0;
}
.guess--latest .guess-title {
  color: var(--accent);
}
.guess-title {
  font-weight: 650;
}
.guess-by {
  color: var(--muted);
}
.guess-year {
  color: var(--muted);
  font-family: var(--type);
  font-size: 0.8125rem;
  margin-left: 0.4rem;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.chip {
  font: 400 0.6875rem/1 var(--type);
  padding: 0.3rem 0.45rem;
  border-radius: 2px;
  border: 1px solid var(--faint);
  color: var(--muted);
  white-space: nowrap;
}
.chip--good {
  border-color: var(--good);
  color: var(--good);
}

/* ----------------------------------------------------------------- result */

.result {
  order: -1;
}
.result-kicker {
  margin: 0;
  font: 700 0.75rem/1.4 var(--type);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.result-title {
  margin: 0.4rem 0 0.25rem;
  font: 800 clamp(2rem, 9.5vw, 3rem) / 1 var(--sans);
  font-stretch: 125%;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  text-wrap: balance;
}
.result-sub {
  margin: 0;
  font-size: 1.0625rem;
}
.result-sub span {
  color: var(--muted);
}

/* The full running order after the game, with the tracks you were dealt marked. */
.side {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 2px solid var(--ink);
  columns: 2 14rem;
  column-gap: 1.5rem;
}
.side li {
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 0.25rem;
  padding: 0.2rem 0;
  break-inside: avoid;
  font-size: 0.9375rem;
  color: var(--muted);
}
.side li.dealt {
  color: var(--ink);
  font-weight: 600;
}
.side .side-n {
  font: 400 0.8125rem/1.6 var(--type);
}
.side li.dealt .side-n {
  color: var(--accent);
  font-weight: 700;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  align-items: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 3rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font: 600 0.9375rem/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.btn svg {
  width: 1.1rem;
  height: 1.1rem;
}
.btn--quiet {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--faint);
}
.countdown {
  margin: 1.25rem 0 0;
  font: 400 0.8125rem/1.4 var(--type);
  color: var(--muted);
}
.source {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ----------------------------------------------------------------- footer */

.foot {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 1.25rem var(--gutter) max(2rem, env(safe-area-inset-bottom));
  font-size: 0.875rem;
  color: var(--muted);
}
.foot p {
  margin: 0.25rem 0;
}

/* ----------------------------------------------------------------- dialogs */

.sheet {
  width: min(30rem, calc(100vw - 2rem));
  padding: 1.5rem 1.5rem 1.75rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
}
.sheet::backdrop {
  background: rgba(10, 10, 10, 0.6);
}
.sheet[open] {
  animation: sheet-in 260ms var(--ease);
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -0.5rem -0.75rem 0.5rem 0;
}
.sheet h2 {
  margin: 0;
  font: 800 1.5rem/1.1 var(--sans);
  font-stretch: 125%;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.rules {
  padding-left: 1.2rem;
}
.rules li {
  margin: 0.5rem 0;
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}
.stat-row div {
  text-align: center;
}
.stat-row dt {
  font: 400 0.6875rem/1.3 var(--type);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-row dd {
  margin: 0 0 0.25rem;
  font: 700 2rem/1 var(--sans);
  font-stretch: 115%;
}
.dist-title {
  margin: 1rem 0 0.5rem;
  font: 700 0.75rem/1.4 var(--type);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.dist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.dist li {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.6rem;
  align-items: center;
  margin: 0.3rem 0;
  font: 400 0.8125rem/1 var(--type);
}
.dist .bar-fill {
  display: block;
  min-width: 1.75rem;
  padding: 0.3rem 0.45rem;
  border-radius: 2px;
  background: var(--raise);
  text-align: right;
}
.dist .is-today .bar-fill {
  background: var(--accent);
  color: var(--card);
}
.next {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 2rem);
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9375rem;
  white-space: pre-line;
  z-index: 20;
}

/* ----------------------------------------------------------------- about + 404 */

.prose h1 {
  margin: 0.5rem 0 1rem;
  font: 800 clamp(2rem, 9vw, 2.75rem) / 1.05 var(--sans);
  font-stretch: 125%;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}
.prose h2 {
  margin: 2rem 0 0.5rem;
  font: 700 0.8125rem/1.4 var(--type);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.prose .cat {
  border: 0;
  padding: 0;
  margin: 0 0 0.5rem;
  color: var(--muted);
}

/* ----------------------------------------------------------------- wide screens */

/* Two columns: the sleeve on the left stays put (sticky) while guesses and the result fill the
   right, so the tracks and the feedback are both in view without scrolling. */
/* Phones: the whole sleeve, the guess box and the latest verdict share one screen, so a guess
   never means scrolling between the track it revealed and what it was told. */
@media (max-width: 40rem) {
  main {
    padding-top: 0.25rem;
  }
  .sleeve {
    padding: 0.85rem 1rem 0.6rem;
  }
  .cat {
    margin-bottom: 0.5rem;
    padding-bottom: 0.55rem;
  }
  .trk {
    padding: 0.28rem 0;
  }
  .trk-title {
    font-size: clamp(1rem, 4.3vw, 1.0625rem);
    line-height: 1.25;
  }
  .fine {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }
  .desk {
    margin-top: 1rem;
  }
}

@media (min-width: 60rem) {
  .bar,
  main,
  .foot {
    max-width: calc(64rem + 2 * var(--gutter));
  }
  main {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 3.5rem;
    align-items: start;
  }
  .sleeve {
    position: sticky;
    top: 1.25rem;
  }
  .desk {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Back to the other games at ringanybells.xyz: one quiet line above the bar, on every page. The
   link is relative, so it reaches the hub's home from /<game>/ and /<game>/about alike. */
.hub {
  box-sizing: border-box;
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: max(0.5rem, env(safe-area-inset-top)) var(--gutter) 0;
  font: 500 0.75rem/1 var(--sans);
  letter-spacing: 0.04em;
}
.hub a {
  display: inline-block;
  padding: 0.4rem 0;
  color: var(--muted);
  text-decoration: none;
}
.hub a:hover {
  color: var(--ink);
}
.hub + .bar {
  padding-top: 0.25rem;
}
