/* ============================================================
   WEEKEND DEPARTURES — amber-on-ink split-flap departure board
   Type roles: Oswald = board signage · Plex Mono = data/fare
               Work Sans = ticket prose
   ============================================================ */

@font-face { font-family: 'Oswald'; src: url('assets/oswald.ttf') format('truetype'); font-weight: 400 700; font-style: normal; }
@font-face { font-family: 'IBM Plex Mono'; src: url('assets/ibm-plex-mono.ttf') format('truetype'); font-weight: 400 700; font-style: normal; }
@font-face { font-family: 'Work Sans'; src: url('assets/work-sans.ttf') format('truetype'); font-weight: 400 700; font-style: normal; }

:root {
  --ink: #14171d;          /* canvas */
  --board: #1b2028;        /* raised surface */
  --board-2: #232a35;      /* hover / flap tile */
  --hairline: rgba(244, 236, 214, 0.14);
  --hairline-soft: rgba(244, 236, 214, 0.07);
  --cream: #f2ead6;        /* primary text */
  --muted: #98a1ac;        /* secondary text */
  --amber: #ffc53d;        /* accent: flaps, primary actions, focus */
  --green: #7ee08a;
  --paper: #f2e9d2;        /* ticket surface */
  --paper-ink: #241d12;     /* ticket text */
  --paper-muted: #7a6f58;
  --paper-line: #b9ac8d;
  --scrim: rgba(9, 11, 15, 0.78);
  --line-art: #ff6b6b;
  --line-film: #a78bfa;
  --line-food: #4ade80;
  --line-literature: #60a5fa;
  --line-music: #f472b6;
  --line-outdoors: #2dd4bf;
  --line-walks: #fb923c;
  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --font-body: 'Work Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  background-image: radial-gradient(1200px 500px at 70% -10%, rgba(255, 197, 61, 0.05), transparent 60%);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.dialog-open { overflow: hidden; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 28px; }

.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; }
.amber { color: var(--amber); }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

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

/* dark focus rings where the background is light */
.ticket :focus-visible,
.empty-reset:focus-visible,
#savedToggle[aria-pressed="true"]:focus-visible,
.legend-chip[aria-pressed="true"]:focus-visible,
.t-save[aria-pressed="false"]:focus-visible {
  outline-color: var(--paper-ink);
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--amber); color: var(--paper-ink);
  font-family: var(--font-mono); font-size: 13px;
  padding: 10px 16px;
}
.skip:focus { left: 12px; top: 12px; }

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 2px solid var(--hairline);
  padding: 18px 0 0;
  background: var(--ink);
}

.topline {
  display: flex; justify-content: space-between; gap: 16px;
  color: var(--muted);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline-soft);
  flex-wrap: wrap;
}
.topline .topline-right { text-align: right; }

.masthead-main {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 32px;
  padding: 34px 0 26px;
}

.masthead-title-block { min-width: 0; }

.flap-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(40px, 6.4vw, 92px);
  line-height: 1.07;
  letter-spacing: 0.015em;
  text-transform: uppercase;
  color: var(--amber);
  user-select: none;
}

/* split-flap tile */
.flap {
  display: inline-block;
  padding: 0.02em 0.055em;
  margin: 0 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 0.05em;
  background: linear-gradient(var(--board-2) 0 48%, var(--ink) 48% 52%, var(--board-2) 52% 100%);
  box-shadow: inset 0 -0.03em 0 rgba(0,0,0,0.4);
  transform-origin: 50% 50%;
  will-change: transform;
}
.flap-space { display: inline-block; width: 0.38em; }
.flap-word { display: inline-block; white-space: nowrap; }

.masthead-sub {
  margin-top: 18px;
  color: var(--muted);
  text-transform: uppercase;
}

