/* pocket.css — all styling for Pocket. Dark only.
 *
 * Owns: the tokens (the whole palette), the page frame lifted from
 * chords.html (body, buttons, overlay), and every size, which is set for a
 * reader 3–6 feet from the screen and moving. The page is one mark: the red
 * tick is the beat, the rings are the beats on their way in, the dot is the
 * clap, the number and the word say the rest. Red is spent on the beat and
 * on nothing else: a beat you clap on is red (ring, pulse, count), a beat
 * that goes by is grey. Must not: introduce a colour that is not a token, draw
 * cards, rounded containers, shadows, gradients, monospace, icons or
 * borders. Chrome is typographic: a control is a word that changes colour.
 * Transitions are 0.15–0.35 s ease, exactly as Chords.
 *
 * Every size on the stage is in em of --s, so the same page scales from a
 * phone held upright to a laptop across the room.
 */

:root {
  --bg: #1c1b19; --ink: #e8e5df; --soft: #6b675f; --faint: #33312d;
  --seal: #b23a2c;   /* site seal red — the beat ONLY */
  --s: clamp(9px, 1.55vw, 17px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--ink);
  touch-action: manipulation; /* no double-tap zoom on a page you tap to the beat */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  font-size: var(--s);
}

button {
  font-family: inherit;
  background: none;
  border: none;
  color: var(--soft);
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
  -webkit-appearance: none;
  appearance: none;
  letter-spacing: inherit;
}
button:hover { color: var(--ink); }
button.on { color: var(--ink); }
button:disabled { opacity: 0.35; cursor: default; }
:focus-visible { outline: 1px solid var(--soft); outline-offset: 4px; }
button:focus:not(:focus-visible) { outline: none; }

/* ---- the two corner lines ------------------------------------------------- */

header { position: absolute; left: 0; right: 0; top: 0; z-index: 2; pointer-events: none; }
header .tl, header .tr {
  position: absolute; top: 1.5em;
  font-size: 0.8em; letter-spacing: 0.12em; color: var(--soft); line-height: 1;
}
header .tl { left: 1.9em; }
header .tr { right: 1.9em; text-align: right; pointer-events: auto; padding: 0.4em 0; }
header .tr:hover { color: var(--ink); }
body.running header { visibility: hidden; }

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

#stage { position: relative; flex: 1; min-height: 0; cursor: pointer; }
body.running #stage { cursor: default; }

