/* Gatehouse — a departures-board task inbox.
   Charcoal board, amber signal, split-flap status plates. */

:root {
  --bg: #0e1013;
  --surface: #14181d;
  --surface-2: #1b2128;
  --plate: #0a0c0f;
  --line: #2a313a;
  --line-strong: #46505c;
  --ink: #ece8dd;
  --muted: #a8aeb7;
  --accent: #ffb300;
  --accent-ink: #1a1300;

  --s-todo: #f1ecdd;
  --s-in-progress: #62d0ff;
  --s-blocked: #ff7a66;
  --s-done: #78e2a0;

  --display: "Avenir Next Condensed", "DIN Condensed", "Barlow Condensed", "Roboto Condensed", "Arial Narrow", Impact, sans-serif;
  --body: "Avenir Next", "Segoe UI", "Helvetica Neue", system-ui, -apple-system, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: clip;
}
body.lock { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

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

.wrap { max-width: 1280px; margin-inline: auto; padding-inline: 32px; }

.label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); line-height: 1.3;
}

/* ---------- focus ---------- */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--accent); }
.open-item:focus-visible { outline: none; }
.open-item:focus-visible::after { outline: 3px solid var(--accent); outline-offset: -3px; }
.skip {
  position: absolute; left: 16px; top: -80px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 12px 20px; font-weight: 700;
  border-radius: 4px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- header ---------- */
.top { border-bottom: 1px solid var(--line); background: var(--bg); }
.top-row { display: flex; align-items: center; justify-content: space-between; min-height: 64px; }
.brand {
  display: inline-flex; align-items: center; gap: 12px; min-height: 44px;
  color: var(--ink); text-decoration: none;
}
.brand-mark { color: var(--accent); flex: none; }
.brand-name {
  font-family: var(--display); font-weight: 700; font-size: 1.625rem;
  letter-spacing: 0.04em; text-transform: uppercase; line-height: 1;
}
.top-nav { display: flex; gap: 8px; }
.top-nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.9375rem;
  border-radius: 4px; transition: color 150ms var(--ease), background-color 150ms var(--ease);
}

/* ---------- hero ---------- */
.hero { padding-block: 40px 40px; }
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 48px; align-items: center;
}
.hero-copy .label { margin-bottom: 16px; color: var(--accent); }
.hero-copy h1 {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: clamp(2.25rem, 4.8vw, 4.5rem); line-height: 1; letter-spacing: -0.01em;
  max-width: 14ch; animation: rise 520ms var(--ease) both;
}
.lede { margin-top: 20px; max-width: 46ch; color: var(--muted); font-size: 1.0625rem; }

.hero-count { display: flex; align-items: center; gap: 28px; justify-content: flex-end; }
.count-flaps { font-size: clamp(5.5rem, 9.5vw, 8.5rem); flex: none; }
.hero .count-flaps .ch { color: var(--accent); }
.count-text { min-width: 0; max-width: 260px; }
.count-label {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 1.75rem; line-height: 1.05; letter-spacing: 0.02em;
}
.count-sub { margin-top: 8px; color: var(--muted); font-size: 0.9375rem; }
.next-btn {
  display: block; width: 100%; margin-top: 16px; text-align: left; min-height: 44px;
  background: transparent; border: 1px solid var(--line-strong); border-left: 4px solid var(--accent);
  border-radius: 4px; padding: 10px 14px;
  transition: background-color 150ms var(--ease), transform 150ms var(--ease);
}
.next-btn .label { display: block; }
.next-title { display: block; font-size: 0.9375rem; font-weight: 600; line-height: 1.35; margin-top: 2px; }

/* hazard kerb: the one stripe on the page */
.board-section { position: relative; padding-top: 8px; padding-bottom: 96px; }
.board-section::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px;
  background: repeating-linear-gradient(135deg, var(--accent) 0 12px, var(--bg) 12px 24px);
}
.board-section > .wrap { padding-top: 40px; }

