/* ============================================================
   QUOTIDIAN — broadsheet-at-night editorial
   Dark ink ground, warm paper-cream ink, category-coded accents.
   Oswald (display) · Literata (body) · IBM Plex Mono (meta)
   ============================================================ */

@font-face { font-family: "Oswald"; src: url("assets/oswald.ttf") format("truetype"); font-weight: 200 700; font-display: swap; }
@font-face { font-family: "Literata"; src: url("assets/literata.ttf") format("truetype"); font-weight: 300 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 700; font-display: swap; }

:root {
  --ink:        #11131a;   /* page ground */
  --ink-2:      #161922;   /* card ground */
  --ink-3:      #1d212c;   /* raised ground */
  --line:       #2c3140;   /* hairlines */
  --line-2:     #3a4154;
  --paper:      #f3ebda;   /* primary text */
  --paper-dim:  #c9c2b1;
  --muted:      #8c8a83;   /* warm grey meta */
  --muted-2:    #6f6d68;

  --amber:      #e8a13c;   /* Culture */
  --terracotta: #e0613b;   /* Food */
  --teal:       #46b3a6;   /* Movement */
  --rose:       #e07a96;   /* People */
  --sage:       #8fae5e;   /* Places */

  --accent: var(--amber);
  --accent-ink: #11131a;

  --maxw: 1280px;
  --gutter: clamp(20px, 4vw, 56px);

  --space-1: 8px;
  --space-2: 14px;
  --space-3: 22px;
  --space-4: 34px;
  --space-5: 56px;
  --space-6: 88px;

  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* category accent map */
[data-cat="Culture"]  { --accent: var(--amber); }
[data-cat="Food"]     { --accent: var(--terracotta); }
[data-cat="Movement"] { --accent: var(--teal); }
[data-cat="People"]   { --accent: var(--rose); }
[data-cat="Places"]   { --accent: var(--sage); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(120% 80% at 85% -10%, rgba(232,161,60,0.08), transparent 60%),
    radial-gradient(100% 70% at 0% 0%, rgba(70,179,166,0.06), transparent 55%),
    var(--ink);
  color: var(--paper);
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.62;
  font-feature-settings: "liga", "kern";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--amber); color: var(--ink); }

/* ---------- skip link ---------- */
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--paper); color: var(--ink);
  font-family: "IBM Plex Mono", monospace; font-size: 13px;
  padding: 8px 14px; border-radius: 3px; text-decoration: none;
  transition: top .18s var(--ease);
}
.skip-link:focus { top: 8px; }

/* ---------- focus rings ---------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- masthead ---------- */
.masthead {
  position: relative;
  padding: 26px var(--gutter) 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent);
}
.masthead-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 18px;
}
.masthead-left, .masthead-right {
  display: flex; flex-direction: column; gap: 5px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--muted);
  text-transform: uppercase;
}
.masthead-right { align-items: flex-end; text-align: right; }
.masthead-date { color: var(--paper-dim); }
.masthead-tag { color: var(--paper-dim); }
.masthead-count {
  color: var(--amber);
  letter-spacing: .02em;
}
.wordmark {
  margin: 0;
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 700;
  font-size: clamp(40px, 7vw, 92px);
  line-height: .86;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper) 62%, var(--muted) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  text-shadow: 0 0 1px rgba(243,235,218,0.15);
}
.rule {
  margin: 16px var(--gutter) 0;
  height: 4px;
  background: var(--paper);
  max-width: var(--maxw);
  margin-left: auto; margin-right: auto;
}
.rule-thin { height: 1px; background: var(--line-2); margin-top: 3px; }

