/* =========================================================================
   infographix — stylesheet
   editorial × terminal. one accent, generous space, quiet grid.
   ========================================================================= */

/* --- design tokens ----------------------------------------------------- */
:root {
  /* color */
  --paper:       #f4efe6;
  --paper-2:     #ebe4d6;
  --ink:         #1a1814;
  --ink-soft:    #4a463e;
  --ink-faint:   #706a5e;
  --rule:        #1a181422;
  --accent:      #c8472b;          /* burnt sienna — change me */
  --accent-soft: #c8472b14;

  /* type */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body:    "Inter Tight", "Helvetica Neue", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --fs-mega: clamp(2.5rem, 7vw, 5.5rem);
  --fs-h1:   clamp(1.75rem, 3.5vw, 2.75rem);
  --fs-h2:   clamp(1.35rem, 2.2vw, 1.9rem);
  --fs-h3:   clamp(1.15rem, 1.6vw, 1.4rem);
  --fs-body: 1rem;
  --fs-small: 0.825rem;
  --fs-tiny:  0.72rem;

  /* space (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 3.5rem;
  --space-9: 5rem;

  /* misc */
  --radius: 2px;
  --shell-max: 1400px;
  --grain: 1;                   /* set to 0 to disable paper grain */
}

/* dark mode kept as a stub — toggleable via [data-theme="dark"] on <html> */
html[data-theme="dark"] {
  --paper:    #14130f;
  --paper-2:  #1c1a15;
  --ink:      #ece6d8;
  --ink-soft: #b3ad9e;
  --ink-faint:#736d60;
  --rule:     #ece6d822;
  --accent:   #e7714f;
  --accent-soft: #e7714f1c;
}

/* --- reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }

/* --- accessibility utilities ------------------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  text-decoration: none;
}
.skip-link:focus {
  top: var(--space-2);
}

/* --- focus-visible ---------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* --- base -------------------------------------------------------------- */
html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* paper grain — subtle SVG noise overlay */
body {
  position: relative;
  min-height: 100vh;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: calc(var(--grain) * 0.55);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0.08 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}

::selection { background: var(--accent); color: var(--paper); }

/* --- layout primitives ------------------------------------------------- */
.shell {
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.rule {
  height: 1px;
  background: var(--rule);
  border: 0;
  margin: 0;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* --- header / nav ------------------------------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.site-header .shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
  gap: var(--space-5);
}
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}
.brand .dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  background: var(--accent);
  border-radius: 50%;
  transform: translateY(-0.15em);
}
.nav {
  display: flex;
  gap: var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
}
.nav a {
  position: relative;
  padding: var(--space-1) 0;
}
.nav a[aria-current="page"]::after,
.nav a:hover::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--accent);
}

/* --- hero (home page) -------------------------------------------------- */
.hero {
  padding-top: var(--space-9);
  padding-bottom: var(--space-8);
  position: relative;
  overflow: hidden;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: var(--fs-mega);
  line-height: 0.95;
  letter-spacing: -0.035em;
  margin: 0 0 var(--space-6);
  max-width: 14ch;
}
.hero__lede {
  max-width: 52ch;
  font-size: 1.1rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* --- hero variant: overview page --------------------------------------- */
.hero--overview { padding-bottom: var(--space-5); }
.hero--overview h1 { font-size: var(--fs-h1); max-width: none; }

/* --- card grid variant: gallery with top padding ---------------------- */
.cards--gallery { padding-top: var(--space-6); }

/* --- section header --------------------------------------------------- */
.section-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-5);
  align-items: end;
  padding: var(--space-6) 0 var(--space-4);
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-h2);
  letter-spacing: -0.02em;
  margin: var(--space-2) 0 0;
}
.section-head .more {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--ink-soft);
  border-bottom: 1px solid var(--ink-faint);
  padding-bottom: 2px;
  transition: color .2s, border-color .2s;
}
.section-head .more:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 600px) {
  .section-head { grid-template-columns: 1fr; }
  .section-head .more { grid-column: 1 / -1; }
}

/* --- CLS prevention: reserve space for JS-injected content ----------- */
#featured { min-height: 60vh; }
#recent-cards { min-height: 320px; }

/* --- featured infographic --------------------------------------------- */
.featured {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--space-7);
  padding: var(--space-5) 0 var(--space-8);
}
@media (max-width: 880px) { .featured { grid-template-columns: 1fr; } }

