/* A field-journal look: paper, ink, hand-drawn edges, a lamp for dark mode.
   Built for smooth scrolling: no blur filters, no backdrop-filter, no scroll
   listeners, no animated full-width layers. Only opacity and transform move. */

:root {
  --paper: #f5efe1;
  --paper-2: #ece3cf;
  --card: #fbf7ec;
  --ink: #2b2418;
  --muted: #675b46;
  --green: #2f5d3a;
  --on-green: #f7f2e4;
  --rust: #a8452a;
  --hl: #f3d86b;
  --on-hl: #2b2418;
  --shadow: rgba(43, 36, 24, 0.28);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --irregular: 8px 14px 9px 15px / 14px 8px 15px 9px;
  --ease: cubic-bezier(0.22, 0.8, 0.2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #16120c;
  --paper-2: #1e1911;
  --card: #221c13;
  --ink: #efe3c8;
  --muted: #b6a88c;
  --green: #8fbf8a;
  --on-green: #16120c;
  --rust: #e8956b;
  --hl: #e8b84a;
  --shadow: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --paper: #16120c;
    --paper-2: #1e1911;
    --card: #221c13;
    --ink: #efe3c8;
    --muted: #b6a88c;
    --green: #8fbf8a;
    --on-green: #16120c;
    --rust: #e8956b;
    --hl: #e8b84a;
    --shadow: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--paper);
  background-image: url("/paper.png");
  color: var(--ink);
  font: 400 1.125rem/1.62 var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-family: var(--display); font-weight: 600; letter-spacing: -0.02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--green); text-underline-offset: 0.2em; text-decoration-thickness: 1.5px; }
a:hover { text-decoration-thickness: 2.5px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--rust);
  outline-offset: 3px;
}

mark { padding: 0 0.15em; border-radius: 3px; background: var(--hl); color: var(--on-hl); -webkit-box-decoration-break: clone; box-decoration-break: clone; }

.wrap { width: 100%; max-width: 62rem; margin: 0 auto; padding: 0 clamp(1.25rem, 4vw, 2.25rem); }
.hand { font-family: var(--hand); font-weight: 600; color: var(--rust); line-height: 1.1; }

.skip { position: fixed; left: 1rem; top: -4rem; z-index: 60; padding: 0.5rem 0.9rem; background: var(--ink); color: var(--paper); border-radius: 6px; }
.skip:focus { top: 1rem; }

/* ───────── Header ───────── */
.top { position: sticky; top: 0; z-index: 40; background: var(--paper); border-bottom: 2px solid var(--ink); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; min-height: 3.6rem; }
.brand { color: var(--ink); font: 700 1.25rem var(--display); letter-spacing: -0.02em; text-decoration: none; white-space: nowrap; }
.brand span { color: var(--rust); }

nav.main ul { display: flex; gap: 0.1rem 0.35rem; }
nav.main a {
  display: block;
  padding: 0.3rem 0.6rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 1rem;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}
nav.main a:hover { color: var(--ink); }
nav.main a[aria-current] { color: var(--ink); border-bottom-color: var(--rust); }

.top-right { display: flex; align-items: center; gap: 0.9rem; }
.top-resume { font-weight: 600; white-space: nowrap; }

.lamp {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0.2rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 600 1.2rem var(--hand);
  cursor: pointer;
}
.lamp-track {
  position: relative;
  width: 2.3rem;
  height: 1.25rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-2);
  transition: background-color 0.25s;
}
.lamp-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.3s var(--ease), background-color 0.25s;
}
.lamp[aria-pressed="true"] .lamp-track { background: color-mix(in srgb, var(--hl) 35%, var(--paper-2)); }
.lamp[aria-pressed="true"] .lamp-knob { transform: translateX(1.05rem); background: var(--hl); }

