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

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

@font-face {
  font-family: "IBM Plex Mono";
  src: url("./assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #ecebe4;
  --paper-raised: #f4f3ed;
  --paper-deep: #e1e0d6;
  --ink: #181b18;
  --ink-soft: #4c5049;
  --muted: #62665c;
  --rule: #c5c4b8;
  --accent: #b5351f;
  --accent-dark: #8e2513;
  --accent-light: #f0a392;
  --accent-soft: #f0ded8;
  --max-width: 1320px;
  --page-pad: clamp(18px, 4vw, 56px);
  --grid-gap: clamp(18px, 2vw, 28px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.reader-open {
  overflow: hidden;
}

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

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

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

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

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.4;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 200;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper-raised);
  font-family: var(--sans);
  font-size: 13px;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

/* Masthead */

.site-header {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px var(--page-pad) 0;
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
}

.topline-note {
  color: var(--ink-soft);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-nav a {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: border-color 160ms ease;
}

.site-nav a:hover {
  border-color: var(--ink);
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 22px 0 18px;
}

.wordmark {
  font-family: var(--sans);
  font-size: clamp(52px, 7.2vw, 104px);
  font-weight: 700;
  line-height: 0.82;
  letter-spacing: -0.06em;
  white-space: nowrap;
}

.mission {
  max-width: 34ch;
  padding-bottom: 5px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-soft);
  text-align: right;
}

.masthead-rule {
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  height: 6px;
}

/* Stories section */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--page-pad);
}

#stories {
  padding-top: 28px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-family: var(--sans);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.result-count {
  color: var(--muted);
}

/* Toolbar */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) minmax(150px, 0.75fr) auto auto;
  align-items: end;
  gap: 12px;
  padding: 12px 0 14px;
  margin-bottom: 26px;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper-raised);
  padding: 0 12px;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
}

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

.field select {
  padding-right: 8px;
  cursor: pointer;
}

.saved-toggle {
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.saved-toggle:hover {
  background: var(--paper-deep);
}

.saved-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper-raised);
}

.saved-toggle[aria-pressed="true"]:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.saved-count {
  color: var(--muted);
}

.saved-toggle[aria-pressed="true"] .saved-count {
  color: var(--paper-raised);
}

.clear-button {
  height: 44px;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.clear-button:hover {
  color: var(--accent);
}

/* Story grid */

.story-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--grid-gap);
  align-items: stretch;
}

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

.story-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms var(--ease);
}

.story-card.is-lead {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  background: var(--ink);
  color: var(--paper-raised);
}

.story-card.is-lead .card-media {
  height: 100%;
  min-height: 360px;
  overflow: hidden;
  background: #2b2e29;
}

.story-card.is-lead .card-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(24px, 3.2vw, 44px);
  margin-top: 0;
  border-top: 0;
}

.story-card.is-lead .card-kicker {
  gap: 18px;
}

.story-card.is-lead .category {
  color: var(--accent-light);
}

.story-card.is-lead .card-date,
.story-card.is-lead .card-meta {
  color: #c3c6bc;
}

.story-card.is-lead .card-title {
  margin: 0;
  font-size: clamp(27px, 3.4vw, 44px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  max-width: 17ch;
}

.story-card.is-lead .card-summary {
  max-width: 46ch;
  color: #d4d6cd;
  font-size: 16px;
  line-height: 1.55;
}

.story-card.is-lead .card-meta {
  margin-top: auto;
  padding-top: 8px;
}

.story-card.is-lead .saved-flag {
  color: var(--accent-light);
}

.story-card.is-lead :focus-visible {
  outline-color: var(--accent-light);
}

.card-media {
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--paper-deep);
}

.card-body {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--rule);
}

