/* The Local Line — a magazine styled as a transit line diagram. */

:root {
  --navy: #121a26;
  --navy-raised: #1c2636;
  --paper: #f1efe5;
  --white: #ffffff;
  --ink: #181d22;
  --ink-soft: #4b5259;
  --on-navy: #f1efe5;
  --on-navy-soft: #b7bfc9;
  --focus: #d99a2b;

  --font-display: Futura, "Century Gothic", "Avenir Next", Avenir, "Segoe UI", Roboto, sans-serif;
  --font-body: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;

  --rail: 34px;
  --content-max: 760px;
}

* {
  box-sizing: border-box;
}

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

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

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0;
}

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

input, select {
  font-family: inherit;
}

a {
  color: inherit;
}

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

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

/* ---------- Departure board (header) ---------- */

.board {
  background: var(--navy);
  color: var(--on-navy);
  padding: 20px 24px 28px;
}

.board-top {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px 28px;
}

.mast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--on-navy);
}

.mast-mark {
  width: 30px;
  height: 30px;
  flex: none;
}

.mast-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
}

.board-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.8rem;
  color: var(--on-navy-soft);
}

.field input,
.field select {
  background: var(--navy-raised);
  border: 1px solid #33415a;
  color: var(--on-navy);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.95rem;
  min-width: 200px;
}

.field input::placeholder {
  color: #7c8798;
}

.field select {
  min-width: 160px;
}

.ticket-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--navy-raised);
  border: 1px solid #33415a;
  color: var(--on-navy);
  border-radius: 999px;
  padding: 9px 16px 9px 12px;
  font-size: 0.95rem;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ticket-toggle .pin-icon {
  width: 17px;
  height: 17px;
  color: var(--on-navy-soft);
  transition: color 0.15s ease;
}

.ticket-toggle:hover {
  border-color: #4a5a78;
}

.ticket-toggle[aria-pressed="true"] {
  background: var(--focus);
  border-color: var(--focus);
  color: #1a1204;
}

.ticket-toggle[aria-pressed="true"] .pin-icon {
  color: #1a1204;
}

.hero {
  max-width: 620px;
  margin: 34px auto 0;
}

.hero h1 {
  font-size: clamp(1.9rem, 3.4vw + 1rem, 2.75rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.hero-sub {
  margin: 14px 0 0;
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--on-navy-soft);
  max-width: 46ch;
  line-height: 1.55;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 1100px;
  margin: 26px auto 0;
  padding: 0;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid #33415a;
  color: var(--on-navy);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  font-size: 0.88rem;
  border-bottom: 3px solid transparent;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.legend-chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chip);
  flex: none;
}

.legend-chip:hover {
  background: var(--navy-raised);
}

.legend-chip[aria-pressed="true"] {
  background: var(--navy-raised);
  border-color: #33415a;
  border-bottom-color: var(--chip);
}

/* ---------- Main / spine ---------- */

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 24px 100px;
}

.result-count {
  margin: 0 0 18px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.line {
  list-style: none;
  margin: 0;
  padding: 4px 0 4px 0;
  position: relative;
}

.line::before {
  content: "";
  position: absolute;
  left: var(--rail);
  top: 6px;
  bottom: 14px;
  width: 3px;
  background: var(--line-color, var(--navy));
  transform: translateX(-50%);
  transform-origin: top center;
  border-radius: 2px;
  transition: background-color 0.2s ease;
}

@media (prefers-reduced-motion: no-preference) {
  .line::before {
    animation: draw-line 0.9s ease-out;
  }
}

@keyframes draw-line {
  from {
    transform: translateX(-50%) scaleY(0);
  }
  to {
    transform: translateX(-50%) scaleY(1);
  }
}

.stop {
  position: relative;
  padding-left: calc(var(--rail) + 26px);
  min-height: 40px;
}

.stop:not(:first-child) {
  margin-top: var(--gap, 40px);
}

.dot {
  position: absolute;
  left: var(--rail);
  top: 8px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  transform: translateX(-50%);
  border: 3px solid var(--paper);
  background: var(--dot-color, var(--navy));
}

.stop-card {
  display: block;
}

.stop-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.28rem;
  line-height: 1.3;
  margin: 0;
}

