/* ============================================================
   TRANSFER — a magazine organised as a transit network
   ============================================================ */

@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* map paper */
  --paper: #e8e9e3;
  --paper-2: #dde0d6;
  --card: #f3f4ef;
  --ink: #14161c;
  --ink-2: #4c505c;
  --ink-3: #767b86;
  --rule: #c2c6ba;

  /* below ground */
  --night: #0b0e16;
  --night-2: #151a27;
  --night-3: #232a3b;
  --night-ink: #eef0e9;
  --night-ink-2: #a7adbc;

  /* signage */
  --sign: #f2c230;

  /* the lines */
  --c-culture: #d0247b;
  --c-food: #e2661a;
  --c-movement: #1b6fdb;
  --c-people: #1e9e55;
  --c-places: #7a3fd1;

  --focus: #1b6fdb;
  --radius: 3px;
  --page: 1180px;
  --font-ui: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-read: "Literata", Georgia, serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(circle, rgba(20, 22, 28, 0.08) 1px, transparent 1.3px);
  background-size: 24px 24px;
  background-position: -6px -6px;
  line-height: 1.5;
}

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

[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 50;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px;
  text-decoration: none;
  border-radius: var(--radius);
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

/* focus ring, everywhere */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------------- masthead ---------------- */

.masthead {
  max-width: var(--page);
  margin: 0 auto;
  padding: 30px clamp(16px, 4vw, 40px) 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
}

.masthead__brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mark { display: block; flex: none; }
.mark svg { display: block; }

.masthead__word h1 {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  line-height: 0.9;
  letter-spacing: -0.035em;
  font-weight: 700;
}

.masthead__tagline {
  margin: 4px 0 0;
  font-family: var(--font-read);
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-style: italic;
  color: var(--ink-2);
}

.masthead__edition {
  margin: 0 0 6px;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  padding-bottom: 2px;
  border-bottom: 2px solid var(--sign);
}

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

.page {
  max-width: var(--page);
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 40px) 60px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 20px;
  align-items: flex-end;
  padding: 16px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 rgba(20, 22, 28, 0.9);
}

.controls__field { display: flex; flex-direction: column; gap: 6px; }
.controls__field--search { flex: 1 1 260px; }
.controls__field--line { flex: 0 1 190px; }
.controls__field--saved { flex: 0 0 auto; }

.controls label,
.controls__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-2);
}

.controls input,
.controls select {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 11px 12px;
  min-height: 46px;
  width: 100%;
}

.controls input::placeholder { color: var(--ink-3); }

.controls select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
                    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
  cursor: pointer;
}

#saved-filter {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
}

#saved-filter .pill {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.76rem;
  font-weight: 700;
}

#saved-filter[aria-pressed="true"] {
  background: var(--sign);
  border-color: var(--ink);
}
#saved-filter[aria-pressed="true"] .pill {
  background: var(--ink);
  color: var(--sign);
}

/* ---------------- network layout ---------------- */

.network {
  margin-top: 44px;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.line-key {
  position: sticky;
  top: 24px;
}

.line-key__title {
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: var(--ink-2);
  font-weight: 600;
}

.line-key__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--ink);
}

.line-btn {
  font: inherit;
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 6px 10px 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.line-btn__code {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--paper);
  background: var(--line);
  border-radius: 3px;
  padding: 3px 0;
  text-align: center;
}

.line-btn__name { font-weight: 600; font-size: 0.95rem; }

.line-btn__count {
  font-size: 0.82rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.line-btn:hover .line-btn__name { text-decoration: underline; text-underline-offset: 3px; }

.line-btn[aria-pressed="true"] {
  background: rgba(20, 22, 28, 0.05);
  background: linear-gradient(90deg, color-mix(in srgb, var(--line) 16%, transparent), transparent);
}
.line-btn[aria-pressed="true"] .line-btn__name::after {
  content: " ◂";
  color: var(--line);
  font-weight: 700;
}

.line-key__note {
  margin: 16px 0 0;
  font-size: 0.8rem;
  color: var(--ink-3);
  line-height: 1.45;
  display: flex;
  gap: 8px;
}

.legend-node {
  flex: none;
  margin-top: 5px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--ink);
}

