/* ---------- Tokens ---------- */
:root {
  --paper: #f5efe1;
  --paper-alt: #ece2cb;
  --paper-raised: #fffcf5;
  --ink: #17213a;
  --ink-soft: #454f68;
  --ink-faint: #7a8298;
  --rail: #b9ae95;
  --focus: #a8380f;
  --line-culture: #6b3fa0;
  --line-food: #b0491c;
  --line-movement: #1a6f9c;
  --line-people: #a53468;
  --line-places: #2e5c2a;

  --font-display: "Bahnschrift", "DIN Alternate", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-body: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --radius-pill: 999px;
  --shadow-panel: -10px 0 34px rgba(23, 33, 58, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

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

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.25rem;
  z-index: 1000;
  border-radius: 0 0 8px 0;
  font-family: var(--font-display);
  text-decoration: none;
}

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

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

button {
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  opacity: 0.8;
}

/* ---------- Masthead ---------- */
.masthead {
  background: var(--paper-alt);
  border-bottom: 3px solid var(--ink);
  padding: 1.5rem clamp(1rem, 4vw, 3rem) 1.75rem;
}

.masthead-top {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0;
  position: relative;
  padding-left: 0.1em;
}

.wordmark::before {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: var(--focus);
  margin-right: 0.35em;
  vertical-align: middle;
  transform: translateY(-0.08em);
}

.tagline {
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1rem;
}

.controls {
  display: flex;
  gap: 1rem 1.25rem;
  flex-wrap: wrap;
  align-items: end;
  margin: 1.25rem auto 0;
  max-width: 1200px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.control label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.search-control {
  flex: 1 1 220px;
}

.filter-control {
  flex: 0 1 200px;
}

input[type="search"],
select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.65rem 1rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--paper-raised);
  color: var(--ink);
  min-height: 44px;
  width: 100%;
}

select {
  appearance: auto;
}

.ticket-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--paper-raised);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ticket-toggle .ticket-icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.ticket-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.ticket-count {
  font-family: var(--font-mono);
  background: var(--focus);
  color: #fff;
  border-radius: var(--radius-pill);
  min-width: 1.5em;
  height: 1.5em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  padding: 0 0.35em;
}

.ticket-toggle[aria-pressed="true"] .ticket-count {
  background: var(--paper);
  color: var(--ink);
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 2.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 3rem) 3rem;
}

.line-key {
  position: sticky;
  top: 1.5rem;
  align-self: start;
}

.line-key h2 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}

.line-key ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.key-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 44px;
  padding: 0.4rem 0.6rem;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 0.95rem;
  text-align: left;
}

.key-btn:hover {
  background: var(--paper-alt);
}

.key-btn[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--paper-raised);
  font-weight: 700;
}

.key-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  background: var(--ink-faint);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1.5px var(--ink-soft);
}

.key-dot--all {
  background: conic-gradient(
    var(--line-culture) 0 20%,
    var(--line-food) 20% 40%,
    var(--line-movement) 40% 60%,
    var(--line-people) 60% 80%,
    var(--line-places) 80% 100%
  );
}

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

main {
  min-width: 0;
}

.section-label {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 0.25rem;
}

.results-status {
  margin: 0 0 1.25rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ---------- Line map (list) ---------- */
.line-map {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 700px;
}

.station {
  position: relative;
  padding: 1.1rem 0.5rem 1.35rem 2.75rem;
  border-bottom: 1px dashed rgba(23, 33, 58, 0.18);
}

.station:last-child {
  border-bottom: none;
}

.station::before {
  content: "";
  position: absolute;
  left: 0.95rem;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--rail);
}

.station:first-child::before {
  top: 1.6rem;
}

.station:last-child::before {
  bottom: calc(100% - 1.6rem);
}

.station-dot {
  position: absolute;
  left: 0.55rem;
  top: 1.35rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 2px var(--ink-faint);
}

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

.station-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.line-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid currentColor;
  white-space: nowrap;
}