/* ---------- split-flap ---------- */
.flaps { display: inline-flex; gap: 0.07em; perspective: 700px; vertical-align: middle; }
.flaps .ch {
  position: relative; display: inline-block; width: 0.64em; height: 1.1em; line-height: 1.1em;
  text-align: center; font-family: var(--display); font-weight: 700; font-size: 1em;
  background: linear-gradient(#242b34 0 50%, #191e25 50% 100%);
  border-radius: 0.09em; color: var(--c, var(--ink));
  font-variant-numeric: tabular-nums;
}
.flaps .ch::after {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px;
  margin-top: -1px; background: var(--plate);
}
.flaps .ch.sp { background: none; width: 0.3em; }
.flaps .ch.sp::after { display: none; }
.flaps[data-s="todo"] { --c: var(--s-todo); }
.flaps[data-s="in-progress"] { --c: var(--s-in-progress); }
.flaps[data-s="blocked"] { --c: var(--s-blocked); }
.flaps[data-s="done"] { --c: var(--s-done); }
.flaps.go .ch {
  animation: flip 420ms var(--ease) backwards;
  animation-delay: calc(var(--r, 0) * 30ms + var(--i, 0) * 28ms);
}

.dot {
  display: inline-block; width: 12px; height: 12px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; vertical-align: middle;
}
.dot[data-s="in-progress"] { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.dot[data-s="blocked"] { border-radius: 2px; background: repeating-linear-gradient(45deg, currentColor 0 2px, transparent 2px 4px); }
.dot[data-s="done"] { background: currentColor; }
.dot[data-s="todo"] { color: var(--s-todo); }
.dot[data-s="in-progress"] { color: var(--s-in-progress); }
.dot[data-s="blocked"] { color: var(--s-blocked); }
.dot[data-s="done"] { color: var(--s-done); }

/* ---------- controls ---------- */
.controls {
  display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px 16px; align-items: end;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
input[type="search"], select {
  width: 100%; height: 48px; padding: 0 14px; font-size: 16px;
  background: var(--plate); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 4px;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
input::placeholder { color: #7f8791; }
select { padding-right: 8px; }

.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px;
  background: transparent; border: 1px solid var(--line-strong); border-radius: 4px;
  font-weight: 600; font-size: 0.9375rem;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease), transform 150ms var(--ease);
}
.chip .n { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] .n { color: var(--accent-ink); }
.chip[aria-pressed="true"] .dot { color: var(--accent-ink); }

.result-line { margin-top: 24px; margin-bottom: 8px; font-size: 0.875rem; color: var(--muted); min-height: 1.4em; }

/* ---------- rows ---------- */
.cols, .row {
  display: grid; align-items: center; column-gap: 24px;
  grid-template-columns: 72px minmax(0, 1fr) 170px 190px;
  grid-template-areas: "due main who status";
  padding-inline: 20px;
}
.cols {
  padding-block: 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}
.rows {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden;
}
.row {
  position: relative; padding-block: 16px; min-height: 80px;
  border-bottom: 1px solid var(--line);
  animation: rise 420ms var(--ease) backwards;
  animation-delay: calc(var(--r, 0) * 40ms);
  transition: background-color 150ms var(--ease);
}
.row:last-child { border-bottom: 0; }
.row.changed { animation: flash 1400ms ease-out; }

.due { grid-area: due; display: flex; flex-direction: column; line-height: 1; }
.due-d { font-family: var(--display); font-weight: 700; font-size: 2.25rem; letter-spacing: -0.01em; }
.due-m { margin-top: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.main { grid-area: main; min-width: 0; }
.t { font-size: 1.0625rem; font-weight: 650; line-height: 1.35; }
.open-item {
  all: unset; box-sizing: border-box; cursor: pointer; display: inline;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; text-decoration-thickness: 2px;
  transition: text-decoration-color 150ms var(--ease);
}
.open-item::after { content: ""; position: absolute; inset: 0; }
.meta { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 0.875rem; color: var(--muted); }
.meta > span { display: inline-flex; align-items: center; gap: 6px; }
.pri::before {
  content: ""; width: 14px; height: 8px; border: 1px solid currentColor; border-radius: 1px;
  background: linear-gradient(90deg, currentColor var(--lv, 33%), transparent var(--lv, 33%));
}
.pri[data-p="high"] { --lv: 100%; color: var(--ink); }
.pri[data-p="medium"] { --lv: 66%; }
.pri[data-p="low"] { --lv: 33%; }

.who { grid-area: who; display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 0.9375rem; }
.av {
  flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line-strong); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted);
}
.status-cell { grid-area: status; display: flex; align-items: center; gap: 12px; font-size: 1.0625rem; justify-self: start; }

/* ---------- empty ---------- */
.empty {
  border: 2px dashed var(--line-strong); border-radius: var(--r); padding: 56px 32px; margin-top: 8px;
}
.empty-big { font-family: var(--display); font-weight: 700; text-transform: uppercase; font-size: clamp(2.25rem, 5vw, 3.5rem); line-height: 1; }
.empty-text { margin: 12px 0 24px; color: var(--muted); max-width: 52ch; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 12px 20px;
  border-radius: 4px; border: 1px solid transparent; font-weight: 700;
  transition: background-color 150ms var(--ease), transform 150ms var(--ease);
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }

/* ---------- detail ---------- */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(5, 6, 8, 0.7); animation: fade 200ms ease-out; }
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(580px, 100vw);
  display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--line-strong); box-shadow: -24px 0 60px rgba(0, 0, 0, 0.5);
  animation: slide 260ms var(--ease);
}
.detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px 12px 28px; border-bottom: 1px solid var(--line); min-height: 68px;
}
.detail-head .label { font-family: var(--mono); letter-spacing: 0.08em; }
.close {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px;
  background: transparent; border: 1px solid var(--line-strong); border-radius: 4px; font-weight: 600;
  transition: background-color 150ms var(--ease), transform 150ms var(--ease);
}
.detail-scroll { flex: 1; overflow-y: auto; padding: 28px 28px 48px; }
.detail-title {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: clamp(2rem, 3.4vw, 2.75rem); line-height: 1.02; letter-spacing: -0.005em;
}
.detail-status {
  margin-top: 24px; padding: 16px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: end;
}
.status-now { display: flex; flex-direction: column; gap: 10px; }
.flap-slot { display: flex; align-items: center; gap: 10px; font-size: 1.375rem; min-height: 48px; }
.save-note { margin-top: 10px; font-size: 0.875rem; color: var(--muted); min-height: 1.4em; }
.save-note.ok { color: var(--s-done); }

