/* City Journal — Memphis-maximal masthead over a calm reading surface.
   Tokens first; every colour below is checked against --paper for body text. */
:root {
  --paper: #fbf8f1;   /* 60: reading surface */
  --surface: #ffffff; /* cards */
  --ink: #1c1a22;     /* body text, 17:1 on paper */
  --muted: #4d4a57;   /* secondary text, ~8:1 on paper */
  --pink: #ff4365;    /* 10: primary action only */
  --teal: #2ec4b6;    /* saved state */
  --yellow: #ffd166;  /* highlights */
  --purple: #7353ba;  /* section bands, focus ring */
  --display: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --body: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --r-sm: 6px;
  --r-md: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--body);
  overflow-x: clip;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

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

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

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

/* ---------- focus & press (shared) ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

button, select, input[type="search"] { min-height: 44px; }

button { cursor: pointer; transition: transform 180ms var(--ease), background-color 180ms var(--ease), color 180ms var(--ease); }
button:active { transform: scale(0.97); }

/* ---------- masthead ---------- */
.masthead {
  position: relative;
  background: var(--ink);
  color: var(--paper);
  padding: 2.5rem 1.25rem 3rem;
  overflow: clip;
}

.masthead__inner {
  position: relative;
  max-width: 1200px;
  margin-inline: auto;
}

.masthead__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.masthead__title {
  margin-top: 1.25rem;
  font-family: var(--display);
  font-size: clamp(3.25rem, 14.5vw, 11rem);
  line-height: 0.88;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}

.masthead__title span { display: block; }
.masthead__title .t-pink { color: var(--pink); }

.masthead__dek {
  margin-top: 1.5rem;
  max-width: 34ch;
  font-size: 1.125rem;
  line-height: 1.5;
}

/* confetti sits in its own band under the masthead, never beneath a text box */
.confetti-strip {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72px;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}

/* ---------- browse controls ---------- */
.browse {
  max-width: 1200px;
  margin-inline: auto;
  padding: 2.5rem 1.25rem 1.5rem;
}

.controls {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  align-items: end;
}

.field { display: grid; gap: 0.375rem; }

.field__label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field input[type="search"],
.field select {
  width: 100%;
  padding: 0.6rem 0.875rem;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-sm);
  font-size: 1rem;
}

.field input[type="search"]::placeholder { color: var(--muted); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9375rem;
  white-space: nowrap;
}

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

.toggle__dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 2px solid currentColor;
}

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

.results-line {
  margin-top: 1rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* ---------- story list ---------- */
.stories {
  list-style: none;
  margin: 0;
  padding: 0 1.25rem 4rem;
  max-width: 1200px;
  margin-inline: auto;
  display: grid;
  gap: 1.25rem;
}

.story {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-md);
  position: relative;
}

.story__num {
  font-family: var(--display);
  font-size: clamp(3rem, 9vw, 5.5rem);
  line-height: 0.9;
  color: var(--pink);
  letter-spacing: -0.03em;
}

.story__cat {
  display: inline-block;
  justify-self: start;
  padding: 0.2rem 0.6rem;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.story__title {
  font-family: var(--display);
  font-size: clamp(1.375rem, 3vw, 1.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.story__summary { color: var(--muted); max-width: 52ch; }

.story__meta {
  font-size: 0.875rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
}

.story__saved {
  font-weight: 700;
  color: var(--ink);
}

.story__saved::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.35rem;
  background: var(--teal);
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.open-item {
  justify-self: start;
  margin-top: 0.25rem;
  padding: 0.65rem 1.25rem;
  background: var(--pink);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 4px 4px 0 var(--ink);
}

.story:focus-within { border-color: var(--purple); }

.empty {
  padding: 2.5rem 1.5rem;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: var(--r-md);
  max-width: 1200px;
  margin: 0 auto 4rem;
  text-align: left;
}

.empty h2 { font-family: var(--display); font-size: 1.5rem; margin-bottom: 0.5rem; }

.empty__action {
  margin-top: 1rem;
  padding: 0.65rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-weight: 700;
}

/* ---------- detail view (dialog) ---------- */
.detail {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  background: var(--paper);
  padding: 0 0 4rem;
}

.detail__bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  z-index: 1;
}

.detail__bar-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.close-detail {
  padding: 0.5rem 1rem;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--paper);
  border-radius: 999px;
  font-weight: 700;
}

.close-detail:focus-visible { outline-color: var(--yellow); }

.detail__article {
  max-width: 68ch;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 0;
}

.detail__cat {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail__title {
  margin-top: 1rem;
  font-family: var(--display);
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.detail__meta {
  margin-top: 1rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

.detail__rule {
  height: 10px;
  margin: 1.5rem 0 2rem;
  background: repeating-linear-gradient(90deg, var(--pink) 0 40px, var(--teal) 40px 80px, var(--purple) 80px 120px, var(--yellow) 120px 160px);
}

.detail__body p { margin: 0 0 1.25em; font-size: 1.1875rem; line-height: 1.7; }

.save-item {
  margin-top: 2rem;
  padding: 0.75rem 1.5rem;
  background: var(--pink);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 4px 4px 0 var(--ink);
}

.save-item[aria-pressed="true"] {
  background: var(--teal);
  box-shadow: none;
}

/* ---------- footer ---------- */
.colophon {
  background: var(--purple);
  color: var(--paper);
  padding: 2.5rem 1.25rem;
  font-size: 0.9375rem;
}

.colophon__inner { max-width: 1200px; margin-inline: auto; }
.colophon p + p { margin-top: 0.5rem; }

/* ---------- hover (fine pointers only) ---------- */
@media (hover: hover) and (pointer: fine) {
  .open-item:hover,
  .save-item:hover,
  .empty__action:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }

  .save-item[aria-pressed="true"]:hover { box-shadow: none; transform: translateY(-2px); }

  .toggle:hover,
  .close-detail:hover { background: var(--yellow); color: var(--ink); }

  .toggle[aria-pressed="true"]:hover { background: var(--teal); }

  .story:hover { transform: translateY(-2px); }

  .story:hover .story__title { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }

  .field select:hover,
  .field input[type="search"]:hover { border-color: var(--purple); }
}

/* press feedback must beat the hover lift above (same specificity, later source order) */
.open-item:active,
.save-item:active,
.empty__action:active {
  transform: scale(0.97);
  box-shadow: 2px 2px 0 var(--ink);
}

/* ---------- responsive ---------- */
@media (min-width: 720px) {
  .controls { grid-template-columns: 1fr auto auto; }

  .story {
    grid-template-columns: auto 1fr;
    column-gap: 1.5rem;
    align-items: start;
  }

  .story__num { grid-row: span 6; }

  .open-item { grid-column: 2; }
}

@media (min-width: 1000px) {
  .stories { grid-template-columns: 1fr 1fr; }
  .story:first-child { grid-column: 1 / -1; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 1ms !important;
  }

  .story, button {
    transform: none !important;
  }
}
