@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: "Literata"; src: url("assets/literata.ttf") format("truetype"); font-weight: 200 900; 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 {
  --asphalt: oklch(0.175 0.014 262);
  --kerb: oklch(0.225 0.016 262);
  --line: oklch(0.34 0.018 262);
  --text: oklch(0.955 0.01 95);
  --muted: oklch(0.76 0.016 95);
  --paint: oklch(0.87 0.175 95);
  --paint-ink: oklch(0.2 0.03 95);
  --paper: oklch(0.962 0.016 95);
  --ink: oklch(0.2 0.025 262);
  --ink-soft: oklch(0.42 0.02 262);

  --display: "Space Grotesk", "Avenir Next", sans-serif;
  --serif: "Literata", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --pad: clamp(1.25rem, 4vw, 3.5rem);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line) var(--asphalt); }
body {
  margin: 0;
  background: var(--asphalt);
  color: var(--text);
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1.5;
  caret-color: var(--paint);
}
::selection { background: var(--paint); color: var(--paint-ink); }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p, dl, dd, figure { margin: 0; }

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

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 10;
  background: var(--paint); color: var(--paint-ink); padding: 0.75rem 1rem; font-weight: 600;
}
.skip:focus { top: 1rem; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.side {
  padding: 1.5rem var(--pad) 1.25rem;
  display: grid;
  gap: 1.25rem;
  border-bottom: 3px dashed var(--paint);
}
.brand { display: grid; grid-template-columns: auto 1fr; column-gap: 0.85rem; align-items: center; }
.mark { width: 2.5rem; height: 2.5rem; color: var(--paint); grid-row: 1 / span 2; }
.name {
  font-size: 2.25rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1; color: var(--paint);
}
.tagline { color: var(--muted); font-size: 0.95rem; line-height: 1.3; margin-top: 0.15rem; }
.issue { display: none; }

/* ---------- controls ---------- */
.controls { display: grid; gap: 0.9rem; }
.field { display: grid; gap: 0.35rem; min-width: 0; }
.field label { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; }
.row { display: flex; gap: 0.75rem; align-items: end; }
.grow { flex: 1; }

.input-wrap { position: relative; }
.input-wrap svg {
  position: absolute; left: 0.9rem; top: 50%; translate: 0 -50%; width: 1.15rem; height: 1.15rem;
  fill: none; stroke: var(--muted); stroke-width: 1.75; stroke-linecap: round; pointer-events: none;
}
input[type="search"], select {
  width: 100%; min-height: 2.9rem; background: var(--kerb); border: 1.5px solid var(--line); border-radius: 0;
  padding: 0.6rem 0.9rem; font-size: 1rem; transition: border-color 0.2s, background-color 0.2s;
}
input[type="search"] { padding-left: 2.7rem; appearance: none; }
input[type="search"]::placeholder { color: oklch(0.68 0.016 95); opacity: 1; }
input[type="search"]::-webkit-search-cancel-button { filter: invert(1); cursor: pointer; }
select {
  appearance: none; cursor: pointer; padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ede9d9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1.1rem;
}
select option { background: var(--kerb); color: var(--text); }
input[type="search"]:hover, select:hover { border-color: var(--muted); }
input[type="search"]:focus-visible, select:focus-visible { border-color: var(--paint); outline-offset: 2px; }

.saved-toggle {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.9rem; padding: 0.5rem 0.9rem;
  background: transparent; border: 1.5px solid var(--paint); color: var(--paint); cursor: pointer; font-weight: 600;
  transition: background-color 0.2s, color 0.2s;
}
.saved-toggle svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
.saved-toggle .count {
  font-family: var(--mono); font-size: 0.8rem; min-width: 1.4rem; text-align: center; padding: 0.05rem 0.35rem;
  border: 1px solid currentColor;
}
.saved-toggle:hover { background: oklch(0.87 0.175 95 / 0.14); }
.saved-toggle[aria-pressed="true"] { background: var(--paint); color: var(--paint-ink); }
.saved-toggle[aria-pressed="true"] svg { fill: currentColor; }

/* ---------- main ---------- */
.main { padding: 1.25rem var(--pad) 4rem; min-width: 0; }
.status-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; min-height: 1.75rem; }
.status { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); letter-spacing: 0.02em; }
.link {
  background: none; border: 0; padding: 0.4rem 0; color: var(--paint); text-decoration: underline;
  text-underline-offset: 0.25em; cursor: pointer; font-weight: 500;
}
.link[hidden] { display: none; }
.centerline { display: none; }

.stories { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1rem; outline: none; }

