@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.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;
  --page: #dbe6eb;
  --surface: #edf3f5;
  --ink: #15272e;
  --muted: #50636b;
  --line: #9fb1b8;
  --accent: #c9412c;
  --accent-ink: #fff8f3;
  --focus: #8b2d20;
  --soft-radius: 14px;
  --control-radius: 8px;
  --pill-radius: 999px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body.reader-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

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

a {
  color: inherit;
}

img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 5;
  padding: 0.7rem 1rem;
  transform: translateY(-150%);
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--control-radius);
}

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

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

.site-header {
  max-width: 1440px;
  min-height: 70px;
  margin: 0 auto;
  padding: 0 2.5rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  width: max-content;
  text-decoration: none;
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.06em;
}

.wordmark span {
  color: var(--accent);
}

.site-header nav {
  display: flex;
  gap: 1.75rem;
}

.site-header nav a,
.edition,
.footer-meta,
.story-meta,
.reader-meta,
.image-note {
  font-size: 0.76rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.site-header nav a {
  text-underline-offset: 0.3em;
  text-decoration-thickness: 1px;
}

.edition {
  justify-self: end;
  margin: 0;
}

.hero {
  max-width: 1440px;
  min-height: 500px;
  margin: 0 auto;
  padding: 3rem 2.5rem;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: stretch;
}

.hero-copy {
  align-self: center;
  padding-left: clamp(0rem, 4vw, 4rem);
}

.hero-kicker {
  width: max-content;
  max-width: 100%;
  margin: 0 0 1.25rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid currentColor;
  border-radius: var(--pill-radius);
  font-size: 0.76rem;
}

.hero h1 {
  max-width: 9ch;
  margin: 0;
  font-family: "Literata", Georgia, serif;
  font-size: clamp(3.4rem, 5.5vw, 5.5rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero-deck {
  max-width: 34ch;
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.hero-collage {
  position: relative;
  min-height: 400px;
}

.hero-photo {
  position: absolute;
  margin: 0;
  overflow: hidden;
  border-radius: var(--soft-radius);
  background: var(--surface);
}

.hero-photo-main {
  inset: 0 12% 6% 0;
}

.hero-photo-inset {
  width: 30%;
  height: 51%;
  right: 0;
  bottom: 0;
  border: 8px solid var(--page);
}

.hero-note {
  position: absolute;
  top: 0;
  right: 0;
  width: 16%;
  margin: 0;
  color: var(--accent);
  font-family: "Literata", Georgia, serif;
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.25;
}

.browse {
  max-width: 1440px;
  margin: 0 auto;
  padding: 4.5rem 2.5rem 7rem;
  border-top: 1px solid var(--line);
}

.browse-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.browse-heading h2 {
  margin: 0;
  font-family: "Literata", Georgia, serif;
  font-size: clamp(2rem, 3vw, 3.2rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
}

.browse-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.controls {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(240px, 1.8fr) minmax(170px, 0.8fr) auto;
  gap: 0.75rem;
  margin: 0 0 3rem;
  padding: 0.75rem;
  background: color-mix(in srgb, var(--page) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--soft-radius);
  backdrop-filter: blur(12px);
}

.field {
  position: relative;
}

.field label {
  position: absolute;
  top: 0.45rem;
  left: 0.8rem;
  z-index: 1;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.field input,
.field select {
  width: 100%;
  min-height: 58px;
  padding: 1.35rem 0.8rem 0.35rem;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--ink);
}

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

.field input:focus-visible,
.field select:focus-visible {
  outline-color: var(--focus);
}

.saved-toggle {
  min-width: 142px;
  min-height: 58px;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--ink);
  border-radius: var(--control-radius);
  background: transparent;
  cursor: pointer;
}

.saved-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
}

.saved-count {
  min-width: 1.8rem;
  min-height: 1.8rem;
  display: inline-grid;
  place-items: center;
  border-radius: var(--pill-radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.78rem;
}

.saved-toggle:active,
.empty-state button:active,
.close-detail:active,
.save-item:active,
.open-item:active {
  transform: scale(0.98);
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4rem 1.25rem;
}

.story-card {
  grid-column: span 6;
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1.2rem;
}

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

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

.story-image {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 0;
  overflow: hidden;
  border-radius: var(--soft-radius);
  background: var(--surface);
}

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

.story-card img {
  transition: transform 450ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.story-copy {
  max-width: 44rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 1.5rem;
}

.story-meta,
.reader-meta {
  margin: 0 0 0.65rem;
  color: var(--accent);
}

.story-title {
  margin: 0;
  font-family: "Literata", Georgia, serif;
  font-size: clamp(1.45rem, 2.4vw, 2.15rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.story-summary {
  max-width: 50ch;
  margin: 0.75rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.open-item {
  width: 2.9rem;
  height: 2.9rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: var(--pill-radius);
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
}

.open-item:hover {
  background: var(--ink);
  color: var(--surface);
}

.loading-grid {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 1.25rem;
}

.skeleton {
  min-height: 390px;
  border-radius: var(--soft-radius);
  background: var(--surface);
  opacity: 0.75;
}

.skeleton:last-child {
  display: none;
}

.empty-state,
.error-state {
  min-height: 330px;
  padding: 4rem 1.5rem;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--soft-radius);
}

.empty-title {
  margin: 0 0 0.4rem;
  font-family: "Literata", Georgia, serif;
  font-size: 2rem;
}

.empty-state p:not(.empty-title),
.error-state p:not(.empty-title) {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.empty-state button {
  min-height: 48px;
  padding: 0 1.2rem;
  border: 0;
  border-radius: var(--control-radius);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 5rem 2.5rem 2rem;
  border-top: 1px solid var(--line);
}

.footer-statement {
  max-width: 14ch;
  margin: 0 0 5rem;
  font-family: "Literata", Georgia, serif;
  font-size: clamp(2.5rem, 5vw, 5rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.footer-meta {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.footer-meta p {
  margin: 0;
}

.footer-meta a {
  text-underline-offset: 0.3em;
}

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

.reader::backdrop {
  background: color-mix(in srgb, var(--ink) 68%, transparent);
}

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

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 70px;
  padding: 0 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--page) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.close-detail,
.save-item {
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--ink);
  border-radius: var(--control-radius);
  background: transparent;
  cursor: pointer;
}

.reader-layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 3rem 2.5rem 7rem;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(350px, 5fr);
  gap: clamp(3rem, 7vw, 7rem);
  align-items: start;
}

.reader-visual {
  position: sticky;
  top: 102px;
}

.reader-visual figure {
  aspect-ratio: 4 / 5;
  margin: 0;
  overflow: hidden;
  border-radius: var(--soft-radius);
  background: var(--surface);
}

.image-note {
  margin: 0.7rem 0 0;
  color: var(--muted);
}

.reader-story {
  padding-top: 1rem;
}

.reader-story h2 {
  margin: 0 0 1.5rem;
  font-family: "Literata", Georgia, serif;
  font-size: clamp(2.8rem, 5vw, 5.4rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.reader-standfirst {
  margin: 0 0 2rem;
  padding-bottom: 2rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 1.2rem;
  line-height: 1.5;
}

.reader-byline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 3rem;
}

.reader-byline p {
  margin: 0;
  font-size: 0.88rem;
}

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

.article-body {
  max-width: 36rem;
  font-family: "Literata", Georgia, serif;
  font-size: 1.13rem;
  line-height: 1.82;
}

.article-body p {
  margin: 0 0 1.6rem;
}

.article-body p:first-child::first-letter {
  float: left;
  margin: 0.04em 0.1em 0 0;
  color: var(--accent);
  font-size: 4.2em;
  line-height: 0.8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #10191d;
    --surface: #1c292f;
    --ink: #e8f0f2;
    --muted: #a9bbc2;
    --line: #445960;
    --accent: #e56550;
    --accent-ink: #17100e;
    --focus: #ff9b89;
  }
}

@media (max-width: 767px) {
  .site-header {
    min-height: 62px;
    padding: 0 1rem;
    grid-template-columns: 1fr auto;
  }

  .site-header nav {
    gap: 1rem;
  }

  .edition {
    display: none;
  }

  .hero {
    min-height: 0;
    padding: 2.25rem 1rem 3rem;
    grid-template-columns: 1fr;
    gap: 2.25rem;
  }

  .hero-copy {
    padding: 0;
  }

  .hero-kicker {
    margin-bottom: 1rem;
  }

  .hero h1 {
    font-size: clamp(3.35rem, 16.5vw, 4.3rem);
  }

  .hero-deck {
    margin-top: 1.2rem;
    font-size: 1rem;
  }

  .hero-collage {
    min-height: 250px;
  }

  .hero-photo-main {
    inset: 0 0 0 0;
  }

  .hero-photo-inset,
  .hero-note {
    display: none;
  }

  .browse {
    padding: 3rem 1rem 5rem;
  }

  .browse-heading {
    display: block;
  }

  .browse-heading h2 {
    font-size: 2.45rem;
  }

  .browse-heading p {
    margin-top: 0.6rem;
  }

  .controls {
    position: static;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
    padding: 0.5rem;
    backdrop-filter: none;
  }

  .saved-toggle {
    min-height: 50px;
  }

  .story-grid {
    grid-template-columns: 1fr;
    gap: 3.25rem;
  }

  .story-card,
  .story-card:nth-child(n) {
    grid-column: 1;
  }

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

  .story-copy {
    gap: 0.75rem;
  }

  .story-title {
    font-size: 1.65rem;
  }

  .story-summary {
    font-size: 0.94rem;
  }

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

  .skeleton {
    min-height: 300px;
  }

  .skeleton:not(:first-child) {
    display: none;
  }

  footer {
    padding: 4rem 1rem 1.5rem;
  }

  .footer-statement {
    margin-bottom: 4rem;
  }

  .footer-meta {
    grid-template-columns: 1fr;
  }

  .reader-bar {
    min-height: 62px;
    padding: 0 1rem;
  }

  .reader-layout {
    padding: 1.25rem 1rem 5rem;
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .reader-visual {
    position: static;
  }

  .reader-visual figure {
    aspect-ratio: 16 / 10;
  }

  .reader-story {
    padding-top: 0;
  }

  .reader-story h2 {
    font-size: clamp(2.5rem, 12vw, 3.6rem);
  }

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

  .article-body {
    font-size: 1.05rem;
    line-height: 1.75;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .hero-copy,
  .hero-photo-main,
  .hero-photo-inset {
    animation: settle-in 650ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  .hero-photo-main {
    animation-delay: 80ms;
  }

  .hero-photo-inset {
    animation-delay: 160ms;
  }

  .story-card {
    animation: settle-in 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--item-index, 0) * 45ms);
  }

  @keyframes settle-in {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

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

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

@media (prefers-reduced-transparency: reduce) {
  .controls,
  .reader-bar {
    background: var(--page);
    backdrop-filter: none;
  }
}
