/* =========================================================================
   Crosstown — a journal of everyday city life
   Visual world: municipal map + transit line. Paper, ink, station dots.
   ========================================================================= */

/* --- Faces ---------------------------------------------------------------- */
@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

/* --- Tokens --------------------------------------------------------------- */
:root {
  --ink: #11161b;
  --ink-2: #1a2229;
  --paper: #e9eae3;
  --panel: #f3f3ee;
  --rule: #c7cabf;
  --rule-soft: #d8dad0;
  --text: #171c21;
  --muted: #4b545c;
  --rule-dark: rgba(233, 234, 227, 0.22);
  --paper-dim: rgba(233, 234, 227, 0.68);

  --cat-culture: #b53327;
  --cat-food: #8a5606;
  --cat-movement: #1c6d88;
  --cat-people: #6c4a8c;
  --cat-places: #2f6340;

  --cat-culture-b: #ff6f5e;
  --cat-food-b: #f0b429;
  --cat-movement-b: #5fbcd9;
  --cat-people-b: #b795d9;
  --cat-places-b: #79cd8f;

  --focus: #0d637e;
  --focus-dark: #ffd166;

  --maxw: 1200px;
  --gut: clamp(1.1rem, 4vw, 2.75rem);
  --display: "Oswald", "Arial Narrow", system-ui, sans-serif;
  --body: "Literata", Georgia, "Times New Roman", serif;
  --mono: "Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  accent-color: #11161b;
  color-scheme: light;
}

/* --- Reset ---------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
input,
select { font: inherit; color: inherit; }

h1, h2, h3, p { margin: 0; }

.mono {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* --- Browser surfaces ----------------------------------------------------- */
::selection { background: var(--ink); color: var(--paper); }
.masthead ::selection,
.reader__bar ::selection { background: var(--paper); color: var(--ink); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}
.masthead :focus-visible,
.reader__bar :focus-visible { outline-color: var(--focus-dark); }

input[type="search"] { caret-color: var(--ink); }
.indexbar { scrollbar-color: var(--rule) transparent; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 0.9rem;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: top 0.18s ease;
}
.skip-link:focus { top: 0.75rem; }

/* =========================================================================
   Masthead
   ========================================================================= */
.masthead {
  position: relative;
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
  border-bottom: 1px solid var(--ink);
}

.masthead__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(233, 234, 227, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233, 234, 227, 0.06) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.35) 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.35) 72%, transparent 100%);
  pointer-events: none;
}

.masthead__inner {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.1rem, 3vw, 1.8rem) var(--gut) clamp(1.4rem, 4vw, 2.4rem);
}

.masthead__meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--paper-dim);
  border-bottom: 1px solid var(--rule-dark);
  padding-bottom: 0.9rem;
}

.wordmark {
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(3.4rem, 15.5vw, 10.5rem);
  line-height: 0.84;
  letter-spacing: 0.005em;
  margin: clamp(0.9rem, 2.5vw, 1.6rem) 0 0;
  white-space: nowrap;
}
.wordmark__town { color: var(--paper); }
.wordmark > span:first-child { color: var(--paper); }
@supports (-webkit-text-stroke: 1px #000) {
  .wordmark > span:first-child {
    color: transparent;
    -webkit-text-stroke: 1.5px var(--paper);
  }
}

.tagline {
  max-width: 46ch;
  margin-top: clamp(0.9rem, 2.5vw, 1.4rem);
  color: var(--paper-dim);
  font-size: clamp(0.95rem, 1.4vw, 1.08rem);
  line-height: 1.6;
}

/* --- Route line (topic navigator) ---------------------------------------- */
.route {
  position: relative;
  margin-top: clamp(1.6rem, 4vw, 2.6rem);
  padding-top: 0.2rem;
}
.route__line {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 0.92rem;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--cat-culture-b),
    var(--cat-food-b),
    var(--cat-movement-b),
    var(--cat-people-b),
    var(--cat-places-b)
  );
  opacity: 0.85;
}
.route__stations {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: clamp(0.6rem, 2.5vw, 2.4rem);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding-bottom: 0.4rem;
}
.route__stations::-webkit-scrollbar { display: none; }

