@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #f2f3ee;
  --paper-raised: #e8eae5;
  --ink: #17201f;
  --muted: #596360;
  --line: #bfc5bf;
  --accent: #3155d7;
  --on-accent: #f7f8f2;
  --focus: var(--accent);
  --shadow: rgba(28, 42, 38, 0.18);
  --radius: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161b1a;
    --paper-raised: #202625;
    --ink: #eef0ea;
    --muted: #abb4b0;
    --line: #46504d;
    --accent: #8298ff;
    --on-accent: #111722;
    --focus: var(--accent);
    --shadow: rgba(2, 8, 7, 0.42);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

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

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  min-height: 68px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 24px;
}

.wordmark,
.detail-brand {
  display: grid;
  width: 42px;
  aspect-ratio: 1;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  letter-spacing: -0.08em;
  text-decoration: none;
}

.issue-line,
.header-link {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
}

.header-link {
  text-underline-offset: 4px;
}

.masthead {
  min-height: 350px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 48px clamp(20px, 4vw, 64px) 40px;
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(260px, 0.8fr);
  gap: 32px;
  align-items: end;
}

.edition {
  margin: 0 0 22px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.masthead h1 {
  margin: 0;
  max-width: 1100px;
  font-size: clamp(5rem, 11.6vw, 10.25rem);
  font-weight: 620;
  letter-spacing: -0.085em;
  line-height: 0.76;
}

.dek {
  max-width: 25ch;
  margin: 0;
  padding-bottom: 4px;
  font-size: clamp(1.1rem, 1.6vw, 1.45rem);
  font-weight: 500;
  line-height: 1.28;
}

.browse {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 64px) 96px;
  border-top: 1px solid var(--ink);
}

.browse-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.browse-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  letter-spacing: -0.06em;
  line-height: 0.98;
}