.stories[hidden] { display: none; }
.story { position: relative; display: grid; gap: 0.9rem; min-width: 0; }
.story .media { position: relative; background: var(--paint); overflow: hidden; aspect-ratio: 3 / 2; }
.story .media img {
  width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.08); mix-blend-mode: multiply;
  transition: transform 0.7s var(--ease);
}
.chip {
  position: absolute; left: 0; bottom: 0; background: var(--asphalt); color: var(--paint);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.3rem 0.6rem;
}
.flag {
  position: absolute; right: 0; top: 0; background: var(--asphalt); color: var(--paint); width: 2rem; height: 2rem;
  display: grid; place-items: center;
}
.flag svg { width: 1rem; height: 1rem; fill: currentColor; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.story h3 {
  font-size: 1.4rem; font-weight: 600; line-height: 1.12; letter-spacing: -0.025em; text-wrap: balance;
}
.open-item {
  all: unset; cursor: pointer; display: inline;
}
.open-item::after { content: ""; position: absolute; inset: 0; }
.open-item:focus-visible { outline: none; }
.open-item:focus-visible::after { outline: 3px solid var(--paint); outline-offset: 6px; }
.story:hover h3 .open-item, .open-item:focus-visible {
  text-decoration: underline; text-decoration-color: var(--paint); text-decoration-thickness: 3px; text-underline-offset: 0.18em;
}
.story:hover .media img { transform: scale(1.045); }
.summary { color: var(--muted); font-family: var(--serif); font-size: 1rem; line-height: 1.5; max-width: 52ch; }
.meta { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); letter-spacing: 0.01em; margin-top: 0.15rem; }
.meta b { color: var(--text); font-weight: 400; }

/* mobile: lead is a poster, the rest are dense rows */
.story:not(:first-child) { grid-template-columns: 6.5rem 1fr; column-gap: 1rem; align-items: start; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.story:not(:first-child) .media { aspect-ratio: 1; }
.story:not(:first-child) .chip { display: none; }
.story:not(:first-child) h3 { font-size: 1.15rem; }
.story:not(:first-child) .summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.92rem; margin-top: 0.4rem; }
.story:not(:first-child) .meta { margin-top: 0.5rem; }
.story:first-child h3 { font-size: 2.1rem; letter-spacing: -0.035em; }
.story:first-child { margin-top: 0.25rem; }

/* empty */
.empty { max-width: 34rem; padding: 3rem 0; display: grid; gap: 0.9rem; justify-items: start; }
.empty[hidden] { display: none; }
.empty h2 { font-size: 2rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.empty p { color: var(--muted); font-family: var(--serif); }
.btn {
  background: var(--paint); color: var(--paint-ink); border: 0; padding: 0.75rem 1.2rem; min-height: 2.9rem; font-weight: 600; cursor: pointer;
  transition: translate 0.2s var(--ease);
}
.btn:hover { translate: 0 -2px; }

/* ---------- desktop: street sidebar ---------- */
@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 22.5rem minmax(0, 1fr); }
  .side {
    position: sticky; top: 0; height: 100vh; align-content: start; gap: 2.5rem; padding: 2.5rem 2rem 2rem;
    border-bottom: 0; border-right: 3px dashed var(--paint); grid-template-rows: auto auto 1fr;
  }
  .brand { display: block; }
  .mark { width: 3rem; height: 3rem; margin-bottom: 1.5rem; }
  .name { font-size: 3.6rem; }
  .tagline { font-size: 1.1rem; margin-top: 0.75rem; }
  .row { flex-wrap: wrap; }
  .row .grow { flex: 1 1 100%; }
  .saved-toggle { width: 100%; justify-content: flex-start; }
  .saved-toggle .count { margin-left: auto; }
  .issue {
    display: block; align-self: end; font-family: var(--mono); font-size: 0.72rem; line-height: 1.5; color: var(--muted);
    max-width: 24ch;
  }
  .main { padding: 2.5rem 3.5rem 6rem; }
  .stories { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3.5rem 2rem; margin-top: 1.5rem; }
  .story, .story:not(:first-child) { display: grid; grid-template-columns: none; gap: 0.9rem; padding-top: 0; border-top: 0; align-content: start; grid-column: span 6; }
  .story:not(:first-child) .media { aspect-ratio: 3 / 2; }
  .story:not(:first-child) .chip { display: block; }
  .story:not(:first-child) h3 { font-size: 1.65rem; }
  .story:not(:first-child) .summary { display: block; font-size: 1rem; margin-top: 0; -webkit-line-clamp: unset; overflow: visible; }
  .story:not(:first-child) .meta { margin-top: 0.15rem; }
  .story:nth-child(n+4):nth-child(-n+6) { grid-column: span 4; }
  .story:nth-child(n+4):nth-child(-n+6) .media { aspect-ratio: 4 / 3; }
  .story:nth-child(n+4):nth-child(-n+6) h3 { font-size: 1.35rem; }
  .story:first-child {
    grid-column: 1 / -1; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: 2.5rem; align-items: end; margin-top: 0;
  }
  .story:first-child .media { aspect-ratio: 4 / 3; }
  .story:first-child h3 { font-size: clamp(2.6rem, 3.6vw, 3.6rem); }
  .story:first-child .text { padding-bottom: 0.25rem; }
  .story:first-child .summary { font-size: 1.2rem; }
}
@media (min-width: 960px) and (max-width: 1199px) {
  .story:nth-child(n+4):nth-child(-n+6) { grid-column: span 6; }
  .story:first-child { grid-template-columns: 1fr; }
}

