/* ─────────────────────────────────────────────────────────────────────
   रेल यात्रा — Rail Yatra
   The poster is the whole design. It carries its own title, its own
   border and its own palette, so the page's job is to hang it on a wall
   and stay out of the way. Every colour below is sampled off the print.
   ───────────────────────────────────────────────────────────────────── */

:root {
  --ground:  #171310;   /* warm near-black — the wall */
  --paper:   #EFE6D2;   /* the print's aged border */
  --cream:   #F8CF97;   /* the 1970 wordmark / the title's outline */
  --crimson: #9E211C;   /* रेल यात्रा */
  --muted:   #8A7C68;

  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --deva: "Noto Sans Devanagari", "Nirmala UI", system-ui, sans-serif;

  --gut: clamp(10px, 1.8vw, 18px);
  --hud: 46px;          /* the margin the artwork must not intrude on */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  /* a warm pool of light behind the print, so the ground reads as a wall
     rather than as empty black */
  background:
    radial-gradient(120% 90% at 50% 42%, #241D18 0%, var(--ground) 62%),
    var(--ground);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── the print ──────────────────────────────────────────────────────── */

.stage { position: fixed; inset: 0; overflow: hidden; }

.poster {
  position: absolute;
  inset: 0;
  background-image:
    image-set(url("bg.avif") type("image/avif"),
              url("bg.webp") type("image/webp"),
              url("bg.jpg")  type("image/jpeg"));
  /* The file is already cropped to 16:9 around the right part of the
     picture, so on a normal screen this fills it with nothing thrown away. */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.04);       /* headroom so the sway never exposes an edge */
  will-change: transform;
}

/* The margin row sits on the artwork now, so it needs its own ground. */
.stage::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom,
    transparent 0%, transparent 56%,
    rgba(23, 19, 16, 0.30) 78%,
    rgba(23, 19, 16, 0.80) 100%);
}
/* The carriage rock, back. Smaller than the full-bleed version was: the
   print is framed now, so it sways inside its margin instead of drifting a
   cropped photo. It only ever moves while the train is running. */
body.is-running .poster { animation: rock 13s ease-in-out infinite; }

/* Every frame keeps scale >= 1.04, so no sway can pull an edge into view. */
@keyframes rock {
  0%   { transform: scale(1.040) translate3d(0, 0, 0)       rotate(0deg); }
  27%  { transform: scale(1.046) translate3d(-6px, 4px, 0)  rotate(0.10deg); }
  54%  { transform: scale(1.050) translate3d(5px, -3px, 0)  rotate(-0.07deg); }
  78%  { transform: scale(1.045) translate3d(-3px, -5px, 0) rotate(0.05deg); }
  100% { transform: scale(1.040) translate3d(0, 0, 0)       rotate(0deg); }
}

/* ── gate ───────────────────────────────────────────────────────────── */

.gate {
  position: fixed; inset: 0; z-index: 40;
  /* sits low, clear of the print's own रेल यात्रा title — a crimson button
     on crimson lettering killed both. The scrim is bottom-weighted for the
     same reason: dark where the button is, light where the title is. */
  display: grid; place-items: end center;
  padding-bottom: calc(var(--hud) + 22px);
  background: linear-gradient(to bottom,
    rgba(23, 19, 16, 0.26) 0%,
    rgba(23, 19, 16, 0.34) 42%,
    rgba(23, 19, 16, 0.80) 100%);
  transition: opacity 800ms ease, visibility 800ms;
}
.gate.is-gone { opacity: 0; visibility: hidden; pointer-events: none; }

