/* ==========================================================================
   Plain Paper — a single stylesheet for the whole site.
   Organised as: tokens, reset, layout, type, components, pages, motion.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */
:root {
  --paper:      #f4efe4;
  --paper-deep: #e8e0cf;
  --ink:        #23201c;
  --ink-soft:   #5d564c;
  --ink-faint:  #8f8677;
  --rule:       #cfc5b0;
  --clay:       #a9503c;
  --clay-deep:  #7e3626;
  --moss:       #5a6b4a;

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans:  "Karla", "Helvetica Neue", sans-serif;

  --measure: 62ch;
  --gutter: clamp(1.25rem, 5vw, 5rem);
  --step: clamp(3rem, 7vw, 6.5rem);
  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body, h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul[class], ol[class] { list-style: none; padding: 0; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }

/* --- Page shell ----------------------------------------------------------- */
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--sans);
  letter-spacing: .005em;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Fixed grain + a slow warm wash behind everything. Never scrolls, never
   repaints, so it costs nothing while the page moves. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}
body::after {
  content: "";
  position: fixed;
  inset: -20vh -10vw auto;
  height: 70vh;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(48% 60% at 18% 12%, rgba(169, 80, 60, .16), transparent 70%),
    radial-gradient(42% 55% at 82% 0%, rgba(90, 107, 74, .14), transparent 72%);
}
.shell { position: relative; z-index: 1; display: contents; }

.wrap {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* --- Masthead ------------------------------------------------------------- */
.masthead {
  position: relative;
  z-index: 3;
  padding-block: 1.6rem;
}
.masthead .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: baseline;
  justify-content: space-between;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font: 600 1.0625rem/1 var(--serif);
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
}
.wordmark svg { width: 26px; height: 26px; overflow: visible; }
.wordmark .nib { transform-origin: 13px 13px; transition: transform .5s var(--ease); }
.wordmark:hover .nib { transform: rotate(-24deg); }

.nav { display: flex; gap: clamp(1rem, 3vw, 2.25rem); font-size: .9375rem; }
.nav a {
  position: relative;
  text-decoration: none;
  padding-block: .25rem;
  color: var(--ink-soft);
  transition: color .25s var(--ease);
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s var(--ease);
}
.nav a:hover { color: var(--ink); }
.nav a:hover::after { transform: scaleX(1); }
.nav a[aria-current="page"] { color: var(--clay-deep); }
.nav a[aria-current="page"]::after { transform: scaleX(1); }

/* --- Type ----------------------------------------------------------------- */
.display {
  font-family: var(--serif);
  font-weight: 600;
  font-variation-settings: "SOFT" 20, "WONK" 1;
  line-height: .96;
  letter-spacing: -.02em;
  font-size: clamp(2.9rem, 9.5vw, 6.4rem);
  text-wrap: balance;
}
.display em {
  font-style: italic;
  font-variation-settings: "SOFT" 60, "WONK" 1;
  color: var(--clay-deep);
}
h2 {
  font: 600 clamp(1.5rem, 3.4vw, 2.3rem)/1.1 var(--serif);
  letter-spacing: -.015em;
  text-wrap: balance;
}
h3 { font: 600 1.1875rem/1.25 var(--serif); letter-spacing: -.01em; }
.lede { font-size: clamp(1.0625rem, 2vw, 1.3125rem); color: var(--ink-soft); max-width: 34ch; }
.prose { max-width: var(--measure); }
.prose p + p { margin-top: 1.1em; }
.prose a { text-decoration-thickness: 1px; text-underline-offset: .22em; text-decoration-color: var(--clay); }
.eyebrow {
  font-size: .75rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.small { font-size: .875rem; color: var(--ink-soft); }
code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: .875em;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .1em .35em;
}

/* --- Hero ----------------------------------------------------------------- */
.hero {
  padding-block: clamp(2rem, 6vw, 5rem) var(--step);
  position: relative;
}
.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: end;
}
.hero-side { padding-bottom: .6rem; display: grid; gap: 1.5rem; }
.hero-figure {
  position: relative;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--rule);
  background: linear-gradient(160deg, #fbf8f0, var(--paper-deep));
  box-shadow: 14px 14px 0 -1px rgba(35, 32, 28, .07);
  overflow: hidden;
  rotate: -1.4deg;
}
.hero-figure svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* --- Rules & sections ----------------------------------------------------- */
.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }
section { padding-block: var(--step); }
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 14rem) minmax(0, 1fr);
  gap: clamp(1rem, 4vw, 3rem);
  align-items: start;
  margin-bottom: clamp(2rem, 4vw, 3.25rem);
}

