:root {
  --ink: #1a1a1a;
  --paper: #f4f1ea;
  --paper-card: #ffffff;
  --rail: #c9c2b2;
  --rail-dark: #2b2b2b;
  --hazard: #ffcc00;
  --culture: #8e44ad;
  --food: #d9711d;
  --movement: #1e8e5a;
  --people: #d64545;
  --places: #2f6fb0;
  --font-display: "Futura", "Trebuchet MS", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--hazard);
  color: var(--ink);
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  z-index: 1000;
  border-radius: 0 0 6px 0;
}

.skip-link:focus {
  left: 0;
}

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

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

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

.site-header {
  background: var(--rail-dark);
  color: var(--paper);
  padding: 2rem 1.5rem 1.25rem;
  border-bottom: 6px solid var(--hazard);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--hazard);
  font-weight: 700;
}

.site-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  line-height: 1.05;
}

.site-tagline {
  margin: 0.6rem 0 0;
  font-size: 1rem;
  max-width: 40em;
  color: #d8d4c8;
}

.line-legend {
  max-width: 900px;
  margin: 1.25rem auto 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.4rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.legend-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 800;
  color: #fff;
}

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

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

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

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
  background: var(--paper-card);
  border: 1px solid var(--rail);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 200px;
}

.control-group label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #444;
}

.control-group input,
.control-group select {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--rail-dark);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
}

.control-filter select {
  border-radius: 8px;
}

.ticket-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 2px dashed var(--rail-dark);
  background: var(--paper);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
}

.ticket-toggle[aria-pressed="true"] {
  background: var(--hazard);
  border-style: solid;
}

.ticket-icon {
  font-size: 1.1rem;
}

.result-count {
  margin: 1.1rem 0.25rem 0;
  font-size: 0.9rem;
  color: #555;
  font-weight: 600;
}

/* ---------- Line map (list) ---------- */

.line-map {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.station {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.25rem 1rem;
  padding: 0.85rem 0;
}

.station::before {
  content: "";
  position: absolute;
  left: 27px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--rail);
  transform: translateX(-50%);
  z-index: 0;
}

.station:first-child::before {
  top: 50%;
}

.station:last-child::before {
  bottom: 50%;
}

.station-bullet {
  position: relative;
  z-index: 1;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  border: 4px solid var(--paper);
  align-self: start;
  margin-top: 0.1rem;
}

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

.station-card {
  background: var(--paper-card);
  border: 1px solid var(--rail);
  border-radius: 10px;
  padding: 0.9rem 1.1rem 1.1rem;
}

.station-open {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 0.35rem;
  color: inherit;
  border-radius: 6px;
}

.station-line-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.4rem;
}

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

.station-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1.25;
  text-decoration: underline;
  text-decoration-color: transparent;
}

.station-open:hover .station-title,
.station-open:focus-visible .station-title {
  text-decoration-color: currentColor;
}

.station-meta {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #555;
  font-weight: 600;
}

.station-summary {
  margin: 0;
  color: #333;
}

.saved-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #8a6d00;
  margin-left: 0.5rem;
}

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

.empty-state {
  margin-top: 2rem;
  padding: 2.25rem 1.5rem;
  text-align: center;
  background: var(--paper-card);
  border: 2px dashed var(--rail-dark);
  border-radius: 10px;
}

.empty-headline {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  margin: 0 0 0.4rem;
}

.empty-copy {
  margin: 0 0 1rem;
  color: #555;
}

#reset-filters {
  background: var(--rail-dark);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.3rem;
  font-weight: 700;
  font-size: 0.9rem;
}

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

.site-footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
  color: #777;
  font-size: 0.78rem;
}

/* ---------- Detail dialog (platform board) ---------- */

.platform-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(720px, 92vw);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.platform-dialog::backdrop {
  background: rgba(10, 10, 10, 0.6);
}

@media (prefers-reduced-motion: no-preference) {
  .platform-dialog[open] {
    animation: rise-in 0.25s ease-out;
  }

  .platform-dialog[open]::backdrop {
    animation: fade-in 0.25s ease-out;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.platform-board {
  background: var(--rail-dark);
  color: var(--paper);
  padding: 1.5rem 1.5rem 1.25rem;
  position: relative;
}

.exit-btn {
  background: transparent;
  border: 2px solid var(--paper);
  color: var(--paper);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.exit-btn:hover {
  background: var(--paper);
  color: var(--rail-dark);
}

.board-eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--hazard);
  margin: 0 0 0.4rem;
}

.board-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  line-height: 1.2;
  margin: 0 0 1rem;
}

.board-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  margin: 0 0 1.1rem;
}

.board-meta-item dt {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b8b4a8;
  font-weight: 700;
}

.board-meta-item dd {
  margin: 0.15rem 0 0;
  font-family: "Courier New", Courier, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.save-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--paper);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.save-toggle[aria-pressed="true"] {
  background: var(--hazard);
}

.platform-body {
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  background: var(--paper-card);
  flex: 1 1 auto;
}

.platform-body p {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  line-height: 1.7;
  color: #222;
  margin: 0 0 1.1rem;
}

.platform-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  background: var(--paper);
  border-top: 1px solid var(--rail);
}

.stop-nav-btn {
  background: none;
  border: 2px solid var(--rail-dark);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
}

.stop-nav-btn:hover {
  background: var(--rail-dark);
  color: var(--paper);
}

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

@media (max-width: 640px) {
  .site-header {
    padding: 1.5rem 1.1rem 1rem;
  }

  main {
    padding: 1.25rem 1rem 2.5rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .ticket-toggle {
    justify-content: center;
  }

  .station {
    grid-template-columns: 44px 1fr;
  }

  .station-bullet {
    width: 44px;
    height: 44px;
    font-size: 0.68rem;
  }

  .station::before {
    left: 21px;
  }

  .platform-dialog {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .platform-nav {
    flex-direction: column;
  }
}

/* Review repair: a closed native dialog must not render in the page. */
.platform-dialog:not([open]) { display: none !important; }
