:root {
  --paper: #f4efe6;
  --surface: #fffdf8;
  --ink: #1d1b18;
  --muted: #5b564d;
  --rule: #cfc6b5;
  --accent: #b8381f;
  --accent-ink: #ffffff;
  --focus: #1f5fbf;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --gutter: clamp(20px, 4vw, 48px);
  --max: 1200px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--ink);
  color: var(--surface);
  padding: 8px 12px;
  z-index: 10;
}
.skip-link:focus { top: 12px; }

/* Masthead */

.masthead {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px var(--gutter) 32px;
  border-bottom: 4px solid var(--ink);
}

.masthead__top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.masthead__top p { margin: 0; }

.masthead__title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(44px, 9vw, 112px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 0;
}

.masthead__dek {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(19px, 2.2vw, 26px);
  line-height: 1.35;
  color: var(--muted);
  max-width: 34em;
  margin: 16px 0 0;
}

/* Browse */

.browse {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px var(--gutter) 64px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 220px auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 32px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="search"],
select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 0;
}

input[type="search"]::placeholder { color: #6f695e; }

.button,
.toggle {
  min-height: 48px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
}

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

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

.button:hover { background: var(--accent); border-color: var(--accent); }
.toggle:hover { background: var(--rule); }
.toggle[aria-pressed="true"]:hover { background: #9c2e19; }

/* Story grid */

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 40px 28px;
}

.item {
  display: flex;
  flex-direction: column;
  border-top: 4px solid var(--ink);
  padding-top: 14px;
  min-width: 0;
}

.item__number {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}

.item__cover {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--cover, #2f5d50);
  color: #fff;
  padding: 16px;
  display: flex;
  align-items: flex-end;
  margin-bottom: 16px;
  overflow: hidden;
}

.item__cover-word {
  font-family: var(--serif);
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  opacity: 0.92;
}

.item__cover::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

.item__kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}

.item__title {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 10px;
  text-wrap: balance;
}

.item__summary {
  color: var(--muted);
  margin: 0 0 14px;
  flex: 1;
}

.item__meta {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 14px;
}

.item__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--rule);
  padding-top: 12px;
}

.item__saved {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.open-item {
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  padding: 8px 0;
  background: none;
  border: 0;
  border-bottom: 2px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
}
.open-item:hover { color: var(--accent); border-color: var(--accent); }

/* Empty state */

.empty {
  border-top: 4px solid var(--ink);
  padding: 32px 0;
  max-width: 560px;
}
.empty h2 {
  font-family: var(--serif);
  font-size: 32px;
  margin: 0 0 8px;
}
.empty p { color: var(--muted); margin: 0 0 20px; }

/* Detail dialog */

.detail {
  width: min(720px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  margin: auto;
  padding: 0;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(29, 27, 24, 0.28);
}
.detail::backdrop { background: rgba(29, 27, 24, 0.55); }

.detail__inner {
  padding: clamp(24px, 5vw, 56px);
}

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

.detail__kicker {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}

.detail__title {
  font-family: var(--serif);
  font-size: clamp(30px, 4.6vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}

.detail__byline {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}

.detail__summary {
  font-family: var(--serif);
  font-style: italic;
  font-size: 21px;
  line-height: 1.4;
  margin: 0 0 24px;
}

.detail__body {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  max-width: 66ch;
}
.detail__body p { margin: 0 0 1.1em; }

.detail__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.close-detail {
  min-height: 48px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  background: none;
  border: 1px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
}
.close-detail:hover { background: var(--rule); }

.save-item {
  min-height: 48px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  background: var(--ink);
  color: var(--surface);
  border: 1px solid var(--ink);
  cursor: pointer;
}
.save-item[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.save-item:hover { opacity: 0.88; }

/* Colophon */

.colophon {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
  border-top: 1px solid var(--rule);
  font-size: 14px;
  color: var(--muted);
}
.colophon p { margin: 0; }

/* Responsive */

@media (max-width: 720px) {
  body { font-size: 16px; }

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

  .toggle { width: 100%; }

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

  .item__title { font-size: 22px; }

  .detail {
    width: 100%;
    max-height: 100vh;
    margin: auto 0 0;
    max-width: none;
  }
  .detail__inner { padding: 24px 20px 28px; }
}

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