/* --- Ledger (asymmetric, zig-zag list) ------------------------------------ */
.ledger { display: grid; gap: 0; counter-reset: row; }
.ledger li {
  counter-increment: row;
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(.75rem, 3vw, 2.5rem);
  align-items: baseline;
  padding-block: 1.6rem;
  border-top: 1px solid var(--rule);
  transition: background-color .3s var(--ease), padding-inline .3s var(--ease);
}
.ledger li:last-child { border-bottom: 1px solid var(--rule); }
.ledger li::before {
  content: "0" counter(row);
  font: 600 .8125rem/1 var(--serif);
  letter-spacing: .1em;
  color: var(--clay);
}
.ledger li:nth-child(even) { transform: translateX(clamp(0px, 2vw, 2.5rem)); }
.ledger li:hover { background: rgba(232, 224, 207, .55); }
.ledger p { color: var(--ink-soft); font-size: .9688rem; }

/* --- Cards / panels ------------------------------------------------------- */
.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: clamp(1rem, 2.5vw, 1.75rem);
}
.panel {
  border: 1px solid var(--rule);
  background: rgba(251, 248, 240, .7);
  padding: clamp(1.25rem, 2.5vw, 1.9rem);
  display: grid;
  gap: .6rem;
  align-content: start;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.panel:nth-child(2) { margin-top: clamp(0px, 2vw, 2rem); }
.panel:nth-child(3) { margin-top: clamp(0px, 4vw, 3.5rem); }
.panel:hover { transform: translateY(-4px); box-shadow: 10px 12px 0 -2px rgba(35, 32, 28, .08); }
.panel p { color: var(--ink-soft); font-size: .9375rem; }

/* --- Buttons / links ------------------------------------------------------ */
.actions { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; margin-top: 2rem; }
.btn {
  --bg: var(--ink);
  --fg: var(--paper);
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  background: var(--bg);
  color: var(--fg);
  text-decoration: none;
  font-size: .9375rem;
  letter-spacing: .02em;
  padding: .8rem 1.4rem;
  border: 1px solid var(--ink);
  transition: transform .2s var(--ease), background-color .25s var(--ease), color .25s var(--ease);
}
.btn:hover { transform: translateY(-2px); background: var(--clay-deep); border-color: var(--clay-deep); }
.btn:active { transform: translateY(0); }
.btn--ghost { --bg: transparent; --fg: var(--ink); border-color: var(--rule); }
.btn--ghost:hover { --fg: var(--paper); }
.btn svg { width: 15px; height: 15px; }

.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  font-size: .9375rem;
  color: var(--clay-deep);
}
.arrow-link span { transition: transform .25s var(--ease); }
.arrow-link:hover span { transform: translateX(4px); }

/* --- Definition pairs (contact / about detail) ---------------------------- */
.pairs { display: grid; gap: 0; }
.pairs > div {
  display: grid;
  grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
  gap: clamp(.5rem, 3vw, 2rem);
  padding-block: 1.15rem;
  border-top: 1px solid var(--rule);
}
.pairs > div:last-child { border-bottom: 1px solid var(--rule); }
.pairs dt { color: var(--ink-faint); font-size: .8125rem; letter-spacing: .16em; text-transform: uppercase; }
.pairs dd { margin: 0; }

/* --- Footer --------------------------------------------------------------- */
.foot {
  margin-top: auto;
  border-top: 1px solid var(--rule);
  padding-block: 2.25rem 3rem;
  position: relative;
  z-index: 1;
}
.foot .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
  align-items: center;
  color: var(--ink-faint);
  font-size: .875rem;
}
.foot a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.foot a:hover { color: var(--ink); border-color: currentColor; }

/* --- 404 ------------------------------------------------------------------ */
.void { padding-block: clamp(4rem, 12vw, 9rem); }
.void .display { font-size: clamp(5rem, 22vw, 14rem); line-height: .8; }

/* --- Focus visibility ----------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--clay-deep);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- Motion: one staggered entrance per page ------------------------------ */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes draw { from { stroke-dashoffset: 620; } to { stroke-dashoffset: 0; } }

.rise { animation: rise .8s var(--ease) both; }
.rise:nth-child(2) { animation-delay: .08s; }
.rise:nth-child(3) { animation-delay: .16s; }
.rise:nth-child(4) { animation-delay: .24s; }
.rise:nth-child(5) { animation-delay: .32s; }
.hero-side .rise { animation-delay: .22s; }
.sketch path, .sketch circle, .sketch line, .sketch rect {
  stroke-dasharray: 620;
  animation: draw 2.6s var(--ease) .3s both;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .sketch path, .sketch circle, .sketch line, .sketch rect { stroke-dashoffset: 0; }
}

/* --- Narrow screens ------------------------------------------------------- */
@media (max-width: 52rem) {
  .hero .wrap,
  .section-head { grid-template-columns: 1fr; }
  .hero-figure { max-width: 22rem; rotate: -1deg; }
  .ledger li {
    grid-template-columns: 2.75rem minmax(0, 1fr);
    row-gap: .35rem;
  }
  .ledger li p { grid-column: 2; }
  .ledger li:nth-child(even) { transform: none; }
  .panel:nth-child(n) { margin-top: 0; }
  .pairs > div { grid-template-columns: 1fr; row-gap: .25rem; }
}
