/* =========================================================================
   NOTEBOOK · Marvel M John
   An engineer's lab notebook: warm paper, blue graph grid, red margin line,
   ink + pencil sketches that draw themselves as you scroll.
   ========================================================================= */

:root {
  /* paper + desk */
  --paper: #f7f3e8;
  --card: #fffdf7;
  --desk: #d9cfb7;
  /* inks */
  --ink: #1f2937;
  --ink-soft: #374151;
  --pencil: #4b5563;
  --pencil-light: #6b7280;
  --blue: #1d4ed8;
  --blue-deep: #1e3a8a;
  --red: #b91c1c;
  --red-pen: #dc2626;
  --hl: rgba(253, 224, 71, .62);
  /* grid + margin */
  --grid-minor: rgba(37, 99, 235, .075);
  --grid-major: rgba(37, 99, 235, .15);
  --margin-red: rgba(220, 38, 38, .5);
  /* sticky notes + tape */
  --sticky-y: #fff1a1;
  --sticky-p: #ffd8e6;
  --sticky-b: #d6e8ff;
  --sticky-g: #d8f1cf;
  --tape: rgba(236, 226, 196, .8);
  /* type */
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --note: "Kalam", "Segoe Print", "Bradley Hand", cursive;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  /* layout: spiral strip, red margin line, content padding */
  --sheet-max: 1440px;
  --bind: 46px;
  --mx: 150px;
  --pl: 192px;
  --pr: 72px;
  --header-h: 66px;
  --gap-entry: clamp(76px, 9vw, 136px);
  --shadow-card: 0 1px 1px rgba(60, 40, 10, .07), 0 14px 26px -16px rgba(60, 40, 10, .42);
  --hand-radius: 255px 14px 225px 14px / 14px 225px 14px 255px;
}

@media (max-width: 1023.98px) {
  :root { --bind: 34px; --mx: 100px; --pl: 128px; --pr: 36px; }
}
@media (max-width: 767.98px) {
  :root { --bind: 0px; --mx: 18px; --pl: 36px; --pr: 18px; --header-h: 58px; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--desk);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { max-width: 100%; }
img { display: block; height: auto; }
a { color: var(--blue-deep); text-underline-offset: .18em; text-decoration-thickness: 1.5px; }
a:hover { color: var(--blue); }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
:focus-visible { outline: 2.5px dashed var(--red-pen); outline-offset: 4px; border-radius: 6px; }
::selection { background: rgba(253, 224, 71, .7); color: var(--ink); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 10px 16px; background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 8px; font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- background layers ---------- */
.sheet {
  position: relative; z-index: 0;
  max-width: var(--sheet-max); margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(60, 40, 10, .06), 0 0 48px rgba(60, 40, 10, .22);
}
.paper { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
/* graph paper: minor 24px, major 120px. JS nudges it down a little as you scroll, so it trails the page (parallax). */
.grid {
  position: absolute; left: 0; right: 0; top: -120px; bottom: 0;
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: var(--mx) 0, var(--mx) 0, var(--mx) 0, var(--mx) 0;
  will-change: transform;
}
/* paper fibre */
.paper::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: .28;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .34 0 0 0 0 .2 0 0 0 .45 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* the red double margin line */
.paper::after {
  content: ""; position: absolute; top: 0; bottom: 0; z-index: 2;
  left: calc(var(--mx) - 3px); width: 5px;
  border-left: 1.5px solid var(--margin-red);
  border-right: 1px solid rgba(220, 38, 38, .28);
}

/* pencil trail canvas: fixed over the paper, under the content */
.trail {
  position: fixed; inset: 0; z-index: 1; width: 100%; height: 100%;
  pointer-events: none;
}

/* spiral binding down the left edge (scrolls with the page) */
.spiral {
  position: absolute; top: 0; bottom: 0; left: 0; z-index: 1; width: var(--bind);
  pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='46' height='36' viewBox='0 0 46 36'%3E%3Cellipse cx='33' cy='21' rx='4.6' ry='4.6' fill='%23463c2c' fill-opacity='.62'/%3E%3Cpath d='M2 26C1 10 26 4 32 18' fill='none' stroke='%23565c69' stroke-width='3.4' stroke-linecap='round'/%3E%3Cpath d='M4.5 20C7 10 23 7.5 28.5 14' fill='none' stroke='%23eef0f4' stroke-width='1.1' stroke-linecap='round' stroke-opacity='.9'/%3E%3C/svg%3E") 0 18px / var(--bind) auto repeat-y,
    linear-gradient(90deg, rgba(60, 40, 10, .14), rgba(60, 40, 10, 0) 70%);
}
@media (max-width: 767.98px) { .spiral { display: none; } }

/* click doodles live here (behind the content, in page coordinates) */
.doodle-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.click-doodle { position: absolute; width: 46px; height: 46px; margin: -23px 0 0 -23px; overflow: visible; }
.click-doodle path {
  fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round;
}
@media (prefers-reduced-motion: no-preference) {
  .click-doodle path { stroke-dasharray: 1 2; stroke-dashoffset: 1; animation: doodle-draw .55s ease-out forwards; }
  .click-doodle { animation: doodle-fade 3.6s ease-in forwards; }
}
@keyframes doodle-draw { to { stroke-dashoffset: 0; } }
@keyframes doodle-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  margin-left: var(--bind);
  min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 calc(var(--pr) - 12px) 0 calc(var(--pl) - var(--bind));
  background: rgba(247, 243, 232, .9);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border-bottom: 1.5px solid rgba(30, 58, 138, .16);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
  font: 600 .86rem/1 var(--mono); letter-spacing: .16em; color: var(--ink); text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--blue-deep); }
.brand-mark { width: 22px; height: 22px; fill: none; stroke: var(--red-pen); stroke-width: 2; stroke-linejoin: round; transform: rotate(-8deg); }

.nav { position: relative; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 2px; }
.nav-list a {
  position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 4px 11px;
  font: 600 1.42rem/1 var(--hand); color: var(--pencil); text-decoration: none; border-radius: 6px;
}
.nav-list a::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: 52%; height: .5em; z-index: -1;
  background: var(--hl); border-radius: 3px 8px 4px 9px; transform: scaleX(0); transform-origin: left;
  transition: transform .25s ease;
}
.nav-list a:hover { color: var(--blue-deep); }
.nav-list a:hover::before, .nav-list a.is-active::before { transform: scaleX(1); }
.nav-list a.is-active { color: var(--ink); }
.nav-list .dots, .nav-list .pg { display: none; }
.nav-extra { display: none; }
.nav-toggle { display: none; }

