/* ==========================================================================
   alexanderdobrindt.com — core stylesheet
   Tokens, base typography, layout primitives
   Palette: forest / olive / warm stone / ivory, copper as restrained accent
   ========================================================================== */

:root {
  /* Colour */
  --forest: #1c3227;
  --forest-2: #24402f;
  --forest-3: #2f5140;
  --olive: #565c3c;
  --olive-2: #737a55;
  --sage: #a9ad8c;
  --stone: #d9d1bf;
  --stone-2: #e6dfcf;
  --ivory: #f5f1e7;
  --cream: #fbf8f1;
  --white: #ffffff;
  --charcoal: #1f2220;
  --ink: #1d221e;
  --ink-2: #3a403a;
  --muted: #5b5f55;
  --rule: #cbc2ad;
  --rule-soft: #ddd5c3;
  --copper: #a45d32;
  --copper-ink: #8a4a22;
  --copper-soft: #e2b994;
  --on-forest: #eee9dc;
  --on-forest-muted: #bcc2ae;

  /* Type */
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;

  --fs-xs: 0.8125rem;   /* 13 */
  --fs-sm: 0.9375rem;   /* 15 */
  --fs-base: 1.0625rem; /* 17 */
  --fs-md: 1.25rem;
  --fs-lg: clamp(1.375rem, 1.1rem + 1vw, 1.75rem);
  --fs-xl: clamp(1.75rem, 1.3rem + 1.8vw, 2.625rem);
  --fs-2xl: clamp(2.25rem, 1.5rem + 3vw, 3.75rem);
  --fs-3xl: clamp(2.75rem, 1.6rem + 4.8vw, 5.5rem);

  /* Space */
  --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);
  --section: clamp(4rem, 3rem + 5vw, 8rem);
  --maxw: 1320px;
  --readw: 42rem;
  --nav-h: 76px;

  --radius: 2px;
  --shadow: 0 1px 2px rgba(28, 50, 39, .06), 0 12px 32px -12px rgba(28, 50, 39, .18);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.7;
  font-feature-settings: "kern", "liga";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
p { margin: 0 0 1.15em; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0 0 1.15em; padding-left: 1.25em; }
figure { margin: 0; }
blockquote { margin: 0; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 0; }
::selection { background: var(--forest); color: var(--cream); }

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 1000;
  background: var(--forest); color: var(--cream); padding: .75rem 1.25rem;
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 1rem; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Typography ---------- */
.display, .h1 {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 30, "WONK" 0;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.02;
}
h1 { font-family: var(--serif); font-size: var(--fs-3xl); line-height: 1.02; letter-spacing: -0.022em; font-weight: 400; font-variation-settings: "SOFT" 30; }
h2 { font-family: var(--serif); font-size: var(--fs-2xl); line-height: 1.08; letter-spacing: -0.018em; font-weight: 400; font-variation-settings: "SOFT" 30; }
h3 { font-family: var(--serif); font-size: var(--fs-lg); line-height: 1.25; letter-spacing: -0.01em; font-weight: 500; }
h4 { font-family: var(--sans); font-size: var(--fs-base); line-height: 1.4; font-weight: 700; letter-spacing: .005em; }
h1 em, h2 em, h3 em { font-style: italic; color: var(--copper-ink); }

.eyebrow {
  display: inline-flex; align-items: center; gap: .6rem;
  font-family: var(--sans); font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--olive);
}
.eyebrow::before { content: "§"; font-family: var(--serif); font-size: 1.15rem; letter-spacing: 0; color: var(--copper); font-weight: 500; text-transform: none; }
.eyebrow.no-mark::before { content: none; }

