/* ─────────────────────────────────────────────────────────────
   कारीगर — karigar.wtf

   Painted enamel signboard on a cement wall. Deliberately NOT the
   centred glass pill this genre defaults to: hard keylines, hard
   offset shadows, nothing blurred, nothing centred by default.
   See PLAN.md §1.10 and §4.1.
   ───────────────────────────────────────────────────────────── */

:root {
  /* Enamel palette — hardware-shop signboard, not a screen palette. */
  --signboard: #f5b301; /* enamel yellow  */
  --oxide: #9c3b24; /* red oxide      */
  --shopgreen: #0e7c66; /* signboard green*/
  --tarp: #1b5fa8; /* tarpaulin blue */
  --cement: #8a8578; /* cement grey    */
  --chuna: #f4f1e8; /* chuna white    */
  --ink: #16130f; /* outline black  */

  --edge: clamp(1rem, 3vw, 2.25rem);

  --display: "Yatra One", "Kohinoor Devanagari", "Nirmala UI", serif;
  --ui: "Anek Devanagari", "Kohinoor Devanagari", "Nirmala UI", system-ui, sans-serif;

  /* One motion vocabulary. Mismatched curves are what make an interface
     feel assembled rather than designed. */
  --swift: 130ms cubic-bezier(0.4, 0, 0.2, 1);
  --glide: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --settle: 620ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Painted objects cast a hard shadow, never a soft glow. */
  --drop: 6px 6px 0 rgba(22, 19, 15, 0.42);
  --drop-sm: 3px 3px 0 rgba(22, 19, 15, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--ui);
  color: var(--ink);
  background: var(--cement);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── The wall ────────────────────────────────────────────────
   Plaster, a damp stain and a strip of hazard tape, all drawn.
   No image request: the whole background is under 1 KB of CSS,
   which matters more than texture fidelity on a 4G phone. */

.wall {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  --wallpaper: none;
  --wall-wash: rgba(244, 241, 232, 0.5);
  --wall-vignette: rgba(22, 19, 15, 0.22);
  background:
    radial-gradient(120% 80% at 20% 0%, #9d9789 0%, #8a8578 45%, #6f6a5f 100%);
}

body[data-block="bhakti"] .wall {
  --wallpaper: url("/assets/wallpapers/bhakti-desktop.webp");
  --wall-wash: rgba(244, 241, 232, 0.48);
  --wall-vignette: rgba(22, 19, 15, 0.16);
}

body[data-block="josh"] .wall {
  --wallpaper: url("/assets/wallpapers/josh-desktop.webp");
  --wall-wash: rgba(244, 241, 232, 0.5);
  --wall-vignette: rgba(22, 19, 15, 0.14);
}

body[data-block="chai"] .wall {
  --wallpaper: url("/assets/wallpapers/chai-desktop.webp");
  --wall-wash: rgba(244, 241, 232, 0.54);
  --wall-vignette: rgba(22, 19, 15, 0.12);
}

body[data-block="full"] .wall {
  --wallpaper: url("/assets/wallpapers/full-desktop.webp");
  --wall-wash: rgba(244, 241, 232, 0.5);
  --wall-vignette: rgba(22, 19, 15, 0.18);
}

body[data-block="chhutti"] .wall {
  --wallpaper: url("/assets/wallpapers/chhutti-desktop.webp");
  --wall-wash: rgba(244, 241, 232, 0.58);
  --wall-vignette: rgba(22, 19, 15, 0.2);
}

body[data-block="night"] .wall {
  --wallpaper: url("/assets/wallpapers/night-desktop.webp");
  --wall-wash: rgba(244, 241, 232, 0.42);
  --wall-vignette: rgba(4, 9, 13, 0.28);
}

@media (max-width: 1100px) and (min-width: 681px) {
  body[data-block="bhakti"] .wall {
    --wallpaper: url("/assets/wallpapers/bhakti-tablet.webp");
  }

  body[data-block="josh"] .wall {
    --wallpaper: url("/assets/wallpapers/josh-tablet.webp");
  }

  body[data-block="chai"] .wall {
    --wallpaper: url("/assets/wallpapers/chai-tablet.webp");
  }

  body[data-block="full"] .wall {
    --wallpaper: url("/assets/wallpapers/full-tablet.webp");
  }

  body[data-block="chhutti"] .wall {
    --wallpaper: url("/assets/wallpapers/chhutti-tablet.webp");
  }

  body[data-block="night"] .wall {
    --wallpaper: url("/assets/wallpapers/night-tablet.webp");
  }
}

@media (max-width: 680px) {
  .wall {
    --wall-wash: rgba(244, 241, 232, 0.58);
  }

  body[data-block="bhakti"] .wall {
    --wallpaper: url("/assets/wallpapers/bhakti-mobile.webp");
  }

  body[data-block="josh"] .wall {
    --wallpaper: url("/assets/wallpapers/josh-mobile.webp");
  }

  body[data-block="chai"] .wall {
    --wallpaper: url("/assets/wallpapers/chai-mobile.webp");
  }

  body[data-block="full"] .wall {
    --wallpaper: url("/assets/wallpapers/full-mobile.webp");
  }

  body[data-block="chhutti"] .wall {
    --wallpaper: url("/assets/wallpapers/chhutti-mobile.webp");
  }

  body[data-block="night"] .wall {
    --wallpaper: url("/assets/wallpapers/night-mobile.webp");
    --wall-wash: rgba(244, 241, 232, 0.5);
  }
}

.wall::before,
.wall::after {
  content: "";
  position: absolute;
  inset: 0;
}

.wall::before {
  background-image: var(--wallpaper);
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 700ms ease;
}

body[data-block] .wall::before {
  opacity: 1;
}

/* A chuna wash over the UI side keeps the Hindi text readable while the
   workers and tools stay visible on the right. */
.wall::after {
  background:
    linear-gradient(90deg, var(--wall-wash) 0%, rgba(244, 241, 232, 0.34) 42%, transparent 74%),
    linear-gradient(to bottom, rgba(244, 241, 232, 0.1), var(--wall-vignette)),
    radial-gradient(42% 58% at 83% 44%, transparent 0%, rgba(22, 19, 15, 0.12) 100%);
}

/* Two turbulence layers: a coarse one for trowel mottle, a fine one for
   grit. One alone reads as digital noise; together they read as plaster.
   Regenerated by the filter, so they stay crisp at any DPR. */
.wall__plaster {
  position: absolute;
  inset: 0;
  z-index: 1;
  mix-blend-mode: multiply;
  opacity: 0.18;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420'%3E%3Cfilter id='c'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.022' numOctaves='5'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='420' height='420' filter='url(%23c)' opacity='0.55'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23f)' opacity='0.3'/%3E%3C/svg%3E");
  background-size: 620px 620px, 200px 200px;
}

/* The damp patch every site wall has, and the red-oxide plinth band that
   every one of them is painted with from the floor up. The band is what
   stops the lower half of the screen being a grey void. */
.wall__stain {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(36% 42% at 80% 30%, rgba(58, 52, 42, 0.16), transparent 72%),
    radial-gradient(26% 30% at 12% 18%, rgba(58, 52, 42, 0.12), transparent 72%),
    linear-gradient(to bottom, rgba(30, 26, 20, 0.1) 0%, transparent 22%);
}

.wall__stain::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26vh;
  min-height: 8rem;
  /* Darker than the board that sits on it, or the two merge into one
     brown mass and the player stops reading as an object. */
  background: linear-gradient(to bottom, rgba(74, 26, 15, 0.9), rgba(52, 18, 10, 0.96));
  /* Hand-painted bands are never level and never clean at the top edge,
     and they always leave a chuna smear where the brush stopped. */
  clip-path: polygon(0 0.7rem, 22% 0.2rem, 55% 0.75rem, 82% 0.15rem, 100% 0.6rem, 100% 100%, 0 100%);
  border-top: 3px solid rgba(244, 241, 232, 0.22);
  mix-blend-mode: multiply;
}