.stack { position: absolute; left: 0; right: 0; top: 24%; text-align: center; transition: opacity 0.35s; }
.num {
  font-size: 9em; font-weight: 600; line-height: 1; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.num .unit { font-size: 0.22em; font-weight: 500; color: var(--soft); margin-left: 0.2em; letter-spacing: 0; }
.word { font-size: 1.8em; font-weight: 500; color: var(--soft); margin-top: 0.35em; min-height: 1.25em; line-height: 1.25; }
.stack.dim { opacity: 0.3; }

.track { position: absolute; left: 12%; right: 12%; top: 68%; height: 0; border-top: 1px solid var(--faint); }
.beat {
  position: absolute; left: 50%; top: -1.4em; width: 2px; height: 2.8em;
  background: var(--seal); transform: translateX(-50%); border-radius: 1px;
}
.beat::after {
  content: ""; position: absolute; inset: -0.6em -0.6em; border-radius: 50%;
  background: var(--seal); opacity: 0; transform: scale(0.4);
}
.beat.pulse::after { animation: pulse 0.42s ease-out; }
@keyframes pulse { 0% { opacity: 0.55; transform: scale(0.4); } 100% { opacity: 0; transform: scale(1.6); } }
/* the beats on their way in: rings that close on the tick and land on it at the beat */
.ring {
  position: absolute; left: 50%; top: 0; width: 9em; height: 9em; border-radius: 50%;
  border: 0.12em solid var(--seal); transform: translate(-50%, -50%) scale(var(--f, 1));
  opacity: var(--o, 0.4); pointer-events: none; will-change: transform, opacity;
}
.ring.down { border-width: 0.2em; }
/* a beat that just goes by: grey, dashed, and quieter than a beat you clap on */
.ring.pass { border-color: var(--soft); border-style: dashed; opacity: calc(var(--o, 0.4) * 0.55); }
.ring.none { display: none; }
.beat.pulse-pass::after { background: var(--soft); animation: pulsePass 0.3s ease-out; }
@keyframes pulsePass { 0% { opacity: 0.4; transform: scale(0.3); } 100% { opacity: 0; transform: scale(0.9); } }
/* the count that just landed, under the tick, until the next one: red when it was yours */
.tickcount {
  position: absolute; left: 50%; top: 2.1em; transform: translateX(-50%);
  font-size: 1.7em; font-weight: 600; color: var(--soft); line-height: 1;
  font-variant-numeric: tabular-nums; pointer-events: none; transition: color 0.1s;
}
.tickcount.target { color: var(--seal); }
.tickcount.none { display: none; }
/* the one line of instruction, above the line, always there: the counts you
 * clap on, and the song (or the click). Both are ways into the settings at
 * any time; during a session a tap on one ends the session first. */
.instr {
  position: absolute; left: 0; right: 0; top: 55%;
  display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 0 0.5em;
  font-size: 0.85em; letter-spacing: 0.12em; color: var(--soft); line-height: 1.4;
}
.instr button { font-size: inherit; letter-spacing: inherit; color: var(--soft); padding: 0.3em 0.2em; line-height: inherit; }
.instr button:hover { color: var(--ink); }
.instr .dot { color: var(--faint); }
.instr b { color: var(--ink); font-weight: 600; font-size: 1.25em; letter-spacing: 0.06em; }
.clap, .ghost {
  position: absolute; top: 0; left: 50%; width: 1.5em; height: 1.5em; border-radius: 50%;
  background: var(--ink); transform: translate(-50%, -50%);
}
.clap { transition: left 0.12s ease-out, opacity 0.3s; }
.clap.hollow { background: none; border: 2px solid var(--ink); }
.clap.none { opacity: 0; }
.ghost { width: 1em; height: 1em; opacity: 0.45; animation: fade 2.6s linear forwards; pointer-events: none; }
@keyframes fade { to { opacity: 0; } }

.status {
  position: absolute; left: 0; right: 0; bottom: 5.4em; text-align: center;
  font-size: 0.8em; letter-spacing: 0.12em; color: var(--soft); line-height: 1.6; min-height: 1.6em;
}
.status:empty { display: none; }
.hint {
  position: absolute; left: 0; right: 0; bottom: 2.2em; text-align: center;
  font-size: 0.8em; letter-spacing: 0.12em; color: var(--soft); line-height: 1.6;
}
.hint b { color: var(--ink); font-weight: 500; }
.hint:empty { display: none; }
/* the only way to end a session: a word in ink with a generous hit area */
.stop {
  position: absolute; left: 50%; bottom: 1.4em; transform: translateX(-50%);
  font-size: 0.85em; letter-spacing: 0.12em; color: var(--ink); line-height: 1;
  padding: 0.9em 1.8em; border-radius: 999px; z-index: 2;
}
.stop:hover { color: var(--soft); }
.stop.none { display: none; }

/* ---- the settings sheet ---------------------------------------------------- */

.sheet { position: fixed; inset: 0; background: var(--bg); z-index: 5; padding: 2.2em 2.4em; overflow-y: auto; }
.sheet .title { font-size: 0.8em; letter-spacing: 0.12em; color: var(--soft); }
.sheet .rows { margin-top: 1.4em; max-width: 60em; }
.sheet .row {
  display: grid; grid-template-columns: 7.5em 1fr; align-items: baseline; gap: 0.6em 1em;
  padding: 0.7em 0; border-top: 1px solid var(--faint); font-size: 1.15em; line-height: 1.5;
}
.sheet .row:first-child { border-top: 0; }
.sheet .k { font-size: 0.7em; letter-spacing: 0.12em; color: var(--soft); }
.sheet .v { color: var(--ink); font-variant-numeric: tabular-nums; }
.sheet .v .s { color: var(--soft); }
.sheet .v .dot { color: var(--faint); padding: 0 0.4em; }
.sheet .v button { color: var(--soft); padding: 0.2em 0.45em; }
.sheet .v button:hover { color: var(--ink); }
.sheet .v button.on { color: var(--ink); }
.sheet .counts { display: inline-flex; gap: 0 0.6em; margin-right: 0.8em; }
.sheet .counts button {
  min-width: 1.2em; text-align: center; padding: 0 0 0.1em;
  border-bottom: 2px solid var(--faint); color: var(--soft); border-radius: 0;
}
.sheet .counts button.on { color: var(--ink); border-bottom-color: var(--ink); }
.sheet .done { position: fixed; right: 2.4em; bottom: 2em; font-size: 1.15em; color: var(--ink); padding: 0.4em 0; }
.sheet .done:hover { color: var(--soft); }
@media (max-width: 640px) {
  .sheet .row { grid-template-columns: 1fr; gap: 0.2em; }
}

/* ---- a phone holds the page upright ------------------------------------- */

@media (max-width: 640px) {
  :root { --s: clamp(8px, 2.6vw, 12px); }
  .stack { top: 22%; }
  .instr { top: 47%; }
  .track { top: 60%; }
  /* the site Menu pill sits bottom-left; the bottom lines step above it */
  .status { bottom: 10.6em; }
  .hint { bottom: 7.4em; }
  .stop { bottom: 6.6em; }
}

/* ---- overlay: entry, calibration, song ----------------------------------- */

#overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  cursor: pointer;
  z-index: 10;
  overflow-y: auto;
  padding: 32px 24px;
  font-size: 16px;
}
#overlay.settled { cursor: pointer; }
#overlay:not(.settled) { cursor: default; }
#overlay button { font-size: 17px; padding: 8px 10px; border-radius: 8px; }
#overlay button.on { color: var(--ink); }
input[type="range"] {
  accent-color: var(--soft);
  width: min(240px, 80vw);
  background: none;
  cursor: pointer;
}
.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  max-width: 34em;
  width: 100%;
}
.panel h1 { font-size: 34px; font-weight: 600; letter-spacing: 0.03em; color: var(--ink); }
.panel h1 .exp { font-size: 13px; font-weight: 400; letter-spacing: 0.12em; color: var(--soft); margin-left: 0.6em; }
.panel p { color: var(--soft); font-size: 17px; line-height: 1.5; }
.panel p:empty { display: none; }
.panel .line { color: var(--ink); font-size: 19px; }
.panel .small { font-size: 13px; letter-spacing: 0.12em; }
.panel .mobile { display: none; }
@media (pointer: coarse), (max-width: 640px) {
  .panel .mobile { display: block; }
}
.panel .error { color: var(--ink); }
.panel .warn { color: var(--ink); }
.panel .action { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; margin-top: 6px; }
.panel .action button { font-size: 21px; color: var(--ink); padding: 10px 14px; }
.panel .action button:hover { color: var(--soft); }
.panel .action button.secondary { color: var(--soft); }
.panel .action button.secondary:hover { color: var(--ink); }
.panel .quietlink { margin-top: 12px; }
.panel .quietlink button { font-size: 15px; color: var(--soft); }
.panel .quietlink button:hover { color: var(--ink); }
.panel .trim { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 8px; }
.panel .trim .soft { font-size: 15px; color: var(--soft); font-variant-numeric: tabular-nums; }
.panel .trim .trimnote { font-size: 14px; letter-spacing: 0; line-height: 1.5; max-width: 30em; margin-top: 4px; }
.panel .soft { color: var(--soft); }
.panel .word { color: var(--soft); font-size: 13px; letter-spacing: 0.12em; margin: 0 2px 0 10px; }

