/* =====================================================================
   PORTFOLIO — shared design system
   Aesthetic: "limestone studio" — warm, editorial, architectural.
   Light, paper-warm surfaces with olive + pine accents and a faint
   drafting grid. Serif headlines, grotesque body, mono spec labels.
   Palette (NEXGRIDCO):
     Studio White #F3F2ED · Warm Linen #E6DDD0 · Limestone #C9C4B8
     Olive Thread #7A7D5A · Stone Shadow #586B54
   Fonts: Spectral (display) · Hanken Grotesk (body) · Spline Sans Mono
   ===================================================================== */

/* ------------------------------ Tokens ------------------------------ */
:root {
  /* Surfaces — oat, tinted toward cocoa */
  --bg:        #F3E6D8;   /* Oat Silk */
  --bg-1:      #ECDDCC;   /* card surface  */
  --bg-2:      #E4D2BE;   /* deeper oat, elevated */
  --bg-inset:  #F6ECE0;

  /* Lines / borders — warm tan */
  --line:        #D9C8B5;
  --line-soft:   #E6D8C7;
  --line-strong: #C7B39E;

  /* Ink — cocoa */
  --text:       #3F3035;  /* deep cocoa */
  --text-dim:   #5F4B51;  /* muted cocoa */
  --text-faint: #6F5A62;  /* faint cocoa-mauve (AA for small labels) */

  /* Accent — cocoa + dusty mauve */
  --accent:        #4E3D42;  /* Cocoa Dust — primary accent */
  --accent-bright: #3A2D31;  /* darker for hover/press */
  --accent-dim:    #8A6F77;  /* dusty mauve — secondary */
  --accent-glow:   rgba(78, 61, 66, 0.14);
  --on-accent:     #F3E6D8;

  /* Faint drafting-grid lines */
  --blueprint: #6E5A60;

  /* Dark footer band */
  --footer-bg:    #443439;
  --footer-line:  rgba(243, 230, 216, 0.16);

  /* Spacing — 4pt scale, semantic */
  --space-2xs: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;
  --space-5xl: 8rem;

  /* Type scale — fluid */
  --step--1: clamp(0.78rem, 0.76rem + 0.10vw, 0.84rem);
  --step-0:  clamp(0.98rem, 0.95rem + 0.15vw, 1.07rem);
  --step-1:  clamp(1.15rem, 1.05rem + 0.45vw, 1.45rem);
  --step-2:  clamp(1.5rem,  1.28rem + 1.05vw, 2.3rem);
  --step-3:  clamp(2rem,    1.55rem + 2.1vw,  3.5rem);
  --step-4:  clamp(2.7rem,  1.95rem + 3.6vw,  5.3rem);
  --step-5:  clamp(3.4rem,  2.2rem  + 5.7vw,  7.5rem);

  --display: "Spectral", Georgia, "Times New Roman", serif;
  --body:    "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --mono:    "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 66ch;
  --shell:   min(1240px, 100% - var(--space-xl));
  --radius:  6px;
  --ease:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
}