/* ───────── Hero ───────── */
.hero { position: relative; overflow: hidden; padding: clamp(3rem, 8vw, 6rem) 0 clamp(3rem, 7vw, 5rem); }
:root[data-theme="dark"] .hero::before {
  content: "";
  position: absolute;
  top: -25%;
  left: -10%;
  width: 70%;
  height: 90%;
  background: radial-gradient(closest-side, rgba(232, 184, 74, 0.16), transparent);
  pointer-events: none;
}
.hero .wrap { position: relative; }
.status { font-size: 1.6rem; }
.hero h1 {
  margin-top: 0.4rem;
  font-size: clamp(3rem, 10.5vw, 7.25rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.035em;
}
.hero h1 .l2 { display: block; color: var(--green); }
.lede { max-width: 24ch; margin-top: 1.5rem; font: 500 clamp(1.5rem, 3.4vw, 2.2rem) / 1.2 var(--display); letter-spacing: -0.015em; }
.focus { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.5rem; }
.chip, .tags li, .focus li {
  padding: 0.12rem 0.75rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--irregular);
  background: var(--card);
  font-size: 0.97rem;
  line-height: 1.5;
}
.blurb { max-width: 56ch; margin-top: 1.5rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }
.hint { margin-top: 2rem; font-size: 1.5rem; }
.sprig { position: absolute; right: 2%; top: 0; width: clamp(9rem, 22vw, 16rem); height: auto; color: var(--green); }
.sprig path { fill: color-mix(in srgb, var(--green) 20%, transparent); stroke: var(--green); stroke-width: 2; stroke-linejoin: round; }
.sprig .stem { fill: none; stroke-linecap: round; stroke-width: 3; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  border: 2px solid var(--ink);
  border-radius: var(--irregular);
  background: var(--card);
  color: var(--ink);
  font: 600 1.02rem var(--serif);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: none; box-shadow: none; }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--on-green); }
.btn.primary:hover { box-shadow: 3px 3px 0 var(--ink); }
.btn svg { width: 1.05em; height: 1.05em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── Chapters ───────── */
.chapter { padding: clamp(3.5rem, 8vw, 6rem) 0 0; }
.chapter:last-of-type { padding-bottom: clamp(3.5rem, 8vw, 6rem); }
.chapter-head { margin-bottom: clamp(1.75rem, 4vw, 2.75rem); }
.chapter-head .hand { font-size: 1.55rem; }
.chapter-head h2 { margin-top: 0.15rem; font-size: clamp(2.3rem, 6.5vw, 4rem); font-weight: 700; line-height: 1; }
.chapter-head .sub { max-width: 52ch; margin-top: 0.9rem; color: var(--muted); }
.squig { display: block; width: clamp(7rem, 18vw, 11rem); height: 0.8rem; margin-top: 0.6rem; color: var(--green); overflow: visible; }
.squig path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.1s var(--ease) 0.15s; }
.js .rv:not(.in) .squig path { stroke-dashoffset: 1; }
.rv.in .squig path, html:not(.js) .squig path { stroke-dashoffset: 0; }

/* ───────── Measurements ───────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: 0; border-top: 2px solid var(--ink); }
.stat { padding: 1.5rem 1.5rem 1.6rem 0; border-bottom: 1.5px dashed color-mix(in srgb, var(--ink) 45%, transparent); }
.stat .num { display: block; color: var(--green); font: 700 clamp(2.8rem, 6vw, 4rem) / 1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat p { max-width: 30ch; margin-top: 0.5rem; }
.stat .hand { display: block; margin-top: 0.35rem; font-size: 1.3rem; }

/* ───────── Expeditions ───────── */
.exp { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 1.25rem 2.5rem; padding: 2.25rem 0; border-top: 2px solid var(--ink); }
.exp:last-child { border-bottom: 2px solid var(--ink); }
.exp-meta .idx { display: block; color: var(--rust); font: 700 2.6rem / 1 var(--display); }
.exp-meta p { margin-top: 0.5rem; color: var(--muted); font-size: 1rem; line-height: 1.45; }
.exp-main h3 { font-size: clamp(1.7rem, 3.6vw, 2.3rem); line-height: 1.1; }
.exp-role { margin-top: 0.15rem; font-weight: 600; }
.exp-summary { max-width: 60ch; margin-top: 0.8rem; color: var(--muted); }
.work { margin-top: 1.75rem; }
.work h4 { font-size: 1.3rem; line-height: 1.25; }
.points { display: grid; gap: 0.6rem; max-width: 66ch; margin-top: 0.8rem; }
.points li { position: relative; padding-left: 1.5rem; }
.points li::before {
  content: "";
  position: absolute;
  left: 0.1rem;
  top: 0.55em;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 0 100% 0 100%;
  background: var(--green);
  transform: rotate(-8deg);
}
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; }
.tags li { font-size: 0.92rem; padding: 0.05rem 0.65rem; background: transparent; }