/* ---------------- departures list ---------------- */

.stops-region__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px;
}

.stops-region__head h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.result-count {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.you-are-here {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 2px 40px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

.you-are-here__dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--sign);
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--sign) 45%, transparent);
}

.stops {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stop {
  position: relative;
  padding: 4px 4px 22px 52px;
  min-height: 92px;
  animation: station-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 65ms);
}

/* the continuous rail; colour changes when the line changes */
.stop::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--line);
}
.stop:last-child { padding-bottom: 4px; }
.stop:last-child::before { bottom: 30px; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; }

.stop__node {
  position: absolute;
  left: 8px;
  top: 20px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--paper);
  border: 4px solid var(--line);
  transition: transform 0.18s ease, background-color 0.18s ease;
  animation: node-in 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.3) backwards;
  animation-delay: calc(var(--i, 0) * 65ms);
  z-index: 1;
}

.stop__saved {
  position: absolute;
  left: 2px;
  top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--sign);
  border: 2px solid var(--ink);
}

.open-item {
  font: inherit;
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 14px 16px 14px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--ink);
  transition: background-color 0.16s ease;
}

.open-item:hover { background: var(--card); }
.stop:hover .stop__node,
.stop:focus-within .stop__node {
  transform: scale(1.18);
  background: var(--line);
}

.stop__top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.stop__code {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--paper);
  background: var(--line);
  border-radius: 3px;
  padding: 2px 6px;
  line-height: 1.5;
}

.stop__min {
  font-size: 0.74rem;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.stop__title {
  display: block;
  margin: 0;
  font-size: clamp(1.15rem, 2.6vw, 1.42rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
  font-weight: 600;
}

.stop__summary {
  display: block;
  margin: 6px 0 0;
  font-family: var(--font-read);
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 62ch;
}

.stop__meta {
  display: block;
  margin: 9px 0 0;
  font-size: 0.78rem;
  color: var(--ink-3);
}
.stop__meta b { font-weight: 600; color: var(--ink-2); }
.stop__meta span::before,
.detail__byline span::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 0.86em;
  background: var(--rule);
  margin: 0 10px;
  vertical-align: -0.1em;
}

/* ---------------- empty state ---------------- */

.empty-state {
  border: 2px dashed var(--ink);
  border-radius: var(--radius);
  padding: 34px 26px;
  margin-top: 20px;
  background: var(--card);
  max-width: 560px;
}

.empty-state__title {
  margin: 0 0 8px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.empty-state__body {
  margin: 0 0 18px;
  font-family: var(--font-read);
  color: var(--ink-2);
  line-height: 1.55;
}

/* ---------------- buttons ---------------- */

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  padding: 12px 18px;
  min-height: 46px;
}

.btn--reset {
  background: var(--sign);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.btn--reset:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn--reset:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

/* ---------------- detail (below ground) ---------------- */

.detail {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  margin: 0;
  color: var(--night-ink);
}
.detail[open] {
  display: grid;
  place-items: center;
}

.detail::backdrop {
  background: rgba(6, 8, 14, 0.66);
  backdrop-filter: blur(2px);
}

.detail__sheet {
  position: relative;
  width: min(760px, 100%);
  margin: auto;
  background: var(--night);
  color: var(--night-ink);
  border: 2px solid var(--night-3);
  border-radius: var(--radius);
  animation: platform-in 0.36s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.detail :focus-visible { outline-color: var(--sign); }

.detail__rail {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 8px;
  background: var(--line);
  border-radius: var(--radius) 0 0 var(--radius);
}

.detail__node {
  position: absolute;
  left: -6px;
  top: 26px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--night);
  border: 4px solid var(--line);
}

.detail__inner {
  padding: 26px clamp(20px, 5vw, 48px) 30px clamp(30px, 6vw, 56px);
  max-height: min(88vh, 900px);
  overflow-y: auto;
}

.detail__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--night-3);
}

.detail__eyebrow {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  color: var(--night-ink-2);
  font-weight: 600;
}