/* ------------------------------ Reset ------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  position: relative;
}

/* Drafting grid + warm lift painted behind everything (subtle cursor parallax) */
body::before {
  content: "";
  position: fixed;
  inset: -40px;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right,  color-mix(in oklab, var(--blueprint) 16%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in oklab, var(--blueprint) 16%, transparent) 1px, transparent 1px);
  background-size: 72px 72px;
  background-position: var(--gx, 0px) var(--gy, 0px);
  opacity: 0.65;
  transition: background-position 0.6s var(--ease);
  -webkit-mask-image: radial-gradient(120% 95% at 50% 0%, #000 0%, transparent 72%);
          mask-image: radial-gradient(120% 95% at 50% 0%, #000 0%, transparent 72%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(90% 55% at 50% -8%, color-mix(in oklab, var(--bg-2) 70%, transparent), transparent 60%);
}

img, svg { display: block; max-width: 100%; }

/* ------------------------------ Type -------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.012em;
  color: var(--text);
  text-wrap: balance;
}
h1 { font-size: var(--step-5); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); font-weight: 600; }
p  { text-wrap: pretty; }

a { color: inherit; text-decoration: none; }

.eyebrow {
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}
.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.mono { font-family: var(--mono); }
.dim  { color: var(--text-dim); }
.faint{ color: var(--text-faint); }
.accent { color: var(--accent); }

/* ----------------------------- Layout ------------------------------- */
.shell { width: var(--shell); margin-inline: auto; }
.section { padding-block: clamp(var(--space-3xl), 8vw, var(--space-5xl)); position: relative; z-index: 1; }
main { position: relative; z-index: 1; }

.section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-lg);
  align-items: baseline;
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--line);
}
.section-head .idx {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--text-faint);
  letter-spacing: 0.1em;
  padding-top: 0.4em;
}
.section-head h2 { margin-bottom: var(--space-sm); }
.section-head p  { color: var(--text-dim); max-width: var(--measure); }

/* --------------------------- Top nav -------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
}
/* No hard line — a frosted gradient. The blur + oat tint are full at the top
   and fade to nothing just below the bar, so the header dissolves into the
   page. Living on a pseudo (not .nav) also keeps it from being a
   backdrop-filtered ancestor of the mobile menu, so both can still frost. */
.nav::before {
  content: "";
  position: absolute;
  inset: 0 0 -30px 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom,
    color-mix(in oklab, var(--bg) 82%, transparent) 0%,
    color-mix(in oklab, var(--bg) 52%, transparent) 50%,
    transparent 100%);
  -webkit-backdrop-filter: blur(10px) saturate(1.08);
          backdrop-filter: blur(10px) saturate(1.08);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 50%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 50%, transparent 100%);
}
.nav__inner {
  width: var(--shell);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 66px;
}
.brand { display: flex; align-items: center; gap: var(--space-sm); font-weight: 700; letter-spacing: -0.01em; font-family: var(--display); }
.brand .mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius);
}
.brand .status {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex; align-items: center; gap: 6px;
}
.brand .status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.6s var(--ease-io) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 45%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.nav__links { display: flex; align-items: center; gap: var(--space-xs); list-style: none; padding: 0; }
.nav__links a {
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
  color: var(--text-dim);
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
  display: inline-flex;
  gap: 0.5ch;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.nav__links a .n { color: var(--text-faint); transition: color 0.2s var(--ease); }
.nav__links a:hover { color: var(--text); background: var(--bg-2); }
.nav__links a:hover .n { color: var(--accent); }
.nav__links a[aria-current="page"] { color: var(--text); }
.nav__links a[aria-current="page"] .n { color: var(--accent); }

.nav__toggle {
  display: none;
  background: none; border: 1px solid var(--line-strong); color: var(--text);
  width: 44px; height: 44px; border-radius: var(--radius); cursor: pointer;
  font-family: var(--mono); font-size: 1.2rem; line-height: 1;
}

/* ---------------------------- Buttons ------------------------------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--space-sm);
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.85rem 1.3rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease),
              border-color 0.2s var(--ease), color 0.2s var(--ease),
              backdrop-filter 0.25s var(--ease), -webkit-backdrop-filter 0.25s var(--ease);
}
.btn .arrow { transition: transform 0.25s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
.btn--primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn--ghost { border-color: var(--line-strong); color: var(--text); }
/* Hover: the button lifts off into frosted glass and rises above neighbouring
   content (z just under the cursor layer, so the cursor still rides on top). */
.btn:hover {
  z-index: 80;
  background: color-mix(in srgb, var(--bg) 36%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
          backdrop-filter: blur(10px) saturate(1.1);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text);
  transform: translateY(-2px);
}
/* Primary stays green — translucent pine glass rather than the light frost. */
.btn--primary:hover {
  background: color-mix(in srgb, var(--accent) 82%, transparent);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  color: var(--on-accent);
}

/* ----------------------------- Bits --------------------------------- */
.grid { display: grid; gap: var(--space-lg); }

.spec {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-sm) var(--space-lg);
  font-family: var(--mono);
  font-size: var(--step--1);
}
.spec dt { color: var(--text-faint); letter-spacing: 0.08em; text-transform: uppercase; }
.spec dd { color: var(--text-dim); }