/* The band above exists to fill the bottom of the *drawn* wall, which is
   otherwise a grey void. With a photograph back there it fills nothing —
   it just covers the bottom quarter of the picture, which is where the
   ground, the machines and the workers' feet are. So: drawn wall keeps
   the plinth, photographed wall doesn't get one. */
body[data-block] .wall__stain::after {
  display: none;
}

/* Hazard tape across the very bottom — the one piece of pure signage. */
.wall__tape {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  height: 15px;
  background: repeating-linear-gradient(-45deg, var(--signboard) 0 14px, var(--ink) 14px 28px);
  border-top: 2px solid rgba(22, 19, 15, 0.55);
}

.yt-host {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Three bands: wordmark up top, the site line painted across the middle,
   the board at the bottom. The middle row is what stops the page reading
   as a wordmark and a widget with a void between them. */
main {
  position: relative;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: start; /* left-hung, not centred */
  /* The top pad clears the rail, and the rail is as tall as the clock. */
  padding: calc(var(--edge) + 6.1rem) var(--edge) calc(var(--edge) + 1.6rem);
}

/* ── Entrance ────────────────────────────────────────────────── */

@keyframes rise {
  from {
    opacity: 0;
    transform: translate3d(0, 16px, 0);
  }
}

@keyframes swing-in {
  from {
    opacity: 0;
    transform: rotate(-6deg) translate3d(-18px, -10px, 0);
  }
}

.rail {
  animation: rise var(--settle) 0.24s both;
}
.mark {
  animation: swing-in var(--settle) 0.05s both;
}
.dock {
  animation: rise var(--settle) 0.14s both;
}
.tools {
  animation: rise var(--settle) 0.34s both;
}

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

.rail {
  position: fixed;
  top: max(var(--edge), env(safe-area-inset-top));
  left: var(--edge);
  right: var(--edge);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

/* The shift badge is information, not chrome: it names the block the
   playlist is currently filtered to. This is the feature. Two objects
   hung side by side on the wall, not one pill. */
.shift {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

/* ── The wall clock ──────────────────────────────────────────
   The one every site office has: plastic bezel, chuna dial, red
   second hand, hung a few degrees off level and never quite dusted.
   Drawn, not photographed, for the same reason the wall is — it
   costs no request and stays crisp at any DPR. */
.clock {
  /* Big enough to read the hands from across the room, which is the only
     size a wall clock is ever built at. At badge size the hands turned
     into specks and the whole thing read as an icon. */
  --clock-size: 4.75rem;
  width: var(--clock-size);
  height: var(--clock-size);
  flex: none;
  transform: rotate(-3.5deg);
  /* A hard offset shadow, same as everything else painted on this wall —
     drop-shadow rather than box-shadow so it follows the circle. */
  filter: drop-shadow(5px 5px 0 rgba(22, 19, 15, 0.42));
}

.clock svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.clock__bezel {
  fill: var(--ink);
}

.clock__dial {
  fill: var(--chuna);
}

.clock__ticks {
  stroke: var(--ink);
}

.clock__tick {
  stroke-width: 2.3;
  opacity: 0.5;
}

.clock__tick--major {
  stroke-width: 3.8;
  opacity: 1;
}

.clock__hand {
  stroke: var(--ink);
  stroke-linecap: round;
  transform-box: view-box;
  transform-origin: 50px 50px;
  transition: transform var(--glide);
}

.clock__hand--h {
  stroke-width: 6.4;
}

.clock__hand--m {
  stroke-width: 4.4;
}

/* Quartz movements jump and settle rather than sweep, so the second hand
   overshoots its tick by a degree and comes back. */
.clock__sec {
  stroke: var(--oxide);
  stroke-width: 1.8;
  stroke-linecap: round;
  transform-box: view-box;
  transform-origin: 50px 50px;
  transition: transform 120ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.clock__pin {
  fill: var(--oxide);
  stroke: var(--ink);
  stroke-width: 1.5;
}

/* The clock was already showing this time when the page loaded, so the
   first paint must land without animating up from twelve. app.js adds
   the class once that position has committed. */
.clock:not(.is-wound) .clock__hand,
.clock:not(.is-wound) .clock__sec {
  transition: none;
}

.shift__block {
  padding: 0.38rem 0.8rem;
  background: var(--ink);
  border-radius: 2px;
  box-shadow: var(--drop-sm);
  font-family: var(--display);
  font-size: 1.02rem;
  color: var(--signboard);
  line-height: 1;
  transform: rotate(-1.2deg);
}

.presence {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  margin: 0;
  padding: 0.32rem 0.62rem;
  background: var(--chuna);
  border: 2px solid var(--ink);
  border-radius: 2px;
  box-shadow: var(--drop-sm);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.presence__dot {
  position: relative;
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--shopgreen);
}

.presence__dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--shopgreen);
  animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%,
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

.presence__count {
  font-variant-numeric: tabular-nums;
}

.presence__label {
  font-weight: 600;
  opacity: 0.66;
}

/* ── Wordmark ───────────────────────────────────────────────────
   Painted straight onto the plaster: black outline, chuna highlight,
   hung off-square the way a hand-painted board always is. */

.mark {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  transform: rotate(-1.6deg);
  transform-origin: left center;
  user-select: none;
}

.mark__word {
  font-family: var(--display);
  font-size: clamp(3.4rem, 13vw, 9rem);
  line-height: 0.92;
  color: var(--signboard);
  /* Enamel sign lettering: a hard black keyline plus a chuna-white
     highlight up and to the left, where the sun would be. */
  text-shadow:
    -2px -2px 0 var(--chuna),
    2px 2px 0 var(--ink),
    4px 4px 0 var(--ink),
    9px 9px 0 rgba(22, 19, 15, 0.28);
}

.mark__line {
  font-family: var(--display);
  font-size: clamp(0.95rem, 2.6vw, 1.5rem);
  color: var(--chuna);
  text-shadow: 2px 2px 0 rgba(22, 19, 15, 0.6);
  padding-left: 0.25em;
}

/* ── The board ───────────────────────────────────────────────── */

.dock {
  position: relative;
  width: min(34rem, 100%);
}

.board {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.9rem 0.6rem 0.6rem;
  background: var(--oxide);
  border: 3px solid var(--ink);
  border-radius: 3px;
  box-shadow: var(--drop);
  transform: rotate(-0.7deg);
  color: var(--chuna);
}

/* A painted board has a keyline drawn just inside its edge. */
.board::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(244, 241, 232, 0.45);
  border-radius: 2px;
  pointer-events: none;
}

/* ── Album art as a circular saw blade ───────────────────────── */

.blade {
  position: relative;
  width: 4rem;
  height: 4rem;
  flex: none;
}

.blade__teeth,
.blade__art {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: spin 7s linear infinite;
  animation-play-state: paused;
}

.board.is-playing .blade__teeth,
.board.is-playing .blade__art {
  animation-play-state: running;
}

.blade__teeth {
  z-index: 2;
  overflow: visible;
}

/* The teeth themselves are a dashed stroke on an oversized circle —
   cheaper than a 40-point path and it reads correctly at this size. */
.blade__disc {
  fill: none;
  stroke: var(--ink);
  stroke-width: 8;
  stroke-dasharray: 3 7.6;
}

.blade__art {
  overflow: hidden;
  background: var(--ink);
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.blade__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* The fallback IS the design, not a gap in it: a painted signboard tile
   with the song's name on it. Rendered live in the DOM so it uses the
   real webfont — an <img> to an SVG file can't. PLAN.md §4.3. */
.tile {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0.3rem;
  text-align: center;
  font-family: var(--display);
  font-size: 0.44rem;
  line-height: 1.15;
  overflow: hidden;
  color: var(--chuna);
  background: var(--tile-bg, var(--shopgreen));
  text-shadow: 1px 1px 0 rgba(22, 19, 15, 0.75);
}

.blade__bolt {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: 0.62rem;
  height: 0.62rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--cement);
  box-shadow:
    0 0 0 2px var(--ink),
    inset 1px 1px 0 rgba(255, 255, 255, 0.5);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Track meta ──────────────────────────────────────────────── */

.meta {
  flex: 1;
  min-width: 0;
}

.meta__title,
.meta__artist {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 200ms ease;
}

.board.is-swapping .meta__title,
.board.is-swapping .meta__artist {
  opacity: 0;
}

.meta__title {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
}

.meta__artist {
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.3;
  color: rgba(244, 241, 232, 0.72);
}

.seek {
  position: relative;
  height: 12px;
  margin-top: 0.3rem;
  cursor: pointer;
  touch-action: none;
}

.seek__rail {
  position: absolute;
  inset-inline: 0;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  overflow: hidden;
  background: rgba(22, 19, 15, 0.45);
  border: 1px solid rgba(22, 19, 15, 0.55);
}

/* scaleX rides the compositor; animating width would jank every frame. */
.seek__fill {
  height: 100%;
  width: 100%;
  background: var(--signboard);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

.seek__knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 11px;
  height: 11px;
  transform: translate(-50%, -50%);
  background: var(--signboard);
  border: 2px solid var(--ink);
  opacity: 0;
  transition: opacity var(--swift);
  will-change: transform;
}

.seek:hover .seek__knob,
.seek:focus-visible .seek__knob {
  opacity: 1;
}

.time {
  margin: 0.1rem 0 0;
  font-size: 0.62rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: rgba(244, 241, 232, 0.6);
}

/* ── Controls ────────────────────────────────────────────────── */

.controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: none;
}

.btn {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: var(--chuna);
  cursor: pointer;
  transition: background var(--swift), transform var(--swift);
}

.btn:hover {
  background: rgba(22, 19, 15, 0.28);
}

.btn:active {
  transform: translate(1px, 1px);
}

.btn--small {
  width: 1.7rem;
  height: 1.7rem;
  opacity: 0.75;
}

.btn--small.is-on {
  opacity: 1;
  background: rgba(22, 19, 15, 0.4);
}

/* The play button is the one thing that must be unmissable on a phone. */
.btn--play {
  width: 2.9rem;
  height: 2.9rem;
  background: var(--signboard);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: var(--drop-sm);
}

.btn--play:hover {
  background: #ffc61f;
}

.btn--play:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(22, 19, 15, 0.38);
}

.btn--play:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

/* Icon swap is pure CSS off .is-playing. Never `svg.hidden = true` —
   `hidden` is an HTMLElement property and doesn't reflect on SVG. */
.i-pause,
.board.is-playing .i-play {
  display: none;
}

.board.is-playing .i-pause {
  display: block;
}

/* ── Playlist ─────────────────────────────────────────────────
   Pops up over the wall so the board never moves. */

.list {
  position: absolute;
  bottom: calc(100% + 0.6rem);
  left: 0;
  right: 0;
  z-index: 5;
  max-height: min(46dvh, 22rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--chuna);
  border: 3px solid var(--ink);
  box-shadow: var(--drop);
  transform: rotate(-0.7deg);
  scrollbar-width: thin;
  scrollbar-color: rgba(22, 19, 15, 0.35) transparent;

  /* visibility is part of the transition so it animates out without
     staying clickable. */
  opacity: 0;
  visibility: hidden;
  translate: 0 8px;
  transition:
    opacity var(--glide),
    translate var(--glide),
    visibility 0s linear 300ms;
}

.list.is-open {
  opacity: 1;
  visibility: visible;
  translate: 0;
  transition:
    opacity var(--glide),
    translate 420ms cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0s;
}

.list::-webkit-scrollbar {
  width: 6px;
}
.list::-webkit-scrollbar-thumb {
  background: rgba(22, 19, 15, 0.35);
}

.list ol {
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  counter-reset: t;
}

.list li {
  counter-increment: t;
}

.list button {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.4rem 0.55rem;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 0.84rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.list button::before {
  content: counter(t);
  flex: none;
  width: 1.5rem;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.45;
}

.list button:hover {
  background: rgba(22, 19, 15, 0.1);
}

.list li.is-current button {
  background: var(--signboard);
}

.list .t-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list .t-block {
  font-family: var(--display);
  font-size: 0.68rem;
  opacity: 0.55;
  white-space: nowrap;
}

/* ── Stencilled site line ────────────────────────────────────── */

/* The middle band. Painted straight onto the plaster, big, at a slight
   angle — the way a slogan actually goes on a wall. */
.stencil {
  position: relative;
  align-self: center;
  /* NOT a ch value: ch resolves against this element's inherited 16px UI
     font, not the display font inside it, so 32ch came out ~300px wide and
     stacked the longer lines six deep. Sized in rem against the real
     rendered text instead. */
  max-width: min(40rem, 100%);
  margin: 0;
  /* The display size lives here, not on the span, so the em units below
     measure against the text you can actually see. */
  font-size: clamp(1.5rem, 4.6vw, 3.1rem);
  /* Room for the ↻ parked in the left margin, and a floor of four lines —
     the longest slogan's worst case — so every line occupies the same box
     and the text centres inside it. They rotate every 11s; a box that
     resized would twitch the whole middle of the page on each change. */
  display: grid;
  align-content: center;
  padding-left: 1.9em;
  min-height: calc(4 * 1.3em);
  transform: rotate(-1.1deg);
  transform-origin: left center;
}

.stencil__text {
  font-family: var(--display);
  font-size: inherit;
  line-height: 1.3;
  text-wrap: balance;
  color: var(--chuna);
  /* Whitewash brushed over plaster: slightly translucent, hard shadow. */
  opacity: 0.94;
  text-shadow: 3px 3px 0 rgba(22, 19, 15, 0.4);
  transition: opacity 220ms ease;
}

.stencil__text.is-swapping {
  opacity: 0;
}

/* Parked in the left margin at a fixed offset instead of flowing after the
   last word — inline, it jumped to a new place on every line change. */
.stencil__next {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  /* Out on its own in the margin it needs an edge, or it reads as a smudge
     on the plaster rather than something you can press. */
  border: 2px solid rgba(244, 241, 232, 0.34);
  border-radius: 50%;
  background: transparent;
  color: rgba(244, 241, 232, 0.72);
  cursor: pointer;
  transition: color var(--swift), background var(--swift), border-color var(--swift),
    rotate 400ms var(--settle);
}

.stencil__next:hover {
  color: var(--chuna);
  border-color: rgba(244, 241, 232, 0.7);
  background: rgba(22, 19, 15, 0.25);
}

.stencil__next:active {
  rotate: 180deg;
}

/* ── The sponsor board ──────────────────────────────────────
   A painted hoarding nailed to the wall. Leans the opposite way to
   the player board so the two read as two objects someone hung, not
   one component used twice. PLAN.md §8.
   ──────────────────────────────────────────────────────────── */

.band {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.signboard {
  position: relative;
  flex: none;
  transform: rotate(1.6deg);
  animation: rise var(--settle) 0.2s both;
}

/* The nail it hangs from. */
.signboard::before {
  content: "";
  position: absolute;
  top: -0.42rem;
  left: 50%;
  width: 0.46rem;
  height: 0.46rem;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--cement);
  box-shadow: 0 0 0 2px var(--ink), 1px 2px 0 rgba(22, 19, 15, 0.45);
}

.signboard__face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 9.5rem;
  padding: 0.7rem 1.1rem 0.6rem;
  background: var(--signboard);
  border: 3px solid var(--ink);
  border-radius: 2px;
  box-shadow: var(--drop);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  transition: transform var(--swift), background var(--swift);
}

/* The keyline every painted board has, drawn just inside the edge. */
.signboard__face::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(22, 19, 15, 0.4);
  pointer-events: none;
}

