/* ============================================================
   Between Stops — a magazine of everyday city life
   Visual world: transit livery. Deep green bands, warm paper
   ground, condensed poster display, timetable metadata, a route
   spine with stops. Topics are lines; keeping is a ticket.
   ============================================================ */

:root {
  --paper: #F5F2EA;
  --paper-2: #EBE7DA;
  --paper-hi: #FBF9F2;
  --ink: #23241D;
  --ink-soft: #57584D;
  --livery: #14382C;
  --livery-deep: #0C241B;
  --marigold: #F0B32C;
  --gold-deep: #A87300;
  --kept-text: #7A5300;
  --line-culture: #763B93;
  --line-food: #B23A26;
  --line-movement: #1E5FA8;
  --line-people: #BC3D6F;
  --line-places: #0C6B62;
  --hairline: rgba(35, 36, 29, 0.16);

  --spine: #14382C;          /* set by JS to the active line color */
  --story-line: #14382C;     /* detail sheet accent */

  --gutter: 58px;            /* route column width */
  --spine-x: 18px;           /* spine offset from route left edge */
  --dot: 15px;
  --dot-half: 7.5px;

  --font-display: 'Oswald', 'Arial Narrow', 'Franklin Gothic Medium', sans-serif;
  --font-body: 'Literata', Georgia, 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

@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: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 200 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;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html {
  scrollbar-color: #7f8a80 var(--paper-2);
}

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

::selection { background: var(--livery); color: var(--paper); }

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

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--livery);
  outline-offset: 2px;
  border-radius: 2px;
}
.masthead :focus-visible,
.detail-bar :focus-visible,
.colophon :focus-visible {
  outline-color: var(--marigold);
}

.icon {
  width: 1em;
  height: 1em;
  flex: none;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--marigold);
  color: var(--livery-deep);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-decoration: none;
  border-radius: 6px;
  transform: translateY(-64px);
}
.skip-link:focus { transform: none; }

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

.masthead {
  background: var(--livery);
  color: var(--paper);
  border-bottom: 6px solid var(--marigold);
}

.masthead-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 26px 32px 22px;
  display: flex;
  align-items: baseline;
  gap: 14px 28px;
  flex-wrap: wrap;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--marigold);
}
.wordmark-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--paper);
}
.transfer-mark { width: 42px; height: 27px; }
.wordmark:hover .wordmark-text { text-decoration: underline; text-underline-offset: 6px; }

.tagline {
  margin: 0;
  font-size: 0.98rem;
  color: rgba(245, 242, 234, 0.85);
}

.issue {
  margin: 0 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(245, 242, 234, 0.8);
}

/* ---------- browsing view ---------- */

.browse-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 44px 32px 72px;
}

.browse-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 30px;
}

/* ----- control rail ----- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 26px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 20px;
}

.control-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 7px;
}

.control-search { flex: 1 1 240px; max-width: 400px; }

.search-wrap { position: relative; }
.icon-search {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--ink-soft);
  pointer-events: none;
}

.search-input, .topic-select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--paper-hi);
  border: 1.5px solid rgba(35, 36, 29, 0.4);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  caret-color: var(--livery);
}
.search-input { padding-left: 40px; }
.search-input::placeholder { color: var(--ink-soft); opacity: 1; }
.search-input:hover, .topic-select:hover { border-color: var(--ink); }
.search-input:focus, .topic-select:focus {
  border-color: var(--livery);
  outline: 3px solid rgba(20, 56, 44, 0.3);
  outline-offset: 0;
}

.control-topic { min-width: 190px; }

.topic-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 9'%3E%3Cpath d='M1 1.5 7 7.5 13 1.5' fill='none' stroke='%2314382C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 14px 9px;
  background-position: right 14px center;
}

.kept-toggle {
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px;
  background: var(--paper-hi);
  border: 1.5px dashed rgba(35, 36, 29, 0.45);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s, border-color 0.25s;
}
.kept-toggle .icon { width: 19px; height: 13px; }
.kept-toggle:hover { border-color: var(--livery); color: var(--livery); }
.kept-toggle[aria-pressed="true"] {
  background: var(--livery);
  border: 1.5px solid var(--livery);
  color: var(--paper);
}
.kept-toggle[aria-pressed="true"]:hover { background: var(--livery-deep); }
.kept-count { color: inherit; opacity: 0.75; }

.count {
  margin: 0 0 0 auto;
  align-self: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ----- route spine + stops ----- */

