/* ============================================================
   site.css — shared design system for shirinprajapati.com
   Tokens, reset, typography, masthead, overlay nav, theme
   toggle, colophon, and shared utilities. Consumed by the
   homepage and every blog post. No build step.
   ============================================================ */

/* ---------- Tokens ---------- */

:root {
  /* surfaces (opaque ladder — no white-alpha fills) */
  --surface-0: #f2eee4;
  --surface-1: #faf7ef;
  --surface-2: #e9e2d1;
  --surface-ink: #1e2438;

  /* ink */
  --ink: #1c2237;
  --ink-2: #3d4459;
  --ink-3: #5c6377;
  --ink-4: #8b8f9d; /* decorative / aria-hidden only */

  /* rules */
  --rule: #cfc6b1;
  --rule-soft: #ddd5c3;
  --rule-ink: #1c2237;

  /* accent 1 — copper */
  --copper: #b85d2e;        /* large numerals & graphics only */
  --copper-text: #9a4a20;   /* AA for small text */
  --copper-soft: rgba(184, 93, 46, 0.12);

  /* accent 2 — verdigris */
  --verdigris: #47695d;
  --verdigris-text: #3d5c51;
  --verdigris-soft: rgba(71, 105, 93, 0.12);

  /* type */
  --font-serif: "Fraunces", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  --text-display: clamp(64px, 11vw, 152px);
  --text-h2: clamp(36px, 4.6vw, 60px);
  --text-h3: clamp(22px, 2.4vw, 30px);
  --text-numeral: clamp(44px, 5vw, 72px);
  --text-lede: clamp(19px, 1.6vw, 21px);
  --text-body: 17px;
  --text-meta: 12px;
  --text-folio: 11px;

  /* space & shape */
  --space-2xs: 8px;  --space-xs: 12px; --space-s: 16px; --space-m: 24px;
  --space-l: 40px;   --space-xl: 64px; --space-2xl: 96px;
  --section-pad: clamp(96px, 14vh, 168px);
  --gutter: clamp(24px, 5vw, 72px);
  --radius: 2px;
  --masthead-h: 64px;
  --shadow-card: 0 1px 0 rgba(28, 34, 55, 0.05), 0 16px 40px -24px rgba(28, 34, 55, 0.25);

  /* motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 200ms;
  --dur-med: 450ms;
  --dur-reveal: 700ms;

  /* grain */
  --grain-opacity: 0.3;
  --grain-blend: multiply;
}

:root[data-theme="dark"] {
  --surface-0: #131720;
  --surface-1: #1b212c;
  --surface-2: #0e1219;
  --surface-ink: #f0ebdf;

  --ink: #f0ebdf;
  --ink-2: #cfc9ba;
  --ink-3: #a3a7b4;
  --ink-4: #6f7482;

  --rule: #303849;
  --rule-soft: #262e3d;
  --rule-ink: #f0ebdf;

  --copper: #d9985f;
  --copper-text: #dda76f;
  --copper-soft: rgba(217, 152, 95, 0.14);

  --verdigris: #7fa896;
  --verdigris-text: #8fb3a3;
  --verdigris-soft: rgba(127, 168, 150, 0.14);

  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.4), 0 20px 48px -20px rgba(0, 0, 0, 0.5);

  --grain-opacity: 0.16;
  --grain-blend: soft-light;
}

/* ---------- Reset & base ---------- */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--ink-2);
  font-family: var(--font-serif);
  font-size: var(--text-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
  transition: background var(--dur-med) ease, color var(--dur-med) ease;
}

/* paper grain */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  mix-blend-mode: var(--grain-blend);
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 0.10 0 0 0 0 0.09 0 0 0 0 0.07 0 0 0 0 0.12 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img, svg { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }

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

a {
  color: inherit;
  text-decoration: none;
}

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

section[id] { scroll-margin-top: calc(var(--masthead-h) + 16px); }

/* ---------- Shared type utilities ---------- */

