/* ============================================================
   HEADWAY — a transit-wayfinding magazine
   Ground: cool putty porcelain. Ink: near-black. One vermilion.
   Line colors live only as station dots and route marks.
   ============================================================ */

@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper: #e9eae4;
  --panel: #fcfcf8;
  --panel-dim: #f3f3ec;
  --ink: #171a18;
  --ink-body: #20241f;
  --ink-2: #545a55;
  --ink-3: #8d9289;
  --rule: #d3d6ca;
  --accent: #e0491a;
  --accent-ink: #be3b0b;
  --accent-deep: #b03707;
  --band: #14171a;
  --band-ink: #f1f1ea;
  --band-dim: #aab1a8;
  --line-places: #0e7c86;
  --line-movement: #2456c4;
  --line-people: #b53a6e;
  --line-food: #b57e14;
  --line-culture: #7a4fc9;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Work Sans", "Helvetica Neue", Arial, sans-serif;
  --serif: "Literata", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html {
  scrollbar-width: thin;
  scrollbar-color: var(--ink-3) var(--paper);
}

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

/* The fixed vermilion strip: the publication's frame */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--accent);
  z-index: 60;
}

::selection { background: var(--accent-deep); color: #fff; }

[hidden] { display: none !important; }

.skip {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 100;
  transform: translateY(-200%);
  background: var(--ink);
  color: var(--band-ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 16px;
  text-decoration: none;
}
.skip:focus { transform: translateY(0); outline: 2px solid var(--accent); outline-offset: 2px; }

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

button { font: inherit; color: inherit; }

/* ============ Masthead band ============ */

.mast {
  background: var(--band);
  color: var(--band-ink);
}

.mast-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 42px clamp(20px, 4vw, 48px) 38px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 28px;
}

.wordmark {
  margin: 0;
  font-size: clamp(48px, 8.6vw, 116px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}

.wordmark-dot {
  display: inline-block;
  width: 0.13em;
  height: 0.13em;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 0.07em;
}

.mast-meta {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--band-dim);
  text-align: right;
  display: grid;
  gap: 7px;
  padding-bottom: 6px;
}
.mast-meta p { margin: 0; }
.mast-meta .mast-tag { color: var(--band-ink); }

/* ============ Controls rail ============ */

.controls {
  max-width: 1160px;
  margin: 0 auto;
  padding: 30px clamp(20px, 2.5vw, 24px) 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 22px;
}

.control { display: flex; flex-direction: column; }
.control.grow { flex: 1 1 300px; }

.micro {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 7px;
}

input[type="search"],
select {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 11px 14px;
  caret-color: var(--accent-deep);
  width: 100%;
}

.control.grow input { flex: 1; }

.control:not(.grow) input,
.control:not(.grow) select { width: auto; min-width: 180px; }

input::placeholder { color: var(--ink-3); opacity: 1; }

input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23171a18' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  cursor: pointer;
}

.toggle {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 11px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.toggle .tick {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  flex: none;
}

.toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--band-ink);
}
.toggle[aria-pressed="true"] .tick {
  background: var(--accent);
  border-color: var(--accent);
}

.count {
  margin: 0 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  padding-bottom: 13px;
}

/* ============ The board ============ */

.board-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 clamp(20px, 2.5vw, 24px);
}

.board-panel {
  background: var(--panel);
  border: 1px solid var(--ink);
}

.board-head {
  display: grid;
  grid-template-columns: 170px 1fr 300px;
  gap: 0 24px;
  padding: 13px 28px;
  border-bottom: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.board-head .right { text-align: right; }

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

.row {
  display: grid;
  grid-template-columns: 170px 1fr 300px;
  gap: 0 24px;
  padding: 21px 28px;
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
}
.row:last-child { border-bottom: 0; }
.row:hover, .row:focus-within { background: var(--panel-dim); }

@media (prefers-reduced-motion: no-preference) {
  .row { animation: row-in 0.35s cubic-bezier(0.22, 0.75, 0.3, 1) backwards; }
}
@keyframes row-in {
  from { opacity: 0; transform: translateY(7px); }
}

.line-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding-top: 5px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line, var(--ink));
  flex: none;
}
.dot.sm { width: 9px; height: 9px; }