.station {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  min-width: 3.6rem;
  padding: 0.35rem 0.1rem;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--paper-dim);
  transition: color 0.2s ease;
}
.station__dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--station-color, var(--paper-dim));
  box-shadow: 0 0 0 3px var(--ink);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s ease;
}
.station__label {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.station:hover { color: var(--paper); }
.station:hover .station__dot { transform: scale(1.18); }
.station[aria-pressed="true"] { color: var(--paper); }
.station[aria-pressed="true"] .station__dot {
  background: var(--station-color, var(--paper));
  transform: scale(1.3);
}

/* =========================================================================
   Index bar — search / filter / saved
   ========================================================================= */
.indexbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(233, 234, 227, 0.93);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.indexbar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.85rem var(--gut);
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field__label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.field--search { flex: 1 1 auto; }
.field__control { position: relative; display: flex; }
.field__icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.05rem;
  height: 1.05rem;
  color: var(--muted);
  pointer-events: none;
}
.field input,
.field select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.62rem 0.8rem;
  font-family: var(--body);
  font-size: 0.95rem;
}
.field input { padding-left: 2.2rem; }
.field input::placeholder { color: #565e66; }
.field input:hover,
.field select:hover { border-color: #a9ada1; }
.field input:focus,
.field select:focus { border-color: var(--ink); outline-offset: 1px; }
.field--select { flex: 0 0 auto; min-width: 10.5rem; }

.saved-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.62rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.saved-toggle svg { width: 1rem; height: 1rem; }
.saved-toggle:hover { border-color: #a9ada1; }
.saved-toggle__count {
  min-width: 1.35em;
  padding: 0.05em 0.35em;
  text-align: center;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  font-size: 0.9em;
}
.saved-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.saved-toggle[aria-pressed="true"] .saved-toggle__count {
  background: var(--paper);
  color: var(--ink);
}
.saved-toggle[aria-pressed="true"] svg path,
.btn--save[aria-pressed="true"] svg path { fill: currentColor; }

/* =========================================================================
   Lead story
   ========================================================================= */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gut); }

.lead { padding: clamp(1.6rem, 4vw, 2.8rem) 0 clamp(1.4rem, 3vw, 2.2rem); }

.lead__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(1.4rem, 4vw, 3rem);
  align-items: center;
}

.media {
  position: relative;
  overflow: hidden;
  background: var(--cat, var(--ink));
  border-radius: 3px;
}
.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: multiply;
  filter: grayscale(1) contrast(1.12) brightness(1.06);
}
.media--lead { aspect-ratio: 5 / 4; }

.lead__title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2rem, 4.6vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: 0.002em;
  text-wrap: balance;
}
.lead__summary {
  margin-top: 1rem;
  font-size: clamp(1.02rem, 1.5vw, 1.18rem);
  color: #2a3238;
  max-width: 56ch;
}
.lead__meta {
  margin-top: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.8rem;
  color: var(--muted);
}
.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cat-tag::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cat, var(--ink));
}

.open-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.4rem;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 2px solid var(--cat, var(--ink));
  padding-bottom: 0.25rem;
  transition: gap 0.18s ease, color 0.18s ease;
}
.open-link:hover { gap: 0.9rem; }
.open-link svg { width: 1rem; height: 1rem; }

/* =========================================================================
   Index list
   ========================================================================= */
.index { padding-bottom: clamp(2rem, 5vw, 4rem); }

.index__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 0.6rem;
}
.index__heading {
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(1.3rem, 2.4vw, 1.9rem);
  letter-spacing: 0.02em;
}
.index__count { color: var(--muted); }

.entry {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr) 9.5rem;
  gap: clamp(1rem, 3vw, 2rem);
  align-items: start;
  padding: clamp(1.3rem, 3vw, 1.9rem) 0;
  border-bottom: 1px solid var(--rule);
}
.entry__no {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--cat, var(--ink));
  padding-top: 0.35rem;
}
.entry__title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  line-height: 1.08;
  text-wrap: balance;
}
.entry__open {
  display: inline;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.14em;
  text-decoration-thickness: 2px;
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}
.entry__open:hover { text-decoration-color: var(--cat, var(--ink)); }
.entry__summary {
  margin-top: 0.55rem;
  color: #2c343a;
  max-width: 62ch;
}
.entry__meta {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.85rem;
  color: var(--muted);
}
.entry__author { font-style: italic; }

.media--thumb { aspect-ratio: 4 / 3; }
.entry:hover .media--thumb img { transform: scale(1.04); }
.media--thumb img { transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* =========================================================================
   Empty state
   ========================================================================= */
.empty-state {
  text-align: center;
  padding: clamp(2.5rem, 8vw, 5rem) 1rem clamp(3rem, 9vw, 6rem);
  border-bottom: 1px solid var(--rule);
}
.empty-state__mark svg { width: 108px; height: 108px; color: var(--cat-movement); margin: 0 auto 1.2rem; }
.empty-state__heading {
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: 0.02em;
}
.empty-state__body {
  max-width: 46ch;
  margin: 0.8rem auto 1.6rem;
  color: var(--muted);
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 1.05rem;
  border-radius: 3px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.btn svg { width: 1rem; height: 1rem; }
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--ink-2); }

.btn--ghost { border-color: var(--rule-dark); color: var(--paper); }
.btn--ghost:hover { border-color: var(--paper); }