/* ---------- stage / lede ---------- */
.stage {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) var(--gutter) var(--space-6);
}
.lede {
  max-width: 760px;
  margin-bottom: clamp(28px, 5vw, 52px);
}
.kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--amber); margin: 0 0 14px;
  display: inline-flex; align-items: center; gap: 10px;
}
.kicker::before {
  content: ""; width: 28px; height: 1px; background: var(--amber);
}
.lede-title {
  margin: 0 0 16px;
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 600;
  font-size: clamp(28px, 4.4vw, 52px);
  line-height: 1.04;
  letter-spacing: .005em;
  text-wrap: balance;
  color: var(--paper);
}
.lede-sub {
  margin: 0;
  font-size: clamp(16px, 1.4vw, 19px);
  line-height: 1.6;
  color: var(--paper-dim);
  max-width: 60ch;
}

/* ---------- controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-end;
  padding: 18px 20px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 22px;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field-search { flex: 1 1 280px; min-width: 220px; }
.field-filter { flex: 0 1 220px; }
.field-saved  { flex: 0 0 auto; margin-left: auto; }

.field-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted);
}

.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute; left: 12px; width: 18px; height: 18px;
  color: var(--muted); pointer-events: none;
}
#search {
  width: 100%;
  font-family: "Literata", Georgia, serif;
  font-size: 15.5px;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 11px 38px 11px 38px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
#search::placeholder { color: var(--muted); font-style: italic; }
#search:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(232,161,60,0.15); }
.search-clear {
  position: absolute; right: 6px;
  width: 28px; height: 28px;
  background: transparent; border: 1px solid var(--line-2);
  color: var(--paper-dim); border-radius: 50%;
  font-size: 16px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
}
.search-clear:hover { color: var(--paper); border-color: var(--paper-dim); }

.select-wrap { position: relative; display: flex; align-items: center; }
#filter {
  appearance: none; -webkit-appearance: none;
  width: 100%;
  font-family: "Literata", Georgia, serif;
  font-size: 15.5px;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 11px 38px 11px 14px;
  cursor: pointer;
}
#filter:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(232,161,60,0.15); }
#filter option { background: var(--ink-2); color: var(--paper); }
.select-caret {
  position: absolute; right: 12px; width: 18px; height: 18px;
  color: var(--muted); pointer-events: none;
}

.toggle-saved {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--paper-dim);
  background: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 11px 18px 11px 14px;
  cursor: pointer;
  transition: color .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
}
.toggle-saved:hover { color: var(--paper); border-color: var(--paper-dim); }
.toggle-saved[aria-pressed="true"] {
  color: var(--ink); background: var(--amber); border-color: var(--amber);
}
.bookmark-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: currentColor; opacity: .45;
  box-shadow: inset 0 0 0 1px transparent;
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}
.toggle-saved[aria-pressed="true"] .bookmark-dot {
  opacity: 1; transform: scale(1.15);
}

/* ---------- results bar ---------- */
.results-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
}
.results-count { color: var(--paper-dim); }
.results-divider { color: var(--muted-2); }

/* ---------- grid (asymmetric bento) ---------- */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 28px 26px;
}
.item {
  grid-column: span 4;
  display: flex; flex-direction: column;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  transition: transform .22s var(--ease), border-color .22s var(--ease), background .22s var(--ease);
}
.item::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
  opacity: .85;
}
.item:hover { border-color: var(--line-2); background: var(--ink-3); transform: translateY(-2px); }
.item:hover::before { opacity: 1; }

/* featured spans wider; first item gets a big treatment */
.item.is-lead { grid-column: span 8; }
.item.is-lead .item-image { aspect-ratio: 16 / 9; }
.item.is-lead .item-title { font-size: clamp(24px, 2.6vw, 36px); }

.item-image {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--ink-3);
}
.item-image img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
  filter: saturate(.9) contrast(1.02) brightness(.82);
  transition: transform .5s var(--ease), filter .4s var(--ease);
}
.item:hover .item-image img { transform: scale(1.04); filter: saturate(1) brightness(.92); }
.item-image::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(17,19,26,0) 40%, rgba(17,19,26,.55) 100%);
  pointer-events: none;
}