.line-badge[data-color="Culture"] { color: var(--line-culture); background: color-mix(in srgb, var(--line-culture) 12%, var(--paper)); }
.line-badge[data-color="Food"] { color: var(--line-food); background: color-mix(in srgb, var(--line-food) 12%, var(--paper)); }
.line-badge[data-color="Movement"] { color: var(--line-movement); background: color-mix(in srgb, var(--line-movement) 12%, var(--paper)); }
.line-badge[data-color="People"] { color: var(--line-people); background: color-mix(in srgb, var(--line-people) 12%, var(--paper)); }
.line-badge[data-color="Places"] { color: var(--line-places); background: color-mix(in srgb, var(--line-places) 12%, var(--paper)); }

.station-open {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0.3rem 0.3rem;
  margin: 0.1rem 0 0 -0.3rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.35;
  color: var(--ink);
  text-align: left;
  min-height: 44px;
  border-radius: 6px;
}

.station-open:hover {
  text-decoration: underline;
  text-decoration-color: var(--focus);
  text-decoration-thickness: 2px;
}

.station-summary {
  margin: 0.4rem 0 0.55rem;
  color: var(--ink-soft);
  max-width: 62ch;
  font-size: 1rem;
}

.station-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  align-items: center;
}

.saved-badge {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--focus);
  border: 1.5px solid var(--focus);
  border-radius: var(--radius-pill);
  padding: 0.05rem 0.5rem;
}

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

/* ---------- Empty state ---------- */
.empty-state {
  max-width: 480px;
  padding: 2rem;
  text-align: center;
  border: 3px dashed var(--ink-faint);
  border-radius: 12px;
  margin-top: 1rem;
}

.empty-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 0.75rem;
  color: var(--focus);
}

.empty-title {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 1.1rem;
  margin: 0 0 0.35rem;
}

.empty-copy {
  color: var(--ink-soft);
  margin: 0 0 1.1rem;
}

.empty-state button {
  min-height: 44px;
  padding: 0.6rem 1.25rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 700;
}

/* ---------- Footer ---------- */
.masthead-footer {
  border-top: 3px solid var(--ink);
  background: var(--paper-alt);
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.masthead-footer p {
  max-width: 700px;
  margin: 0 auto;
}

/* ---------- Detail platform (dialog) ---------- */
.platform-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 35, 0.55);
  display: flex;
  justify-content: flex-end;
  z-index: 100;
}

.platform-overlay[hidden] {
  display: none;
}

.platform {
  background: var(--paper);
  width: min(600px, 100%);
  height: 100%;
  overflow-y: auto;
  padding: clamp(1.5rem, 4vw, 3rem);
  padding-top: calc(clamp(1.5rem, 4vw, 3rem) + 28px);
  box-shadow: var(--shadow-panel);
  position: relative;
  border-left: 4px solid var(--ink);
}

.close-detail {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--paper-raised);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.close-detail svg {
  width: 18px;
  height: 18px;
}

.platform-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid currentColor;
  max-width: calc(100% - 60px);
}

.platform-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  line-height: 1.2;
  margin: 0.6rem 0 0.4rem;
}

.platform-meta {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 1.25rem;
}

.save-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--paper-raised);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.save-item .ticket-icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.save-item[aria-pressed="true"] {
  background: var(--focus);
  border-color: var(--focus);
  color: #fff;
}

.platform-body {
  font-size: 1.08rem;
  line-height: 1.7;
  max-width: 68ch;
}

.platform-body p {
  margin: 0 0 1.1rem;
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .platform {
    animation: slide-in 0.28s ease-out;
  }

  .station-dot {
    transition: transform 0.15s ease;
  }

  .wordmark::before {
    animation: signal-pulse 2.4s ease-in-out infinite;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes signal-pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(168, 56, 15, 0.45);
  }
  50% {
    opacity: 0.85;
    box-shadow: 0 0 0 5px rgba(168, 56, 15, 0);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .line-key {
    display: none;
  }
}

@media (max-width: 640px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-control,
  .search-control {
    flex: 1 1 auto;
  }

  .platform {
    width: 100%;
    border-left: none;
  }
}