.facts { margin-top: 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; padding-block: 24px; border-block: 1px solid var(--line); }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin-top: 4px; font-weight: 600; }
.facts .wide { grid-column: 1 / -1; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags span { border: 1px solid var(--line-strong); border-radius: 3px; padding: 2px 10px; font-size: 0.875rem; font-weight: 600; }

.sub-label { margin-top: 32px; margin-bottom: 12px; }
.body { max-width: 60ch; }
.body p { font-size: 1.0625rem; line-height: 1.7; }
.body p + p { margin-top: 16px; }
.body strong { color: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; justify-content: space-between;
  background: var(--ink); color: #15171a; border-radius: 6px; padding: 10px 10px 10px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55); border-left: 6px solid var(--accent);
  animation: rise 260ms var(--ease);
}
.toast-text { font-weight: 600; font-size: 0.9375rem; line-height: 1.4; }
.toast-actions { display: flex; gap: 4px; }
.toast-actions button {
  min-height: 44px; padding: 0 14px; background: transparent; border: 0; border-radius: 4px;
  font-weight: 700; text-decoration: underline; text-underline-offset: 3px; color: #15171a;
  transition: background-color 150ms var(--ease), transform 150ms var(--ease);
}
.toast :focus-visible { outline-color: #15171a; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); padding-block: 24px; color: var(--muted); font-size: 0.875rem; }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes flip {
  0% { transform: rotateX(-90deg); opacity: 0; }
  60% { transform: rotateX(14deg); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
@keyframes flash { from { background-color: rgba(255, 179, 0, 0.3); } to { background-color: transparent; } }

/* ---------- hover (pointer devices only) ---------- */
@media (hover: hover) and (pointer: fine) {
  .top-nav a:hover { color: var(--ink); background: var(--surface-2); }
  .brand:hover .brand-name { color: var(--accent); }
  .next-btn:hover { background: var(--surface-2); }
  .chip:hover { background: var(--surface-2); }
  .chip[aria-pressed="true"]:hover { background: #ffc233; }
  .row:hover { background: var(--surface-2); }
  .row:hover .open-item { text-decoration-color: var(--accent); }
  .row:hover .av { color: var(--ink); border-color: var(--ink); }
  input[type="search"]:hover, select:hover { border-color: var(--muted); }
  .btn-primary:hover { background: #ffc233; }
  .close:hover { background: var(--surface-2); }
  .toast-actions button:hover { background: rgba(0, 0, 0, 0.1); }
  .skip:hover { text-decoration: underline; }
}

/* ---------- press ---------- */
.btn:active, .chip:active, .close:active, .next-btn:active, .toast-actions button:active, .top-nav a:active { transform: scale(0.97); }
.row:active { background: var(--surface-2); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; gap: 32px; }
  .hero-count { justify-content: flex-start; }
  .cols { display: none; }
  .row {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas: "due main main" "due who status";
    row-gap: 12px; column-gap: 16px;
  }
  .status-cell { justify-self: end; }
}

@media (max-width: 640px) {
  .wrap { padding-inline: 20px; }
  .hero { padding-block: 28px 32px; }
  .hero-copy h1 { font-size: 2.5rem; }
  .hero-count { gap: 20px; flex-wrap: wrap; }
  .count-flaps { font-size: 5.25rem; }
  .count-text { max-width: none; flex: 1 1 180px; }
  .board-section > .wrap { padding-top: 28px; }
  .controls { grid-template-columns: 1fr; }
  .chips { gap: 8px; }
  .chip { padding: 0 12px; gap: 8px; }
  .row { padding: 16px; }
  .due-d { font-size: 2rem; }
  .status-cell { font-size: 0.9375rem; gap: 8px; }
  .detail { width: 100vw; border-left: 0; }
  .detail-head { padding-left: 20px; padding-right: 16px; }
  .detail-scroll { padding: 24px 20px 48px; }
  .detail-status { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; gap: 16px; }
  .empty { padding: 32px 20px; }
  .toast { bottom: 12px; }
}

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