.route {
  position: relative;
  padding-left: var(--gutter);
  margin-top: 14px;
}
.route::before {
  content: "";
  position: absolute;
  left: var(--spine-x);
  top: 10px;
  bottom: 44px;
  width: 4px;
  border-radius: 2px;
  background: var(--spine);
  transition: background-color 0.35s ease;
  -webkit-mask-image: linear-gradient(#000 0, #000 calc(100% - 56px), transparent);
  mask-image: linear-gradient(#000 0, #000 calc(100% - 56px), transparent);
  transform-origin: 50% 0;
  animation: spine-draw 0.7s cubic-bezier(0.2, 0.8, 0.25, 1);
}
@keyframes spine-draw {
  from { transform: scaleY(0); }
}

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

.story {
  position: relative;
}
.story::before {
  content: "";
  position: absolute;
  left: calc(var(--spine-x) + 2px - var(--gutter) - var(--dot-half));
  top: 30px;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--lc, var(--livery));
  box-shadow: 0 0 0 3px var(--paper);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.25, 1);
}

.story--lead {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px 44px;
  align-items: start;
  padding: 10px 16px 34px 10px;
  border-radius: 16px;
  --dot: 18px;
  --dot-half: 9px;
}
.story--lead::before { top: 18px; }
.story--lead:has(.story-link:hover)::before,
.story--lead:has(.story-link:focus-visible)::before { transform: scale(1.35); }

.story--row {
  padding: 26px 16px 26px 10px;
  border-top: 1px solid var(--hairline);
  border-radius: 14px;
  transition: background-color 0.25s ease;
}
.story--row:has(.story-link:hover) { background: var(--paper-2); }
.story--row:has(.story-link:hover)::before,
.story--row:has(.story-link:focus-visible)::before { transform: scale(1.4); }

.story-in { animation: stop-in 0.45s cubic-bezier(0.2, 0.9, 0.25, 1) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes stop-in {
  from { opacity: 0; transform: translateY(10px); }
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.meta-sep { opacity: 0.5; }
.meta-line { color: var(--lc); font-weight: 700; }
.meta-kept {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--kept-text);
  font-weight: 700;
}
.meta-kept .icon { width: 16px; height: 11px; }

.story-title {
  margin: 0 0 10px;
  line-height: 1.14;
  text-wrap: balance;
}
.story-link {
  color: var(--ink);
  text-decoration: none;
}
.story-link::after { content: ""; position: absolute; inset: 0; }
.story-link:hover { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 2px; text-decoration-color: var(--lc, var(--livery)); }

.story--lead .story-title { font-size: clamp(1.6rem, 2.6vw, 2.2rem); }
.story--lead .story-title, .story--row .story-title { font-family: var(--font-display); font-weight: 500; letter-spacing: 0; }
.story--row .story-title { font-size: clamp(1.25rem, 1.7vw, 1.5rem); }

.story-summary {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.55;
  max-width: 62ch;
}
.story--lead .story-summary { font-size: 1.14rem; max-width: 46ch; }
.story--row .story-summary { font-size: 0.98rem; }

/* photo plate on the lead story */
.story-plate {
  position: relative;
  margin: 0;
  border: 1px solid rgba(35, 36, 29, 0.25);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 14px 28px -16px rgba(20, 30, 22, 0.35);
}
.story-plate img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}
.plate-tag {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 9px;
  background: var(--livery);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 4px;
}

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

.empty {
  max-width: 560px;
  margin: 40px auto 0;
  padding: 64px 24px 40px;
  text-align: center;
}
.empty-mark { width: 116px; height: 70px; color: var(--livery); margin: 0 auto 22px; }
.empty-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.55rem;
  margin: 0 0 12px;
}
.empty-text {
  margin: 0 0 26px;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.6;
}

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

.ticket-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
  border-radius: 999px;
  border: 1.5px solid var(--livery);
  background: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--livery);
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s;
}
.ticket-btn:hover { background: var(--livery); color: var(--paper); }

/* ---------- detail view ---------- */

.detail {
  position: relative;
  min-height: 100vh;
  background: var(--paper);
}

.detail-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 20px 15px;
  background: var(--livery);
}
.bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  background: none;
  border: 1.5px solid transparent;
  border-radius: 999px;
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.25s;
}
.bar-btn:hover { background: rgba(245, 242, 234, 0.14); }
.bar-btn .icon { width: 17px; height: 17px; }
.bar-btn .icon-ticket { width: 21px; height: 14px; }