.mono {
  font-family: var(--font-mono);
  font-size: var(--text-meta);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-folio);
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--copper-text);
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--copper);
  flex: 0 0 auto;
}

/* underline that draws in from the left — the site-wide link hover */
.draw-link {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: left calc(100% - 0.08em);
  transition: background-size 250ms var(--ease-out), color var(--dur-fast) ease;
  padding-bottom: 0.14em;
}

.draw-link:hover,
.draw-link:focus-visible {
  background-size: 100% 1px;
}

.arrow-link {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}

.arrow-link .arrow {
  transition: transform 250ms var(--ease-out);
}

.arrow-link:hover .arrow,
.arrow-link:focus-visible .arrow {
  transform: translateX(6px);
}

.arrow-link.is-muted { color: var(--ink-3); }
.arrow-link.is-muted:hover { color: var(--ink); }

/* letterpress stamp chip */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--text-folio);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 5px 10px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  transform: rotate(-1deg);
  color: var(--ink-3);
}

.stamp-copper { color: var(--copper-text); background: var(--copper-soft); }
.stamp-verdigris { color: var(--verdigris-text); background: var(--verdigris-soft); }

.stamp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--copper-soft); }
  50% { opacity: 0.5; box-shadow: 0 0 0 5px transparent; }
}

/* ---------- Layout primitives ---------- */

.shell {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: var(--section-pad);
}

.section-inset { background: var(--surface-2); }

/* folio device — every section's running head */
.folio {
  display: flex;
  align-items: baseline;
  gap: 18px;
  border-top: 1px solid var(--rule-ink);
  padding-top: 14px;
  font-family: var(--font-mono);
  font-size: var(--text-folio);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.folio .folio-no { color: var(--copper-text); }
.folio .folio-count { margin-left: auto; color: var(--ink-4); }

/* ghost numeral behind section headers */
.section-head { position: relative; }

.ghost-num {
  position: absolute;
  top: -0.12em;
  right: -0.05em;
  z-index: 0;
  font-family: var(--font-serif);
  font-size: clamp(140px, 19vw, 250px);
  font-weight: 300;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--rule);
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

.section-head > * { position: relative; z-index: 1; }
.section-head > .ghost-num { z-index: 0; }

.section-title {
  margin-top: var(--space-l);
  font-size: var(--text-h2);
  font-weight: 320;
  line-height: 1.04;
  letter-spacing: -0.025em;
  color: var(--ink);
  max-width: 18ch;
}

.section-title em {
  font-style: italic;
  color: var(--copper);
}

.section-lede {
  margin-top: var(--space-m);
  font-size: var(--text-lede);
  line-height: 1.65;
  color: var(--ink-3);
  max-width: 46ch;
}

/* ---------- Reveal on scroll ---------- */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity var(--dur-reveal) var(--ease-out),
    transform var(--dur-reveal) var(--ease-out);
  transition-delay: calc(var(--reveal-i, 0) * 70ms);
}

.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* ---------- Progress rail ---------- */

.rail {
  position: fixed;
  top: var(--masthead-h);
  left: 0;
  height: 2px;
  width: 0;
  background: var(--copper);
  z-index: 60;
}

/* ---------- Masthead ---------- */

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--surface-ink);
  color: var(--surface-0);
  font-family: var(--font-mono);
  font-size: var(--text-meta);
  letter-spacing: 0.12em;
  transform: translateY(-64px);
  transition: transform var(--dur-fast) ease;
}

.skip-link:focus-visible { transform: none; }

.masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--masthead-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-m);
  padding-inline: clamp(20px, 3.4vw, 44px);
  border-bottom: 1px solid transparent;
  transition: background var(--dur-med) ease, border-color var(--dur-med) ease;
}