.signboard__face:hover {
  transform: translate(-1px, -2px);
}

.signboard__face:active {
  transform: translate(2px, 2px);
  box-shadow: var(--drop-sm);
}

.signboard__kicker {
  font-family: var(--ui);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.signboard__name {
  font-family: var(--display);
  font-size: 1.35rem;
  line-height: 1.15;
}

.signboard__foot {
  margin-top: 0.15rem;
  font-family: var(--ui);
  font-size: 0.62rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.72;
}

/* Vacant, it advertises itself — chuna board, painted-over look, and it
   sits back a little so it never outshouts the music. */
.signboard.is-vacant .signboard__face {
  background: var(--chuna);
  opacity: 0.9;
}

.signboard.is-vacant .signboard__face:hover {
  opacity: 1;
  background: var(--signboard);
}

/* ── The tool rail ──────────────────────────────────────────
   Four painted buttons hung on the wall like tools on a pegboard.
   Stacked, right-hand side, clear of the board. */

.tools {
  position: fixed;
  right: var(--edge);
  bottom: calc(var(--edge) + 1.2rem);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

/* Chuna-white, not black: the rail sits on the dark oxide plinth and black
   buttons disappeared into it entirely. These read as painted tool tags. */
.tool {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.34rem 0.7rem 0.34rem 0.5rem;
  background: var(--chuna);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 2px;
  box-shadow: var(--drop-sm);
  font-family: var(--display);
  font-size: 0.86rem;
  line-height: 1;
  cursor: pointer;
  transition: transform var(--swift), background var(--swift), color var(--swift);
}

/* चाय is the one everybody presses, so it gets the enamel green and sits
   at the top of the rail. The machines are painted black like tools. */
.tool--chai {
  background: var(--shopgreen);
  color: var(--chuna);
  border-color: var(--ink);
  font-size: 1rem;
  padding: 0.42rem 0.8rem 0.42rem 0.55rem;
}

.tool:hover {
  background: var(--signboard);
}

.tool--chai:hover {
  background: #119b80;
}

.tool:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* A tap rings; a machine judders for as long as it runs. */
.tool.is-ringing {
  animation: ring 0.42s ease;
}

.tool.is-working {
  animation: judder 0.16s linear 3;
  background: var(--signboard);
}

@keyframes ring {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  15% { transform: translate(-3px, 1px) rotate(-2deg); }
  45% { transform: translate(4px, -1px) rotate(2deg); }
  75% { transform: translate(-2px, 0) rotate(-1deg); }
}

@keyframes judder {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1.5px, 1px); }
  50% { transform: translate(1.5px, -1px); }
  75% { transform: translate(-1px, -1px); }
}