.bar-save { border-color: rgba(245, 242, 234, 0.55); }
.bar-save.is-kept {
  background: var(--marigold);
  border-color: var(--marigold);
  color: var(--livery-deep);
  font-weight: 700;
}
.bar-save.is-kept:hover { background: #f7c153; }

.read-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: rgba(245, 242, 234, 0.14);
}
#read-progress-fill {
  display: block;
  height: 100%;
  background: var(--marigold);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.detail-sheet {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
  padding: 46px 26px 90px;
  border-top: 8px solid var(--story-line);
  animation: sheet-rise 0.4s cubic-bezier(0.2, 0.8, 0.25, 1);
}
@keyframes sheet-rise {
  from { opacity: 0; transform: translateY(14px); }
}

.detail-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 4.6vw, 3.1rem);
  line-height: 1.06;
  letter-spacing: 0;
  margin: 0 0 22px;
  text-wrap: balance;
}
.detail-title:focus { outline: none; }

.detail-dek {
  margin: 0 0 22px;
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 36em;
}
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 34px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}
.detail-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--lc);
  font-weight: 700;
}
.detail-line::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lc);
}

.detail-plate {
  margin: 0 0 44px;
}
.detail-plate img {
  width: 100%;
  max-height: 440px;
  object-fit: cover;
  border: 1px solid rgba(35, 36, 29, 0.25);
  border-radius: 6px;
  box-shadow: 0 16px 32px -18px rgba(20, 30, 22, 0.4);
}
.detail-plate figcaption {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.detail-body {
  font-size: 1.21rem;
  line-height: 1.72;
  color: #2B2C24;
}
.detail-body p {
  margin: 0 0 1.4em;
  max-width: 66ch;
}
.detail-body p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 3.6em;
  line-height: 0.78;
  float: left;
  padding: 0.06em 0.12em 0 0;
  color: var(--story-line);
}

.detail-end {
  margin-top: 58px;
  padding-top: 34px;
  border-top: 1px solid var(--hairline);
  text-align: center;
}
.detail-end-mark {
  margin: 0 0 22px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

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

.colophon {
  background: var(--livery-deep);
  color: var(--paper);
  border-top: 6px solid var(--marigold);
}
.colophon-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 34px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 48px;
  align-items: baseline;
  justify-content: space-between;
}
.colophon-word {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.95rem;
}
.colophon-note {
  margin: 0;
  max-width: 62ch;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.8;
  letter-spacing: 0.04em;
  color: rgba(245, 242, 234, 0.75);
}

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

@media (max-width: 860px) {
  .masthead-inner { padding: 20px 20px 18px; }
  .wordmark-text { font-size: 1.4rem; }
  .transfer-mark { width: 34px; height: 22px; }
  .tagline { flex-basis: 100%; order: 3; font-size: 0.92rem; }
  .issue { margin-left: auto; }

  .browse-inner { padding: 30px 20px 56px; }
  .browse-heading { margin-bottom: 22px; }

  .story--lead { grid-template-columns: 1fr; gap: 20px; padding: 8px 14px 28px 8px; }
  .story--lead::before { top: 14px; }
  .story-plate img { aspect-ratio: 16 / 9; }
}

@media (max-width: 600px) {
  :root { --gutter: 34px; --spine-x: 9px; --dot: 12px; --dot-half: 6px; }
  .story--row { padding: 22px 12px 22px 6px; }
  .story--row::before { top: 26px; }

  .masthead-inner { padding: 16px 18px; gap: 8px 16px; }
  .wordmark-text { font-size: 1.18rem; }
  .transfer-mark { width: 28px; height: 18px; }
  .wordmark { gap: 9px; }
  .tagline { order: 3; }

  .browse-inner { padding: 24px 18px 48px; }
  .controls { gap: 14px; }
  .control-search, .control-topic { flex-basis: 100%; max-width: none; }
  .control-kept { flex-basis: 100%; }
  .kept-toggle { width: 100%; justify-content: center; }
  .count { margin-left: 0; flex-basis: 100%; }

  .story--lead::before { top: 16px; }
  .story--lead .story-summary { max-width: none; }

  .detail-bar { padding: 8px 12px; }
  .bar-btn { padding: 9px 11px; font-size: 0.68rem; }
  .bar-btn .icon-arrow { display: none; }
  .detail-sheet { padding: 34px 18px 70px; }
  .detail-body { font-size: 1.06rem; }
  .detail-dek { font-size: 1.14rem; }
  .detail-body p:first-of-type::first-letter { font-size: 3.2em; }

  .colophon-inner { padding: 26px 18px; flex-direction: column; gap: 10px; }
}

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

@media (prefers-reduced-motion: reduce) {
  .route::before { animation: none; }
  .story-in { animation: none; }
  .detail-sheet { animation: none; }
  .story, .story::before, .kept-toggle, .ticket-btn, .bar-btn { transition: none; }
}
