/* Concourse, a city magazine styled as a departures board.
   Palette: graphite + a single amber signal color. Category "lines" use
   their own wayfinding hues, always paired with text (never color-only). */

@font-face {
  font-family: 'Oswald';
  src: url('assets/oswald.ttf') format('truetype');
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Work Sans';
  src: url('assets/work-sans.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #121212;
  --bg-elevated: #1a1a18;
  --bg-row: #171613;
  --border: #34322c;
  --text: #f5f3ee;
  --text-muted: #b6b0a4;
  --text-faint: #948c7c;
  --accent: #f2b134;
  --accent-contrast: #1a1400;
  --focus-ring: #ffd873;

  --line-culture: #b09be0;
  --line-food: #e0864a;
  --line-movement: #5ea3df;
  --line-people: #de7f96;
  --line-places: #62b884;

  --radius-box: 10px;
  --radius-pill: 999px;

  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: 'Work Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-box);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
  transition: top 0.2s ease;
  z-index: 100;
}

.skip-link:focus {
  top: 1rem;
}

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

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 2rem 1.5rem 1.5rem;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 2.75rem);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0;
  color: var(--text);
}

.wordmark span {
  color: var(--accent);
}

.tagline {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* ---------- Main layout ---------- */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 200px auto;
  gap: 0.9rem;
  align-items: end;
  margin-bottom: 1.1rem;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-field label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.control-field input,
.control-field select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-box);
  font-size: 0.95rem;
  font-family: var(--font-body);
}

.control-field input::placeholder {
  color: var(--text-faint);
}

.control-field input:focus-visible,
.control-field select:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.pill-toggle {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-pill);
  padding: 0.65rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.pill-toggle:active {
  transform: scale(0.98);
}

.pill-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.result-count {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  letter-spacing: 0.03em;
  margin: 0 0 1.25rem;
}

/* ---------- Board ---------- */

.board-head {
  display: grid;
  grid-template-columns: 84px 1fr 130px 160px;
  gap: 1rem;
  padding: 0 1.1rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}

.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.6rem;
}

.board-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-box);
  background: var(--bg-row);
  overflow: hidden;
}

.row-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 84px 1fr 130px 160px;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1.1rem;
  background: transparent;
  border: none;
  text-align: left;
  border-radius: var(--radius-box);
  transition: background 0.15s ease;
}

.row-btn:hover,
.row-btn:focus-visible {
  background: rgba(242, 177, 52, 0.08);
}

.time-block {
  font-family: var(--font-mono);
  line-height: 1.1;
}

.time-block .digits {
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
  display: inline-block;
}

.time-block .unit {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-top: 0.1rem;
}

.story-col {
  min-width: 0;
}

.story-title {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.08rem;
  letter-spacing: 0.01em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.story-summary {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.saved-flag {
  display: inline-block;
  margin-left: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  vertical-align: middle;
}

.line-badge {
  justify-self: start;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-pill);
  color: var(--accent-contrast);
  white-space: nowrap;
}

.byline {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* board-row entry animation, motivated by list updates (search/filter feedback) */
@media (prefers-reduced-motion: no-preference) {
  .board-row {
    animation: flap-in 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 45ms);
  }

  @keyframes flap-in {
    from {
      opacity: 0;
      transform: perspective(600px) rotateX(-8deg) translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-box);
  margin-top: 0.6rem;
}

.empty-state p {
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-size: 1rem;
}

.empty-state button {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  padding: 0.65rem 1.3rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.9rem;
}

.empty-state button:active {
  transform: scale(0.98);
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.site-footer p {
  font-size: 0.78rem;
  color: var(--text-faint);
  max-width: 65ch;
}

/* ---------- Detail dialog (the boarding pass) ---------- */

dialog#detail-dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(640px, 92vw);
  width: 100%;
  max-height: 88dvh;
  border-radius: var(--radius-box);
  overflow: visible;
}

dialog#detail-dialog::backdrop {
  background: rgba(8, 7, 5, 0.72);
}

@media (prefers-reduced-motion: no-preference) {
  dialog#detail-dialog[open] .ticket {
    animation: ticket-in 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  @keyframes ticket-in {
    from {
      opacity: 0;
      transform: translateY(18px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

.ticket {
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-box);
  overflow: hidden;
}

.ticket-media {
  position: relative;
  height: 200px;
  flex-shrink: 0;
}

.ticket-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.close-detail-btn {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: var(--radius-pill);
  background: rgba(18, 18, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--text);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.close-detail-btn:hover {
  background: rgba(18, 18, 18, 0.9);
}

.ticket-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px dashed var(--border);
  flex-shrink: 0;
}

.ticket-header .line-badge {
  margin-bottom: 0.6rem;
}

.ticket-title {
  margin: 0 0 0.7rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--text);
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.save-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--bg-row);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.55rem 1.1rem 0.55rem 0.7rem;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.save-toggle .stub {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 2px;
  border: 1.5px solid var(--text-muted);
  flex-shrink: 0;
}

.save-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.save-toggle[aria-pressed="true"] .stub {
  background: var(--accent-contrast);
  border-color: var(--accent-contrast);
}

.ticket-body {
  padding: 1.25rem 1.5rem 1.75rem;
  overflow-y: auto;
}

.ticket-body p {
  max-width: 65ch;
  margin: 0 0 1rem;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.65;
}

.ticket-body p:last-child {
  margin-bottom: 0;
}

/* ---------- Line badge colors (semantic, always paired with text) ---------- */

.line-badge[data-line="Culture"] { background: var(--line-culture); }
.line-badge[data-line="Food"] { background: var(--line-food); }
.line-badge[data-line="Movement"] { background: var(--line-movement); }
.line-badge[data-line="People"] { background: var(--line-people); }
.line-badge[data-line="Places"] { background: var(--line-places); }

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .pill-toggle {
    width: 100%;
    text-align: center;
  }

  .board-head {
    display: none;
  }

  .row-btn {
    grid-template-columns: 60px 1fr;
    grid-template-areas:
      "time story"
      "line line"
      "byline byline";
    row-gap: 0.5rem;
  }

  .time-block { grid-area: time; }
  .story-col { grid-area: story; }
  .line-badge { grid-area: line; }
  .byline {
    grid-area: byline;
    text-align: left;
  }

  .ticket {
    max-height: 92dvh;
  }

  dialog#detail-dialog {
    max-height: 92dvh;
  }
}