.tags { display: flex; flex-wrap: wrap; gap: var(--space-xs); list-style: none; padding: 0; }
.tags li {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 0.3rem 0.6rem;
  border-radius: 100px;
  background: var(--bg-1);
}

/* footer — dark pine band */
.footer { position: relative; z-index: 1; background: var(--footer-bg); color: var(--bg); }
.footer__inner { width: var(--shell); margin-inline: auto; padding-block: var(--space-3xl); }
.footer__cta {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between;
  gap: var(--space-xl); padding-bottom: var(--space-2xl); margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--footer-line);
}
.footer__cta h2 { font-size: var(--step-3); color: var(--bg); }
.footer .eyebrow { color: color-mix(in oklab, var(--accent-dim) 28%, var(--bg)); }
.footer__meta {
  display: flex; flex-wrap: wrap; gap: var(--space-lg) var(--space-2xl);
  font-family: var(--mono); font-size: var(--step--1);
  color: color-mix(in oklab, var(--bg) 92%, var(--footer-bg));
}
.footer__meta a { color: var(--bg); transition: color 0.2s var(--ease); }
.footer__meta a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.footer__meta strong { color: color-mix(in oklab, var(--bg) 80%, var(--footer-bg)); font-weight: 500; display: block; margin-bottom: 4px; letter-spacing: 0.1em; text-transform: uppercase; font-size: 0.66rem; }
.footer .btn--primary { background: var(--bg); color: var(--text); }
.footer .btn--primary:hover { background: color-mix(in srgb, var(--bg) 60%, transparent); color: var(--text); }

/* reveal-on-scroll — only hides when JS is active */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }

/* skip link */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 0.6rem 1rem; font-family: var(--mono); border-radius: var(--radius);
}
.skip:focus { left: var(--space-md); top: var(--space-md); }

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

/* ----------------------------- Mobile ------------------------------- */
@media (max-width: 720px) {
  .nav__toggle { display: inline-flex; align-items: center; justify-content: center; }
  .brand .status { display: none; }
  .nav__links {
    position: absolute; inset: 66px 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    -webkit-backdrop-filter: blur(10px) saturate(1.08);
            backdrop-filter: blur(10px) saturate(1.08);
    border-bottom: 1px solid var(--line);
    padding: var(--space-sm);
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
  }
  .nav__links.open { transform: none; opacity: 1; pointer-events: auto; }
  .nav__links a { padding: 0.85rem; font-size: var(--step-0); }
}

/* =====================================================================
   MOTION LAYER — micro-interactions, custom cursor, scroll progress
   All enhancements are additive; reduced-motion + touch fall back
   gracefully (the cursor/parallax are only enabled from JS).
   ===================================================================== */

/* ---- Scroll progress (thin pine line above the nav) ---- */
.scroll-prog {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  z-index: 60;
  background: var(--accent);
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
  pointer-events: none;
}

/* ---- Custom cursor: soft blend disc (an olive lens) ---- */
.cursor-on, .cursor-on a, .cursor-on button,
.cursor-on .work-row, .cursor-on .channel, .cursor-on .nav__toggle { cursor: none; }

/* Single element so it can carry both its own transform AND backdrop-filter
   (backdrop-filter breaks when an *ancestor* is transformed). JS writes the
   full translate + rotate + scale; transform-origin keeps deformation centered. */