.gate__inner {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  animation: rise 800ms cubic-bezier(.2,.7,.2,1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.gate__note {
  margin: 0;
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--paper);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.board {
  display: inline-flex; align-items: baseline; gap: 12px;
  padding: 15px 34px;
  background: var(--crimson);
  color: var(--cream);
  border: 1px solid rgba(248, 207, 151, 0.45);   /* the title's cream keyline */
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 17px; font-weight: 500; letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: transform 130ms ease, background-color 200ms ease;
}
.board:hover  { background: #B32822; }
.board:active { transform: scale(0.98); }
.board:disabled { background: #4A2A28; color: var(--muted); border-color: transparent; cursor: progress; }
.board__sub {
  font-size: 10px; letter-spacing: 0.16em;
  opacity: 0.65;
}

/* ── margin row ─────────────────────────────────────────────────────── */

.hud {
  position: fixed;
  left: var(--gut); right: var(--gut); bottom: 0;
  z-index: 30;
  height: var(--hud);
  display: flex; align-items: center; gap: 16px;
  /* deliberately no background, no border, no plate */
}

.brand {
  flex-shrink: 0;
  display: block; line-height: 0;
  opacity: 0.58;
  transition: opacity 220ms ease;
}
.brand:hover { opacity: 0.95; }
.brand img {
  width: auto; height: 26px;          /* very small, but still readable */
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.7));
}

.callout { flex: 1; min-width: 0; text-align: center; }
.callout__text {
  display: inline-block;
  font-size: 13px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--cream);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
  opacity: 0;                          /* silent unless something is happening */
  transform: translateY(4px);
  transition: opacity 380ms ease, transform 380ms ease;
}
.callout__text.is-on { opacity: 1; transform: none; }
.callout__text.is-horn { color: #E8695C; }
.callout__text.is-deva {
  font-family: var(--deva);
  font-size: 17px; letter-spacing: 0.04em; text-transform: none;
}

.hud__ctl { display: flex; gap: 6px; flex-shrink: 0; }

.ctl {
  padding: 7px 12px;
  background: transparent;
  color: var(--paper);
  border: 1px solid rgba(239, 230, 210, 0.2);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.ctl:hover { background: rgba(239, 230, 210, 0.1); border-color: rgba(239, 230, 210, 0.4); }
.ctl[aria-expanded="true"] { color: var(--cream); border-color: rgba(248, 207, 151, 0.55); }
.ctl--ghost { border-color: transparent; color: var(--muted); }

/* ── mixer ──────────────────────────────────────────────────────────── */

.mixer {
  position: fixed;
  right: var(--gut);
  bottom: calc(var(--hud) + 6px);
  z-index: 31;
  width: min(320px, calc(100vw - var(--gut) * 2));
  padding: 15px;
  background: rgba(23, 19, 16, 0.94);
  border: 1px solid rgba(239, 230, 210, 0.18);
  border-radius: 3px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
  animation: rise 300ms cubic-bezier(.2,.7,.2,1) both;
}
.mixer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 11px; margin-bottom: 4px;
  border-bottom: 1px solid rgba(239, 230, 210, 0.18);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted);
}
.mixer__rows { display: flex; flex-direction: column; }

.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 5px 9px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(239, 230, 210, 0.07);
}
.row:last-child { border-bottom: 0; }

/* the level read-out lives here now, where a level display belongs */
.row__meter {
  width: 3px; height: 22px;
  background: rgba(239, 230, 210, 0.14);
  border-radius: 1px;
  position: relative; overflow: hidden;
  grid-row: span 2;
}
.row__fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: var(--muted);
  transition: height 140ms linear, background-color 200ms ease;
}
.row.is-hot .row__fill  { background: var(--cream); }
.row.is-horn .row__fill { background: #E8695C; }

.row__name {
  font-size: 11px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--paper);
}
.row__val {
  font-size: 10px; letter-spacing: 0.1em; color: var(--muted);
  font-variant-numeric: tabular-nums; min-width: 30px; text-align: right;
}
.row__when {
  grid-column: 2 / -1;
  font-size: 10px; color: var(--muted); margin-top: -2px;
}
.row input[type="range"] {
  grid-column: 2 / -1;
  width: 100%; height: 15px; margin: 3px 0 0;
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
.row input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: rgba(239, 230, 210, 0.2); border-radius: 1px;
}
.row input[type="range"]::-moz-range-track {
  height: 2px; background: rgba(239, 230, 210, 0.2); border-radius: 1px;
}
.row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 11px; height: 11px; margin-top: -4.5px;
  background: var(--cream); border: 0; border-radius: 50%;
}
.row input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px; background: var(--cream); border: 0; border-radius: 50%;
}

.mixer__hint {
  margin: 11px 0 0;
  font-size: 10px; line-height: 1.6; color: var(--muted);
}
.mixer__hint kbd, .mixer__hint code {
  font-family: var(--mono); font-size: 10px; color: var(--paper);
  background: rgba(239, 230, 210, 0.1); padding: 1px 4px; border-radius: 2px;
}

/* ── quality floor ──────────────────────────────────────────────────── */

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

/* Portrait crops so hard sideways that the title would be destroyed, so
   show the whole picture instead and let it sit on the ground colour. */
@media (orientation: portrait) {
  .poster { background-size: contain; transform: none; }
  body.is-running .poster { animation: none; }
  .stage::after { background: linear-gradient(to bottom,
    transparent 0%, transparent 70%, rgba(23, 19, 16, 0.55) 100%); }
}

@media (max-width: 620px) {
  :root { --hud: 40px; }
  .brand img { height: 16px; }
  .callout__text { font-size: 11px; letter-spacing: 0.12em; }
  .callout__text.is-deva { font-size: 15px; }
  .ctl { padding: 6px 9px; letter-spacing: 0.12em; }
  .mixer { left: var(--gut); width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  body.is-running .poster { animation: none; }
  .gate__inner, .mixer { animation-duration: 1ms; }
  * { transition-duration: 1ms !important; }
}
