/* ─────────────────────────────────────────────────────────────
   SAMVIT.XYZ — "Paper Terminal"
   Design tokens. Dark theme lands later by re-declaring these
   under [data-theme="dark"] — keep every color a token.
   ───────────────────────────────────────────────────────────── */
:root {
  --paper: #F4F0E6;
  --paper-raise: #FBF8F0;
  --ink: #1D1B16;
  --ink-60: rgba(29, 27, 22, .64);
  --ink-40: rgba(29, 27, 22, .42);
  --ink-10: rgba(29, 27, 22, .10);
  --line: rgba(29, 27, 22, .16);
  --line-soft: rgba(29, 27, 22, .06);
  --grid: rgba(29, 27, 22, .035);
  --accent: #DE5B21;
  --accent-ink: #B24312;
  /* drafting blue — hand-drawn SVG strokes ONLY, never text (see design.md) */
  --ink-blue: #2743C6;
  /* wavy hover underline; the stroke duplicates --ink-blue (url() can't read tokens) */
  --wavy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 6' preserveAspectRatio='none'%3E%3Cpath d='M1 4 C6 2 10 5 15 3.5 C20 2 24 5 29 3.5 C34 2 38 5 43 3.5 C48 2 52 4.5 55 3' fill='none' stroke='%232743C6' stroke-width='1.6' stroke-linecap='round' opacity='.85'/%3E%3C/svg%3E");

  --serif: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --w: 1100px;
  --pad: clamp(20px, 4vw, 48px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--paper);
  /* faint blueprint grid, à la Metrik */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 72px 72px;
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); font-variant-ligatures: none; }

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

a { color: inherit; }

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

