/* TERMINUS. Split-flap departure board for one weekend.
   Palette lock: near-black board, warm off-white type, one phosphor-amber accent.
   Radius lock: all sharp. */

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

:root {
  --board: #0e0e10;
  --panel: #17171a;
  --tile: #1d1d21;
  --tile-hi: #242428;
  --line: #2b2b30;
  --ink: #f2efe6;
  --ink-dim: #a8a49a;
  --amber: #ffb000;
  --amber-dim: #8a6410;
  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--board);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body:has(dialog[open]) { overflow: hidden; }

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

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

.dim { color: var(--ink-dim); }

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

.masthead {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 24px 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.flapline {
  margin: 0;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.flap-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.72em;
  height: 1.24em;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(44px, 6vw, 76px);
  line-height: 1;
  color: var(--ink);
  background: var(--tile);
  border-top: 1px solid #3a3a40;
  box-shadow: inset 0 -0.55em 0 rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.flap-char.space { width: 0.34em; background: none; border: none; box-shadow: none; }

@media (prefers-reduced-motion: no-preference) {
  .flap-char {
    animation: flap-drop 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: calc(var(--i) * 60ms);
  }
  @keyframes flap-drop {
    0% { transform: rotateX(-90deg); opacity: 0; }
    60% { opacity: 1; }
    100% { transform: rotateX(0deg); opacity: 1; }
  }
}

.masthead-sub {
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.masthead-meta { text-align: right; }

.masthead-dates {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--amber);
}

.masthead-countdown {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-dim);
}

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

.controls {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 26px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 200px auto;
  gap: 18px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.control { display: grid; gap: 6px; }

.control-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.control-input {
  width: 100%;
  background: var(--tile);
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--amber-dim);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 11px 12px;
  border-radius: 0;
}
.control-input:hover { border-color: #3c3c42; }
.control-input::placeholder { color: #8a857b; }

.control-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--amber) 50%),
    linear-gradient(135deg, var(--amber) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
  cursor: pointer;
}

.held-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--tile);
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--amber-dim);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 11px 16px;
  cursor: pointer;
  border-radius: 0;
}
.held-toggle:hover { border-color: #3c3c42; }

.held-dot {
  width: 9px;
  height: 9px;
  background: var(--line);
  flex: none;
}
.held-toggle[aria-pressed="true"] { border-bottom-color: var(--amber); }
.held-toggle[aria-pressed="true"] .held-dot { background: var(--amber); }

.board-status {
  grid-column: 1 / -1;
  margin: -6px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
}

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

.board { max-width: 1180px; margin: 0 auto; padding: 8px 24px 8px; }

.day-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin: 34px 0 12px;
}

.day-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 3.4vw, 40px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.day-count {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--amber);
  text-transform: uppercase;
}

.rows { display: grid; gap: 6px; }

.row { position: relative; }
.row::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--amber);
  opacity: 0;
}
.row.is-held::before { opacity: 1; }

.row-open {
  display: grid;
  grid-template-columns: 108px 1fr auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 14px 18px;
  cursor: pointer;
  border-radius: 0;
  font: inherit;
}
.row-open:hover { background: var(--tile); border-color: #3c3c42; }
.row-open:hover .row-arrow { transform: translateX(4px); color: var(--amber); }
.row-open:active { transform: translateY(1px); }

.row-time {
  display: grid;
  gap: 2px;
  justify-items: start;
}

.row-dep {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 22px;
  color: var(--amber);
  line-height: 1;
}

.row-until {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-dim);
}

.row-main { display: grid; gap: 4px; min-width: 0; }

.row-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 21px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.2;
}

.row-venue {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-dim);
}

.row-held-stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: #141416;
  background: var(--amber);
  padding: 2px 7px;
  width: fit-content;
}

.row-side {
  display: grid;
  gap: 8px;
  justify-items: end;
  align-content: center;
}

.row-code {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--amber);
  border: 1px solid var(--amber-dim);
  padding: 4px 9px;
}

.row-fare {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.row-fare.free { color: var(--amber); }

.row-arrow {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--ink-dim);
  transition: transform 0.2s ease, color 0.2s ease;
}

@media (prefers-reduced-motion: no-preference) {
  .board--animate .row { animation: row-in 0.4s ease both; animation-delay: calc(var(--i) * 40ms); }
  @keyframes row-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }
}

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