.detail__code {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--night);
  background: var(--line);
  border-radius: 3px;
  padding: 3px 7px;
}

.detail__close {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--night-ink);
  border: 1px solid var(--night-3);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  white-space: nowrap;
}
.detail__close:hover { background: var(--night-2); border-color: var(--night-ink-2); }

.detail__title {
  margin: 26px 0 12px;
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  line-height: 1.06;
  letter-spacing: -0.025em;
  font-weight: 700;
  text-wrap: balance;
}

.detail__byline {
  margin: 0 0 26px;
  font-size: 0.84rem;
  color: var(--night-ink-2);
}
.detail__byline b { color: var(--night-ink); font-weight: 600; }
.detail__byline span::before { background: var(--night-3); }

.detail__body {
  max-width: 66ch;
  font-family: var(--font-read);
}
.detail__body p {
  margin: 0 0 1.15em;
  font-size: clamp(1.04rem, 2.4vw, 1.16rem);
  line-height: 1.72;
  color: #e3e6de;
}
.detail__body p:first-child::first-letter {
  float: left;
  font-family: var(--font-ui);
  font-size: 3.1em;
  line-height: 0.82;
  font-weight: 700;
  padding: 0.05em 0.12em 0 0;
  color: var(--line);
}

.detail__actions {
  position: sticky;
  bottom: 0;
  margin-top: 28px;
  padding: 18px 0 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  background: linear-gradient(to top, var(--night) 74%, transparent);
}

.btn--save {
  background: var(--night-ink);
  color: var(--night);
  border-color: var(--night-ink);
}
.btn--save:hover { background: var(--line); border-color: var(--line); color: #fff; }

.btn--save[aria-pressed="true"] {
  background: var(--sign);
  border-color: var(--sign);
  color: var(--ink);
}
.btn--save[aria-pressed="true"]::before {
  content: "✓ ";
  font-weight: 700;
}

.detail__saved-note {
  margin: 0;
  font-size: 0.84rem;
  color: var(--night-ink-2);
}

/* ---------------- colophon ---------------- */

.colophon {
  max-width: var(--page);
  margin: 0 auto;
  padding: 26px clamp(16px, 4vw, 40px) 50px;
  border-top: 2px solid var(--ink);
  font-size: 0.82rem;
  color: var(--ink-3);
  line-height: 1.6;
}
.colophon p { margin: 0; max-width: 72ch; }
.colophon strong { color: var(--ink); }

/* ---------------- motion ---------------- */

@keyframes station-in {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes node-in {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
@keyframes platform-in {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------- responsive ---------------- */

@media (max-width: 860px) {
  .network {
    grid-template-columns: 1fr;
    gap: 26px;
    margin-top: 32px;
  }
  .line-key { position: static; }
  .line-key__list {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    border-top: 0;
    padding-bottom: 6px;
    scrollbar-width: thin;
  }
  .line-btn {
    min-width: 122px;
    grid-template-columns: auto 1fr auto;
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    padding: 8px 10px;
    background: var(--card);
    flex: none;
  }
  .line-key__note { display: none; }

  .controls { box-shadow: 4px 4px 0 rgba(20, 22, 28, 0.9); }
  .controls__field--saved { flex: 1 1 100%; }
  #saved-filter { width: 100%; justify-content: center; }
}

@media (max-width: 560px) {
  .masthead { padding-top: 20px; }
  .masthead__edition { display: none; }
  .stop { padding-left: 44px; }
  .stop::before { left: 12px; width: 5px; }
  .stop__node { left: 5px; }
  .you-are-here { margin-left: 34px; }
  .open-item { padding-right: 6px; }
}

/* full-screen platform on small screens */
@media (max-width: 620px) {
  .detail[open] { place-items: stretch; }
  .detail__sheet {
    width: 100%;
    min-height: 100%;
    border: 0;
    border-radius: 0;
    display: flex;
  }
  .detail__inner {
    max-height: 100vh;
    padding-bottom: 24px;
    flex: 1;
  }
  .detail__actions { bottom: 0; }
}

@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;
  }
}