.stop-title-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease;
}

.stop-title-btn:hover,
.stop-title-btn:focus-visible {
  color: var(--dot-color, var(--navy));
}

.stop-summary {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.5;
  max-width: 56ch;
}

.stop-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.stop-meta span {
  padding-left: 14px;
  border-left: 1px solid #c9c4b4;
}

.stop-meta span:first-child {
  padding-left: 0;
  border-left: none;
}

.stop-line-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stop-line-name::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot-color, var(--navy));
  flex: none;
}

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

.empty-state {
  padding: 48px 20px;
  text-align: center;
  max-width: 44ch;
  margin: 0 auto;
}

.empty-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  margin: 0 0 10px;
}

.empty-body {
  color: var(--ink-soft);
  margin: 0 0 20px;
  line-height: 1.5;
}

#reset-filters {
  background: var(--navy);
  color: var(--on-navy);
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 0.95rem;
  font-family: var(--font-display);
}

#reset-filters:hover {
  background: var(--navy-raised);
}

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

dialog.platform {
  border: none;
  padding: 0;
  margin: 0;
  max-width: min(640px, 100vw);
  width: min(640px, 100vw);
  height: 100vh;
  max-height: 100vh;
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  bottom: auto;
  background: var(--white);
  color: var(--ink);
  overflow-y: auto;
  box-shadow: -12px 0 40px rgba(18, 26, 38, 0.25);
}

dialog.platform::backdrop {
  background: rgba(18, 26, 38, 0.45);
}

@media (prefers-reduced-motion: no-preference) {
  dialog.platform {
    transition: transform 0.3s ease, opacity 0.3s ease;
  }

  dialog.platform::backdrop {
    transition: opacity 0.3s ease;
  }

  @starting-style {
    dialog.platform[open] {
      transform: translateX(28px);
      opacity: 0;
    }

    dialog.platform[open]::backdrop {
      opacity: 0;
    }
  }
}

.platform-bar {
  height: 8px;
  background: var(--line-color, var(--navy));
}

.platform-inner {
  padding: 24px 28px 80px;
  max-width: 640px;
}

.close-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 0.95rem;
  padding: 8px 8px 8px 2px;
  margin-left: -2px;
  border-radius: 6px;
}

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

.close-btn:hover {
  color: var(--ink);
}

.platform-head {
  margin-top: 18px;
}

.platform-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.platform-line::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-color, var(--navy));
  flex: none;
}

#detail-title {
  font-size: clamp(1.7rem, 2.6vw + 1rem, 2.3rem);
  line-height: 1.2;
  font-weight: 700;
}

.platform-meta {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.platform-meta span {
  padding-left: 14px;
  border-left: 1px solid #d8d4c6;
}

.platform-meta span:first-child {
  padding-left: 0;
  border-left: none;
}

.save-btn {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--navy);
  color: var(--on-navy);
  border: none;
  border-radius: 999px;
  padding: 10px 20px 10px 14px;
  font-size: 0.95rem;
  font-family: var(--font-display);
  transition: background-color 0.15s ease;
}

.save-btn .pin-icon {
  width: 17px;
  height: 17px;
}

.save-btn[aria-pressed="true"] {
  background: var(--focus);
  color: #1a1204;
}

.save-btn:hover {
  background: var(--navy-raised);
}

.save-btn[aria-pressed="true"]:hover {
  background: #c68a26;
}

.platform-body {
  margin-top: 30px;
  font-family: var(--font-body);
  font-size: 1.08rem;
  line-height: 1.7;
  max-width: 62ch;
  white-space: pre-wrap;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  :root {
    --rail: 22px;
  }

  .board {
    padding: 16px 16px 22px;
  }

  .board-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .field input,
  .field select {
    min-width: 0;
    width: 100%;
  }

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

  .hero {
    margin-top: 24px;
  }

  main {
    padding: 22px 16px 80px;
  }

  .stop {
    padding-left: calc(var(--rail) + 18px);
  }

  dialog.platform {
    width: 100vw;
    max-width: 100vw;
  }

  .platform-inner {
    padding: 18px 18px 64px;
  }
}