.line-name {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.story-cell { min-width: 0; }

.open-btn {
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  text-decoration: underline transparent 2px;
  text-underline-offset: 5px;
  transition: text-decoration-color 0.15s ease;
}
.open-btn:hover,
.open-btn:focus-visible {
  text-decoration-color: var(--accent);
}

.summary {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 62ch;
}

.filed-cell {
  font-family: var(--mono);
  text-align: right;
  padding-top: 3px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: 1px solid var(--accent-ink);
  color: var(--accent-ink);
  padding: 2px 8px 1px;
}
.tag.saved-tag {
  border: 0;
  background: var(--ink);
  color: var(--band-ink);
}

.author {
  font-size: 12.5px;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.when {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--ink-2);
}

.row.latest {
  padding-top: 30px;
  padding-bottom: 30px;
}
.row.latest .open-btn { font-size: 26px; }
.row.latest .summary { font-size: 16px; }

/* ============ Empty state ============ */

.empty {
  padding: 64px 28px 70px;
  text-align: center;
}
.empty-title {
  margin: 0;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.empty-note {
  margin: 10px auto 24px;
  max-width: 44ch;
  font-size: 15px;
  color: var(--ink-2);
}
.btn {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 12px 18px;
  cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--band-ink); }

/* ============ Colophon ============ */

.colophon {
  max-width: 1160px;
  margin: 30px auto 64px;
  padding: 0 clamp(20px, 2.5vw, 24px);
}
.colophon p {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.75;
  color: var(--ink-2);
  max-width: 100ch;
}

/* ============ Detail view ============ */

.detail-top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 3vw, 32px);
}

.close-btn {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 9px 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.close-btn svg { display: block; }
.close-btn:hover { background: var(--ink); color: var(--band-ink); }

.detail-brand {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
}
.brand-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 6px;
}

.sheet {
  max-width: 720px;
  margin: 0 auto;
  padding: 54px 24px 88px;
}

.sheet h1 {
  margin: 0;
  font-size: clamp(32px, 4.6vw, 46px);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.meta {
  margin: 18px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.meta .cat {
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.meta .sep { color: var(--ink-3); }

/* Signature: the route line draws itself when a story opens */
.route {
  --line: var(--ink);
  position: relative;
  height: 12px;
  margin: 26px 0 12px;
}
.route .line {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 5px;
  height: 2px;
  background: var(--line);
  transform: scaleX(0);
  transform-origin: left center;
}
.route .stn {
  position: absolute;
  top: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.route .stn.start { left: 0; background: var(--line); }
.route .stn.end { right: 0; background: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  .route .line { animation: route-draw 0.8s cubic-bezier(0.25, 0.7, 0.25, 1) 0.12s forwards; }
  .route .stn { animation: stn-in 0.25s ease-out backwards; }
  .route .stn.start { animation-delay: 0.1s; }
  .route .stn.end { animation-delay: 0.85s; }
}
@keyframes route-draw { to { transform: scaleX(1); } }
@keyframes stn-in { from { transform: scale(0); } }

.actions { margin-top: 18px; }

.save-btn {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 13px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.save-btn .punch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  flex: none;
}
.save-btn:hover { background: var(--panel-dim); }
.save-btn[aria-pressed="true"] {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #fff;
}
.save-btn[aria-pressed="true"] .punch { background: currentColor; border-color: #fff; }

.plate { margin: 42px 0 0; }
.plate img {
  display: block;
  width: 100%;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  border: 1px solid var(--ink);
  background: var(--panel-dim);
}
.plate figcaption {
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-2);
}

.body {
  margin-top: 42px;
  max-width: 66ch;
  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 1.78;
  color: var(--ink-body);
}
.body p { margin: 0 0 1.4em; }
.body p:last-child { margin-bottom: 0; }

.transfers {
  margin-top: 64px;
  border-top: 2px solid var(--ink);
  padding-top: 16px;
}
.xfer-label {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.transfer {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 14px 2px;
  cursor: pointer;
}
.transfer:last-child { border-bottom: 0; }
.transfer .t-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: underline transparent 2px;
  text-underline-offset: 4px;
  transition: text-decoration-color 0.15s ease;
}
.transfer:hover .t-title,
.transfer:focus-visible .t-title { text-decoration-color: var(--accent); }
.transfer .t-line {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
}

/* ============ Mobile ============ */

@media (max-width: 720px) {
  .mast-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    padding: 26px 20px 24px;
  }
  .mast-meta { text-align: left; padding-bottom: 0; }

  .controls { padding: 22px 16px 16px; gap: 14px; }
  .control.grow { flex-basis: 100%; }
  .control:not(.grow) select { flex: 1; min-width: 0; width: 100%; }
  .control .toggle { width: 100%; justify-content: center; }
  .control:not(.grow) { flex: 1 1 40%; }
  .count { margin-left: 0; flex-basis: 100%; padding-bottom: 0; }

  .board-wrap { padding: 0 16px; }
  .board-head { display: none; }

  .row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 20px 18px;
  }
  .line-cell {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding-top: 0;
  }
  .row.latest { padding-top: 26px; padding-bottom: 26px; }
  .row.latest .open-btn { font-size: 22px; }
  .open-btn { font-size: 19px; }

  .filed-cell {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 12px;
    padding-top: 0;
  }
  .tag { order: 3; }

  .sheet { padding: 38px 18px 64px; }
  .plate img { aspect-ratio: 16 / 9; }
  .body { font-size: 17.5px; }
  .detail-top { padding: 10px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .route .line { transform: scaleX(1); }
}