/* The wall rings when a tool goes off. Applied to the inner spans, because
   .mark already owns an animation for its entrance and a second one would
   replace it outright. */
@keyframes wall-shake {
  0% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-5px, 2px, 0) rotate(-0.8deg); }
  32% { transform: translate3d(4px, -2px, 0) rotate(0.7deg); }
  52% { transform: translate3d(-3px, 1px, 0) rotate(-0.4deg); }
  72% { transform: translate3d(2px, 0, 0) rotate(0.2deg); }
  100% { transform: none; }
}

.mark.is-shaking .mark__word,
.mark.is-shaking .mark__line {
  animation: wall-shake 700ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ── Footer ──────────────────────────────────────────────────── */

.foot {
  position: fixed;
  left: var(--edge);
  /* Clears the hazard tape — text sitting on the stripes is unreadable. */
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  z-index: 15;
  display: flex;
  gap: 0.4rem;
  font-size: 0.66rem;
  font-weight: 600;
  color: rgba(244, 241, 232, 0.88);
  /* It used to sit on the plinth band and could borrow contrast from it.
     Now it sits straight on the photo — sand at चाय, wet concrete at
     night — so it carries its own: a hard offset for the edge and a soft
     halo underneath, which is cheaper than putting a panel back over the
     picture. */
  text-shadow:
    1px 1px 0 rgba(22, 19, 15, 0.85),
    0 0 7px rgba(22, 19, 15, 0.7);
}

.foot a {
  color: inherit;
}

.foot__lineage {
  opacity: 0.75;
}

.noscript {
  position: fixed;
  inset: auto 0 40% 0;
  text-align: center;
  font-weight: 700;
  color: var(--chuna);
}

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

/* ── The test rail ───────────────────────────────────────────
   Dev tool. Mounted by app.js only on localhost or with ?test,
   so on karigar.wtf none of this ever has an element to match.

   Deliberately off-palette — a taped-on site notice in surveyor
   orange, not enamel. If it ever leaked into production it should
   look like a mistake, not like a feature nobody documented. */

.testrail {
  position: fixed;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  max-width: min(96vw, 52rem);
  font-family: var(--ui);
  font-size: 0.7rem;
  font-weight: 700;
}

.testrail button {
  font: inherit;
  cursor: pointer;
  color: var(--ink);
  background: #ffb020;
  border: 2px solid var(--ink);
  border-radius: 2px;
  box-shadow: var(--drop-sm);
  padding: 0.34rem 0.5rem;
  line-height: 1.1;
  transition: transform var(--swift), background var(--swift);
}

.testrail button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(22, 19, 15, 0.38);
}