.clockbox { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.clock { display: block; }
.clock-face { fill: var(--board); }
.clock-ring { fill: none; stroke: var(--hairline); stroke-width: 2; }
#clock-ticks line { stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.hand { stroke-linecap: round; transform-origin: 50px 50px; }
.hand-h { stroke: var(--cream); stroke-width: 4.5; }
.hand-m { stroke: var(--cream); stroke-width: 3; }
.hand-sec { transform-origin: 50px 50px; transition: transform 0.22s cubic-bezier(0.35, 1.9, 0.5, 1); }
.hand-sec line { stroke: var(--line-art); stroke-width: 1.8; }
@media (prefers-reduced-motion: reduce) { .hand-sec { transition: none; } }
.clock-cap { fill: var(--line-art); }
.clock-label { color: var(--muted); }

.masthead-days {
  display: flex; gap: 14px; align-items: stretch; flex-wrap: wrap;
  padding-bottom: 22px;
}
.day-chip {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(15px, 2vw, 21px);
  letter-spacing: 0.14em;
  color: var(--amber);
  background: linear-gradient(var(--board-2) 0 48%, var(--ink) 48% 52%, var(--board-2) 52% 100%);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 10px 18px;
}
.day-chip .flap { border: none; box-shadow: none; background: none; padding: 0; margin: 0; }
.day-chip-note {
  color: var(--muted);
  background: none;
  border: 1px dashed var(--hairline);
  display: flex; align-items: center;
}

/* ---------- line legend ---------- */

.legend {
  display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto;
  padding: 6px 28px 18px;
  scrollbar-width: thin;
}
.legend-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em;
  color: var(--cream);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.legend-chip:hover { background: var(--board); }
.legend-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--line);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--line) 20%, transparent);
}
.legend-chip .legend-n { color: var(--muted); }
.legend-chip[aria-pressed="true"] {
  background: var(--amber); border-color: var(--amber); color: var(--paper-ink);
}
.legend-chip[aria-pressed="true"] .legend-n { color: #6b5410; }
.legend-chip[aria-pressed="true"] .legend-dot { box-shadow: 0 0 0 3px rgba(36,29,18,0.25); }

/* ---------- controls bar ---------- */

.controls {
  position: sticky; top: 0; z-index: 30;
  background: rgba(20, 23, 29, 0.96);
  border-bottom: 2px solid var(--hairline);
  backdrop-filter: blur(6px);
}
.controls-inner {
  display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap;
  padding-top: 14px; padding-bottom: 14px;
}
.ctl { display: flex; flex-direction: column; gap: 6px; }
.ctl-search { flex: 1 1 260px; }
.ctl-line { flex: 0 1 190px; }
.ctl-saved { flex: 0 1 auto; }
.ctl-count {
  margin-left: auto; color: var(--muted);
  padding-bottom: 10px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ctl-label { color: var(--muted); text-transform: uppercase; }

input[type="search"], select {
  font-family: var(--font-mono); font-size: 16px;
  color: var(--cream);
  background: var(--board);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 10px 12px;
  width: 100%;
}
input[type="search"]::placeholder { color: #6d7684; }
input[type="search"]:focus, select:focus { border-color: var(--amber); outline: none; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }

#savedToggle {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.05em;
  color: var(--cream);
  border: 1px solid var(--amber);
  border-radius: 3px;
  padding: 10px 14px;
  transition: background 0.15s ease, color 0.15s ease;
}
#savedToggle .st-icon {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--amber);
}
#savedToggle .st-count {
  background: var(--board-2); border-radius: 999px;
  padding: 1px 8px; font-size: 12px; font-weight: 700;
}
#savedToggle[aria-pressed="true"] { background: var(--amber); color: var(--paper-ink); }
#savedToggle[aria-pressed="true"] .st-icon { border-color: var(--paper-ink); background: var(--paper-ink); }
#savedToggle[aria-pressed="true"] .st-count { background: rgba(36,29,18,0.18); }
#savedToggle[aria-pressed="true"]:hover { background: #ffd670; }

/* ---------- board ---------- */

#board { scroll-margin-top: 130px; }

.board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  padding-top: 44px;
  padding-bottom: 72px;
  align-items: start;
}

.day-h { display: flex; align-items: baseline; gap: 14px; border-bottom: 3px solid var(--cream); padding-bottom: 12px; margin-bottom: 4px; }
.day-h h2 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(26px, 2.6vw, 34px);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.day-h .day-n { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }

.dep-list { list-style: none; }

.dep { border-bottom: 1px solid var(--hairline-soft); }
.dep-btn {
  display: grid;
  grid-template-columns: 86px 40px 1fr auto 22px;
  gap: 18px; align-items: center;
  width: 100%; text-align: left;
  padding: 18px 8px;
  border-radius: 3px;
  transition: background 0.15s ease;
}
.dep-btn:hover { background: var(--board); }

.dep-when { display: flex; flex-direction: column; gap: 2px; }
.dep-time {
  font-family: var(--font-mono); font-weight: 700; font-size: 26px;
  color: var(--cream); font-variant-numeric: tabular-nums; line-height: 1;
}
.dep-dur { font-family: var(--font-mono); font-size: 11px; color: var(--muted); letter-spacing: 0.06em; }

.dep-badge {
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  text-align: center;
  color: var(--line);
  border: 1.5px solid var(--line);
  border-radius: 5px;
  padding: 6px 0;
  background: color-mix(in srgb, var(--line) 9%, var(--board-2));
}