.card-kicker {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.category {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.card-date {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.card-title {
  margin: 9px 0 7px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.012em;
}

.card-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 160ms ease;
}

.card-open:hover,
.card-open:focus-visible {
  text-decoration-color: currentColor;
}

.card-summary {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 13px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.saved-flag {
  color: var(--accent);
}

.story-card:hover img {
  transform: scale(1.025);
}

.journal-note {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 22px;
  padding: 24px;
  background: var(--paper-deep);
  border-top: 3px solid var(--accent);
}

.journal-note h3 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.journal-note p {
  margin-top: 9px;
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.journal-note .note-foot {
  margin-top: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Skeleton and status */

.skeleton-card {
  min-width: 0;
}

.skeleton-media,
.skeleton-line {
  background: var(--paper-deep);
}

.skeleton-media {
  aspect-ratio: 3 / 2;
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-line {
  height: 12px;
  margin-top: 12px;
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-line-short {
  width: 42%;
  margin-top: 16px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

.load-error,
.empty-state {
  max-width: 54ch;
  padding: 56px 0 40px;
  border-top: 2px solid var(--ink);
}

.load-error-title,
.empty-title {
  font-family: var(--serif);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.empty-copy,
.load-error p + p {
  margin-top: 12px;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink-soft);
}

.empty-state .button {
  margin-top: 22px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 0;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 120ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button-solid {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--paper-raised);
}

.button-solid:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* Footer */

.site-footer {
  max-width: var(--max-width);
  margin: 76px auto 0;
  padding: 26px var(--page-pad) 44px;
  border-top: 2px solid var(--ink);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: clamp(28px, 6vw, 90px);
}

.footer-intro h2 {
  font-family: var(--sans);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.footer-intro p {
  max-width: 48ch;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.footer-notes {
  max-width: 54ch;
  padding-top: 4px;
}

.footer-notes p {
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.footer-type {
  margin-top: 10px;
  color: var(--muted) !important;
}

/* Reader */

.reader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.reader.is-open {
  pointer-events: auto;
}

.reader-scrim {
  position: absolute;
  inset: 0;
  background: rgba(20, 23, 20, 0.58);
  opacity: 0;
  transition: opacity 240ms ease;
}

.reader-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(100%, 1060px);
  height: 100dvh;
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(12, 14, 12, 0.28);
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 260ms var(--ease),
    transform 260ms var(--ease);
}

.reader.is-open .reader-scrim {
  opacity: 1;
}

.reader.is-open .reader-panel {
  opacity: 1;
  transform: translateY(0);
}

.reader-bar {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px clamp(12px, 2vw, 22px);
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.reader-close,
.save-toggle {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.reader-close {
  justify-self: start;
}

.reader-close:hover {
  background: var(--ink);
  color: var(--paper-raised);
}

.reader-wordmark {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.reader-bar .save-toggle {
  justify-self: end;
}

.reader-bar .save-toggle:hover {
  background: var(--paper-deep);
}

.reader-bar .save-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper-raised);
}

.reader-bar .save-toggle[aria-pressed="true"]:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.reader-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(30px, 4.4vw, 54px) clamp(18px, 4vw, 36px) 80px;
}

.reader-article {
  max-width: 760px;
  margin: 0 auto;
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
}

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

.reader-title {
  margin: 14px 0 16px;
  font-family: var(--serif);
  font-size: clamp(31px, 4.4vw, 52px);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.022em;
}

.reader-standfirst {
  max-width: 60ch;
  font-family: var(--serif);
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.52;
  color: var(--ink-soft);
}

.reader-figure {
  margin: 30px 0 0;
}

.reader-figure img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--paper-deep);
}

.reader-figure figcaption {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.reader-body {
  margin-top: 30px;
}

.reader-body p {
  max-width: 66ch;
  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 1.7;
  color: var(--ink);
}

.reader-body p + p {
  margin-top: 1.05em;
}

.reader-body p:first-child::first-letter {
  float: left;
  margin: 0.08em 0.09em 0 0;
  font-family: var(--serif);
  font-size: 3.5em;
  font-weight: 600;
  line-height: 0.78;
  color: var(--accent);
}

.reader-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 24px;
  margin-top: 38px;
  padding-top: 18px;
  border-top: 1px solid var(--ink);
  color: var(--muted);
}

/* Responsive */

@media (max-width: 1099px) {
  .story-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .story-card.is-lead {
    grid-template-columns: 1fr 1fr;
  }

  .story-card.is-lead .card-media {
    min-height: 320px;
  }
}

@media (max-width: 900px) {
  .toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .field-search {
    grid-column: 1 / -1;
  }

  .clear-button {
    grid-column: 1 / -1;
    justify-self: start;
    height: auto;
    padding: 2px 0 0;
  }

  .masthead {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .mission {
    max-width: 50ch;
    text-align: left;
    padding-bottom: 0;
  }
}

@media (max-width: 699px) {
  .story-grid {
    grid-template-columns: 1fr;
  }

  .story-card.is-lead {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .story-card.is-lead .card-media {
    height: auto;
    aspect-ratio: 16 / 10;
    min-height: 0;
  }

  .story-card.is-lead .card-body {
    gap: 14px;
  }

  .story-card.is-lead .card-title {
    max-width: none;
  }

  .journal-note {
    min-height: 0;
  }

  .reader-bar {
    grid-template-columns: 1fr auto;
  }

  .reader-wordmark {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

@media (max-width: 520px) {
  .site-header {
    padding-top: 12px;
  }

  .topline {
    gap: 10px;
  }

  .topline-note {
    font-size: 10px;
    letter-spacing: 0.09em;
  }

  .site-nav {
    gap: 14px;
  }

  .site-nav a {
    font-size: 12px;
  }

  .masthead {
    padding: 18px 0 14px;
  }

  .wordmark {
    font-size: clamp(46px, 14vw, 58px);
  }

  .mission {
    font-size: 14.5px;
  }

  .section-head h2 {
    font-size: 23px;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .field-search {
    grid-column: 1 / -1;
  }

  .field-topic {
    grid-column: 1 / 2;
  }

  .saved-toggle {
    grid-column: 2 / 3;
    padding: 0 12px;
    font-size: 12px;
  }

  .clear-button {
    grid-column: 1 / -1;
  }

  .story-card.is-lead .card-body {
    padding: 22px 20px 24px;
  }

  .reader-scroll {
    padding-left: 18px;
    padding-right: 18px;
  }

  .reader-title {
    font-size: clamp(29px, 8.4vw, 36px);
  }

  .reader-body p {
    font-size: 17.5px;
  }

  .reader-close,
  .save-toggle {
    padding: 0 10px;
    font-size: 12px;
  }

  .reader-bar {
    gap: 10px;
    padding: 9px 12px;
  }

  .reader-foot {
    display: block;
  }

  .reader-foot span {
    display: block;
  }

  .reader-foot span + span {
    margin-top: 6px;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .story-card:hover img {
    transform: none;
  }
}