.masthead.is-scrolled {
  background: color-mix(in srgb, var(--surface-0) 92%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom-color: var(--rule);
}

.masthead-wordmark {
  justify-self: start;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* on the homepage the giant hero name is right below the masthead, so the
   wordmark only fades in once the visitor scrolls past the cover */
.masthead:not(.is-scrolled) .masthead-wordmark {
  opacity: 0;
  pointer-events: none;
}

.masthead .masthead-wordmark {
  transition: opacity var(--dur-med) ease;
}

.masthead-nav {
  display: flex;
  gap: clamp(18px, 2.4vw, 34px);
}

.masthead-nav a {
  position: relative;
  font-family: var(--font-mono);
  font-size: var(--text-folio);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-block: 6px;
  transition: color var(--dur-fast) ease;
}

.masthead-nav a sup {
  font-size: 8px;
  margin-left: 4px;
  color: var(--ink-4);
  letter-spacing: 0.08em;
}

.masthead-nav a:hover,
.masthead-nav a:focus-visible { color: var(--ink); }

.masthead-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 4px;
  height: 4px;
  background: var(--copper);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--dur-fast) ease, transform 250ms var(--ease-out);
}

.masthead-nav a.is-active { color: var(--ink); }

.masthead-nav a.is-active::after {
  opacity: 1;
  transform: none;
}

.masthead-meta {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 16px;
}

.masthead-clock {
  font-family: var(--font-mono);
  font-size: var(--text-folio);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  min-width: 15ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Theme + menu toggles ---------- */

.theme-toggle,
.menu-toggle {
  appearance: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--rule);
  background: var(--surface-1);
  color: var(--ink-3);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease, transform var(--dur-fast) ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible,
.menu-toggle:hover,
.menu-toggle:focus-visible {
  color: var(--copper-text);
  border-color: var(--copper);
  box-shadow: 0 0 0 3px var(--copper-soft);
  outline: none;
}

.theme-toggle:active { transform: scale(0.86); }

.theme-toggle.is-toggling {
  animation: toggle-morph 440ms var(--ease-out);
  pointer-events: none;
}

@keyframes toggle-morph {
  0% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(0.05) rotate(160deg); }
  100% { transform: scale(1) rotate(360deg); }
}

.menu-toggle { display: none; }

/* ---------- Mobile overlay nav ---------- */

.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: var(--surface-0);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--gutter);
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-out), visibility 0s linear var(--dur-med);
}

.nav-overlay.is-open {
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}

.nav-overlay-links {
  display: flex;
  flex-direction: column;
}

.nav-overlay-links a {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-soft);
  font-family: var(--font-serif);
  font-size: clamp(32px, 9vw, 48px);
  font-weight: 320;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--dur-med) var(--ease-out), transform var(--dur-med) var(--ease-out);
  transition-delay: 0s;
}

.nav-overlay.is-open .nav-overlay-links a {
  opacity: 1;
  transform: none;
  transition-delay: calc(60ms + var(--reveal-i, 0) * 55ms);
}

.nav-overlay-links a .num {
  font-family: var(--font-mono);
  font-size: var(--text-folio);
  letter-spacing: 0.18em;
  color: var(--copper-text);
}

.nav-overlay-links a.is-active .num { color: var(--copper); }

.nav-overlay-foot {
  margin-top: var(--space-l);
  font-family: var(--font-mono);
  font-size: var(--text-folio);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- Colophon ---------- */

.colophon {
  border-top: 1px solid var(--rule-ink);
  padding-block: var(--space-l);
}

.colophon .shell {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-m);
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: var(--text-meta);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.colophon .colophon-center { text-align: center; }
.colophon .colophon-end { text-align: right; }
.colophon a { color: var(--ink-3); }
.colophon a:hover, .colophon a:focus-visible { color: var(--copper-text); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  :root { --masthead-h: 56px; }
  .masthead { grid-template-columns: auto 1fr; }
  .masthead-nav { display: none; }
  .masthead-clock { display: none; }
  .menu-toggle { display: inline-flex; }
  .colophon .shell {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }
  .colophon .colophon-center,
  .colophon .colophon-end { text-align: left; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
  }
  html { scroll-behavior: auto; }
  .js [data-reveal] { opacity: 1; transform: none; }
}