.item-cat {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink);
  background: var(--accent);
  padding: 5px 9px; border-radius: 2px;
  font-weight: 700;
}
.item-saved-mark {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); border: 1px solid var(--accent);
  color: var(--accent);
  display: none; place-items: center;
}
.item.is-saved .item-saved-mark { display: grid; }
.item-saved-mark svg { width: 13px; height: 13px; fill: currentColor; }

.item-body {
  padding: 18px 20px 20px;
  display: flex; flex-direction: column; gap: 10px;
  flex: 1;
}
.item-title {
  margin: 0;
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 600;
  font-size: clamp(20px, 1.7vw, 25px);
  line-height: 1.12;
  letter-spacing: .004em;
  color: var(--paper);
  text-wrap: balance;
}
.item-summary {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--paper-dim);
}
.item-meta {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; letter-spacing: .04em;
  color: var(--muted);
  text-transform: uppercase;
}
.item-meta .author { color: var(--paper-dim); }
.item-meta .dot { color: var(--muted-2); }

.open-item {
  margin-top: 14px;
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--paper);
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.open-item:hover { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.open-item .arrow { transition: transform .18s var(--ease); }
.open-item:hover .arrow { transform: translateX(3px); }

/* item entrance animation */
.item { opacity: 0; transform: translateY(8px); animation: itemIn .5s var(--ease) forwards; }
.item:nth-child(2) { animation-delay: .05s; }
.item:nth-child(3) { animation-delay: .1s; }
.item:nth-child(4) { animation-delay: .15s; }
.item:nth-child(5) { animation-delay: .2s; }
@keyframes itemIn { to { opacity: 1; transform: none; } }

/* ---------- empty state ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  padding: 56px 28px;
  border: 1px dashed var(--line-2);
  border-radius: 4px;
  background: var(--ink-2);
}
.empty-title {
  font-family: "Oswald", sans-serif; font-weight: 600; font-size: 22px;
  color: var(--paper); letter-spacing: .01em;
}
.empty-sub { color: var(--paper-dim); margin: 0; max-width: 50ch; }
.recover {
  font-family: "IBM Plex Mono", monospace; font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink); background: var(--amber);
  border: none; border-radius: 2px;
  padding: 10px 18px; cursor: pointer;
  margin-top: 4px;
}
.recover:hover { filter: brightness(1.08); }

/* ---------- colophon ---------- */
.colophon {
  border-top: 1px solid var(--line);
  background: var(--ink-2);
  padding: 28px var(--gutter);
}
.colophon-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline;
  font-family: "IBM Plex Mono", monospace; font-size: 11px;
  letter-spacing: .04em; color: var(--muted); text-transform: uppercase;
}
.colophon-mark { color: var(--paper); letter-spacing: .14em; font-weight: 700; }
.colophon-note { color: var(--paper-dim); text-transform: none; letter-spacing: .02em; }
.colophon-meta { color: var(--muted-2); }

/* ============================================================
   DETAIL DIALOG
   ============================================================ */
.detail-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(6, 7, 11, .72);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .22s var(--ease);
}
.detail-backdrop.is-open { opacity: 1; }
dialog.detail {
  position: fixed; inset: 0;
  margin: auto;
  width: min(960px, 100vw);
  max-width: 100vw;
  max-height: 100vh;
  height: 100vh; height: 100dvh;
  padding: 0; border: none;
  background: var(--ink);
  color: var(--paper);
  z-index: 50;
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: detailIn .3s var(--ease);
}
@keyframes detailIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
dialog.detail::backdrop { background: rgba(6,7,11,.72); }