.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 2.5rem; margin-top: 3rem; }
.pair h3 { font-size: 1.6rem; }
.pair h3 + .squig { margin-bottom: 1rem; }
.entry + .entry { margin-top: 1.25rem; }
.entry .hand { font-size: 1.3rem; }
.entry h4 { font-size: 1.2rem; line-height: 1.3; }
.entry p:not(.hand) { color: var(--muted); }

/* ───────── Specimen plates ───────── */
.plates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 2.5rem 2rem; padding-top: 0.5rem; }
.plate {
  position: relative;
  padding: 1.9rem 1.6rem 1.5rem;
  background: var(--card);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.35s var(--ease);
}
.plate:hover, .plate:focus-within { transform: rotate(0deg) translateY(-4px); }
.plate::before {
  content: "";
  position: absolute;
  top: -0.5rem;
  left: 50%;
  width: 0.95rem;
  height: 0.95rem;
  margin-left: -0.475rem;
  border-radius: 50%;
  background: var(--rust);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.25), 0 3px 4px var(--shadow);
}
.sketch { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; color: var(--ink); }
.sketch path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sketch .again { opacity: 0.45; stroke-width: 1.2; }
.plate > :not(.sketch) { position: relative; }
.plate .no { font-size: 1.35rem; }
.plate h3 { margin-top: 0.1rem; font-size: clamp(1.5rem, 3vw, 1.95rem); line-height: 1.12; }
.plate .latin { margin-top: 0.15rem; color: var(--muted); font-style: italic; }
.plate .kind { margin-top: 0.7rem; color: var(--green); font-weight: 600; font-size: 1rem; }
.plate .summary { margin-top: 0.5rem; }
.plate .tags { margin-top: 1rem; }
.plate-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }
.plate-links .btn { padding: 0.4rem 0.9rem; font-size: 0.97rem; }
details.more { margin-top: 1rem; }
details.more summary { display: inline-block; color: var(--rust); font: 600 1.35rem var(--hand); cursor: pointer; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+ "; }
details.more[open] summary::before { content: "− "; }
details.more .points { margin-top: 0.6rem; font-size: 1.02rem; }
.growing { margin-top: 3.5rem; }
.growing .plates { grid-template-columns: minmax(0, 28rem); }
.tape { display: inline-block; margin-bottom: 0.4rem; padding: 0.05rem 0.6rem; background: var(--hl); color: var(--on-hl); font: 600 1.2rem var(--hand); transform: rotate(-2deg); }

/* ───────── Search ("Try it") ───────── */
.ask { position: relative; max-width: 46rem; padding: 1.75rem 1.5rem 1.5rem; background: var(--card); }
.ask > :not(.sketch) { position: relative; }
.ask label { display: block; margin-bottom: 0.5rem; font: 600 1.5rem var(--hand); color: var(--rust); }
.field { display: flex; gap: 0.5rem; padding: 0.3rem; border: 2px solid var(--ink); border-radius: var(--irregular); background: var(--paper); }
.field:focus-within { outline: 3px solid var(--rust); outline-offset: 3px; }
.field input { flex: 1; min-width: 0; padding: 0.55rem 0.8rem; border: 0; background: transparent; color: var(--ink); font: inherit; -webkit-appearance: none; appearance: none; }
.field input:focus, .field input:focus-visible { outline: none; }
.field input::placeholder { color: var(--muted); opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.chips button {
  padding: 0.15rem 0.8rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--irregular);
  background: transparent;
  color: var(--ink);
  font: 400 0.97rem var(--serif);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s var(--ease);
}
.chips button:hover { background: var(--hl); color: var(--on-hl); transform: translateY(-2px); }
.fineprint { max-width: 58ch; margin-top: 1rem; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
#answers { margin-top: 1.25rem; }
#answers:empty { margin: 0; }
.status-line, .empty { margin-bottom: 0.8rem; color: var(--muted); }
.results { display: grid; gap: 0.9rem; }
.result {
  padding: 1rem 1.15rem;
  border: 1.5px solid var(--ink);
  border-left-width: 6px;
  border-left-color: var(--green);
  border-radius: 4px 10px 6px 10px;
  background: var(--paper);
  animation: rise 0.45s var(--ease) both;
  animation-delay: calc(var(--i) * 70ms);
}
.result h3 { margin: 0.25rem 0 0.35rem; font-size: 1.2rem; line-height: 1.25; }
.result-meta { display: flex; flex-wrap: wrap; gap: 0.1rem 1rem; color: var(--muted); font-size: 0.93rem; }
.result-section { color: var(--rust); font: 600 1.25rem var(--hand); }
.score { margin-left: auto; font-variant-numeric: tabular-nums; }
.matched { margin-top: 0.5rem; color: var(--muted); font-size: 0.93rem; }
.jump { display: inline-block; margin-top: 0.5rem; font-weight: 600; font-size: 0.98rem; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ───────── Toolkit ───────── */
.kits { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1.75rem 2.5rem; }
.kit .hand { font-size: 1.45rem; }
.kit .tags { margin-top: 0.4rem; }

/* ───────── Contact ───────── */
.send { position: relative; max-width: 46rem; padding: clamp(1.75rem, 5vw, 3rem); background: var(--card); }
.send > :not(.sketch) { position: relative; }
.send h2 { font-size: clamp(2.3rem, 6.5vw, 4rem); font-weight: 700; line-height: 1; }
.send p:not(.hand) { max-width: 38ch; margin-top: 1rem; font: 500 clamp(1.25rem, 2.6vw, 1.6rem) / 1.35 var(--display); letter-spacing: -0.01em; }
.send .actions { margin-top: 1.5rem; }
.foot { padding: 0 0 3rem; color: var(--muted); font-size: 0.95rem; }
.foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.4rem 2rem; padding-top: 1.5rem; border-top: 2px solid var(--ink); }

/* ───────── Reveal ───────── */
.js .rv { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease var(--d, 0ms), transform 0.6s var(--ease) var(--d, 0ms); }
.js .rv.in { opacity: 1; transform: none; }
.js .plate.rv { transform: translateY(14px) rotate(var(--tilt, 0deg)); }
.js .plate.rv.in { transform: rotate(var(--tilt, 0deg)); }

/* ───────── Responsive ───────── */
@media (max-width: 52rem) {
  .sprig { display: none; }
  .top-in { flex-wrap: wrap; padding-top: 0.5rem; padding-bottom: 0.25rem; }
  nav.main { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  nav.main::-webkit-scrollbar { display: none; }
  nav.main ul { width: max-content; }
  html { scroll-padding-top: 6.5rem; }
  .exp { grid-template-columns: 1fr; gap: 0.75rem; }
  .exp-meta { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
  .exp-meta p { margin-top: 0; }
  .top-resume { display: none; }
}
@media (max-width: 34rem) {
  .field { flex-direction: column; }
  .field .btn { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0ms !important; transition-duration: 0.001ms !important; transition-delay: 0ms !important; }
  .js .rv, .js .plate.rv { opacity: 1; transform: rotate(var(--tilt, 0deg)); }
  .squig path { stroke-dashoffset: 0 !important; }
}

@media print {
  .top, .ask, .sprig, .skip { display: none; }
  body { background: #fff; color: #000; }
  .js .rv { opacity: 1; transform: none; }
}
