/* =========================================================
   Khue Le — Remote Sensing & GIS portfolio
   Palette is an NDVI ramp on an orbit-blue night side.
   ========================================================= */
:root {
  --orbit: #0b1622;
  --orbit-2: #10202f;
  --orbit-3: #172c3e;
  --line: rgba(230, 234, 216, 0.12);
  --lichen: #e6ead8;
  --mist: #98a8b2;

  /* NDVI ramp: bare soil -> dense canopy */
  --r0: #8c4a2f;
  --r1: #d6a84a;
  --r2: #e3d97a;
  --r3: #8fc25a;
  --r4: #3d8f4f;
  --r5: #1f6b45;
  --ramp: linear-gradient(90deg, var(--r0), var(--r1), var(--r2), var(--r3), var(--r4), var(--r5));

  --honey: #f4b62f;
  --water: #6fa8c7;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;

  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius-lg: 22px;
  --radius-sm: 8px;
  --ease: cubic-bezier(.2, .7, .1, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
body {
  margin: 0;
  background: var(--orbit);
  color: var(--lichen);
  font-family: var(--serif);
  font-size: clamp(17px, 1.05vw + 12px, 19px);
  line-height: 1.6;
  font-optical-sizing: auto;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, video, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: var(--r3); color: var(--orbit); }
:focus-visible { outline: 2px solid var(--r2); outline-offset: 3px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--lichen); color: var(--orbit); padding: 8px 14px; border-radius: 6px; }
.skip:focus { left: 8px; }

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

/* ---------- Type scale ---------- */
.h1, .h2, .h4, .case__title, .contact__title, .hero__name { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.02; margin: 0; }
.h1 { font-size: clamp(40px, 6vw, 84px); font-variation-settings: "wdth" 80; }
.h2 { font-size: clamp(30px, 3.6vw, 48px); font-weight: 600; line-height: 1.08; }
.h4 { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 14px; }
.prose { max-width: 62ch; margin: 0 0 1em; color: color-mix(in srgb, var(--lichen) 88%, var(--mist)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5em;
  font-family: var(--display); font-weight: 600; font-size: 16px;
  padding: 13px 22px; border-radius: 999px; text-decoration: none;
  transition: transform .25s var(--ease), background .25s, color .25s, border-color .25s;
}
.btn--solid { background: var(--lichen); color: var(--orbit); }
.btn--solid:hover { background: var(--r2); transform: translateY(-2px); }
.btn--ghost { border: 1.5px solid var(--line); }
.btn--ghost:hover { border-color: var(--lichen); transform: translateY(-2px); }

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px var(--gutter);
  font-family: var(--display);
  transition: background .35s, backdrop-filter .35s, padding .35s;
}
.nav.is-solid { background: rgba(11, 22, 34, .72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); padding-block: 10px; border-bottom: 1px solid var(--line); }
.nav__mark { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 18px; }
.nav__mark svg { width: 30px; height: 30px; fill: none; stroke: var(--r3); stroke-width: 2.2; stroke-linecap: round; }
.nav__mark svg circle { fill: var(--lichen); stroke: none; }
.nav nav { display: flex; gap: clamp(12px, 2.4vw, 30px); align-items: center; font-size: 15px; font-weight: 500; }
.nav nav a { text-decoration: none; opacity: .8; transition: opacity .2s; }
.nav nav a:hover { opacity: 1; }
.nav__cta { border: 1.5px solid var(--line); padding: 8px 16px; border-radius: 999px; opacity: 1 !important; }
@media (max-width: 640px) {
  .nav nav a:not(.nav__cta) { display: none; }
}

/* ---------- Hero ---------- */
.hero { position: relative; min-height: 100svh; display: grid; align-items: end; overflow: hidden; isolation: isolate; }
.hero__canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; touch-action: pan-y; cursor: crosshair; }
.hero__fallback { position: absolute; inset: 0; z-index: -2; background:
  radial-gradient(120% 60% at 70% 100%, rgba(61, 143, 79, .35), transparent 60%),
  radial-gradient(60% 50% at 20% 90%, rgba(214, 168, 74, .18), transparent 60%), var(--orbit); }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(11,22,34,.55) 0%, transparent 28%, transparent 55%, rgba(11,22,34,.85) 100%); }