.cursor {
  position: fixed;
  top: 0; left: 0;
  z-index: 90;
  width: 22px; height: 22px;
  border-radius: 50%;
  translate: -50% -50%;
  transform-origin: center;
  pointer-events: none;
  opacity: 0;                 /* hidden until the first pointer move (JS reveals it) */
  /* frosted glass: barely-there olive tint + a soft backdrop blur + faint rim */
  background: color-mix(in srgb, var(--accent-dim) 14%, transparent);
  -webkit-backdrop-filter: blur(5px) saturate(1.12);
          backdrop-filter: blur(5px) saturate(1.12);
  border: 1px solid color-mix(in srgb, var(--bg) 45%, transparent);
  will-change: transform;
  transition: opacity 0.3s var(--ease), width 0.3s var(--ease),
              height 0.3s var(--ease), background-color 0.3s var(--ease);
}
.cursor-on.is-hover .cursor { width: 40px; height: 40px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
.cursor-on.is-down  .cursor { width: 14px; height: 14px; }

/* ---- Nav links: underline that draws from the left ---- */
.nav__links a { position: relative; }
.nav__links a::after {
  content: "";
  position: absolute;
  left: 0.7rem; right: 0.7rem; bottom: 0.25rem;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.3s var(--ease);
}
.nav__links a:hover::after,
.nav__links a[aria-current="page"]::after { transform: scaleX(1); }

/* ---- Buttons: press feedback + magnetic-ready ---- */
.btn { will-change: transform; }
.btn:active { transform: translateY(0) scale(0.97); transition-duration: 0.08s; }
.brand .mark { transition: transform 0.3s var(--ease), background-color 0.2s var(--ease); }
.brand:hover .mark { transform: rotate(-6deg) scale(1.06); }

/* ---- Cards: lift into frosted green glass on hover (like the buttons) ---- */
.field, .work-card, .edu .card { position: relative; }
.field, .work-card, .edu .card, .aside-card {
  transition: transform 0.28s var(--ease), border-color 0.35s var(--ease),
              background 0.35s var(--ease),
              backdrop-filter 0.35s var(--ease), -webkit-backdrop-filter 0.35s var(--ease);
}
/* Lift + cursor-follow comes from the magnetic JS; here we just raise the
   stack order and switch to frosted glass. */
.field:hover, .work-card:hover, .edu .card:hover {
  z-index: 80;
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent-dim) 22%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
          backdrop-filter: blur(10px) saturate(1.1);
}

/* ---- Section divider draws in when revealed ---- */
.js .section-head { position: relative; }
.js .section-head::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--accent-dim);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.8s var(--ease) 0.15s;
}
.js .section-head.in::after { transform: scaleX(1); }

/* ---- Work rows: title underline + arrow travel ---- */
.work-row .title { position: relative; display: inline-block; }
.work-row .title::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.4s var(--ease);
}
.work-row:hover .title::after { transform: scaleX(1); }

/* ---- Project case-study links / channels arrow ---- */
.channel .go, .work-row .go { will-change: transform; }

/* ---- Tags: gentle hover ---- */
.tags li { transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease); }
.tags li:hover { transform: translateY(-2px); border-color: var(--accent-dim); color: var(--text); }

/* ---- Hero headline: left-to-right wipe on entrance ----
   Driven by a load animation (NOT the scroll observer): a clipped element
   reports zero area to IntersectionObserver, which would deadlock the reveal. */
.js .hero h1 { animation: heroWipe 1.1s var(--ease) 0.12s both; }
@keyframes heroWipe {
  from { clip-path: inset(0 100% 0 0); opacity: 0; transform: translateY(16px); }
  to   { clip-path: inset(0 0 0 0);    opacity: 1; transform: none; }
}

/* Reduced motion: strip the cursor + parallax entirely, restore native cursor */
@media (prefers-reduced-motion: reduce) {
  .cursor, .scroll-prog { display: none !important; }
  .cursor-on, .cursor-on * { cursor: auto !important; }
  .js .hero h1 { animation: none; clip-path: none; opacity: 1; transform: none; }
  body::before { transition: none; }
}