/* ---------- reader (detail) ---------- */
.reader {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--paper); color: var(--ink); overflow-y: auto; overscroll-behavior: contain; color-scheme: light;
  scrollbar-color: oklch(0.7 0.02 95) var(--paper);
}
.reader::backdrop { background: var(--asphalt); }
.reader[open] { animation: lift 0.6s var(--ease); }
@keyframes lift { from { clip-path: inset(12% 0 0 0); opacity: 0; translate: 0 3rem; } to { clip-path: inset(0); opacity: 1; translate: 0 0; } }
.reader :focus-visible { outline-color: var(--ink); }
.reader ::selection { background: var(--ink); color: var(--paper); }
body.locked { overflow: hidden; }

.bar {
  position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.75rem var(--pad); background: var(--asphalt); color: var(--text);
}
.bar .name-sm { font-weight: 700; letter-spacing: -0.03em; color: var(--paint); font-size: 1.2rem; display: none; }
.bar button {
  display: inline-flex; align-items: center; gap: 0.55rem; min-height: 2.75rem; padding: 0.5rem 1rem; cursor: pointer; font-weight: 600;
  border: 1.5px solid var(--paint); background: transparent; color: var(--paint); transition: background-color 0.2s, color 0.2s;
}
.bar button svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.bar button:hover { background: oklch(0.87 0.175 95 / 0.16); }
.bar button[aria-pressed="true"] { background: var(--paint); color: var(--paint-ink); }
.bar button[aria-pressed="true"] svg { fill: currentColor; }
.bar :focus-visible { outline-color: var(--paint); }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--line); }
.progress i { display: block; height: 100%; background: var(--paint); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }

.sheet { max-width: 76rem; margin: 0 auto; padding: 2.25rem var(--pad) 5rem; }
.sheet h2 {
  font-size: clamp(2.2rem, 7vw, 5rem); font-weight: 700; line-height: 1; letter-spacing: -0.04em; text-wrap: balance; max-width: 18ch; outline: none;
}
.deck { font-family: var(--serif); font-size: clamp(1.2rem, 2.4vw, 1.6rem); line-height: 1.4; color: var(--ink-soft); max-width: 40ch; margin-top: 1.25rem; font-weight: 400; }
.fig { margin-top: 2.25rem; }
.fig .frame { background: var(--paint); aspect-ratio: 16 / 10; overflow: hidden; }
.fig img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.08); mix-blend-mode: multiply; }
.fig figcaption { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-soft); margin-top: 0.6rem; max-width: 60ch; }

.cols { display: grid; gap: 1.75rem; margin-top: 2.25rem; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; align-content: start; padding-top: 1rem; border-top: 3px dashed var(--ink); }
.facts dt { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); }
.facts dd { font-weight: 600; font-size: 1.05rem; margin-top: 0.1rem; }
.prose { font-family: var(--serif); font-size: 1.1875rem; line-height: 1.72; max-width: 66ch; font-variation-settings: "opsz" 18; }
.prose p + p { margin-top: 1.35em; }
.prose p:first-child { font-size: 1.3em; line-height: 1.55; }
.next { margin-top: 4rem; padding-top: 1.5rem; border-top: 3px dashed var(--ink); }
.next button {
  all: unset; box-sizing: border-box; cursor: pointer; display: block; max-width: 30rem; padding: 0.25rem 0;
}
.next button span { display: block; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); }
.next button strong { display: block; font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.1; letter-spacing: -0.03em; margin-top: 0.4rem; text-wrap: balance; }
.next button:hover strong { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 0.18em; text-decoration-color: var(--ink); }
.next button:focus-visible { outline: 3px solid var(--ink); outline-offset: 6px; }

@media (min-width: 960px) {
  .bar .name-sm { display: block; }
  .bar { padding: 0.85rem 3.5rem; }
  .sheet { padding: 4rem 3.5rem 7rem; }
  .cols { grid-template-columns: 15rem minmax(0, 1fr); gap: 4rem; margin-top: 3.5rem; }
  .facts { grid-template-columns: 1fr; position: sticky; top: 6rem; align-self: start; }
  .fig .frame { aspect-ratio: 21 / 9; }
  .prose { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .story:hover .media img { transform: none; }
}
@media (forced-colors: active) {
  .saved-toggle[aria-pressed="true"], .bar button[aria-pressed="true"] { outline: 2px solid; }
}