.hero__content { padding: 0 var(--gutter) clamp(64px, 11vh, 120px); max-width: 1400px; width: 100%; margin-inline: auto; pointer-events: none; }
.hero__content a { pointer-events: auto; }
.hero__name {
  font-size: clamp(96px, 24vw, 300px); line-height: .82; letter-spacing: -0.045em;
  font-variation-settings: "wdth" 75; font-weight: 800;
  margin-left: -0.04em;
}
.hero__line { display: block; overflow: hidden; padding-bottom: .04em; }
.hero__line > span { display: inline-block; }
.hero__line:nth-child(2) > span {
  background: var(--ramp); -webkit-background-clip: text; background-clip: text; color: transparent;
  background-size: 200% 100%; animation: rampShift 9s linear infinite;
}
@keyframes rampShift { to { background-position: -200% 0; } }
.hero__lede { max-width: 46ch; font-size: clamp(18px, 1.4vw + 10px, 23px); line-height: 1.5; margin: 28px 0 30px; text-shadow: 0 1px 18px rgba(11,22,34,.8); }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }

.hero__scroll { position: absolute; left: 50%; bottom: 22px; translate: -50% 0; width: 24px; height: 38px; border: 1.5px solid var(--line); border-radius: 12px; }
.hero__scroll span { position: absolute; left: 50%; top: 8px; width: 3px; height: 8px; margin-left: -1.5px; border-radius: 3px; background: var(--lichen); animation: wheel 1.8s var(--ease) infinite; }
@keyframes wheel { 0% { opacity: 0; transform: translateY(-3px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(12px); } }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 6vw, 96px); align-items: center; padding-block: clamp(96px, 14vw, 180px); }
.about__photo { margin: 0; position: relative; border-radius: var(--radius-lg); overflow: hidden; transform-style: preserve-3d; transition: transform .4s var(--ease); box-shadow: 0 40px 80px -30px rgba(0,0,0,.6); }
.about__photo img { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; }
.about__photo figcaption { position: absolute; left: 14px; top: 14px; font-family: var(--display); font-size: 13px; padding: 6px 12px; border-radius: 999px; background: rgba(11,22,34,.7); backdrop-filter: blur(6px); }
.about__photo::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--line); pointer-events: none; }
.about__text .h2 { margin-bottom: 28px; max-width: 18ch; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 28px; margin: 34px 0 0; padding-top: 26px; border-top: 1px solid var(--line); font-family: var(--display); }
.facts dt { color: var(--mist); font-size: 14px; }
.facts dd { margin: 2px 0 0; font-weight: 600; font-size: 17px; }
@media (max-width: 820px) { .about { grid-template-columns: 1fr; } .about__photo { max-width: 380px; } }

/* ---------- Work / cases ---------- */
.work { padding-bottom: 40px; }
.work > .wrap > .h1 { margin-bottom: clamp(40px, 6vw, 72px); }
.case { position: relative; padding-block: clamp(56px, 8vw, 110px); }
.case + .case { border-top: 1px solid var(--line); }
.case--bee { --accent: var(--honey); }
.case--forest { --accent: var(--r3); }
.case__meta { font-family: var(--display); color: var(--accent); font-weight: 600; font-size: 15px; margin: 0 0 12px; }
.case__title { font-size: clamp(38px, 5.4vw, 76px); font-variation-settings: "wdth" 85; max-width: 16ch; }
.case__lede { font-size: clamp(19px, 1.2vw + 12px, 24px); line-height: 1.5; max-width: 54ch; margin: 24px 0 26px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; font-family: var(--display); font-size: 14px; }
.tags li { padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); color: color-mix(in srgb, var(--lichen) 85%, var(--mist)); }

/* bee path */
.beepath { margin-top: clamp(40px, 6vw, 70px); }
.beepath svg { width: 100%; height: clamp(110px, 16vw, 200px); overflow: visible; }
#beeRoute { fill: none; stroke: var(--honey); stroke-width: 2.5; stroke-dasharray: 6 9; stroke-linecap: round; opacity: .9; }
.beepath__nodes circle { fill: var(--orbit); stroke: var(--r3); stroke-width: 2.5; transition: fill .3s; }
.beepath__nodes circle.on { fill: var(--r3); }
.beepath__bee ellipse:first-child { fill: var(--honey); }
.beepath__bee path { stroke: var(--orbit); stroke-width: 2; }
.beepath__bee { transform-box: view-box; }
.beepath__bee .w { fill: rgba(230,234,216,.75); transform-box: fill-box; transform-origin: 50% 100%; animation: buzz .08s linear infinite alternate; }
@keyframes buzz { to { transform: scaleY(.55); } }
.beepath__labels { display: flex; justify-content: space-between; font-family: var(--display); font-size: 14px; color: var(--mist); margin-top: 6px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(16px, 3vw, 40px); margin-top: clamp(40px, 6vw, 72px); }
.stat { padding-top: 18px; border-top: 2px solid var(--accent); }
.stat__n { display: block; font-family: var(--display); font-weight: 700; font-size: clamp(40px, 4.8vw, 68px); line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; font-variation-settings: "wdth" 80; }
.stat__l { display: block; margin-top: 10px; font-size: 16px; line-height: 1.45; color: var(--mist); max-width: 26ch; }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.case__grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 5vw, 72px); margin-top: clamp(56px, 8vw, 100px); align-items: start; }
@media (max-width: 960px) { .case__grid { grid-template-columns: 1fr; } }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 20px 48px; font-size: 17px; line-height: 1.5; color: color-mix(in srgb, var(--lichen) 85%, var(--mist)); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 14px; background: var(--orbit-3); color: var(--accent); }
.steps li::after { content: ""; position: absolute; left: 15.5px; top: 34px; bottom: 2px; width: 1px; background: var(--line); }
.steps li:last-child::after { display: none; }
.steps b { color: var(--lichen); font-weight: 600; }