.result-count {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.saved-toggle,
.save-item,
.close-detail,
.empty-state button,
.error-state button {
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  padding: 11px 15px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.saved-toggle:hover,
.save-item:hover,
.close-detail:hover,
.empty-state button:hover,
.error-state button:hover {
  background: var(--ink);
  color: var(--paper);
}

.saved-toggle:active,
.save-item:active,
.close-detail:active,
.empty-state button:active,
.error-state button:active,
.open-item:active {
  transform: translateY(1px);
}

.saved-toggle[aria-pressed="true"],
.save-item[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.saved-count {
  display: inline-grid;
  min-width: 1.5em;
  margin-left: 6px;
  place-items: center;
  border-left: 1px solid currentColor;
  padding-left: 9px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1.7fr) minmax(190px, 0.65fr);
  gap: 16px;
  margin-bottom: 40px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.field input,
.field select {
  min-height: 52px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
  color: var(--ink);
  padding: 0 15px;
  appearance: none;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.category-field {
  position: relative;
}

.category-field::after {
  content: "+";
  position: absolute;
  right: 16px;
  bottom: 12px;
  pointer-events: none;
  color: var(--muted);
  font-size: 1.15rem;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 50px 24px;
}

.story-card {
  grid-column: span 4;
  min-width: 0;
}

.story-card:first-child {
  grid-column: span 8;
  grid-row: span 2;
}

.story-card:nth-child(2) {
  grid-column: span 4;
}

.story-card:nth-child(4n + 3) {
  grid-column: span 5;
}

.story-card:nth-child(4n + 4) {
  grid-column: span 7;
}

.story-card figure {
  margin: 0 0 18px;
  overflow: hidden;
  background: var(--paper-raised);
}

.story-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  filter: saturate(0.82) contrast(1.03);
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1), filter 220ms ease;
}

.story-card:first-child img {
  aspect-ratio: 16 / 9;
}

.story-card:nth-child(4n + 3) img {
  aspect-ratio: 5 / 4;
}

.story-card:nth-child(4n + 4) img {
  aspect-ratio: 16 / 9;
}

.story-card:hover img {
  transform: scale(1.025);
  filter: saturate(1) contrast(1.02);
}

.story-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.story-category {
  color: var(--accent);
}

.story-card h3 {
  margin: 0 0 11px;
  max-width: 18ch;
  font-size: clamp(1.45rem, 2.5vw, 2.35rem);
  letter-spacing: -0.045em;
  line-height: 1.03;
}

.story-card:first-child h3 {
  max-width: 17ch;
  font-size: clamp(2rem, 4.4vw, 4.6rem);
  line-height: 0.98;
}

.story-summary {
  max-width: 52ch;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.story-card:first-child .story-summary {
  max-width: 58ch;
  font-size: 1.02rem;
}

.open-item {
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: var(--radius);
  background: transparent;
  padding: 2px 0;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  text-underline-offset: 4px;
}

.open-item:hover {
  color: var(--accent);
}

.status-panel,
.empty-state {
  min-height: 270px;
  border-top: 1px solid var(--line);
  padding: 48px 0;
}

.loading-state {
  display: grid;
  align-content: start;
  gap: 14px;
}

.loading-line {
  display: block;
  width: min(420px, 70%);
  height: 22px;
  background: var(--paper-raised);
}

.loading-line-long {
  width: min(680px, 95%);
  height: 66px;
}

.loading-line-short {
  width: min(250px, 50%);
}

.error-state p,
.empty-kicker {
  font-weight: 700;
}

.empty-state h3 {
  margin: 0 0 12px;
  font-size: clamp(2.5rem, 5vw, 5rem);
  letter-spacing: -0.06em;
}

.empty-state p:not(.empty-kicker) {
  max-width: 42ch;
  color: var(--muted);
}

.site-footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 64px) 48px;
  border-top: 1px solid var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  font-size: 0.82rem;
  font-weight: 650;
}

.site-footer p {
  margin: 0;
}

.article-dialog {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}

.article-dialog::backdrop {
  background: rgba(6, 12, 11, 0.72);
}

.dialog-shell {
  min-height: 100dvh;
}

.detail-nav {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 68px;
  padding: 12px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.article-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(42px, 7vw, 96px) clamp(20px, 4vw, 64px) 100px;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 64px 8vw;
}

.article-intro {
  align-self: end;
}

.article-category {
  margin: 0 0 24px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 700;
}

.article-intro h2 {
  margin: 0;
  font-size: clamp(3rem, 6vw, 6.8rem);
  letter-spacing: -0.075em;
  line-height: 0.93;
}

.article-summary {
  max-width: 42ch;
  margin: 28px 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.5;
}

.article-byline {
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.article-byline p {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 650;
}

.article-figure {
  margin: 0;
}

.article-figure img {
  display: block;
  width: 100%;
  min-height: 560px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  filter: saturate(0.85) contrast(1.03);
}

.article-figure figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.73rem;
}

.article-body {
  grid-column: 1 / -1;
  width: min(680px, 100%);
  margin: 18px auto 0;
  font-family: "Literata", Georgia, serif;
  font-size: clamp(1.08rem, 1.5vw, 1.3rem);
  line-height: 1.83;
}

.article-body p {
  margin: 0 0 1.45em;
}

body:has(.article-dialog[open]) {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

@media (max-width: 767px) {
  .site-header {
    min-height: 60px;
    grid-template-columns: 40px 1fr;
    gap: 14px;
    padding: 10px 16px;
  }

  .wordmark,
  .detail-brand {
    width: 38px;
  }

  .issue-line {
    text-align: right;
    font-size: 0.72rem;
  }

  .header-link {
    display: none;
  }

  .masthead {
    min-height: 300px;
    padding: 38px 16px 28px;
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .edition {
    margin-bottom: 20px;
  }

  .masthead h1 {
    font-size: clamp(4rem, 22vw, 6rem);
    line-height: 0.82;
  }

  .dek {
    max-width: 30ch;
    font-size: 1.06rem;
  }

  .browse {
    padding: 24px 16px 64px;
  }

  .browse-heading {
    align-items: end;
    margin-bottom: 22px;
  }

  .browse-heading h2 {
    max-width: 9ch;
    font-size: 2.35rem;
  }

  .saved-toggle {
    padding: 9px 11px;
  }

  .controls {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 32px;
  }

  .story-grid {
    grid-template-columns: 1fr;
    gap: 44px;
  }

  .story-card,
  .story-card:first-child,
  .story-card:nth-child(2),
  .story-card:nth-child(4n + 3),
  .story-card:nth-child(4n + 4) {
    grid-column: auto;
    grid-row: auto;
  }

  .story-card img,
  .story-card:first-child img,
  .story-card:nth-child(4n + 3) img,
  .story-card:nth-child(4n + 4) img {
    aspect-ratio: 4 / 3;
  }

  .story-card h3,
  .story-card:first-child h3 {
    max-width: 19ch;
    font-size: 2rem;
    line-height: 1;
  }

  .site-footer {
    padding: 24px 16px 36px;
    flex-direction: column;
  }

  .detail-nav {
    min-height: 60px;
    padding: 10px 16px;
  }

  .close-detail {
    padding: 9px 11px;
  }

  .article-layout {
    padding: 42px 16px 72px;
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .article-intro h2 {
    font-size: clamp(2.8rem, 13vw, 4.2rem);
  }

  .article-byline {
    align-items: flex-start;
    flex-direction: column;
  }

  .article-figure {
    grid-row: 2;
  }

  .article-figure img {
    min-height: 0;
    aspect-ratio: 4 / 3;
  }

  .article-body {
    grid-column: auto;
    margin-top: 8px;
    font-size: 1.08rem;
    line-height: 1.72;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
