/* ————————————————————————————————————————————————
   Between Stops — a journal of everyday city life
   Palette: sage paper, deep board, five transit lines.
   Type: Oswald (signage) + Literata (reading).
   ———————————————————————————————————————————————— */

@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: 300 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #e8eae2;
  --paper-2: #f6f6f0;
  --ink: #22271f;
  --ink-soft: #5a6155;
  --board: #23261e;
  --board-deep: #191c15;
  --flap-letter: #f1eddf;
  --line-culture: #b32c13;
  --line-food: #9a6600;
  --line-movement: #135f70;
  --line-people: #6b4e9b;
  --line-places: #35682f;
  --font-sign: 'Oswald', 'Arial Narrow', sans-serif;
  --font-read: 'Literata', Georgia, serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-read);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

/* category line colors as a per-item custom property */
.cat-culture  { --line: var(--line-culture); }
.cat-food     { --line: var(--line-food); }
.cat-movement { --line: var(--line-movement); }
.cat-people   { --line: var(--line-people); }
.cat-places   { --line: var(--line-places); }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

[hidden] { display: none !important; }

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

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--ink);
  color: var(--paper-2);
  padding: 8px 14px;
  z-index: 50;
  text-decoration: none;
  font-family: var(--font-sign);
  transition: top 0.15s ease;
}
.skip:focus { top: 12px; }

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

.wrap {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
}

/* ————— the split-flap board ————— */

.masthead {
  padding: 26px 0 34px;
}

.board {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  background: linear-gradient(180deg, var(--board) 0%, var(--board-deep) 100%);
  border-radius: 16px;
  padding: clamp(12px, 2.6vw, 24px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.07),
    inset 0 -3px 0 rgba(0, 0, 0, 0.45),
    0 14px 34px rgba(24, 28, 20, 0.35);
}

.flaps {
  display: flex;
  gap: clamp(3px, 0.7vw, 7px);
}

.flap {
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, #2b2f25 0%, #23271d 48%, #14170f 54%, #1a1d14 100%);
  border-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -2px 3px rgba(0, 0, 0, 0.5),
    0 2px 2px rgba(0, 0, 0, 0.4);
  font-family: var(--font-sign);
  font-weight: 500;
  font-size: clamp(13px, 3vw, 32px);
  color: var(--flap-letter);
  text-transform: uppercase;
  overflow: hidden;
  perspective: 240px;
}

.flap::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  background: rgba(0, 0, 0, 0.55);
}
.flap { position: relative; }

.flap.tick { animation: flick 55ms linear; }
@keyframes flick {
  0%   { transform: rotateX(0deg); }
  45%  { transform: rotateX(-78deg); }
  100% { transform: rotateX(0deg); }
}

.board-strip {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-top: clamp(10px, 2vw, 16px);
  padding: 0 2px;
}

.tagline,
.issue {
  margin: 0;
  color: #cfccbc;
  font-size: 13px;
}
.tagline { font-style: italic; }
.issue {
  font-family: var(--font-sign);
  font-weight: 400;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ————— controls ————— */

.controls {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) max-content max-content;
  gap: 20px 26px;
  align-items: end;
  margin-bottom: 8px;
}

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

.field label {
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.field input,
.field select {
  font-family: var(--font-read);
  font-size: 16px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--ink);
  padding: 7px 2px;
  border-radius: 0;
}

.field input::placeholder { color: #8b9083; }

.field input:focus-visible,
.field select:focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 3px;
}

.field select {
  padding-right: 26px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% + 1px),
    calc(100% - 9px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.saved-toggle {
  align-self: end;
  margin-bottom: 1px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: 15px;
  letter-spacing: 0.02em;
  padding: 8px 16px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.saved-toggle .count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: 12.5px;
  font-weight: 600;
}

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

/* ————— departure listings ————— */

.departures {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  border-top: 2px dashed rgba(34, 39, 31, 0.35);
}

.departures:empty { display: none; }

.departure {
  border-bottom: 2px dashed rgba(34, 39, 31, 0.35);
}

.departure-open {
  display: grid;
  grid-template-columns: auto 1fr max-content;
  gap: 8px 18px;
  align-items: center;
  width: 100%;
  padding: 20px 10px;
  margin: 0;
  background: transparent;
  border: none;
  text-align: left;
  border-radius: 8px;
  transition: background-color 0.15s ease;
}

.departure-open:hover {
  background: color-mix(in srgb, var(--line) 8%, transparent);
}

.bullet {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--line);
  color: var(--paper-2);
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: 15px;
  flex: none;
}

.cat-food .bullet { color: var(--ink); }

.dep-main { min-width: 0; }

.dep-title {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 500;
  font-size: clamp(19px, 2.4vw, 23px);
  line-height: 1.22;
  letter-spacing: 0.005em;
}

.dep-summary {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
  max-width: 62ch;
}

.dep-meta {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
}

.dep-time {
  text-align: right;
  font-family: var(--font-sign);
  line-height: 1;
  color: var(--ink);
}

.dep-time b {
  display: block;
  font-weight: 600;
  font-size: clamp(20px, 2.6vw, 30px);
}

.dep-time span {
  display: block;
  margin-top: 3px;
  font-weight: 400;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.kept-chip {
  font-family: var(--font-sign);
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--line);
  border: 1.5px dashed var(--line);
  border-radius: 4px;
  padding: 2px 7px 1px;
  transform: rotate(-4deg);
}

/* ————— empty state ————— */

.empty {
  margin: 34px 0 10px;
  padding: 30px 26px;
  border: 2px dashed rgba(34, 39, 31, 0.4);
  border-radius: 12px;
  text-align: center;
}