.poster { margin: 0; position: sticky; top: 90px; }
.poster__open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 14px; overflow: hidden; position: relative; box-shadow: 0 30px 70px -25px rgba(0,0,0,.7); }
.poster__open img { width: 100%; height: auto; transition: transform .7s var(--ease); }
.poster__open:hover img { transform: scale(1.025); }
.poster__hint { position: absolute; right: 12px; bottom: 12px; display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 999px; background: rgba(11,22,34,.82); font-family: var(--display); font-size: 14px; font-weight: 600; }
.poster__hint svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.poster figcaption { margin-top: 12px; font-size: 15px; color: var(--mist); }

.videos { margin-top: clamp(56px, 8vw, 100px); }
.videos__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(20px, 3vw, 36px); }
@media (max-width: 760px) { .videos__grid { grid-template-columns: 1fr; } }
.yt { margin: 0; }
.yt__frame { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: var(--orbit-2); box-shadow: 0 0 0 1px var(--line); }
.yt__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt__facade { position: absolute; inset: 0; padding: 0; border: 0; cursor: pointer; background: #000; }
.yt__facade img { width: 100%; height: 100%; object-fit: cover; opacity: .85; transition: opacity .3s, transform .6s var(--ease); }
.yt__facade:hover img { opacity: 1; transform: scale(1.03); }
.yt__play { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 74px; height: 74px; border-radius: 50%; background: var(--honey); display: grid; place-items: center; box-shadow: 0 10px 40px rgba(244,182,47,.45); transition: transform .3s var(--ease); }
.yt__play svg { width: 30px; height: 30px; fill: var(--orbit); margin-left: 4px; }
.yt__facade:hover .yt__play { transform: scale(1.08); }
.yt figcaption { margin-top: 14px; font-size: 16px; line-height: 1.5; color: var(--mist); }
.yt figcaption b { color: var(--lichen); font-weight: 600; }
.yt figcaption a { display: inline-block; margin-left: 4px; color: var(--honey); font-family: var(--display); font-size: 14px; font-weight: 600; }

.case__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; margin-top: clamp(48px, 6vw, 80px); }
.case__take { max-width: 64ch; margin: 0; font-size: 18px; }

