@font-face { font-family: "DM Serif Display"; src: url("assets/dm-serif.ttf") format("truetype"); font-display: swap; }
@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; }

:root {
  --night: #12151c;
  --night-2: #1a1f2a;
  --night-3: #252c3a;
  --line: #333b4c;
  --ink: #efe9dc;
  --muted: #b3b9c6;
  --amber: #f4b942;
  --amber-deep: #c98a10;
  --paper: #f6f0e2;
  --paper-ink: #1d1a14;
  --paper-muted: #5a5446;
  --focus: #8fd3ff;
  --display: "DM Serif Display", "Iowan Old Style", Georgia, serif;
  --ui: "Space Grotesk", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --read: "Literata", Charter, Georgia, serif;
  --rail: 24rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: 400 1rem/1.55 var(--ui);
  min-height: 100vh;
}
body:has(dialog[open]) { overflow: hidden; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

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

.skip {
  position: absolute; left: .75rem; top: -4rem; z-index: 50;
  background: var(--amber); color: #14110a; padding: .6rem 1rem; border-radius: 6px; font-weight: 600;
}
.skip:focus { top: .75rem; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  padding: 2.25rem 2rem 2rem;
  display: flex; flex-direction: column; gap: 2rem;
  background:
    radial-gradient(ellipse 22rem 20rem at 3rem 0, rgba(244, 185, 66, .22), transparent 70%),
    var(--night-2);
  border-right: 1px solid var(--line);
}

.masthead { display: flex; gap: 1rem; align-items: flex-start; }
.lamp { color: var(--amber); flex: none; margin-top: .35rem; filter: drop-shadow(0 0 14px rgba(244, 185, 66, .55)); }
.issue { font-size: .8125rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.name { font: 400 3.5rem/1 var(--display); letter-spacing: -.01em; color: var(--ink); margin: .2rem 0 .5rem; }
.tag { color: var(--amber); font-size: .9375rem; }

/* ---------- controls ---------- */
.controls { display: grid; gap: 1.1rem; }
.field label { display: block; font-size: .8125rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .4rem; }
.field input, .field select {
  width: 100%; min-height: 48px; padding: .6rem .9rem;
  background: var(--night); border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 1rem;
}
.field input::placeholder { color: #8e95a4; }
.field input:hover, .field select:hover { border-color: #566077; }
.field input:focus-visible, .field select:focus-visible { outline-offset: 1px; border-color: var(--focus); }
.field select { appearance: none; -webkit-appearance: none; padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23f4b942' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1rem center;
}
.field select option { background: var(--night-2); color: var(--ink); }

.saved-toggle {
  display: flex; align-items: center; gap: .6rem;
  min-height: 48px; padding: .55rem .9rem;
  background: transparent; border: 1.5px solid var(--line); border-radius: 10px; text-align: left;
  transition: background .2s, border-color .2s, color .2s;
}
.saved-toggle span:nth-of-type(1) { flex: 1; font-weight: 500; }
.saved-toggle .bm { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.saved-toggle:hover { border-color: var(--amber); }
.saved-toggle[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); color: #14110a; }
.saved-toggle[aria-pressed="true"] .bm { fill: currentColor; }
.pill { min-width: 1.7rem; text-align: center; padding: 0 .45rem; border-radius: 99px; background: var(--night-3); color: var(--ink); font-size: .8125rem; line-height: 1.6rem; }
.saved-toggle[aria-pressed="true"] .pill { background: #14110a; color: var(--amber); }

/* ---------- shelf ---------- */
.shelf { margin-top: auto; border-top: 1px solid var(--line); padding-top: 1.25rem; }
.shelf h2 { font-size: .8125rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: .6rem; }
.shelf-list li + li { margin-top: .15rem; }
.shelf-list button {
  width: 100%; text-align: left; background: none; border: 0; padding: .55rem .5rem; min-height: 44px;
  font: 400 1rem/1.3 var(--display); border-radius: 8px; color: var(--ink);
}
.shelf-list button:hover { background: var(--night-3); }
.shelf-empty { color: var(--muted); font-size: .9375rem; }

/* ---------- main index ---------- */
.main { padding: 2.25rem clamp(1.5rem, 4vw, 4rem) 3rem; max-width: 70rem; outline: none; }
.main-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem; border-bottom: 2px solid var(--amber); padding-bottom: .9rem; }
.main-head h2 { font: 400 2rem/1.1 var(--display); }
.status { color: var(--muted); font-size: .9375rem; }

.list > li { border-bottom: 1px solid var(--line); }
.item {
  position: relative;
  display: grid; grid-template-columns: 3.5rem minmax(0, 1fr) 15rem; gap: 0 1.75rem; align-items: center;
  padding: 1.6rem .75rem; border-radius: 4px;
  transition: background .25s;
}
.item:hover { background: rgba(244, 185, 66, .06); }
.num { font: 400 2.5rem/1 var(--display); color: var(--amber-deep); align-self: start; font-variant-numeric: lining-nums; }
.kicker { display: flex; flex-wrap: wrap; gap: .35rem .9rem; align-items: center; font-size: .8125rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .45rem; }
.cat { color: var(--amber); font-weight: 600; }
.saved-mark { display: none; align-items: center; gap: .3rem; color: var(--ink); }
.item.is-saved .saved-mark { display: inline-flex; }
.saved-mark svg { fill: var(--amber); }
.item h3 { font: 400 1.75rem/1.2 var(--display); letter-spacing: -.005em; }
.open-item { all: unset; cursor: pointer; }
.open-item:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 3px; }
.open-item::after { content: ""; position: absolute; inset: 0; }
.item:hover .open-item { text-decoration: underline; text-decoration-color: var(--amber); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.summary { margin-top: .6rem; color: #d4d0c6; max-width: 38rem; }
.byline { margin-top: .7rem; font-size: .875rem; color: var(--muted); }
.thumb {
  aspect-ratio: 4 / 3; border-radius: 6px; background-color: var(--night-3);
  background-size: cover; background-position: center; overflow: hidden;
  filter: saturate(.85) contrast(1.02);
  transition: transform .35s ease, filter .35s;
}
.item:hover .thumb { transform: translateY(-3px) rotate(-.6deg); filter: saturate(1.05); }

/* lead story */
.list > li:first-child .item { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 2.25rem; padding: 2rem .75rem 2.25rem; }
.list > li:first-child .num { display: none; }
.list > li:first-child .text { order: 1; }
.list > li:first-child .thumb { order: 2; aspect-ratio: 16 / 10; }
.list > li:first-child h3 { font-size: 2.75rem; line-height: 1.1; }
.list > li:first-child .summary { font-size: 1.125rem; }
.list > li:first-child .kicker::before { content: "Lead story"; color: #14110a; background: var(--amber); padding: .1rem .5rem; border-radius: 3px; font-weight: 700; }

/* ---------- empty & footer ---------- */
.empty { text-align: center; padding: 4rem 1rem; border: 1.5px dashed var(--line); border-radius: 14px; margin-top: 2rem; }
.empty[hidden] { display: none; }
.empty-title { font: 400 2rem/1.2 var(--display); margin-bottom: .5rem; }
.empty p + p { color: var(--muted); margin-bottom: 1.4rem; }
.btn {
  min-height: 48px; padding: .6rem 1.3rem; border-radius: 10px; font-weight: 600;
  background: var(--amber); color: #14110a; border: 2px solid var(--amber);
}
.btn:hover { background: #ffd070; }
.foot { margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; max-width: 40rem; }

/* ---------- detail sheet ---------- */
.sheet {
  margin: 0 0 0 auto; padding: 0; border: 0;
  width: min(48rem, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  background: var(--paper); color: var(--paper-ink);
  box-shadow: -30px 0 80px rgba(0, 0, 0, .55);
  overflow-y: auto; overscroll-behavior: contain;
}
.sheet:not([open]) { display: none; }
.sheet[open] { animation: slide .32s cubic-bezier(.2, .8, .2, 1); }
.sheet::backdrop { background: rgba(6, 8, 12, .72); }
.sheet[open]::backdrop { animation: fade .3s ease; }
@keyframes slide { from { transform: translateX(3rem); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.detail-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .75rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(246, 240, 226, .96); backdrop-filter: blur(6px);
  border-bottom: 1px solid #ddd3bc;
}
.bar-btn {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 46px; padding: .5rem 1rem;
  border-radius: 10px; font-weight: 600; background: transparent; color: var(--paper-ink);
  border: 2px solid var(--paper-ink);
}
.bar-btn:hover { background: var(--paper-ink); color: var(--paper); }
.bar-btn svg { stroke: currentColor; fill: none; stroke-width: 2; }
.sheet :focus-visible { outline-color: #0b5cad; }
.save-btn[aria-pressed="true"] { background: var(--paper-ink); color: var(--amber); border-color: var(--paper-ink); }
.save-btn .bm { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.save-btn[aria-pressed="true"] .bm { fill: currentColor; }

.detail-hero { height: clamp(11rem, 28vh, 17rem); background-color: #cfc5ab; background-size: cover; background-position: center; margin: 0; }
.photo-note { padding: .4rem clamp(1rem, 4vw, 2.5rem); font-size: .8125rem; color: var(--paper-muted); background: #ece4cf; }
.article { padding: 2rem clamp(1.25rem, 5vw, 3.5rem) 4rem; max-width: 42rem; }
.article .cat { color: #7a4f00; }
.article .kicker { color: var(--paper-muted); }
.article h2 { font: 400 clamp(2rem, 5.2vw, 3rem)/1.1 var(--display); margin: .4rem 0 1rem; text-wrap: balance; }
.dek { font: italic 400 1.25rem/1.5 var(--read); color: #3b362b; margin-bottom: 1.25rem; }
.meta { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-size: .9375rem; color: var(--paper-muted); padding: .9rem 0; border-block: 1px solid #cfc5ab; margin-bottom: 1.75rem; }
.meta strong { color: var(--paper-ink); font-weight: 600; }
.body p { font: 400 1.1875rem/1.75 var(--read); margin-bottom: 1.2em; }
.body p:first-child::first-letter { font: 400 4.2rem/.8 var(--display); float: left; padding: .35rem .6rem 0 0; color: #8a5a00; }
.end { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid #cfc5ab; display: flex; flex-wrap: wrap; gap: .75rem; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --rail: 20rem; }
  .rail { padding: 2rem 1.5rem; }
  .name { font-size: 3rem; }
  .item { grid-template-columns: 2.75rem minmax(0, 1fr) 11rem; gap: 0 1.25rem; }
  .list > li:first-child h3 { font-size: 2.25rem; }
}

@media (max-width: 860px) {
  .shell { display: block; }
  .rail { position: static; height: auto; overflow: visible; padding: 1.25rem 1rem 1.25rem; gap: 1.1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .masthead { align-items: center; gap: .85rem; }
  .lamp { width: 28px; height: 42px; margin: 0; }
  .name { font-size: 2.6rem; margin: 0 0 .15rem; }
  .issue { font-size: .75rem; }
  .controls { grid-template-columns: 1fr 1fr; gap: .8rem; }
  .controls .field:first-child { grid-column: 1 / -1; }
  .saved-toggle { align-self: end; padding-inline: .7rem; }
  .shelf { display: none; }

  .main { padding: 1.25rem 1rem 2.5rem; }
  .main-head h2 { font-size: 1.6rem; }
  .item, .list > li:first-child .item {
    grid-template-columns: minmax(0, 1fr) 6.5rem; gap: 0 1rem; padding: 1.25rem .25rem; align-items: start;
  }
  .num { display: none; }
  .item h3 { font-size: 1.3rem; }
  .summary { display: none; }
  .byline { font-size: .8125rem; }
  .thumb { aspect-ratio: 1; }
  .list > li:first-child .item { grid-template-columns: 1fr; gap: .9rem; padding-top: 1.25rem; }
  .list > li:first-child .thumb { order: 0; aspect-ratio: 16 / 9; }
  .list > li:first-child .text { order: 1; }
  .list > li:first-child h3 { font-size: 1.9rem; }
  .list > li:first-child .summary { display: block; font-size: 1rem; }
  .item:hover .thumb { transform: none; }

  .sheet { width: 100vw; }
  .bar-btn { padding-inline: .8rem; }
  .body p { font-size: 1.125rem; }
}

@media (max-width: 400px) {
  .controls { grid-template-columns: 1fr; }
  .item, .list > li:first-child .item { padding-inline: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
