/* ============================================================
   WEEKEND DEPARTURES — a split-flap departures board
   World: Solari-style board. Bezel, flap-yellow tiles, transit
   line bullets, printed-ticket detail view.
   ============================================================ */

@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #0c0906;
  --board: #191410;
  --board-2: #211a12;
  --board-3: #292013;
  --edge: #3a2f1c;
  --ivory: #efe3c0;
  --dim: #b2a37f;
  --dim-2: #8d7f5c;
  --ink: #1a1408;
  --flap: #f2c744;
  --flap-hi: #ffd95e;
  --flap-split: #c9991d;
  --red: #cc3d26;
  --red-deep: #8f2213;
  --paper: #f4e9cc;
  --paper-2: #eaddba;
  --paper-ink: #241a08;
  --paper-dim: #6f5f3d;
  --perf: #cbb98c;
  --line-art: #d9503a;
  --line-film: #4b8fd0;
  --line-food: #e0a32e;
  --line-literature: #8b74c9;
  --line-music: #d97cae;
  --line-outdoors: #57a05c;
  --line-walks: #45a794;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --disp: "Oswald", "Arial Narrow", Impact, sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 90% at 50% 0%, #131009 0%, var(--bg) 55%),
    var(--bg);
  color: var(--ivory);
  font-family: var(--disp);
  -webkit-font-smoothing: antialiased;
  padding: clamp(10px, 2.4vw, 28px);
}

::selection { background: var(--flap); color: var(--ink); }

/* ---------- scrollbar & focus ---------- */
* { scrollbar-color: var(--edge) var(--board); scrollbar-width: thin; }
:focus-visible {
  outline: 2px solid var(--flap);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  background: var(--flap);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 4px;
  transition: top 0.15s ease-out;
}
.skip:focus { top: 12px; }

/* ---------- station bezel ---------- */
.station {
  max-width: 1160px;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(255, 214, 94, 0.045), rgba(255, 214, 94, 0) 120px),
    var(--board);
  border: 1px solid var(--edge);
  border-radius: 14px;
  box-shadow:
    inset 0 1px 0 rgba(242, 199, 68, 0.14),
    0 24px 60px -18px rgba(0, 0, 0, 0.85),
    0 2px 0 rgba(0, 0, 0, 0.5);
  overflow: clip;
}

/* ---------- masthead ---------- */
.masthead { padding: clamp(14px, 2.6vw, 26px) clamp(16px, 3vw, 34px) 0; }
.chrome-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 16px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid #2a2114;
  padding-bottom: 12px;
  margin: 0;
}
.chrome-row p { margin: 0; }
.chrome-dot {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--red);
  margin: 0 8px;
  vertical-align: 2px;
}
.clock {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 20px;
  color: var(--flap);
  letter-spacing: 0.08em;
  margin-left: 8px;
}
.colon { font-style: normal; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }

.wordmark { margin: clamp(16px, 3vw, 30px) 0 0; line-height: 1; }
.masthead-sub {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 18px 0 22px;
}
.masthead-sub .sep { color: #6e5f3f; margin: 0 6px; }

/* ---------- flap tiles ---------- */
.tile-line { display: flex; flex-wrap: wrap; gap: 0.26em; align-items: center; }
.word { display: inline-flex; gap: 0.09em; }
.t {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--flap-hi) 0%, var(--flap) 46%, #e6b733 100%);
  color: var(--ink);
  border-radius: 0.14em;
  position: relative;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.t::after {
  content: "";
  position: absolute;
  left: 0.06em; right: 0.06em; top: calc(50% - 0.5px);
  height: 1px;
  background: var(--flap-split);
  opacity: 0.75;
}
@keyframes flap {
  0%   { transform: rotateX(94deg); filter: brightness(1.7); }
  100% { transform: rotateX(0deg);   filter: brightness(1); }
}
.fresh .t {
  animation: flap 0.22s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(min(var(--i), 24) * 18ms);
}
.fresh .when,
.fresh .where,
.fresh .fare,
.fresh .bullet {
  animation: settle 0.32s ease-out both;
  animation-delay: calc(min(var(--n), 24) * 18ms + 80ms);
}
@keyframes settle {
  0%   { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* wordmark scale */
.wordmark .t { width: 0.74em; height: 1.42em; font-size: clamp(21px, 4.6vw, 40px); font-weight: 600; }

/* ---------- controls ---------- */
.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px clamp(16px, 3vw, 34px);
  background: linear-gradient(180deg, var(--board) 78%, rgba(25, 20, 16, 0.88));
  border-top: 1px solid #2a2114;
  border-bottom: 1px solid #2a2114;
}
.ctl {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}
.ctl-find { flex: 1 1 220px; }
input[type="search"],
select {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--ivory);
  background: #131009;
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 10px 12px;
  caret-color: var(--flap);
  flex: 1;
  min-width: 0;
}
input[type="search"] { width: 100%; }
input[type="search"]::placeholder { color: var(--dim-2); }
input[type="search"]::-webkit-search-cancel-button { filter: invert(0.8) sepia(0.4); }

select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23f2c744' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.held-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ivory);
  background: #131009;
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
}
.held-toggle:hover { border-color: #57472a; background: #1a1510; }
.held-toggle .ico { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.held-toggle .count {
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
}
.held-toggle[aria-pressed="true"] {
  background: var(--flap);
  color: var(--ink);
  border-color: var(--flap);
}
.held-toggle[aria-pressed="true"] .count { background: var(--ink); color: var(--flap); }

/* ---------- the board ---------- */
.board { padding: 6px clamp(16px, 3vw, 34px) 26px; }
.day-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 26px 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--flap);
}
.day-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #4a3b1b, transparent);
}
.day-head .dh-days { color: var(--dim); letter-spacing: 0.14em; }

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