/* forest */
.forest { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: clamp(32px, 6vw, 90px); margin-top: clamp(48px, 7vw, 90px); align-items: center; }
@media (max-width: 860px) { .forest { grid-template-columns: 1fr; } }
.forest__video { margin: 0; justify-self: center; width: min(320px, 100%); }
.device { border-radius: 34px; padding: 10px; background: linear-gradient(160deg, #2a3e50, #0e1a26); box-shadow: 0 40px 90px -30px rgba(0,0,0,.8), inset 0 0 0 1px rgba(230,234,216,.1); }
.device video { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 26px; background: #000; }
.forest__video figcaption { text-align: center; margin-top: 14px; font-size: 15px; color: var(--mist); }

.stack { position: relative; height: clamp(340px, 36vw, 440px); perspective: 1600px; margin: 24px 0 18px; overflow: hidden; contain: paint; }
.stack__layer { position: absolute; left: 50%; top: 60%; width: min(300px, 62%); aspect-ratio: 1; translate: -50% -50%; transform-style: preserve-3d; transition: filter .3s; cursor: pointer; }
.stack__layer canvas { width: 100%; height: 100%; image-rendering: pixelated; filter: drop-shadow(0 0 1px rgba(230,234,216,.5)) drop-shadow(0 18px 18px rgba(0,0,0,.45)); }
.stack__layer:hover { filter: brightness(1.3); }
.traj { display: flex; flex-wrap: wrap; gap: 10px 26px; list-style: none; padding: 0; margin: 0; font-family: var(--display); font-size: 15px; }
.traj li { display: flex; align-items: center; gap: 8px; color: var(--mist); }
.traj i { width: 14px; height: 14px; border-radius: 4px; background: var(--c); }
.traj b { color: var(--lichen); }

.forest__methods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(24px, 4vw, 56px); margin-top: clamp(56px, 8vw, 100px); padding-top: 40px; border-top: 1px solid var(--line); }
.forest__methods .prose { font-size: 17px; }
.formula { font-family: var(--display); font-weight: 600; font-size: 17px; color: var(--r3); margin: 0 0 12px; }
@media (max-width: 860px) { .forest__methods { grid-template-columns: 1fr; } }

/* ---------- Experience ---------- */
.exp { padding-block: clamp(96px, 12vw, 160px); }
.exp .h1 { margin-bottom: clamp(40px, 6vw, 72px); }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 190px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline__fill { position: absolute; left: 190px; top: 8px; width: 2px; height: 0; background: var(--ramp); background: linear-gradient(180deg, var(--r1), var(--r3), var(--r5)); }
.role { display: grid; grid-template-columns: 190px minmax(0, 1fr); padding-bottom: clamp(40px, 5vw, 64px); position: relative; }
.role::before { content: ""; position: absolute; left: 184px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--orbit); border: 2px solid var(--r3); z-index: 1; }
.role__when { font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--mist); padding-right: 30px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.role__body { padding-left: 44px; }
.role h3 { font-family: var(--display); font-size: clamp(22px, 2vw, 28px); font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; margin: 0; }
.role__org { margin: 6px 0 14px; color: var(--r3); font-family: var(--display); font-size: 15px; font-weight: 500; }
.role ul { margin: 0; padding-left: 1.1em; max-width: 64ch; }
.role li { margin-bottom: 6px; color: color-mix(in srgb, var(--lichen) 85%, var(--mist)); }
.role li::marker { color: var(--r1); }
@media (max-width: 720px) {
  .timeline::before, .timeline__fill { left: 6px; }
  .role { grid-template-columns: 1fr; padding-left: 34px; }
  .role::before { left: 0; }
  .role__body { padding-left: 0; }
  .role__when { padding: 0 0 6px; }
}

/* ---------- Skills ---------- */
.skills { padding-block: clamp(80px, 10vw, 140px); background: var(--orbit-2); border-block: 1px solid var(--line); }
.skills .h1 { margin-bottom: clamp(36px, 5vw, 64px); }
.legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(28px, 4vw, 56px); }
@media (max-width: 860px) { .legend { grid-template-columns: 1fr; } }
.legend__group h3 { font-family: var(--display); font-weight: 650; font-size: 22px; margin: 0 0 18px; }
.legend__group ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.legend__group li { font-family: var(--display); font-size: 15px; padding: 8px 14px; border-radius: 10px; background: color-mix(in srgb, var(--sw) 12%, transparent); border: 1px solid color-mix(in srgb, var(--sw) 35%, transparent); transition: background .25s, transform .25s var(--ease); }
.legend__group li:hover { background: color-mix(in srgb, var(--sw) 30%, transparent); transform: translateY(-2px); }

/* ---------- Contact ---------- */
.contact { padding-block: clamp(110px, 14vw, 200px); }
.contact__title { font-size: clamp(42px, 7vw, 104px); font-variation-settings: "wdth" 78; line-height: .95; margin-bottom: 26px; }
.contact__links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding-block: 28px 40px; border-top: 1px solid var(--line); font-family: var(--display); font-size: 14px; color: var(--mist); }

/* ---------- Poster viewer ---------- */
.viewer { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(6, 12, 19, .96); color: var(--lichen); overflow: hidden; }
.viewer::backdrop { background: rgba(6, 12, 19, .9); }
.viewer[open] { display: grid; grid-template-rows: 1fr auto; animation: fadeIn .3s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.viewer__stage { position: relative; overflow: hidden; cursor: grab; touch-action: none; }
.viewer__stage.is-dragging { cursor: grabbing; }
.viewer__stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; user-select: none; will-change: transform; }
.viewer__loading { position: absolute; left: 50%; top: 20px; translate: -50% 0; font-family: var(--display); font-size: 14px; padding: 6px 14px; border-radius: 999px; background: rgba(23,44,62,.9); }
.viewer__loading[hidden] { display: none; }
.viewer__bar { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-family: var(--display); font-size: 14px; }
.viewer__bar button, .viewer__bar a { min-width: 42px; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--orbit-2); cursor: pointer; text-decoration: none; display: inline-grid; place-items: center; font-weight: 600; font-size: 15px; }
.viewer__bar button:hover, .viewer__bar a:hover { border-color: var(--lichen); }
#viewerPct { min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; }
.viewer__close { background: var(--lichen) !important; color: var(--orbit); }

/* ---------- Reveal (applied by JS only) ---------- */
.js .reveal { opacity: 0; transform: translateY(26px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