.filelabel {
  display: inline-block;
  cursor: pointer;
  font-size: 21px;
  color: var(--ink);
  padding: 10px 14px;
  transition: color 0.15s;
}
.filelabel:hover { color: var(--soft); }
.filelabel input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.filelabel:focus-within { outline: 1px solid var(--soft); outline-offset: 4px; }

/* Bundled public-domain recordings: a bare list under the file action. */
.bundled { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 6px; }
.bundled .alts { display: flex; flex-direction: column; align-items: center; gap: 0; }
.bundled .alts button { font-size: 19px; color: var(--ink); padding: 8px 12px; }
.bundled .alts button:hover { color: var(--soft); }
.bundled .alts button .meta { color: var(--soft); font-size: 15px; margin-left: 0.5em; }
/* While a file is being dragged over the page, the ground says it will take it. */
body.dropping #overlay, body.dropping #stage { outline: 1px dashed var(--soft); outline-offset: -14px; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; min-height: 40px; }
.row.center { justify-content: center; }
.val { font-size: 17px; color: var(--soft); padding: 8px 6px; font-variant-numeric: tabular-nums; }
.val.on { color: var(--ink); }
.audition, .manual { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.audition .row, .manual .row { justify-content: center; }
.song-counts { display: flex; justify-content: center; gap: 0 18px; font-size: clamp(28px, 5vw, 40px); }
.song-counts button {
  font-size: inherit; font-weight: 600; color: var(--soft); padding: 0 0.1em 4px;
  border-bottom: 2px solid var(--faint); border-radius: 0; min-width: 1.1em;
}
.song-counts button.on { color: var(--ink); border-bottom-color: var(--ink); }
.alts button { font-size: 17px; }
.alts button.on { color: var(--ink); }
[data-song-play] { font-size: 19px; width: 44px; color: var(--ink); }
[data-song-click].on { color: var(--ink); }
.song-tap { font-size: 21px; color: var(--ink); padding: 14px 20px; }
