/* ============================================================
   BETWEEN STOPS — a routebook of everyday city life
   Paper tickets, transit lines, punched holes.
   ============================================================ */

@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 200 900;
  font-display: swap;
}

:root {
  --paper: #f4efe2;
  --paper-2: #ece4d0;
  --ink: #27221b;
  --muted: #5e5546;
  --line: #cdc2a7;
  --accent: #b53511;
  --accent-bright: #e0521f;

  --cat-culture: #6e4a9e;
  --cat-food: #9a5e0d;
  --cat-movement: #2563a8;
  --cat-people: #b04a67;
  --cat-places: #27714a;

  --gutter: 96px;
  --sway: 30px;
  --font-display: "Space Grotesk", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-body: "Literata", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* paper grain over everything, but never in the way */
.grain {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: none;
  transition: top 0.2s;
}
.skip:focus { top: 12px; }

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

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

/* ---------------- top tape ticker ---------------- */
.tape {
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 8px 0;
}
.tape-track {
  display: inline-block;
  padding-left: 100%;
  animation: tape 60s linear infinite;
}
@keyframes tape {
  to { transform: translateX(-100%); }
}

/* ---------------- masthead ---------------- */
.masthead {
  max-width: 1240px;
  margin: 0 auto;
  padding: 30px 28px 8px;
}
.mast-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 10px 0;
}
.issue {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.barcode {
  display: flex;
  align-items: center;
  gap: 10px;
}
.barcode-bars {
  width: 120px;
  height: 26px;
  background: repeating-linear-gradient(
    90deg,
    var(--ink) 0 2px, transparent 2px 5px,
    var(--ink) 5px 9px, transparent 9px 11px,
    var(--ink) 11px 12px, transparent 12px 16px,
    var(--ink) 16px 20px, transparent 20px 23px
  );
}
.barcode-no {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
}

.brand {
  margin: 26px 0 10px -5px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(58px, 9.5vw, 148px);
  line-height: 0.9;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  color: var(--ink);
}
.brand-line { display: block; }
.brand-line:first-child { margin-left: 0.06em; }
.brand-dot {
  width: 0.62em;
  height: 0.62em;
  margin-left: 0.12em;
  color: var(--accent);
  display: inline-block;
  vertical-align: baseline;
  transform: translateY(0.02em);
}
.tagline {
  margin: 18px 0 26px;
  max-width: 44ch;
  font-size: 18px;
  font-style: italic;
  color: var(--muted);
}

/* scissors cut line */
.cut {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cut::before,
.cut::after {
  content: "";
  flex: 1;
  border-top: 2px dashed var(--ink);
  opacity: 0.65;
}
.scissors {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--ink);
  transform: scaleX(-1);
}

/* ---------------- journey planner ---------------- */
.planner {
  max-width: 1240px;
  margin: 26px auto 0;
  padding: 0 28px;
}
.planner-title {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.planner-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 16px;
  align-items: end;
  border: 2px solid var(--ink);
  background: var(--paper-2);
  padding: 18px 20px;
  box-shadow: 6px 6px 0 rgba(39, 34, 27, 0.18);
}
.lab {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
input[type="search"],
select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 10px 12px;
  border-radius: 0;
  appearance: none;
}
select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2327221B' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 rgba(39, 34, 27, 0.35);
}
.btn:active { transform: translate(0, 0); box-shadow: none; }
.btn .icon { width: 16px; height: 16px; }

.kept-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.legend button {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--line);
  padding: 6px 10px 6px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: border-color 0.12s, background 0.12s;
}
.legend button::before {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--c);
  flex: none;
}
.legend button:hover { border-color: var(--ink); background: var(--paper-2); }
.legend button.is-active {
  border-color: var(--ink);
  border-style: solid;
  background: var(--paper-2);
  box-shadow: 3px 3px 0 rgba(39, 34, 27, 0.2);
}

.count {
  margin: 12px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------- the route board ---------------- */
.board {
  max-width: 1240px;
  margin: 30px auto 0;
  padding: 0 28px 10px;
  position: relative;
}
.terminus {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0 calc(var(--gutter) * 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}
.terminus::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--ink);
  flex: none;
}
.terminus.top { margin-bottom: 6px; }
.terminus.bottom { margin-top: 6px; }