.featured__visual {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  aspect-ratio: 3/4;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.featured__visual img,
.featured__visual svg {
  width: 100%; height: 100%;
  object-fit: cover;
}
.featured__visual::after {
  content: attr(data-id);
  position: absolute;
  bottom: var(--space-3);
  right: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
  letter-spacing: 0.1em;
}
.featured__body h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-h1);
  letter-spacing: -0.025em;
  margin: var(--space-2) 0 var(--space-5);
  line-height: 1.05;
}
.featured__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-5) 0;
}
.tag {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  background: transparent;
  transition: background .15s, color .15s, border-color .15s;
  cursor: pointer;
  text-decoration: none;
}
.tag:hover, .tag.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.featured__summary { color: var(--ink-soft); margin-bottom: var(--space-5); max-width: 50ch; }

/* --- card grid (gallery) ---------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: var(--space-5);
  padding-bottom: var(--space-8);
}
.card {
  display: flex;
  flex-direction: column;
  background: transparent;
  border-top: 1px solid var(--rule);
  padding-top: var(--space-4);
  transition: transform .25s ease, opacity .2s;
}
.card:hover { transform: translateY(-2px); }
.card__visual {
  background: var(--paper-2);
  aspect-ratio: 4/3;
  margin-bottom: var(--space-4);
  overflow: hidden;
  position: relative;
}
.card__visual img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.card:hover .card__visual img { transform: scale(1.03); }
.card__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
  display: flex;
  justify-content: space-between;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}
.card h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-h3);
  margin: 0 0 var(--space-3);
  letter-spacing: -0.015em;
}
.card p { color: var(--ink-soft); font-size: 0.95rem; margin: 0 0 var(--space-3); }
.card__tags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: auto; }

/* --- filter bar ------------------------------------------------------- */
.filterbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5) 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.filterbar__search {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: var(--space-2) var(--space-3);
  width: 100%;
  max-width: 320px;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color .2s;
}
.filterbar__search::placeholder { color: var(--ink-faint); }
.filterbar__search:focus { border-color: var(--accent); }
.filterbar__divider {
  height: 1px;
  background: var(--rule);
}
.filterbar__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
@media (max-width: 600px) {
  .filterbar__tags {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-2);
  }
  .filterbar__tags .tag { white-space: nowrap; flex-shrink: 0; }
}

/* --- error states ---------------------------------------------------- */
.error-msg {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--ink);
  padding: var(--space-4);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}
.error-state {
  padding: var(--space-9) 0;
  text-align: center;
}

/* --- back link ------------------------------------------------------- */
.back-link { border-bottom: 1px solid; }

/* --- footer ----------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: var(--space-9);
  padding: var(--space-6) 0 var(--space-7);
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}
.site-footer .shell {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* --- single infographic page ----------------------------------------- */
.ig-detail {
  padding-top: var(--space-7);
  padding-bottom: var(--space-7);
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-7);
  align-items: start;
}
.ig-detail__info {
  position: sticky;
  top: calc(var(--space-4) * 2 + 1.4rem + 1px + var(--space-5));
  /* offset = header height approx (padding + font + border) + breathing room */
}
.ig-detail__info h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-h1);
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: var(--space-2) 0 var(--space-4);
}
.ig-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.ig-summary {
  color: var(--ink-soft);
  margin: var(--space-5) 0;
  max-width: 42ch;
}
.ig-detail__figure {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: var(--space-4);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.ig-detail__figure img {
  max-height: 85vh;
  max-width: 100%;
  object-fit: contain;
  cursor: none;
}
.ig-lens {
  position: absolute;
  width: 800px;
  height: 800px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 16px rgba(0,0,0,.18);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease-out;
  background-repeat: no-repeat;
  z-index: 10;
}
@media (prefers-reduced-motion: reduce) {
  .ig-lens { transition: none; }
}
.ig-actions {
  display: flex;
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
}
.ig-action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color .2s;
  text-decoration: none;
}
.ig-action:hover { color: var(--accent); }
.ig-action svg { flex-shrink: 0; }
@media (max-width: 880px) {
  .ig-detail {
    grid-template-columns: 1fr;
  }
  .ig-detail__info { position: static; }
  .ig-detail__figure { padding: var(--space-2); }
}
/* --- lightbox --------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  overflow: auto;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease-out, visibility .3s ease-out;
  padding: var(--space-5);
}
.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}
.lightbox img {
  display: block;
  margin: 0 auto;
  max-width: none;
}
@media (prefers-reduced-motion: reduce) {
  .lightbox { transition: none; }
}

/* --- reveal animation on load ---------------------------------------- */
.reveal { opacity: 0; transform: translateY(8px); animation: reveal .7s ease-out forwards; }
.reveal:nth-child(1) { animation-delay: .05s; }
.reveal:nth-child(2) { animation-delay: .15s; }
.reveal:nth-child(3) { animation-delay: .25s; }
.reveal:nth-child(4) { animation-delay: .35s; }
.reveal:nth-child(5) { animation-delay: .45s; }
@keyframes reveal { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
}