.row { position: relative; border-bottom: 1px solid #241c10; }
.row:last-child { border-bottom: none; }
.row-btn {
  display: grid;
  grid-template-columns: 92px 34px 1fr minmax(150px, auto) 74px;
  grid-template-areas: "when bullet title where fare";
  gap: 10px 14px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 13px 10px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.14s ease-out;
}
.row-btn:hover { background: rgba(242, 199, 68, 0.05); }
.row-btn:hover .t { filter: brightness(1.06); }
.row-btn:active { background: rgba(242, 199, 68, 0.09); }

.when { grid-area: when; font-family: var(--disp); }
.when .day {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--dim);
  text-transform: uppercase;
  margin-bottom: 3px;
}
.when .time {
  display: block;
  font-size: 21px;
  font-weight: 500;
  color: var(--ivory);
  letter-spacing: 0.04em;
  line-height: 1;
}
.when .ends {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim-2);
  margin-top: 3px;
}

.bullet {
  grid-area: bullet;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: var(--disp);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--line);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22);
}

.title { grid-area: title; perspective: 340px; font-size: 17.5px; }
.title .t { width: 0.63em; height: 1.38em; font-weight: 500; }

.where {
  grid-area: where;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  text-align: right;
  line-height: 1.7;
}
.where .platform { display: block; color: var(--ivory); }
.where .zone { display: block; }

.fare {
  grid-area: fare;
  font-family: var(--disp);
  font-size: 17px;
  font-weight: 500;
  color: var(--flap);
  letter-spacing: 0.03em;
  justify-self: end;
  min-width: 74px;
  text-align: right;
}
.fare.free { color: #8fae62; font-size: 12px; font-family: var(--mono); letter-spacing: 0.12em; }

.held-tab {
  position: absolute;
  right: 18px;
  top: -1px;
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 3px 8px 2px;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.row:not(.held) .held-tab { display: none; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 54px 16px 66px; }
.empty .t { width: 0.72em; height: 1.5em; font-size: clamp(17px, 3.4vw, 27px); font-weight: 600; }
.empty-copy {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--dim);
  margin: 22px auto 26px;
  max-width: 52ch;
}
.btn-reset {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--flap);
  border: none;
  border-radius: 6px;
  padding: 12px 22px;
  cursor: pointer;
  box-shadow: 0 6px 14px -6px rgba(242, 199, 68, 0.45);
  transition: transform 0.12s ease-out, background 0.12s ease-out;
}
.btn-reset:hover { background: var(--flap-hi); transform: translateY(-1px); }
.btn-reset:active { transform: translateY(0); }

/* ---------- small print ---------- */
.smallprint {
  padding: 16px clamp(16px, 3vw, 34px) 22px;
  border-top: 1px solid #241c10;
}
.smallprint p {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--dim-2);
  text-transform: uppercase;
}

/* ============================================================
   TICKET — the detail view: printed paper over the dark hall
   ============================================================ */