.empty-title {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 500;
  font-size: 24px;
}

.empty-copy {
  margin: 8px auto 18px;
  color: var(--ink-soft);
  max-width: 46ch;
}

.btn-reset {
  font-family: var(--font-sign);
  font-size: 15px;
  padding: 9px 20px;
  background: var(--ink);
  color: var(--paper-2);
  border: none;
  border-radius: 999px;
}

/* ————— footer / legend ————— */

.footer {
  margin-top: 56px;
  padding: 26px 0 40px;
  border-top: 2px solid var(--ink);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 20px;
}

.legend button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 6px;
  background: transparent;
  border: 1.5px solid rgba(34, 39, 31, 0.25);
  border-radius: 999px;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.legend button:hover { border-color: var(--line); }
.legend button[aria-pressed="true"] {
  border-color: var(--ink);
  background: color-mix(in srgb, var(--line) 10%, transparent);
}

.legend .bullet { width: 28px; height: 28px; font-size: 12.5px; }

.colophon {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  max-width: 72ch;
}

/* ————— ticket detail overlay ————— */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(23, 26, 19, 0.55);
  display: grid;
  place-items: center;
  padding: 28px;
  overflow-y: auto;
}

.ticket {
  position: relative;
  width: min(700px, 100%);
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  background: var(--paper-2);
  border-radius: 14px;
  box-shadow: 0 30px 70px rgba(10, 12, 8, 0.55);
  --notch: 58px;
  mask-image:
    radial-gradient(circle 13px at 0 var(--notch), transparent 12.5px, #000 13px),
    radial-gradient(circle 13px at 100% var(--notch), transparent 12.5px, #000 13px);
  mask-composite: intersect;
  -webkit-mask-image:
    radial-gradient(circle 13px at 0 var(--notch), transparent 12.5px, #000 13px),
    radial-gradient(circle 13px at 100% var(--notch), transparent 12.5px, #000 13px);
  -webkit-mask-composite: source-in;
}

.ticket-band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 30px;
  background: var(--line);
  color: var(--paper-2);
  border-bottom: 2px dashed rgba(246, 246, 240, 0.65);
}

.cat-food .ticket-band,
.cat-food .band-btn { color: var(--ink); }

.band-route {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sign);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.band-route .bullet { background: var(--paper-2); color: var(--line); }

.band-actions { display: inline-flex; gap: 10px; }

.band-btn {
  font-family: var(--font-sign);
  font-size: 14.5px;
  letter-spacing: 0.03em;
  padding: 7px 15px;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  background: transparent;
}

.band-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper-2);
  border-color: var(--ink);
}

.ticket-inner { padding: 30px 34px 38px; }

.ticket-title {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: clamp(26px, 4.6vw, 38px);
  line-height: 1.14;
  max-width: 24ch;
}

.ticket-summary {
  margin: 14px 0 0;
  font-size: 17.5px;
  font-style: italic;
  color: var(--ink-soft);
  max-width: 58ch;
}

.ticket-meta {
  margin: 16px 0 0;
  padding-bottom: 18px;
  border-bottom: 2px dashed rgba(34, 39, 31, 0.35);
  font-size: 14px;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.story-body {
  margin-top: 22px;
  position: relative;
  padding-left: 32px;
}

.story-body::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--line), color-mix(in srgb, var(--line) 20%, transparent));
}

.story-body p {
  position: relative;
  margin: 0 0 1.1em;
  font-size: 17px;
  line-height: 1.68;
  max-width: 62ch;
}
.story-body p:last-child { margin-bottom: 0; }

.story-body p::before {
  content: "";
  position: absolute;
  left: -31px;
  top: 0.52em;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
  box-shadow: 0 0 0 3px var(--paper-2);
}

.stamp {
  position: absolute;
  top: 86px;
  right: 26px;
  transform: rotate(-8deg);
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--line);
  border: 3px solid var(--line);
  border-radius: 6px;
  padding: 4px 12px 3px;
  opacity: 0.9;
  pointer-events: none;
}

@keyframes stamp-in {
  from { transform: rotate(-8deg) scale(1.6); opacity: 0; }
  to   { transform: rotate(-8deg) scale(1); opacity: 0.9; }
}

.stamp.pop { animation: stamp-in 0.22s ease-out both; }

/* ————— responsive ————— */

@media (max-width: 720px) {
  .controls {
    grid-template-columns: 1fr max-content;
  }
  .field-search { grid-column: 1 / -1; }
  .board-strip { flex-direction: column; gap: 2px; align-items: flex-start; }
  .issue { order: -1; }
  .legend { gap: 8px 10px; }
}

@media (max-width: 640px) {
  .masthead { padding: 16px 0 24px; }
  .departure-open {
    grid-template-columns: auto 1fr auto;
    gap: 6px 12px;
    padding: 16px 6px;
  }
  .dep-summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .dep-time b { font-size: 19px; }
  .dep-time span { font-size: 10px; }
  .overlay { padding: 0; }
  .ticket {
    width: 100%;
    max-height: none;
    height: 100%;
    border-radius: 0;
    mask-image: none;
    -webkit-mask-image: none;
  }
  .ticket-band { padding: 12px 18px; }
  .ticket-inner { padding: 22px 20px 30px; }
  .story-body { padding-left: 0; }
  .story-body::before, .story-body p::before { display: none; }
  .stamp { top: 118px; right: 12px; font-size: 15px; }
}

/* ————— reduced motion ————— */

@media (prefers-reduced-motion: reduce) {
  .flap.tick { animation: none; }
  .stamp { animation: none !important; }
  * { transition: none !important; }
}