.stops {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.route-wrap { position: relative; }
.route {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--gutter);
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.route path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}
.bus {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--gutter);
  pointer-events: none;
  z-index: 3;
  display: flex;
  justify-content: center;
}
.bus svg { width: 34px; height: 19px; filter: drop-shadow(1px 2px 0 rgba(39,34,27,0.25)); }

/* each stop */
.stop {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  column-gap: 26px;
  padding: 30px 0 34px;
  position: relative;
  border-bottom: 1px dashed var(--line);
}
.stop:last-child { border-bottom: none; }

.marker {
  justify-self: center;
  align-self: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--paper);
  border: 4px solid var(--c, var(--ink));
  position: relative;
  z-index: 2;
  transition: transform 0.15s ease;
}
.stop:hover .marker { transform: scale(1.25) rotate(8deg); }
.marker.is-saved::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--c, var(--ink)) inset;
}

.stop-meta {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.stop-code { color: var(--ink); font-weight: 600; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--c);
}
.chip::before {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--c);
}
.stop-saved-flag { color: var(--accent); font-weight: 600; }

.stop-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
  letter-spacing: -0.01em;
}
.stop-title button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
  transition: text-decoration-color 0.15s;
}
.stop-title button:hover { text-decoration-color: var(--accent-bright); }

.stop-summary {
  margin: 0 0 12px;
  max-width: 62ch;
  font-size: 17px;
  font-style: italic;
  color: var(--muted);
}
.stop-foot {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
}
.stop-foot .read-cue { color: var(--accent); font-weight: 600; }
.read-cue-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: text-decoration-color 0.15s, color 0.15s;
}
.read-cue-btn:hover {
  color: var(--accent);
  text-decoration-color: var(--accent-bright);
}

.stop-view {
  position: absolute;
  right: 0;
  top: 34px;
  width: 168px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 2px solid var(--ink);
  filter: grayscale(1) sepia(0.22) contrast(1.05) brightness(1.02);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stop:hover .stop-view {
  transform: translate(-3px, -3px) rotate(-1deg);
  box-shadow: 5px 5px 0 rgba(39, 34, 27, 0.3);
}
.stop-body { min-width: 0; padding-right: 200px; }

/* empty state */
.empty {
  margin: 40px 0 40px var(--gutter);
  border: 2px dashed var(--ink);
  padding: 36px 32px;
  max-width: 560px;
}
.empty-code {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
.empty-text { margin: 0 0 20px; font-size: 17px; color: var(--muted); }

/* ---------------- colophon ---------------- */
.colophon {
  max-width: 1240px;
  margin: 70px auto 0;
  padding: 22px 28px 46px;
  border-top: 3px solid var(--ink);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 28px;
  align-items: start;
}
.colophon p { margin: 0; font-size: 14px; color: var(--muted); max-width: 78ch; }
.colophon strong { color: var(--ink); font-family: var(--font-display); letter-spacing: 0.02em; text-transform: uppercase; font-size: 13px; }
.colophon-note { grid-column: 1 / -1; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.barcode.small { padding-top: 4px; }
.barcode.small .barcode-bars { width: 90px; height: 20px; }

/* ============================================================
   DETAIL — the ticket
   ============================================================ */
.detail {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  background: var(--paper);
  padding: 30px 20px 80px;
}
.detail[data-open="true"] .ticket { animation: ticket-in 0.28s ease-out; }
@keyframes ticket-in {
  from { opacity: 0; transform: translateY(26px) rotate(-0.4deg); }
  to { opacity: 1; transform: none; }
}

.ticket {
  max-width: 880px;
  margin: 0 auto;
  background: var(--paper-2);
  border: 3px solid var(--ink);
  box-shadow: 10px 10px 0 rgba(39, 34, 27, 0.28);
}

.stub {
  padding: 26px 30px 22px;
  border-bottom: 2px dashed var(--ink);
  position: relative;
}
/* ticket side notches on the perforation */
.stub::before,
.stub::after {
  content: "";
  position: absolute;
  bottom: -14px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--ink);
  z-index: 1;
}
.stub::before { left: -16px; border-left-color: transparent; }
.stub::after { right: -16px; border-right-color: transparent; }

.stub-brand {
  margin: 0 0 22px;
  padding-right: 120px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.stub-brand::after { content: ""; flex: 1; border-top: 1.5px solid var(--line); }

.stub-now {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
}
.ticket-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 5.4vw, 56px);
  line-height: 1.0;
  letter-spacing: -0.015em;
  max-width: 24ch;
}
.stub-meta {
  margin: 0 0 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}
.stub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.save-btn { font-size: 12.5px; padding: 12px 16px; }
.esc-hint {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.save-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
}
.save-btn .hole {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2.5px dashed currentColor;
  flex: none;
  transition: background 0.15s, border-style 0.15s;
}
.save-btn[aria-pressed="true"] .hole {
  border-style: solid;
  background: var(--paper-2);
  box-shadow: 0 0 0 2.5px var(--accent) inset;
}

/* big punch hole on the stub corner */
.punch {
  position: absolute;
  top: 18px;
  right: 120px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 2.5px var(--accent) inset, 0 0 0 6px var(--paper) inset, 0 0 0 7.5px var(--accent) inset;
  transform: rotate(8deg) scale(0);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.ticket.is-saved .punch { transform: rotate(8deg) scale(1); }

.close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  background: var(--paper);
  color: var(--ink);
}
.close-btn:hover { background: var(--ink); color: var(--paper); }
.close-btn svg { width: 16px; height: 16px; }

.ticket-figure { margin: 0; }
.ticket-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 21 / 8;
  object-fit: cover;
  border-bottom: 3px solid var(--ink);
  filter: grayscale(1) sepia(0.22) contrast(1.05) brightness(1.02);
}
.ticket-figure figcaption {
  padding: 10px 30px;
  border-bottom: 1.5px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.ticket-body {
  padding: 34px 30px 40px;
}
.ticket-body p {
  margin: 0 0 1.15em;
  font-size: 18.5px;
  line-height: 1.62;
  max-width: 66ch;
}
.ticket-body p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 3.05em;
  float: left;
  line-height: 0.82;
  padding: 0.06em 0.12em 0 0;
  color: var(--accent);
}