.btn--save { border-color: var(--paper-dim); color: var(--paper); }
.btn--save:hover { border-color: var(--paper); }
.btn--save[aria-pressed="true"] {
  background: var(--focus-dark);
  border-color: var(--focus-dark);
  color: var(--ink);
}

/* =========================================================================
   Reader (detail view)
   ========================================================================= */
.reader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--paper);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--rule) transparent;
  -webkit-animation: reader-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation: reader-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.reader[hidden] { display: none; }
body.reader-open { overflow: hidden; }

@keyframes reader-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.reader__bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem max(var(--gut), calc((100vw - var(--maxw)) / 2 + var(--gut))) 0.7rem;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 1px solid var(--ink-2);
}
.reader__bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--cat, var(--cat-culture-b));
}
.reader__bar > * { position: relative; z-index: 1; }

.reader__article {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(1.6rem, 4vw, 3rem) var(--gut) clamp(4rem, 10vw, 7rem);
}

.reader__media {
  aspect-ratio: 16 / 9;
  margin-bottom: clamp(1.4rem, 4vw, 2.2rem);
}

.reader__meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.8rem;
  margin: 1.3rem 0 0;
}
.reader__title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2rem, 5.4vw, 3.4rem);
  line-height: 1.03;
  text-wrap: balance;
}
.reader__standfirst {
  margin-top: 1.1rem;
  font-size: clamp(1.08rem, 2vw, 1.28rem);
  line-height: 1.55;
  color: #2a3238;
}
.reader__standfirst::after {
  content: "";
  display: block;
  width: 4rem;
  height: 3px;
  margin-top: 1.4rem;
  background: var(--cat, var(--ink));
}
.reader__body { margin-top: 1.5rem; }
.reader__body p {
  font-size: clamp(1.06rem, 1.6vw, 1.17rem);
  line-height: 1.78;
  color: #202729;
  margin-bottom: 1.35em;
}
.reader__body p:first-of-type::first-letter {
  float: left;
  font-family: var(--display);
  font-weight: 600;
  font-size: 3.5em;
  line-height: 0.78;
  padding: 0.06em 0.1em 0 0;
  color: var(--cat, var(--ink));
}
.reader__credit {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
}

/* =========================================================================
   Colophon
   ========================================================================= */
.colophon {
  background: var(--ink);
  color: var(--paper-dim);
  margin-top: 2rem;
}
.colophon__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.2rem) var(--gut);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem 2rem;
  align-items: center;
}
.colophon__inner p { font-size: 0.88rem; }
.colophon__name {
  color: var(--paper);
  font-family: var(--display) !important;
  font-size: 1.3rem !important;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.colophon__edition { text-align: right; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 980px) {
  .lead__grid { grid-template-columns: 1fr; }
  .media--lead { aspect-ratio: 16 / 9; }
  .lead__text { order: -1; }
  .entry { grid-template-columns: 2.6rem minmax(0, 1fr) 7.5rem; }
}

@media (max-width: 760px) {
  .masthead__meta-right { display: none; }
  .route__line { display: none; }
  .route__stations {
    flex-wrap: wrap;
    overflow: visible;
    justify-content: center;
    row-gap: 0.9rem;
    column-gap: clamp(0.8rem, 4vw, 1.6rem);
  }
  .station { flex: 0 1 auto; min-width: 4.25rem; }
  .indexbar__inner { flex-wrap: wrap; align-items: flex-end; }
  .field--search { flex: 1 1 100%; }
  .field--select { flex: 1 1 auto; }
  .saved-toggle { flex: 0 0 auto; }

  .entry { grid-template-columns: minmax(0, 1fr) 5.5rem; gap: 1rem; }
  .entry__no { display: none; }
  .entry__title { font-size: 1.4rem; }
  .entry__summary { font-size: 0.95rem; }

  .colophon__inner { grid-template-columns: 1fr; }
  .colophon__edition { text-align: left; }
}

@media (max-width: 430px) {
  .wordmark { font-size: 18vw; }
  .entry { grid-template-columns: minmax(0, 1fr); }
  .entry__thumb { display: none; }
  .reader__bar { flex-wrap: wrap; }
  .reader__bar .btn { flex: 1 1 auto; justify-content: center; }
}

/* =========================================================================
   Coarse pointers — keep touch targets reachable
   ========================================================================= */
@media (pointer: coarse) {
  .btn,
  .saved-toggle,
  .station { min-height: 44px; }
  .field input,
  .field select { min-height: 44px; }
  .open-link { min-height: 44px; align-items: center; }
  .entry__open { padding: 0.1em 0; }
}

/* =========================================================================
   Motion preferences
   ========================================================================= */
@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;
  }
  .reader { animation: none; }
}