.lede { font-family: var(--serif); font-size: var(--fs-lg); line-height: 1.45; color: var(--ink-2); font-weight: 300; }
.small { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.serif { font-family: var(--serif); }
.prose { max-width: var(--readw); }
.prose p, .prose li { color: var(--ink-2); }
.prose h2 { font-size: var(--fs-xl); margin: 2.4em 0 .7em; }
.prose h3 { margin: 2em 0 .6em; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose a, .link {
  color: var(--forest-3); text-decoration: underline; text-decoration-color: var(--copper-soft);
  text-underline-offset: .2em; text-decoration-thickness: 1px; transition: text-decoration-color .2s var(--ease), color .2s;
}
.prose a:hover, .link:hover { color: var(--copper-ink); text-decoration-color: var(--copper); }
.dropcap::first-letter {
  float: left; font-family: var(--serif); font-size: 4.6em; line-height: .82;
  padding: .06em .1em 0 0; color: var(--forest); font-weight: 400;
}

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-narrow { width: 100%; max-width: 920px; margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--section); }
.section-tight { padding-block: calc(var(--section) * .6); }
.bg-cream { background: var(--cream); }
.bg-stone { background: var(--stone-2); }
.bg-forest { background: var(--forest); color: var(--on-forest); }
.bg-forest h2, .bg-forest h3, .bg-forest h4 { color: var(--cream); }
.bg-forest .eyebrow { color: var(--sage); }
.bg-forest .muted, .bg-forest p { color: var(--on-forest-muted); }
.bg-forest .prose p, .bg-forest .prose li { color: var(--on-forest); }
.bg-forest a { color: var(--cream); }
.rule-top { border-top: 1px solid var(--rule); }

.grid { display: grid; gap: var(--gutter); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gutter); }

/* Section heading with ledger margin */
.sec-head { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); gap: var(--gutter); margin-bottom: clamp(2rem, 4vw, 3.5rem); align-items: end; }
.sec-head .sec-num { font-family: var(--serif); font-size: var(--fs-sm); color: var(--muted); border-top: 1px solid var(--ink); padding-top: .8rem; align-self: start; }
.sec-head .sec-num b { display: block; font-size: 2.2rem; font-weight: 300; color: var(--copper); line-height: 1.1; }
.sec-head h2 { max-width: 18ch; }
.sec-head p { margin-top: 1rem; max-width: 60ch; color: var(--muted); }
.bg-forest .sec-head .sec-num { border-color: var(--on-forest-muted); color: var(--on-forest-muted); }

/* ---------- Images: never cropped ---------- */
.fig { position: relative; }
.fig img { width: 100%; height: auto; display: block; background: var(--stone-2); }
.fig figcaption {
  margin-top: .75rem; font-size: var(--fs-xs); line-height: 1.5; color: var(--muted);
  display: flex; gap: .6rem; align-items: baseline;
}
.fig figcaption::before { content: ""; flex: 0 0 18px; height: 1px; background: var(--copper); transform: translateY(-.25em); }
.bg-forest .fig figcaption { color: var(--on-forest-muted); }
/* Frame that preserves full image: fixed box + contain */
.frame-contain { background: var(--stone-2); display: flex; align-items: center; justify-content: center; }
.frame-contain img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
/* Small source images are shown at native size, never stretched */
.fig.native { max-width: var(--native, 100%); }
.fig.native img { width: 100%; }
.fig-mat { padding: clamp(.6rem, 1.2vw, 1rem); background: var(--cream); border: 1px solid var(--rule-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .7rem; min-height: 48px;
  padding: .8rem 1.4rem; border: 1px solid var(--forest); background: var(--forest); color: var(--cream);
  font-family: var(--sans); font-weight: 600; font-size: var(--fs-sm); letter-spacing: .02em;
  text-decoration: none; cursor: pointer; border-radius: var(--radius);
  transition: background .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
}
.btn:hover { background: var(--copper-ink); border-color: var(--copper-ink); }
.btn .arr { transition: transform .25s var(--ease); }
.btn:hover .arr { transform: translateX(4px); }
.btn-ghost { background: transparent; color: var(--forest); }
.btn-ghost:hover { background: var(--forest); color: var(--cream); border-color: var(--forest); }
.bg-forest .btn { background: var(--cream); color: var(--forest); border-color: var(--cream); }
.bg-forest .btn:hover { background: var(--copper-soft); border-color: var(--copper-soft); }
.bg-forest .btn-ghost { background: transparent; color: var(--cream); border-color: var(--on-forest-muted); }

.text-link {
  display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; font-size: var(--fs-sm);
  color: var(--forest); text-decoration: none; border-bottom: 1px solid var(--copper); padding-bottom: 2px;
}
.text-link:hover { color: var(--copper-ink); }
.bg-forest .text-link { color: var(--cream); }

/* ---------- Reveal motion ---------- */
.reveal { opacity: 1; transform: none; }
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}