@media (max-width: 1099.98px) {
  html.js .nav-toggle {
    display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 14px;
    font: 700 1.45rem/1 var(--hand); color: var(--blue-deep); cursor: pointer;
    background: var(--card); border: 2px solid var(--blue-deep); border-radius: var(--hand-radius);
    box-shadow: 2px 3px 0 rgba(30, 58, 138, .16);
  }
  .nt-lines { display: grid; gap: 4px; width: 20px; }
  .nt-lines i { display: block; height: 2px; background: currentColor; border-radius: 2px; transition: transform .2s; }
  .nt-lines i:nth-child(2) { width: 80%; }
  .nav-toggle[aria-expanded="true"] .nt-lines i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .nt-lines i:nth-child(2) { transform: scaleX(0); }
  .nav-toggle[aria-expanded="true"] .nt-lines i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* the index card dropdown */
  html.js .nav-list {
    position: absolute; right: 0; top: calc(100% + 12px);
    width: min(300px, calc(100vw - 32px));
    display: none; flex-direction: column; align-items: stretch; gap: 0;
    padding: 14px 16px 12px;
    background:
      linear-gradient(var(--red-pen), var(--red-pen)) 0 50px / 100% 1.5px no-repeat,
      repeating-linear-gradient(transparent 0 43px, rgba(59, 130, 246, .2) 43px 44px) 0 51px / 100% calc(100% - 51px) no-repeat,
      var(--card);
    border-radius: 3px; box-shadow: var(--shadow-card), 0 0 0 1px rgba(60, 40, 10, .08);
    transform: rotate(.6deg);
  }
  html.js .nav-list::before {
    content: "Index"; display: block; height: 36px; margin-bottom: 4px;
    font: 700 1.7rem/36px var(--hand); color: var(--blue-deep);
  }
  html.js .topbar.is-open .nav-list { display: flex; }
  html.js .nav-list li { display: block; }
  html.js .nav-list a { display: flex; width: 100%; padding: 0 4px; min-height: 44px; font-size: 1.5rem; color: var(--ink); }
  html.js .nav-list a::before { display: none; }
  html.js .nav-list a.is-active { color: var(--blue); }
  html.js .nav-list .dots { display: block; flex: 1; margin: 0 8px; height: 1.1em; border-bottom: 2px dotted rgba(75, 85, 99, .4); align-self: center; transform: translateY(-.25em); }
  html.js .nav-list .pg { display: inline; font: 500 .82rem/1 var(--mono); color: var(--red); }
  /* without JS: a plain wrapping row of links */
  html:not(.js) .topbar { position: relative; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  html:not(.js) .nav-list { flex-wrap: wrap; }
  html:not(.js) .nav-extra { display: block; }
  html:not(.js) .nav-list a { font-size: 1.25rem; padding: 4px 8px; }
}
@media (max-width: 480px) {
  .brand { font-size: .74rem; letter-spacing: .12em; gap: 8px; }
  .brand-mark { width: 18px; height: 18px; }
  html.js .nav-toggle { padding: 6px 12px; font-size: 1.35rem; }
}
@media (max-width: 374.98px) {
  .brand span { letter-spacing: .08em; }
}

/* ---------- main column + entries ---------- */
main { position: relative; z-index: 2; padding: 0 var(--pr) 0 var(--pl); }
.entry { position: relative; padding-top: var(--gap-entry); scroll-margin-top: calc(var(--header-h) - 10px); }

/* margin column (left of the red line) */
.margin {
  position: absolute; top: calc(var(--gap-entry) - 2px);
  left: calc(var(--bind) - var(--pl) + 6px); width: calc(var(--mx) - var(--bind) - 18px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 26px;
}
.pg { font: 700 1.7rem/1 var(--hand); color: var(--red); transform: rotate(-4deg); white-space: nowrap; }
@media (max-width: 1023.98px) { .pg { font-size: 1.45rem; } }
@media (max-width: 767.98px) {
  .margin { position: static; flex-direction: row; align-items: center; width: auto; margin: 0 0 6px; gap: 12px; }
  .margin .vd { display: none; }
  .pg { font-size: 1.35rem; }
}

/* velocity doodles: JS feeds --dr (extra rotation) and --ds (scale) from scroll speed */
.vd {
  display: block; width: 50px; height: 50px; color: var(--blue); opacity: .72;
  transform: rotate(calc(var(--r, 0deg) + var(--dr, 0deg))) scale(var(--ds, 1));
}
.vd-2 { --r: -12deg; color: var(--pencil); width: 40px; height: 40px; }
.vd[data-k="spin"] { color: var(--pencil); }
.vd[data-k="drift"] { color: var(--red-pen); opacity: .55; }
.vd .dd-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.dd { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.vd-abs { position: absolute; width: 44px; height: 44px; right: calc(var(--pr) * -1 + 12px); }
.vd-abs-a { top: calc(var(--gap-entry) + 10px); }
.vd-abs-b { top: calc(var(--gap-entry) + 30px); color: var(--red-pen); }
@media (max-width: 1023.98px) { .vd-abs { display: none; } }

.entry-head { margin-bottom: 18px; }
.kicker { font: 500 .78rem/1.3 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--pencil); margin-bottom: 8px; }
.hand-h {
  display: inline-block; max-width: 100%;
  font: 700 clamp(2.6rem, 1.75rem + 2.5vw, 4rem)/1 var(--hand); color: var(--blue-deep);
}
.hand-h > span { display: block; }
.uline { display: block; width: 100%; height: 14px; margin-top: 2px; overflow: visible; }
.intro { max-width: 62ch; color: var(--ink-soft); margin-bottom: 8px; }

/* ---------- shared sketch styles ---------- */
.sk, .uline, .ring, .tick, .spine, .note-arrow { overflow: visible; }
.s { fill: none; stroke: var(--blue); stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.s.p2 { stroke-width: 1.1; opacity: .5; }
.s.thin { stroke-width: 1.6; }
.s.pc { stroke: var(--pencil); stroke-width: 1.5; opacity: .85; }
.s.rd { stroke: var(--red-pen); }
.s.hl { stroke: rgba(253, 224, 71, .8); stroke-width: 14; stroke-linecap: butt; }
.t { font-family: var(--note); fill: var(--ink); }
.t-ink { fill: var(--blue-deep); }
.t-pc { fill: var(--pencil); }
.t-rd { fill: var(--red-pen); }

/* Undrawn starting state: only with JS and only when motion is welcome.
   Without JS (or with reduced motion) every sketch is simply fully drawn. */
@media (prefers-reduced-motion: no-preference) {
  .js [data-draw] .s { stroke-dasharray: 1 2; stroke-dashoffset: 1; visibility: hidden; }
  .js [data-draw] .t { opacity: 0; }
  .js mark.hl { --hl-p: 0; }
}

.fig { margin: 0; }
.fig .sk { display: block; width: 100%; height: auto; }
.fig figcaption { margin-top: 12px; font-size: .93rem; line-height: 1.5; color: var(--pencil); }
.fig-n { font: 700 1.35rem/1 var(--hand); color: var(--red); margin-right: 8px; }

/* highlighter: JS sweeps --hl-p from 0 to 1 as the phrase scrolls in */
mark.hl {
  color: inherit;
  padding: 0 .14em; margin: 0 -.08em;
  background: linear-gradient(100deg, rgba(253, 224, 71, 0) 0, var(--hl) .25em, var(--hl) calc(100% - .2em), rgba(253, 224, 71, .25) 100%) no-repeat 0 62% / calc(var(--hl-p, 1) * 100%) 74%;
  border-radius: .25em .5em .3em .45em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* crossed out + corrected */
.fix s { position: relative; text-decoration: none; color: var(--pencil-light); margin-right: .1em; white-space: nowrap; }
.fix s::after {
  content: ""; position: absolute; left: -6%; right: -6%; top: 52%; height: 2.5px;
  background: var(--red-pen); border-radius: 2px; transform: rotate(-5deg);
}
.corr { display: inline-block; font: 700 1.35em/1 var(--hand); font-style: normal; color: var(--red-pen); transform: rotate(-3deg) translateY(-.08em); }

/* ringed word */
.circled { position: relative; display: inline-block; padding: 0 .2em; }
.ring { position: absolute; left: -16%; top: -26%; width: 132%; max-width: none; height: 150%; pointer-events: none; }

/* ---------- buttons, tags, stamps ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px;
  font: 600 1rem/1.1 var(--body); color: var(--blue-deep); text-decoration: none; cursor: pointer;
  background: var(--card); border: 2px solid var(--blue-deep); border-radius: var(--hand-radius);
  box-shadow: 2px 3px 0 rgba(30, 58, 138, .2);
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.btn:hover { color: var(--blue-deep); transform: translate(-1px, -2px) rotate(-.6deg); box-shadow: 4px 6px 0 rgba(30, 58, 138, .2); }
.btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 rgba(30, 58, 138, .2); }
.btn-ink { background: var(--blue-deep); color: #fff; }
.btn-ink:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-sm { min-height: 44px; padding: 8px 18px; font-size: .95rem; }

.tags { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  font: 500 .78rem/1 var(--mono); color: var(--ink-soft);
  padding: 7px 10px; background: rgba(255, 253, 247, .8);
  border: 1.5px solid rgba(31, 41, 55, .45); border-radius: 12px 4px 10px 5px / 5px 10px 4px 12px;
}

.stamp {
  display: inline-block; margin-top: 18px; padding: 8px 12px;
  font: 600 .76rem/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--red); border: 2.5px solid currentColor; border-radius: 6px;
  transform: rotate(-3deg); opacity: .92;
  box-shadow: inset 0 0 0 1px rgba(185, 28, 28, .25);
}
.stamp-blue { color: var(--blue-deep); box-shadow: inset 0 0 0 1px rgba(30, 58, 138, .2); }

.num { font: 700 1.6rem/1 var(--hand); color: var(--red); margin-bottom: 6px; }
h3 { font: 600 1.22rem/1.3 var(--body); color: var(--ink); margin-bottom: 8px; }
.red-note { margin-top: 18px; font: 600 1.4rem/1.2 var(--hand); color: var(--red-pen); transform: rotate(-1.5deg); transform-origin: left; }

/* ---------- tape, sticky notes, index cards ---------- */
.tape {
  position: absolute; width: 96px; height: 28px; z-index: 2; pointer-events: none;
  background: var(--tape);
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, .22) 0 2px, transparent 2px 7px);
  box-shadow: 0 1px 2px rgba(60, 40, 10, .1);
  clip-path: polygon(2% 8%, 8% 0, 16% 6%, 26% 0, 38% 5%, 52% 0, 64% 6%, 78% 0, 90% 5%, 98% 0, 100% 50%, 97% 100%, 85% 94%, 72% 100%, 58% 95%, 44% 100%, 30% 94%, 16% 100%, 4% 95%, 0 50%);
}
.tape-c { left: 50%; top: -14px; transform: translateX(-50%) rotate(-3deg); }
.tape-s { width: 70px; height: 24px; left: 50%; top: -12px; transform: translateX(-50%) rotate(4deg); }

.sticky {
  position: relative; color: var(--ink);
  padding: 22px 18px 16px;
  background: var(--sticky-y);
  box-shadow: 0 1px 1px rgba(60, 40, 10, .08), 0 12px 18px -12px rgba(60, 40, 10, .45);
  border-bottom-right-radius: 14px 6px;
}
.sticky-y { background: linear-gradient(180deg, #fff6b8, var(--sticky-y)); }
.sticky-p { background: linear-gradient(180deg, #ffe4ee, var(--sticky-p)); }
.sticky-b { background: linear-gradient(180deg, #e3effe, var(--sticky-b)); }
.sticky-g { background: linear-gradient(180deg, #e5f6de, var(--sticky-g)); }

.icard {
  position: relative; padding: 0 22px 22px;
  background:
    linear-gradient(rgba(220, 38, 38, .6), rgba(220, 38, 38, .6)) 0 58px / 100% 1.5px no-repeat,
    repeating-linear-gradient(transparent 0 29px, rgba(59, 130, 246, .2) 29px 30px) 0 59px / 100% calc(100% - 59px) no-repeat,
    var(--card);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(60, 40, 10, .06);
  border-radius: 2px;
}
.icard-h { height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.icard-h h3 { margin: 0; font: 700 1.9rem/1 var(--hand); color: var(--blue-deep); white-space: nowrap; }
.layer { font: 500 .7rem/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--pencil); text-align: right; }
.icard .inline, .icard .edu-line, .icard .hand-sm { line-height: 30px; }
.inline { list-style: none; padding: 0; margin: 0; }
.inline li { display: inline; }
.inline li:not(:last-child)::after { content: " · "; color: var(--red-pen); font-weight: 600; }
.hand-sm { margin-top: 0; font: 600 1.3rem/30px var(--hand); color: var(--blue); }
.icard-title { height: 58px; display: flex; align-items: center; font: 700 1.9rem/1 var(--hand); color: var(--blue-deep); }

.box {
  position: relative; padding: 22px 22px 24px;
  background: rgba(255, 253, 247, .62);
  border: 1.5px solid rgba(31, 41, 55, .42);
  border-radius: 14px 4px 12px 6px / 6px 12px 4px 14px;
}

/* ---------- p.01 hero ---------- */
.entry-hero { padding-top: clamp(36px, 5vw, 72px); }
.hero {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .85fr);
  grid-template-areas: "head photo" "body photo";
  column-gap: clamp(32px, 5vw, 80px); align-items: center;
}
.hero-head { grid-area: head; align-self: end; }
.hero-body { grid-area: body; align-self: start; }
.hero-photo { grid-area: photo; }
.belongs { display: flex; align-items: flex-end; gap: 6px; font: 600 1.65rem/1 var(--hand); color: var(--pencil); }
.note-arrow { width: 70px; height: 46px; flex: none; transform: translateY(18px); }
/* sized so "Marvel M John" stays on one line in its column */
.name { display: inline-block; max-width: 100%; margin: 14px 0 0; font: 700 clamp(3.2rem, 9.8vw - 1.7rem, 7.4rem)/.92 var(--hand); color: var(--blue-deep); letter-spacing: .005em; white-space: nowrap; }
.name-text { display: block; }
.name .uline { height: 18px; margin-top: 4px; }
.role { margin-top: 22px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 1.06rem; }
.role strong { font-weight: 600; }
.where { display: inline-flex; align-items: center; gap: 6px; color: var(--pencil); }
.where svg { width: 16px; height: 19px; fill: none; stroke: var(--red-pen); stroke-width: 2; }
.pitch { margin-top: 20px; max-width: 36ch; font-size: clamp(1.18rem, 1rem + .7vw, 1.5rem); line-height: 1.5; color: var(--ink); }
.cta { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 14px 16px; }
.psst { display: none; margin-top: 22px; font: 600 1.35rem/1.2 var(--hand); color: var(--pencil-light); transform: rotate(-1.5deg); transform-origin: left; }
.js .psst { display: block; }

.hero-photo { position: relative; width: 100%; max-width: 420px; justify-self: center; padding: 18px 0 64px; }
.polaroid {
  position: relative; width: 78%; margin: 0;
  padding: 13px 13px 0; background: #fffefa;
  box-shadow: 0 2px 3px rgba(60, 40, 10, .1), 0 22px 34px -18px rgba(60, 40, 10, .55);
  transform: rotate(3deg);
}
/* the photo file is a circle on a dark square: crop to a 3:4 window inside the circle */
.photo { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: #d9d9d6; }
.photo img { position: absolute; max-width: none; width: 169.5%; height: 127.1%; left: -34.75%; top: -13.35%; }
.polaroid figcaption { height: 58px; display: flex; align-items: center; padding-left: 10px; font: 700 1.75rem/1 var(--hand); color: var(--ink-soft); }
.tape-l { left: -24px; top: 6px; transform: rotate(-38deg); }
.tape-r { right: -24px; top: 6px; transform: rotate(36deg); }
.todo {
  position: absolute; right: 0; bottom: 8px; width: 52%; max-width: 210px;
  transform: rotate(-4deg); padding: 24px 16px 14px;
}
.sticky-h { font: 700 1.45rem/1.1 var(--hand); color: var(--blue-deep); margin-bottom: 6px; }
.todo ul { list-style: none; padding: 0; margin: 0; font: 400 1rem/1.75 var(--note); }
.todo li { position: relative; padding-left: 28px; }
.todo li::before { content: ""; position: absolute; left: 2px; top: .5em; width: 15px; height: 15px; border: 1.8px solid var(--ink-soft); border-radius: 2px 4px 2px 3px; }
.todo li::after {
  content: ""; position: absolute; left: 8px; top: .12em; width: 8px; height: 17px;
  border: solid var(--red-pen); border-width: 0 2.6px 2.6px 0; border-radius: 0 0 3px 0;
  transform: rotate(38deg) skewY(-6deg);
}

.fig-arch { margin-top: clamp(48px, 5vw, 72px); max-width: 1120px; }
.sk-arch-v { display: none !important; }
@media (max-width: 639.98px) {
  .sk-arch-h { display: none !important; }
  .sk-arch-v { display: block !important; max-width: 360px; margin: 0 auto; }
}

/* ---------- p.02 summary ---------- */
.summary { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: clamp(36px, 5vw, 80px); align-items: start; }
.lead { font: 600 clamp(1.25rem, 1.05rem + .6vw, 1.5rem)/1.35 var(--body); margin-bottom: 18px; }
.ticks { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.ticks li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; align-items: start; }
.tick { width: 22px; height: 22px; margin-top: 3px; }
.summary-side { display: grid; gap: 44px; }
.fig-pipe .sk { max-width: 600px; }
.facts { padding-bottom: 14px; }
.facts dl { margin: 0; }
.facts dl > div { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; padding: 0; line-height: 30px; }
.facts dt { font: 700 1.3rem/30px var(--hand); color: var(--red); }
.facts dd { font-size: .98rem; line-height: 30px; }

/* ---------- p.03 skills ---------- */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 44px 34px; margin-top: 40px; align-items: start; }
.cards .icard:nth-child(odd) { transform: rotate(-.7deg); }
.cards .icard:nth-child(even) { transform: rotate(.6deg); }
.fig-rack { align-self: center; }
.fig-rack .sk { max-width: 400px; }

/* ---------- p.04 work ---------- */
.job-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(32px, 5vw, 72px); align-items: center; margin-top: 36px; }
.job-main .job-text > p:not(.num):not(.red-note) { max-width: 52ch; }
.fig-tree .sk { max-width: 520px; }
.jobs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; margin-top: 56px; align-items: stretch; }
.jobs .job { display: flex; flex-direction: column; }
.jobs .job .stamp { align-self: flex-start; }
.jobs .sk-small { display: block; margin: 18px 0 0 auto; height: auto; }
.sk-receipts { width: 150px; }
.sk-figma { width: 210px; }
.sk-card { width: 170px; }
.jobs .sk-card { margin-top: auto; padding-top: 18px; }

/* ---------- p.05 freelance ---------- */
.scraps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 30px; margin-top: 40px; align-items: start; }
.scrap {
  position: relative; padding: 30px 22px 24px; background: var(--card);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(60, 40, 10, .06);
}
.scrap:nth-child(1) { transform: rotate(-.9deg); }
.scrap:nth-child(2) { transform: rotate(.7deg); margin-top: 22px; }
.scrap:nth-child(3) { transform: rotate(-.4deg); }
.chain { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 2px 8px; font: 400 1rem/1.6 var(--note); color: var(--blue-deep); }
.chain span[aria-hidden] { color: var(--red-pen); }
.sticky.mini { display: inline-block; margin-top: 18px; padding: 12px 16px 10px; font: 700 1.45rem/1 var(--hand); transform: rotate(3deg); }

/* ---------- p.06 research ---------- */
.exp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 80px); align-items: center; margin-top: 56px; }
.exp .fig .sk { max-width: 520px; }
.exp-flip .fig { order: 2; }
.exp-text > p:not(.num):not(.stamp) { max-width: 46ch; }
.award { display: inline-block; margin-top: 22px; max-width: 280px; transform: rotate(-2.5deg); }
.exp-flip .award { transform: rotate(2deg); }
.award p { font: 400 1rem/1.4 var(--note); }
.award .award-rank { font: 700 1.75rem/1.1 var(--hand); color: var(--red); margin-bottom: 2px; }
.award .circled { padding: 0 .25em; }
.award .circled .ring { left: -14%; width: 136%; top: -22%; height: 150%; }
.exp-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px; margin-top: 64px; }
.exp-sm .award { margin-top: 18px; }
.exp-sm:nth-child(2) .award { transform: rotate(2deg); }

/* ---------- p.07 log ---------- */
.log-wrap { position: relative; margin-top: 40px; --when: 168px; --spine-x: 196px; }
.spine { position: absolute; left: calc(var(--spine-x) - 12px); top: 10px; width: 24px; height: calc(100% - 40px); }
.log { list-style: none; margin: 0; padding: 0; }
.log-item { position: relative; display: grid; grid-template-columns: var(--when) minmax(0, 1fr); gap: 0 64px; padding-bottom: 46px; }
.log-item::before {
  content: ""; position: absolute; left: calc(var(--spine-x) - 8px); top: 10px; width: 16px; height: 16px;
  border: 2.5px solid var(--blue); border-radius: 50% 45% 55% 50%; background: var(--paper);
}
.when { text-align: right; font: 700 1.75rem/1.1 var(--hand); color: var(--blue-deep); padding-top: 2px; }
.when .circled { padding: 0 .3em; }
.when .ring { left: -22%; width: 144%; top: -34%; height: 168%; }
.what { max-width: 60ch; }
.what h3 { margin-bottom: 2px; }
.org { font: 500 .82rem/1.5 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--pencil); margin-bottom: 8px; }
.award-eom { margin-top: 8px; }

/* ---------- p.08 education ---------- */
.edu { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr); gap: 34px; margin-top: 36px; align-items: start; }
.edu .icard:nth-child(1) { transform: rotate(-.5deg); }
.edu .icard:nth-child(2) { transform: rotate(.7deg); }
.edu .icard:nth-child(3) { transform: rotate(-.3deg); }
.edu-line { margin: 0; }
.cgpa { font-weight: 600; }
.cgpa .circled { margin-left: 6px; font: 700 1.45rem/30px var(--hand); color: var(--red); }

/* ---------- p.09 contact ---------- */
.mail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; margin-top: 36px; max-width: 1000px; }
.envelope {
  position: relative; padding: 76px 24px 24px; background: var(--card);
  border: 7px solid transparent;
  border-image: repeating-linear-gradient(-45deg, #d33 0 9px, #fffdf7 9px 15px, #2a54c9 15px 24px, #fffdf7 24px 30px) 7;
  box-shadow: var(--shadow-card);
}
/* envelope flap */
.envelope::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 58px; pointer-events: none;
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), rgba(30, 58, 138, .28) 50%, transparent calc(50% + 1px)) left / 50% 100% no-repeat,
    linear-gradient(to top left, transparent calc(50% - 1px), rgba(30, 58, 138, .28) 50%, transparent calc(50% + 1px)) right / 50% 100% no-repeat;
}
.postmark {
  position: absolute; right: 16px; top: 12px; width: 50px; height: 58px;
  display: grid; place-items: center;
  font: 700 1rem/1 var(--mono); color: var(--red);
  background: #fff6f2; border: 2px dashed rgba(185, 28, 28, .55); transform: rotate(5deg);
}
.env-label { font: 700 2rem/1 var(--hand); color: var(--red); margin-bottom: 8px; }
.addr { display: inline-block; max-width: 100%; padding: 9px 0; font: 600 clamp(1.02rem, .9rem + .5vw, 1.3rem)/1.35 var(--body); color: var(--blue-deep); overflow-wrap: anywhere; }
.env-actions { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.copy { display: none; }
.js .copy { display: inline-flex; }
.copy-status { font: 600 1.3rem/1 var(--hand); color: var(--red-pen); min-height: 1em; }
.plane-wrap { display: flex; justify-content: flex-end; max-width: 1000px; margin-top: 10px; }
.sk-plane { width: 220px; height: auto; }

/* ---------- footer ---------- */
.foot {
  position: relative; z-index: 2;
  margin: clamp(56px, 8vw, 110px) var(--pr) 0 var(--pl);
  padding: 30px 0 48px; border-top: 2px dashed rgba(75, 85, 99, .35);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px;
  font-size: .92rem; color: var(--pencil);
}
.fin { width: 100%; font: 700 1.6rem/1 var(--hand); color: var(--blue-deep); }
.to-top { display: inline-flex; align-items: center; min-height: 44px; font: 700 1.35rem/1 var(--hand); color: var(--red); text-decoration: none; }
.to-top:hover { color: var(--red-pen); text-decoration: underline; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1239.98px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scraps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scrap:nth-child(2) { margin-top: 0; }
  .jobs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edu-main { grid-column: 1 / -1; max-width: 560px; }
}
@media (max-width: 1023.98px) {
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); grid-template-areas: "head head" "body photo"; }
  .hero-body { align-self: center; }
  .name { font-size: clamp(3.2rem, 1rem + 8vw, 6rem); }
  /* narrow photo column: the to-do note sits under the polaroid instead of over its caption */
  .hero-photo { padding-bottom: 8px; }
  .polaroid { width: 86%; }
  .todo { position: relative; right: auto; bottom: auto; width: 74%; max-width: 230px; margin: 8px 0 0 auto; transform: rotate(-3deg); }
  .summary { grid-template-columns: minmax(0, 1fr); }
  .summary-side { gap: 40px; }
  .facts { max-width: 560px; }
  .job-main { grid-template-columns: minmax(0, 1fr); }
  .fig-tree { max-width: 520px; }
  .exp { grid-template-columns: minmax(0, 1fr); gap: 24px; margin-top: 64px; }
  .exp-flip .fig { order: 0; }
  .exp .fig { max-width: 520px; }
  .log-wrap { --when: 120px; --spine-x: 146px; }
  .log-item { gap: 0 52px; }
}
@media (max-width: 767.98px) {
  body { font-size: 1rem; }
  .hero { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "body" "photo"; }
  .hero-photo { margin-top: 36px; padding-bottom: 64px; }
  .todo { position: absolute; right: 0; bottom: 8px; width: 50%; margin: 0; transform: rotate(-4deg); }
  .name { font-size: clamp(2.9rem, 1rem + 10.5vw, 4.4rem); }
  .hero-photo { max-width: 330px; }
  .polaroid { width: 74%; }
  .summary-side { grid-template-columns: minmax(0, 1fr); }
  .cards, .scraps, .jobs, .edu, .exp-pair, .mail { grid-template-columns: minmax(0, 1fr); }
  .cards { gap: 36px; }
  .cards .icard:nth-child(odd), .edu .icard:nth-child(odd), .scrap:nth-child(odd) { transform: rotate(-.5deg); }
  .cards .icard:nth-child(even), .edu .icard:nth-child(even), .scrap:nth-child(even) { transform: rotate(.4deg); }
  .edu-main { max-width: none; }
  .icard { padding: 0 18px 18px; }
  .facts dl > div { grid-template-columns: 88px minmax(0, 1fr); gap: 8px; }
  .log-wrap { --spine-x: 10px; }
  .log-item { grid-template-columns: minmax(0, 1fr); padding-left: 36px; padding-bottom: 36px; }
  .when { text-align: left; margin-bottom: 6px; }
  .when .circled { margin-left: -.2em; }
  .envelope { padding: 70px 18px 20px; }
  .postmark { width: 44px; height: 50px; }
  .env-label { font-size: 1.8rem; }
  .sk-plane { width: 170px; }
  .foot { flex-direction: column; align-items: flex-start; }
  .todo .sticky-h { font-size: 1.28rem; }
  /* sketches shrink on phones: keep their pencil labels legible */
  .sk-glove .t-pc, .sk-robot .t-pc, .sk-headset .t-pc, .sk-flowtree .t-pc { font-size: 21px; }
  .sk-pipeline .t-pc { font-size: 20px; }
}
@media (max-width: 400px) {
  .icard-h h3 { font-size: 1.65rem; }
  .layer { font-size: .64rem; letter-spacing: .06em; }
  .cta { gap: 12px; }
  .cta .btn { padding: 10px 15px; }
}

/* =========================================================================
   Reduced motion: no continuous motion, sketches stay fully drawn
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .vd { transform: rotate(var(--r, 0deg)); }
  .grid { transform: none !important; }
  .trail { display: none; }
}

@media print {
  .paper, .trail, .spiral, .doodle-layer, .topbar, .vd { display: none !important; }
  body { background: #fff; }
}