.dep-main { min-width: 0; }
.dep-title-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dep-title {
  font-family: var(--font-display); font-weight: 400;
  font-size: 18.5px; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--cream);
}
.dep-btn:hover .dep-title { color: var(--amber); }
.dep-held {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em;
  color: var(--amber);
  border: 1px dashed var(--amber);
  border-radius: 999px;
  padding: 2px 8px 1px;
  white-space: nowrap;
}
.dep-meta {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em;
  color: var(--muted); margin-top: 5px;
}
.dep-track { position: relative; height: 3px; margin-top: 10px; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--hairline) 0 3px, transparent 3px 8px); }
.dep-bar { position: absolute; top: 0; height: 3px; border-radius: 2px; }

.dep-fare {
  font-family: var(--font-mono); font-weight: 700; font-size: 16px;
  color: var(--cream); font-variant-numeric: tabular-nums;
  text-align: right; min-width: 52px;
}
.dep-fare.free { color: var(--green); }

.dep-go { color: var(--muted); font-size: 20px; line-height: 1; transition: transform 0.15s ease, color 0.15s ease; }
.dep-btn:hover .dep-go { color: var(--amber); transform: translateX(4px); }

/* ---------- empty state ---------- */

.empty { text-align: center; padding: 90px 24px 110px; }
.empty-code {
  font-size: 20px; font-weight: 700; letter-spacing: 0.35em;
  color: var(--amber); margin-bottom: 18px;
}
.empty-msg { color: var(--muted); max-width: 46ch; margin: 0 auto 26px; }
.empty-reset {
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.08em;
  color: var(--paper-ink);
  background: var(--amber);
  border-radius: 3px;
  padding: 12px 22px;
  transition: background 0.15s ease;
}
.empty-reset:hover { background: #ffd670; }

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

.footer { border-top: 2px solid var(--hairline); background: var(--board); }
.footer-inner {
  display: grid; grid-template-columns: 1.2fr 0.9fr 1fr; gap: 48px;
  padding-top: 44px; padding-bottom: 56px;
}
.foot-h { color: var(--amber); margin-bottom: 14px; }
.foot-col p { color: var(--muted); font-size: 14px; }
.foot-lines { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.foot-lines li { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.foot-lines .legend-dot { flex: 0 0 auto; }

/* ---------- ticket (detail dialog) ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: var(--scrim);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 16px 24px;
  overflow-y: auto;
}
.scrim[hidden] { display: none; }

.ticket {
  position: relative;
  width: min(780px, 100%);
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 6px;
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.6);
  display: grid;
  grid-template-columns: 1fr 216px;
  margin: auto 0;
}

.t-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 38px; height: 38px;
  font-size: 26px; line-height: 1;
  color: var(--paper-muted);
  border-radius: 50%;
  transition: background 0.15s ease, color 0.15s ease;
}
.t-close:hover { background: rgba(36,29,18,0.09); color: var(--paper-ink); }

.t-main { padding: 34px 34px 30px 38px; min-width: 0; }
.t-topline { color: var(--paper-muted); text-transform: uppercase; margin-bottom: 14px; letter-spacing: 0.1em; }
.t-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(28px, 4.4vw, 40px);
  line-height: 1.08; text-transform: uppercase; letter-spacing: 0.012em;
  margin-bottom: 22px;
}

.t-spec {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px 22px;
  border-top: 1.5px solid var(--paper-line);
  border-bottom: 1.5px solid var(--paper-line);
  padding: 16px 0;
  margin-bottom: 22px;
}
.t-spec dt { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; color: #6f6449; margin-bottom: 3px; }
.t-spec dd { font-size: 15px; font-weight: 600; }
.t-spec dd.mono-v { font-family: var(--font-mono); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

.t-body p { font-size: 15.5px; line-height: 1.62; max-width: 62ch; }
.t-body p + p { margin-top: 12px; }
.t-body p:nth-child(2) { color: #4c4230; }

/* stub */
.t-stub {
  position: relative;
  border-left: 2px dashed var(--paper-line);
  padding: 34px 22px 26px;
  display: flex; flex-direction: column; gap: 16px;
  border-radius: 0 6px 6px 0;
  background:
    radial-gradient(circle 11px at 0 0, var(--ink) 98%, transparent),
    radial-gradient(circle 11px at 0 100%, var(--ink) 98%, transparent),
    var(--paper);
}
.t-hole {
  position: absolute; left: -15px; top: 50%;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.6), 0 0 0 4px var(--paper);
  transform: translateY(-50%) rotate(8deg);
}
.t-stub-h { color: var(--paper-muted); letter-spacing: 0.22em; text-align: center; }

.t-stamp {
  align-self: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 15px; letter-spacing: 0.3em;
  color: var(--stamp-c, var(--paper-muted));
  border: 3px double currentColor;
  border-radius: 4px;
  padding: 6px 10px 5px 14px;
  transform: rotate(-9deg);
  opacity: 0.95;
}

.t-stub-fare { text-align: center; color: var(--paper-muted); font-size: 12px; letter-spacing: 0.1em; }

.t-save {
  font-family: var(--font-mono); font-weight: 700; font-size: 12px; letter-spacing: 0.07em;
  text-align: center;
  color: var(--paper-ink);
  background: var(--amber);
  border: 2px solid var(--amber);
  border-radius: 3px;
  padding: 12px 10px;
  transition: background 0.15s ease, color 0.15s ease;
}
.t-save:hover { background: #ffd670; }
.t-save[aria-pressed="true"] {
  background: transparent;
  border: 2px dashed var(--paper-ink);
}
.t-save[aria-pressed="true"]:hover { background: rgba(36,29,18,0.07); }

.t-stub-lower { margin-top: auto; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.t-barcode {
  width: 100%; height: 36px;
  background: repeating-linear-gradient(90deg,
    var(--paper-ink) 0 2px, transparent 2px 4px,
    var(--paper-ink) 4px 7px, transparent 7px 9px,
    var(--paper-ink) 9px 10px, transparent 10px 14px,
    var(--paper-ink) 14px 16px, transparent 16px 18px);
  opacity: 0.85;
}
.t-no { color: var(--paper-muted); font-size: 11px; letter-spacing: 0.12em; }

.t-back {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.06em;
  color: var(--paper-muted);
  text-decoration: underline;
  padding: 6px 2px;
  align-self: center;
  transition: color 0.15s ease;
}
.t-back:hover { color: var(--paper-ink); }

/* ---------- responsive ---------- */

@media (max-width: 1020px) {
  .board { grid-template-columns: 1fr; gap: 44px; }
}

@media (max-width: 760px) {
  .wrap { padding: 0 20px; }
  .topline .topline-right { display: none; }
  .masthead-main { flex-direction: column; align-items: flex-start; gap: 20px; padding: 24px 0 18px; }
  .clockbox { flex-direction: row; gap: 14px; }
  .clock { width: 74px; height: 74px; }
  .day-chip { font-size: 13px; padding: 8px 12px; }
  .legend { padding: 6px 20px 14px; }

  .controls-inner { gap: 12px; padding-top: 12px; padding-bottom: 12px; }
  .ctl-search { flex-basis: 100%; }
  .ctl-count { margin-left: 0; padding-bottom: 2px; align-self: center; }

  .board { padding-top: 26px; gap: 36px; }
  .dep-btn { grid-template-columns: 64px 34px 1fr auto; gap: 12px; padding: 15px 4px; }
  .dep-time { font-size: 20px; }
  .dep-badge { font-size: 11px; padding: 5px 0; border-radius: 4px; }
  .dep-go { display: none; }
  .dep-title { font-size: 16px; }

  .footer-inner { grid-template-columns: 1fr; gap: 30px; }

  .ticket { grid-template-columns: 1fr; }
  .t-main { padding: 26px 22px 22px; }
  .t-spec { grid-template-columns: 1fr 1fr; }
  .t-stub {
    border-left: none;
    border-top: 2px dashed var(--paper-line);
    border-radius: 0 0 6px 6px;
    background:
      radial-gradient(circle 11px at 0 0, var(--ink) 98%, transparent),
      radial-gradient(circle 11px at 100% 0, var(--ink) 98%, transparent),
      var(--paper);
    padding: 24px 22px 22px;
  }
  .t-hole { left: 50%; top: -15px; transform: translateX(-50%) rotate(8deg); }
  .t-close { top: 6px; right: 6px; }
}

@media (max-width: 460px) {
  .dep-btn { grid-template-columns: 1fr auto; grid-template-rows: auto auto; row-gap: 8px; }
  .dep-when { grid-column: 1 / -1; grid-row: 1; flex-direction: row; align-items: baseline; gap: 8px; }
  .dep-dur { display: none; }
  .dep-badge { display: none; }
  .dep-main { grid-column: 1; grid-row: 2; }
  .dep-fare { grid-column: 2; grid-row: 2; align-self: start; }
  .t-spec { grid-template-columns: 1fr; }
}

/* ---------- motion ---------- */

@keyframes stampIn {
  0% { transform: rotate(-9deg) scale(1.6); opacity: 0; }
  60% { transform: rotate(-9deg) scale(0.94); opacity: 1; }
  100% { transform: rotate(-9deg) scale(1); opacity: 0.95; }
}
.t-stamp.stamped { animation: stampIn 0.28s ease-out; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .hand-sec line { transition: none; }
}