.testrail__toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.testrail__tag {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

.testrail__time {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

/* The one piece of state worth shouting: you are no longer on real
   time, and anything you screenshot from here is staged. */
.testrail.is-offset .testrail__toggle {
  /* Stripes along the bottom edge only — run them behind the text and the
     one label you need to read becomes the one you can't. */
  background:
    repeating-linear-gradient(-45deg, #ffb020 0 6px, #16130f 6px 12px) bottom / 100% 5px no-repeat,
    var(--ink);
  color: var(--chuna);
  padding-bottom: 0.55rem;
}

.testrail__body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.testrail.is-collapsed .testrail__body {
  display: none;
}

.testrail__block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  background: var(--chuna);
}

.testrail__hours {
  font-size: 0.58rem;
  font-weight: 600;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

.testrail__block[aria-pressed="true"] {
  background: var(--shopgreen);
  color: var(--chuna);
}

.testrail__step,
.testrail__live {
  align-self: stretch;
  background: var(--chuna);
}

.testrail__live {
  background: #ffb020;
}

@media (prefers-reduced-motion: reduce) {
  .testrail button {
    transition: none;
  }
}

/* On a phone the top strip is already three deep — clock, counter, tools —
   so the rail drops into the empty middle of the wall instead, and starts
   collapsed (app.js) so it is a chip until you want it. */
@media (max-width: 680px) {
  .testrail {
    top: 46%;
    left: 0.5rem;
    right: 0.5rem;
    transform: none;
    max-width: none;
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Small screens ───────────────────────────────────────────── */

@media (max-width: 680px) {
  main {
    grid-template-rows: auto 1fr auto;
    /* Clears the two stacked rail rows — the clock, and the counter under
       it. At 5.6rem the wordmark's top edge grazed the counter. */
    padding-top: calc(var(--edge) + 7rem);
    row-gap: 1.4rem;
  }

  .rail {
    /* The chai button owns the top-right on phones, so the counter tucks
       under the shift badge instead of fighting it. Two stacked rows —
       main's padding-top above has to clear both. */
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    right: auto;
  }

  .clock {
    --clock-size: 3.7rem;
  }

  .mark__word {
    font-size: clamp(3.6rem, 17vw, 9rem);
  }

  .stencil {
    align-self: end;
    max-width: 100%;
  }

  /* Stacked on phones: side by side there is room for neither. */
  .band {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.1rem;
  }

  .signboard__face {
    min-width: 0;
    padding: 0.5rem 0.85rem 0.45rem;
  }

  .signboard__name {
    font-size: 1.1rem;
  }

  .dock {
    width: 100%;
  }

  .board {
    flex-wrap: wrap;
    row-gap: 0.55rem;
    padding: 0.7rem;
  }

  .controls {
    width: 100%;
    justify-content: center;
  }

  /* On phones the rail goes horizontal along the top-right, icons only —
     four stacked labels would eat a third of the screen. */
  .tools {
    bottom: auto;
    top: max(var(--edge), env(safe-area-inset-top));
    right: var(--edge);
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
  }

  .tool:not(.tool--chai) .tool__text {
    display: none;
  }

  .tool:not(.tool--chai) {
    padding: 0.34rem;
  }

  .foot__lineage,
  .foot__dot {
    display: none;
  }
}

/* Below this the wordmark starts fighting the board for the viewport. */
@media (max-height: 620px) {
  .mark__word {
    font-size: clamp(2.4rem, 9vw, 4rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .blade__teeth,
  .blade__art,
  .presence__dot::after {
    animation: none !important;
  }

  /* A hand that twitches in the corner once a second is the definition of
     what this query is asking us to stop. The hour and minute hands stay:
     they carry the shift, and they move too slowly to register as motion.
     app.js reads the same query and drops to a lazy repaint. */
  .clock__sec {
    display: none;
  }
}