.empty {
  max-width: 1180px;
  margin: 0 auto;
  padding: 70px 24px 90px;
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.empty-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0.05em;
  color: var(--ink);
}

.empty-body {
  margin: 0 0 10px;
  color: var(--ink-dim);
  max-width: 44ch;
}

.btn {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 12px 20px;
  cursor: pointer;
  border-radius: 0;
  border: none;
}
.btn:active { transform: translateY(1px); }

.btn-amber { background: var(--amber); color: #141416; font-weight: 700; }
.btn-amber:hover { background: #ffc23d; }
.btn-amber:focus-visible, .btn-hold:focus-visible { outline-color: var(--ink); }

/* ---------- colophon ---------- */

.colophon {
  max-width: 1180px;
  margin: 30px auto 0;
  padding: 22px 24px 40px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
  display: grid;
  gap: 6px;
}
.colophon p { margin: 0; }
.colophon-dim { color: #8a857b; }

/* ---------- ticket dialog ---------- */

.ticket {
  border: none;
  padding: 24px;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
}
.ticket[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
.ticket::backdrop { background: rgba(6, 6, 8, 0.78); }

.ticket-panel {
  background: var(--panel);
  border: 1px solid #3a3a40;
  max-width: 620px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  margin: 0 auto;
}

@media (prefers-reduced-motion: no-preference) {
  .ticket[open] .ticket-panel { animation: ticket-in 0.3s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
  @keyframes ticket-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
  }
}

.ticket-photo { margin: 0; }
.ticket-photo img {
  display: block;
  width: 100%;
  height: 210px;
  object-fit: cover;
  filter: saturate(0.82) contrast(1.02);
}
.ticket-photo-cap {
  padding: 8px 22px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #8a857b;
}

.ticket-stubline {
  margin: 18px 22px 0;
  border-top: 2px dashed var(--line);
}

.ticket-body { padding: 14px 22px 26px; }

.ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.ticket-code {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--amber);
  border: 1px solid var(--amber-dim);
  padding: 4px 9px;
}

.ticket-close {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 0;
}
.ticket-close:hover { border-color: var(--amber); color: var(--amber); }

.ticket-when {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--amber);
}

.ticket-title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.12;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

.ticket-prose p { margin: 0 0 12px; font-size: 16px; color: var(--ink); }
.ticket-prose p:first-child { color: var(--ink); font-size: 17px; }
.ticket-prose p + p { color: var(--ink-dim); }

.ticket-facts {
  margin: 18px 0 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.ticket-fact-label {
  margin: 0 0 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 400;
}

.ticket-fact-value {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14.5px;
  color: var(--ink);
}

.ticket-access { margin-top: 18px; }
.ticket-access p { margin: 0; font-size: 14.5px; color: var(--ink-dim); }

.ticket-actions { margin-top: 22px; display: flex; gap: 12px; }

.btn-hold {
  flex: 1;
  background: var(--amber);
  color: #141416;
  font-weight: 700;
  border: 1px solid var(--amber);
}
.btn-hold:hover { background: #ffc23d; }
.btn-hold[aria-pressed="true"] {
  background: var(--tile);
  color: var(--amber);
  border: 1px solid var(--amber);
}

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

@media (max-width: 860px) {
  .controls { grid-template-columns: 1fr; align-items: stretch; }
  .masthead { padding-top: 24px; }
  .masthead-meta { text-align: left; }
}

@media (max-width: 640px) {
  .masthead { padding: 22px 16px 16px; }
  .controls { padding: 0 16px 20px; gap: 14px; }
  .board { padding: 4px 16px; }
  .colophon { padding: 18px 16px 34px; }

  .row-open {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "time side"
      "main main";
    gap: 10px 14px;
    padding: 14px 16px;
  }
  .row-time { grid-area: time; grid-auto-flow: column; align-items: baseline; gap: 8px; }
  .row-side { grid-area: side; grid-auto-flow: column; align-content: center; }
  .row-main { grid-area: main; }
  .row-title { font-size: 19px; }
  .row-dep { font-size: 19px; }
  .row-arrow { display: none; }

  .ticket { padding: 0; }
  .ticket-panel { max-width: none; max-height: 100vh; height: 100%; }
  .ticket-photo img { height: 170px; }
  .ticket-facts { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