.detail-scroll {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.detail-topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(18px, 4vw, 36px);
  background: rgba(17,19,26,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.detail-topbar-left {
  display: flex; align-items: center; gap: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}
.detail-cat-pill {
  color: var(--ink); background: var(--accent);
  padding: 4px 9px; border-radius: 2px; font-weight: 700; letter-spacing: .1em;
}
.detail-actions { display: flex; align-items: center; gap: 10px; }

.close-detail, .save-item {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.close-detail {
  color: var(--paper);
  background: transparent;
  border: 1px solid var(--line-2);
  padding: 9px 16px 9px 12px;
}
.close-detail:hover { background: var(--ink-3); border-color: var(--paper-dim); }
.close-detail svg { width: 16px; height: 16px; }

.save-item {
  color: var(--paper-dim);
  background: var(--ink-2);
  border: 1px solid var(--line-2);
  padding: 9px 16px 9px 12px;
}
.save-item:hover { color: var(--paper); border-color: var(--paper-dim); }
.save-item[aria-pressed="true"] {
  color: var(--ink); background: var(--accent); border-color: var(--accent);
}
.save-item .bm { width: 14px; height: 16px; flex: none; }
.save-item .bm path {
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linejoin: round; stroke-linecap: round;
}
.save-item[aria-pressed="true"] .bm path { fill: currentColor; stroke: currentColor; }

.detail-hero {
  position: relative;
  height: clamp(220px, 32vh, 360px);
  overflow: hidden;
}
.detail-hero img {
  width: 100%; height: 100%; object-fit: cover;
  filter: saturate(.92) contrast(1.04) brightness(.78);
}
.detail-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(17,19,26,.2) 0%, rgba(17,19,26,.05) 35%, var(--ink) 100%);
}
.detail-article {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 48px) 80px;
}
.detail-title {
  margin: 0 0 14px;
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: clamp(30px, 4.6vw, 56px);
  line-height: 1.03;
  letter-spacing: .004em;
  text-wrap: balance;
}
.detail-summary {
  margin: 0 0 24px;
  font-size: clamp(17px, 1.6vw, 21px);
  line-height: 1.5;
  color: var(--paper-dim);
  font-style: italic;
  border-left: 3px solid var(--accent);
  padding-left: 18px;
}
.detail-byline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding-bottom: 24px; margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
}
.detail-byline .who { color: var(--paper); }
.detail-byline .sep { color: var(--muted-2); }

.detail-body p {
  margin: 0 0 1.3em;
  font-size: clamp(17px, 1.4vw, 19px);
  line-height: 1.75;
  color: var(--paper);
}
.detail-body p:first-child::first-letter {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 3.4em;
  line-height: .82;
  float: left;
  margin: 6px 12px 0 0;
  color: var(--accent);
}
.detail-foot {
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 14px;
}
.detail-foot-note {
  font-family: "IBM Plex Mono", monospace; font-size: 11px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .item { grid-column: span 6; }
  .item.is-lead { grid-column: span 12; }
  .item.is-lead .item-image { aspect-ratio: 16 / 8; }
}
@media (max-width: 640px) {
  :root { --gutter: 18px; }
  .masthead-inner { grid-template-columns: 1fr; text-align: center; }
  .masthead-left, .masthead-right { align-items: center; text-align: center; }
  .wordmark { letter-spacing: .1em; }
  .lede-title { font-size: clamp(26px, 7vw, 40px); }
  .controls { flex-direction: column; align-items: stretch; }
  .field-search, .field-filter, .field-saved { flex: 1 1 auto; margin-left: 0; }
  .grid { grid-template-columns: 1fr; gap: 22px; }
  .item, .item.is-lead { grid-column: span 1; }
  .item.is-lead .item-image { aspect-ratio: 4/3; }
  .detail-hero { height: clamp(180px, 30vh, 260px); }
  .detail-topbar { flex-wrap: wrap; gap: 10px; }
  .detail-actions { width: 100%; justify-content: space-between; }
  .detail-topbar-left { font-size: 10px; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .item { opacity: 1; transform: none; }
}
body[data-reduce-motion="true"] *,
body[data-reduce-motion="true"] *::before,
body[data-reduce-motion="true"] *::after {
  animation-duration: .001ms !important;
  transition-duration: .001ms !important;
}