.ticket-end {
  border-top: 2px dashed var(--ink);
  padding: 20px 30px 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  position: relative;
}
.ticket-end::before,
.ticket-end::after {
  content: "";
  position: absolute;
  top: -14px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--ink);
}
.ticket-end::before { left: -16px; border-left-color: transparent; }
.ticket-end::after { right: -16px; border-right-color: transparent; }
.end-label { display: flex; align-items: center; gap: 10px; }
.end-label::before { content: ""; width: 10px; height: 10px; background: var(--ink); }
.next-btn { text-align: left; }
.next-btn .next-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}

/* ============================================================
   responsive
   ============================================================ */
@media (max-width: 860px) {
  :root { --gutter: 60px; --sway: 18px; }
  .masthead, .planner, .board, .colophon { padding-left: 18px; padding-right: 18px; }
  .cut { padding: 0 18px; }
  .planner-grid { grid-template-columns: 1fr 1fr; }
  .field-kept { grid-column: 1 / -1; }
  .colophon { grid-template-columns: 1fr; }
  .stop-view { display: none; }
  .stop-body { padding-right: 0; }
}
@media (max-width: 640px) {
  :root { --gutter: 42px; --sway: 11px; }
  .planner-grid { grid-template-columns: 1fr; }
  .barcode { display: none; }
  .tagline { font-size: 16px; }
  .stub, .ticket-body, .ticket-end, .ticket-figure figcaption { padding-left: 18px; padding-right: 18px; }
  .stub-brand { padding-right: 56px; }
  .punch { right: 60px; top: 60px; width: 28px; height: 28px; }
  .close-btn { top: 10px; right: 10px; width: 36px; height: 36px; }
  .ticket-figure img { aspect-ratio: 16 / 9; }
  .ticket-body p { font-size: 17.5px; }
  .empty { margin-left: 0; }
  .detail { padding: 14px 10px 60px; }
  .ticket { box-shadow: 5px 5px 0 rgba(39, 34, 27, 0.28); }
}

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  .tape-track { animation: none; white-space: normal; padding-left: 24px; }
  .bus { display: none; }
  .detail[data-open="true"] .ticket { animation: none; }
  .btn:hover { transform: none; box-shadow: none; }
  .marker, .stop-view, .punch, .save-btn .hole { transition: none; }
}