.container {
  max-width: var(--w);
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* film grain — HF0's texture, barely there */
.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.10 0 0 0 0 0.08 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── header ─────────────────────────────────────────────── */
.site-head {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px var(--pad);
  /* no backdrop-filter here: blur on a fixed header makes Chrome leave
     ghost copies of the page text behind while scrolling */
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  border-bottom: 1px solid var(--line);
}

.mark {
  font-size: 13px; font-weight: 700; letter-spacing: .14em;
  text-decoration: none;
}
.mark:hover { color: var(--accent-ink); }

.site-head nav { display: flex; gap: clamp(14px, 3vw, 34px); }
.site-head nav a {
  font-size: 11px; letter-spacing: .18em; text-decoration: none;
  color: var(--ink-60);
  transition: color .2s;
}
.site-head nav a:hover { color: var(--accent-ink); }

.progress {
  position: absolute; left: 0; bottom: -1px;
  height: 1px; width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* ── ink layer (hand-drawn SVG, draws itself) ───────────── */
svg.ink { overflow: visible; display: block; }
.ink .hand { filter: url(#inkwobble); }
.ink path {
  stroke: var(--ink-blue);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 101;   /* paths carry pathLength="100" */
  stroke-dashoffset: 101;
}
.ink.drawn path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset var(--dur, .8s) ease-out var(--d, 0s);
}
.ink path.lead {
  stroke-dasharray: 3 6;
  stroke-dashoffset: 0;
  stroke-width: 1.3;
  opacity: 0;
  transition: opacity .5s ease var(--d, 1s);
}
.ink.drawn path.lead { opacity: .65; }
.ink path.faint { opacity: .35; stroke-width: 1.1; }
.ink text {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  fill: var(--ink-40);
  opacity: 0;
  transition: opacity .5s ease var(--d, 1.2s);
}
.ink.drawn text { opacity: 1; }

/* static drawings: rendered finished, no draw-on (owner's call; only the
   contact arrow and the small asides keep the animation) */
.ink.static path { stroke-dashoffset: 0; }
.ink.static path:not(.lead) { stroke-dasharray: none; }
.ink.static path.lead { opacity: .65; }
.ink.static text { opacity: 1; }

/* ── hero ───────────────────────────────────────────────── */
.hero {
  min-height: 92svh;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) auto;
  align-items: center;
  gap: clamp(24px, 5vw, 72px);
  padding-top: 110px;
  padding-bottom: 48px;
}

.eyebrow {
  font-size: 11px; letter-spacing: .22em;
  color: var(--accent-ink);
  margin-bottom: 26px;
}

/* memo header — the typed part of the memorandum */
.memo { margin-bottom: 26px; }
.memo-line { font-size: 11px; letter-spacing: .2em; color: var(--accent-ink); }
.memo .eyebrow {
  display: inline-block;
  font-size: 10px; letter-spacing: .18em;
  color: var(--ink-40);
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.hero-ink { grid-column: 1 / -1; margin-top: clamp(4px, 2vh, 24px); }
.hero-ink svg { width: 100%; height: auto; }
.hero-ink path { stroke-width: 2.5; }

h1 {
  font-size: clamp(2.1rem, 5.4vw, 4.1rem);
  font-weight: 420;
  line-height: 1.13;
  letter-spacing: -.01em;
  max-width: 16em;
}
h1 .decode-on-load { font-style: italic; font-weight: 560; }

.caret {
  color: var(--accent);
  animation: blink 1.1s steps(1) infinite;
  margin-left: .06em;
}
@keyframes blink { 50% { opacity: 0; } }

.sub {
  margin-top: 30px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-60);
  max-width: 46em;
}
.sub a { color: var(--accent-ink); text-decoration-color: var(--line); text-underline-offset: 3px; }
.sub a:hover { text-decoration: none; background: var(--wavy) repeat-x 0 100% / 56px 6px; padding-bottom: 2px; }

.skills {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 10.5px; letter-spacing: .2em;
  color: var(--ink-40);
}

.hero-art { position: relative; text-decoration: none; }
.hero-art pre {
  font-family: var(--mono);
  font-variant-ligatures: none;
  font-size: clamp(9px, 1.45vw, 17px);
  line-height: 1.15;
  color: var(--ink);
  opacity: .2;
  transition: opacity .35s, color .35s;
}
.hero-art .art-bin {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(5px, .78vw, 9.5px);
  opacity: 0;
  white-space: pre;
}
.hero-art:hover .art-42 { opacity: 0; }
.hero-art:hover .art-bin { opacity: .9; color: var(--accent-ink); }

/* ── sections ───────────────────────────────────────────── */
.section { padding-block: clamp(56px, 9vh, 110px); }

.section-head {
  display: flex; align-items: baseline; gap: 18px;
  margin-bottom: clamp(34px, 5vh, 56px);
}
.section-head .num { font-size: 11px; color: var(--accent-ink); letter-spacing: .1em; }
.section-head h2 {
  font-size: 12px; font-weight: 500; letter-spacing: .26em;
  color: var(--ink);
}
.section-head .rule { flex: 1; height: 1px; background: var(--line); transform: translateY(-4px); }

/* ── selected work ──────────────────────────────────────── */
.feature { max-width: 720px; }
.feature + .feature { margin-top: clamp(48px, 8vh, 88px); padding-top: clamp(40px, 6vh, 64px); border-top: 1px solid var(--line-soft); }

.meta {
  font-size: 10.5px; letter-spacing: .16em;
  color: var(--ink-40);
  margin-bottom: 14px;
}
.feature h3 {
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  font-weight: 540; line-height: 1.1;
}
.accent { color: var(--accent); }

.tagline {
  font-style: italic; font-size: clamp(1.05rem, 1.8vw, 1.3rem);
  color: var(--ink-60);
  margin-top: 6px;
}
.prose {
  margin-top: 18px;
  font-size: 1.02rem; line-height: 1.75;
  color: var(--ink);
  max-width: 58ch;
}

.textlink {
  display: inline-block;
  margin-top: 22px;
  font-size: 11px; letter-spacing: .16em;
  color: var(--accent-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  transition: border-color .25s;
}
.textlink:hover {
  border-color: transparent;
  background: var(--wavy) repeat-x 0 100% / 56px 6px;
}

/* FIG. diagrams — patent-style margin figures */
.fig { position: relative; margin: 0; }
.fig svg { width: 100%; height: auto; }
.figcap {
  margin-top: 12px;
  font-size: 9.5px; letter-spacing: .14em;
  color: var(--ink-40);
  text-align: center;
}
@media (min-width: 1100px) {
  .feature { position: relative; }
  .fig {
    position: absolute;
    left: 745px;
    top: 50%;
    transform: translateY(-50%);
    width: 260px;
  }
}
@media (max-width: 1099.98px) {
  .fig { margin-top: 36px; max-width: 320px; }
}

/* ── index rows ─────────────────────────────────────────── */
.rows { list-style: none; border-top: 1px solid var(--line); }
.rows li { border-bottom: 1px solid var(--line); }

.row {
  display: grid;
  grid-template-columns: 3.2em minmax(9em, 14em) 9em 1fr auto;
  align-items: baseline;
  gap: 16px;
  padding: 20px 10px;
  text-decoration: none;
  transition: background .25s, padding-left .25s;
}
.row:hover { background: var(--paper-raise); padding-left: 20px; }

.row .n { font-size: 11px; color: var(--ink-40); }
.row .name {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 500;
  white-space: nowrap;
}
.row:hover .name { color: var(--accent-ink); }
.row .tag { font-size: 10px; letter-spacing: .14em; color: var(--ink-40); }
.row .desc { font-size: 11.5px; color: var(--ink-60); }
.row .go { font-size: 14px; color: var(--ink-40); transition: transform .25s, color .25s; }
.row:hover .go { color: var(--accent); transform: translate(3px, -3px); }

/* glider doodle beside Game of Life */
.rows .row { position: relative; }
.glider {
  position: absolute;
  right: 64px; top: 50%;
  transform: translateY(-50%);
  width: 42px;
}

/* ── about ──────────────────────────────────────────────── */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(240px, 1fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}
.prose-col .prose + .prose { margin-top: 20px; }

.manifest {
  border: 1px solid var(--line);
  background: var(--paper-raise);
  padding: 24px 26px;
  font-size: 11px;
}
.manifest > div {
  display: flex; justify-content: space-between; gap: 18px;
  padding-block: 8px;
}
.manifest > div + div { border-top: 1px solid var(--line-soft); }
.manifest dt { color: var(--ink-40); letter-spacing: .14em; }
.manifest dd { text-align: right; letter-spacing: .05em; }
.manifest a { color: var(--accent-ink); text-decoration: none; }
.manifest a:hover { background: var(--wavy) repeat-x 0 100% / 56px 6px; padding-bottom: 3px; }

.answer {
  position: relative;
  font: inherit; color: var(--accent-ink);
  background: none; border: none; cursor: pointer;
  letter-spacing: inherit;
}
.ink-circle {
  position: absolute;
  left: -14px; top: -8px;
  width: 54px; height: 33px;
  pointer-events: none;
}
.ink-circle path { stroke-width: 1.8; }

/* ── contact ────────────────────────────────────────────── */
.bigline {
  font-size: clamp(1.7rem, 4vw, 2.9rem);
  font-weight: 440; line-height: 1.25;
  max-width: 18em;
}

.cta-wrap { position: relative; display: inline-block; margin-top: 34px; }
.cta-ink {
  position: absolute;
  left: calc(100% + 10px); bottom: 4px;
  width: 150px;
  pointer-events: none;
}

.cta {
  display: inline-block;
  padding: 16px 26px;
  font-size: 12px; letter-spacing: .16em;
  color: var(--paper);
  background: var(--ink);
  text-decoration: none;
  transition: background .25s, transform .15s;
  will-change: transform;
}
.cta:hover { background: var(--accent-ink); }

.fish { margin-top: 14px; font-size: 11px; color: var(--accent-ink); min-height: 1.5em; }

.socials {
  margin-top: 36px;
  display: flex; flex-wrap: wrap; gap: 10px 26px;
}
.socials a {
  font-size: 11px; letter-spacing: .16em;
  color: var(--ink-60); text-decoration: none;
  transition: color .2s;
  padding-bottom: 3px;
}
.socials a:hover {
  color: var(--accent-ink);
  background: var(--wavy) repeat-x 0 100% / 56px 6px;
}

/* ── footer: drawing title block + status bar ───────────── */
.site-foot { border-top: 1px solid var(--line); }

.titleblock {
  display: flex; flex-wrap: wrap;
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--line-soft);
}
.titleblock > div {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 26px 13px 0;
  margin-right: 26px;
  border-right: 1px solid var(--line-soft);
}
.titleblock > div:last-child { border-right: none; }
.titleblock span { font-size: 8px; letter-spacing: .22em; color: var(--ink-40); }
.titleblock b { font-size: 10.5px; letter-spacing: .12em; font-weight: 500; color: var(--ink-60); }

.statusbar {
  display: flex; flex-wrap: wrap; gap: 8px 28px;
  justify-content: space-between;
  padding: 14px var(--pad);
  font-size: 10px; letter-spacing: .12em;
  color: var(--ink-40);
}
.statusbar .status { color: var(--accent-ink); }
.statusbar .caret { margin-left: 4px; }

/* ── 42 overlay ─────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  color: var(--paper);
  text-align: center;
  cursor: pointer;
}
.overlay[hidden] { display: none; }
.overlay pre { font-size: clamp(10px, 2.4vw, 20px); line-height: 1.15; color: var(--accent); }
.overlay-quote {
  margin-top: 30px;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  font-style: italic; max-width: 26em; margin-inline: auto;
}
.overlay-src { margin-top: 14px; font-size: 10.5px; letter-spacing: .2em; opacity: .55; }
.overlay-hint { margin-top: 44px; font-size: 10px; letter-spacing: .3em; opacity: .4; }

/* ── reveal-on-scroll ───────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .7s ease, transform .7s ease;
  transition-delay: var(--d, 0s);
}
.reveal.in { opacity: 1; transform: none; }

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 120px;
    gap: 40px;
  }
  .hero-art { justify-self: center; }
  .hero-art pre { font-size: 9px; opacity: .28; }

  .row { grid-template-columns: 2.4em 1fr auto; row-gap: 6px; }
  .row .tag { display: none; }
  .row .desc { grid-column: 2 / 3; }
  .row .go { grid-row: 1; grid-column: 3; }
  svg.glider { display: none; }

  .about-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  svg.cta-ink { display: none; }
}

@media (max-width: 520px) {
  .site-head nav { gap: 12px; }
  .site-head nav a { font-size: 10px; letter-spacing: .12em; }
  .statusbar { justify-content: flex-start; }
  .harmless { display: none; }
}

/* ── reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .caret { animation: none; }
  .ink path { stroke-dashoffset: 0; }
  .ink path.lead, .ink text { opacity: 1; }
  .ink path.lead { opacity: .65; }
  * { transition-duration: .01ms !important; }
}