.ticket-shelf {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: none;
  padding: clamp(12px, 3.4vw, 40px);
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.ticket-shelf::backdrop {
  background: rgba(8, 6, 3, 0.82);
  backdrop-filter: blur(2px);
}

.ticket {
  position: relative;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 10px;
  width: min(640px, 100%);
  margin: auto;
  box-shadow:
    inset 0 1px 0 #fff,
    0 30px 70px -20px rgba(0, 0, 0, 0.9),
    0 4px 14px rgba(0, 0, 0, 0.5);
  transform: rotate(-0.35deg);
  animation: ticket-in 0.2s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
@keyframes ticket-in {
  0% { opacity: 0; transform: rotate(-0.35deg) translateY(14px) scale(0.97); }
  100% { opacity: 1; transform: rotate(-0.35deg) translateY(0) scale(1); }
}
.ticket:focus-visible { outline-offset: 6px; }

.t-band {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--line);
  color: var(--ink);
  padding: 13px 18px;
  border-radius: 10px 10px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.t-band .t-no { margin-left: auto; }
.t-close {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 6px;
  border: none;
  background: rgba(0, 0, 0, 0.14);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s ease-out;
}
.t-close:hover { background: rgba(0, 0, 0, 0.26); }
.t-close svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2.2; fill: none; }

.t-main { padding: 24px 26px 4px; }
.t-main h2 {
  margin: 0 0 16px;
  font-size: clamp(27px, 5.5vw, 38px);
  font-weight: 600;
  line-height: 1.04;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.t-summary {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0 0 20px;
  max-width: 62ch;
}

.t-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--perf);
  border: 1px solid var(--perf);
  border-radius: 8px;
  overflow: hidden;
  margin: 0 0 22px;
}
.t-grid > div { background: var(--paper); padding: 11px 13px; }
.t-grid dt {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin: 0 0 4px;
}
.t-grid dd { margin: 0; font-size: 16px; font-weight: 500; line-height: 1.15; }
.t-grid dd small {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--paper-dim);
  margin-top: 2px;
}

.t-notes-head {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin: 0 0 8px;
}
.t-notes p {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0 0 10px;
  max-width: 62ch;
}
.t-notes p.access { color: #4a3c1c; }

.t-perf {
  height: 0;
  border-top: 2px dashed var(--perf);
  margin: 18px 10px 0;
}

.t-stub {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 22px 22px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, var(--paper-2), #e3d2a6);
}
.t-stub .barcode {
  flex: 1;
  display: block;
  height: 54px;
  min-width: 0;
  opacity: 0.9;
}
.t-stub .barcode svg { width: 100%; height: 100%; display: block; }

.save-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: #fffbe8;
  border: 1.5px solid var(--ink);
  border-radius: 7px;
  padding: 13px 18px;
  cursor: pointer;
  transition: background 0.13s ease-out, transform 0.13s ease-out, box-shadow 0.13s ease-out;
  box-shadow: 0 2px 5px rgba(36, 26, 8, 0.35);
}
.save-btn:hover { background: #fff; }
.save-btn:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(36, 26, 8, 0.35); }
.save-btn .ico { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.save-btn[aria-pressed="true"] {
  background: var(--red);
  border-color: var(--red-deep);
  color: #fff;
}
.save-btn[aria-pressed="true"] .ico { stroke: #fff; }

.punch {
  position: absolute;
  left: 14px;
  bottom: 46px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--board);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(255, 255, 255, 0.5);
  display: none;
}
.ticket.held .punch { display: block; animation: punch-in 0.18s cubic-bezier(0.2, 0.7, 0.3, 1.4) both; }
@keyframes punch-in {
  0% { transform: scale(0.2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.t-hint {
  display: none;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--paper-dim);
  margin: 10px 0 0;
}
.ticket.held .t-hint { display: block; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .controls { position: static; }
  .ctl-find { flex-basis: 100%; order: 1; }
  .ctl-line { flex: 1; order: 2; }
  .held-toggle { order: 3; }

  .row-btn {
    grid-template-columns: 92px 34px 1fr auto;
    grid-template-areas:
      "title title title title"
      "when bullet where fare";
    row-gap: 9px;
    padding: 13px 6px;
  }
  .where { text-align: left; align-self: center; }
  .fare { align-self: center; }
  .title { font-size: 15.5px; }
  .when .time { font-size: 18px; }

  .t-grid { grid-template-columns: repeat(2, 1fr); }
  .t-main { padding: 20px 18px 4px; }
  .t-stub { flex-wrap: wrap; }
  .t-stub .barcode { flex-basis: 100%; order: 3; height: 44px; }
  .punch { bottom: auto; top: -13px; left: auto; right: 12px; }
}

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