/* =========================================================
   Soh Weng Sing — Portfolio
   Palette: deep navy · ivory · brass gold · ledger teal
   ========================================================= */

:root {
  /* Brand */
  --navy-900: #0F2340;
  --navy-800: #15305A;
  --navy-700: #1E4170;
  --navy-600: #2B5690;
  --gold-500: #B8913A;
  --gold-400: #CDA954;
  --gold-100: #F3EAD3;
  --teal-600: #1F7A6D;
  --teal-100: #DCEFEA;

  /* Light theme (default) */
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #EDF0F5;
  --text: #14233B;
  --text-muted: #5A6A82;
  --line: rgba(20, 35, 59, .12);
  --accent: var(--gold-500);
  --accent-2: var(--teal-600);
  --link: #1E4F8F;
  --nav-bg: rgba(246, 244, 239, .72);
  --day: var(--navy-700);
  --shadow: 0 1px 2px rgba(15, 35, 64, .05), 0 10px 30px rgba(15, 35, 64, .07);

  /* Type & layout */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --radius: 24px;
  --container: 1120px;
  --nav-h: 56px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

[data-theme="dark"] {
  --bg: #0E1D33;
  --surface: #14284A;
  --surface-2: #112443;
  --text: #EAF0F8;
  --text-muted: #A3B2C8;
  --line: rgba(234, 240, 248, .12);
  --accent: var(--gold-400);
  --accent-2: #3FB3A0;
  --link: #E2C27A;
  --nav-bg: rgba(14, 29, 51, .72);
  --day: var(--navy-600);
  --shadow: 0 10px 30px rgba(5, 14, 30, .35);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background-color .4s var(--ease), color .4s var(--ease);
}
body.menu-open, body.modal-open { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3 { font-weight: 700; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
section[id] { scroll-margin-top: var(--nav-h); }

.container { width: min(100% - 2.5rem, var(--container)); margin-inline: auto; }

.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 999;
  padding: .6rem 1rem; border-radius: 10px; background: var(--navy-900); color: #fff;
}
.skip-link:focus { top: 1rem; }

.eyebrow {
  margin: 0;
  font-size: .78rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
}
.accent {
  font-family: var(--font-serif); font-style: italic; font-weight: 400;
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  padding-right: .08em;
}

/* ---------- Scroll progress ---------- */
.scroll-progress {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 200;
  transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .85rem 1.5rem; border-radius: 980px;
  font-size: .95rem; font-weight: 500; line-height: 1;
  transition: transform .25s var(--ease), background-color .25s, border-color .25s, color .25s;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--navy-900); color: #F4F7FB; }
.btn--primary:hover { background: var(--navy-700); }
[data-theme="dark"] .btn--primary { background: var(--gold-400); color: var(--navy-900); }
[data-theme="dark"] .btn--primary:hover { background: #DDBB6A; }
.btn--link { color: var(--link); padding-inline: .5rem; }
.btn--link .chev { display: inline-block; font-size: 1.25em; transition: transform .25s var(--ease); }
.btn--link:hover .chev { transform: translateX(4px); }
.btn--ghost { background: var(--surface); border: 1px solid var(--line); }
.btn--ghost:hover { border-color: var(--accent); }
/* "Get in touch" — warm gold pill with an arrow that slides on hover */
.btn--touch {
  padding: .5rem .55rem .5rem 1.35rem; gap: .75rem;
  background: var(--gold-100); color: #6B4F14; font-weight: 600;
  border: 1px solid rgba(184, 145, 58, .35);
  box-shadow: 0 6px 18px rgba(184, 145, 58, .18);
}
.btn--touch .chev {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--gold-500); color: #fff; transition: transform .3s var(--ease), background-color .3s;
}
.btn--touch .chev .i { width: 16px; height: 16px; stroke-width: 2.2; }
.btn--touch:hover { background: #EEDFB8; border-color: var(--gold-500); }
.btn--touch:hover .chev { transform: translateX(3px); background: var(--navy-900); }
[data-theme="dark"] .btn--touch { background: rgba(205, 169, 84, .14); color: var(--gold-400); border-color: rgba(205, 169, 84, .4); box-shadow: none; }
[data-theme="dark"] .btn--touch .chev { background: var(--gold-400); color: var(--navy-900); }
[data-theme="dark"] .btn--touch:hover .chev { background: #F4F7FB; }
.btn .i { width: 18px; height: 18px; }
.btn--gold { background: var(--gold-400); color: var(--navy-900); }
.btn--gold:hover { background: #DDBB6A; }
.btn--outline-light { border: 1px solid rgba(234, 240, 248, .3); color: #EAF0F8; }
.btn--outline-light:hover { border-color: var(--gold-400); }

/* ---------- Navigation (frosted glass, hides on scroll down) ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100; height: var(--nav-h);
  border-bottom: 1px solid transparent;
  transition: transform .5s var(--ease), background-color .3s, border-color .3s;
}
.nav.is-scrolled, body.menu-open .nav {
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom-color: var(--line);
}
.nav.is-hidden { transform: translateY(-100%); }
.nav__inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.nav__logo { display: inline-flex; align-items: center; gap: .65rem; font-weight: 600; font-size: .92rem; }
.nav__mark {
  display: grid; place-items: center; height: 30px; padding: 0 .55rem; border-radius: 9px;
  background: var(--navy-900); color: var(--gold-400);
  font-size: .68rem; font-weight: 700; letter-spacing: .12em;
}
[data-theme="dark"] .nav__mark { background: var(--gold-400); color: var(--navy-900); }
.nav__links { display: flex; gap: 2rem; }
.nav__links a { position: relative; font-size: .82rem; color: var(--text-muted); transition: color .2s; }
.nav__links a:hover, .nav__links a.is-active { color: var(--text); }
.nav__links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform .35s var(--ease);
}
.nav__links a.is-active::after { transform: scaleX(1); }
.nav__actions { display: flex; align-items: center; gap: .25rem; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  color: var(--text-muted); transition: background-color .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.nav__resume {
  margin-right: .35rem; padding: .45rem .95rem; border-radius: 999px;
  border: 1px solid var(--line); font-size: .8rem; font-weight: 500;
  transition: border-color .2s, background-color .2s;
}
.nav__resume:hover { border-color: var(--accent); background: var(--surface); }
.nav__burger { display: none; place-content: center; gap: 6px; }
.nav__burger span { display: block; width: 18px; height: 1.5px; border-radius: 2px; background: currentColor; transition: transform .4s var(--ease); }
.nav__burger[aria-expanded="true"] span:first-child { transform: translateY(3.75px) rotate(45deg); }
.nav__burger[aria-expanded="true"] span:last-child { transform: translateY(-3.75px) rotate(-45deg); }

.mobile-menu {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column;
  padding: calc(var(--nav-h) + 2rem) 1.5rem 2rem;
  background: var(--bg);
  opacity: 0; visibility: hidden;
  transition: opacity .4s var(--ease), visibility .4s;
}
.mobile-menu.is-open { opacity: 1; visibility: visible; }
.mobile-menu a {
  padding: .7rem 0; border-bottom: 1px solid var(--line);
  font-size: 1.75rem; font-weight: 600; letter-spacing: -.02em;
  opacity: 0; transform: translateY(-10px);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
}
.mobile-menu.is-open a { opacity: 1; transform: none; transition-delay: calc(var(--i) * 50ms + 80ms); }

@media (max-width: 820px) {
  .nav__links, .nav__resume { display: none; }
  .nav__burger { display: grid; }
}
@media (max-width: 380px) { .nav__name { display: none; } }

/* ---------- Hero ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: 100vh; min-height: 100svh;
  display: flex; align-items: center;
  padding: calc(var(--nav-h) + 4rem) 0 6rem;
}
.hero__bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; will-change: transform; }
.hero__glow { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .32; animation: drift 14s ease-in-out infinite; }
.hero__glow--gold { width: 520px; height: 520px; top: -160px; right: -140px; background: var(--gold-400); }
.hero__glow--blue { width: 460px; height: 460px; bottom: 5%; left: -180px; background: #4F7FBF; animation-delay: -7s; }
.hero__grid {
  position: absolute; inset: 0; opacity: .7;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 80% 65% at 50% 40%, #fff 25%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 65% at 50% 40%, #fff 25%, transparent 75%);
}
.hero__chart { position: absolute; left: 0; bottom: 0; width: 100%; height: 58%; }
.chart-line { fill: none; stroke: url(#lineGrad); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.4s var(--ease) .5s forwards; }
.chart-area { fill: url(#areaGrad); opacity: 0; animation: fadeIn 1.4s ease 1.5s forwards; }
.chart-bench { fill: none; stroke: var(--text-muted); stroke-opacity: .35; stroke-width: 1.5; stroke-dasharray: 6 8; opacity: 0; animation: fadeIn 1s ease 1s forwards; }
.chart-points circle {
  fill: var(--bg); stroke: var(--accent); stroke-width: 3;
  transform-box: fill-box; transform-origin: center; transform: scale(0);
  animation: pop .6s var(--ease) forwards;
}
.chart-points circle:nth-child(1) { animation-delay: 1.1s; }
.chart-points circle:nth-child(2) { animation-delay: 1.4s; }
.chart-points circle:nth-child(3) { animation-delay: 1.7s; }
.chart-points circle:nth-child(4) { animation-delay: 2s; }

.hero__content { position: relative; will-change: transform, opacity; }
.hero__title {
  margin: 1rem 0 1.5rem;
  font-size: clamp(3rem, 10vw, 7.5rem); line-height: 1.02; letter-spacing: -.045em;
}
.hero__period { color: var(--accent); }
.hero__tagline {
  margin: 0 0 1.25rem; font-size: clamp(1.45rem, 3.6vw, 2.6rem); font-weight: 600;
  line-height: 1.15; letter-spacing: -.03em; color: var(--text-muted);
}
.hero__title .line { display: block; overflow: hidden; padding-bottom: .08em; }
.hero__title .line > span { display: inline-block; transform: translateY(110%); animation: rise 1.1s var(--ease) forwards; }
.hero__sub { max-width: 36em; margin: 0 0 2rem; font-size: clamp(1.05rem, 1.8vw, 1.3rem); color: var(--text-muted); }
.hero__cta { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.hero__status {
  display: inline-flex; align-items: center; gap: .6rem; margin: 2.75rem 0 0;
  padding: .55rem 1rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: .85rem; color: var(--text-muted);
}
.hero__status strong { color: var(--text); font-weight: 600; }
@media (max-width: 600px) { .hero__status { border-radius: 16px; font-size: .8rem; } }
.dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); animation: pulse 2s infinite; }

.fade-up { opacity: 0; transform: translateY(18px); animation: fadeUp .9s var(--ease) forwards; animation-delay: var(--d, 0s); }

.scroll-cue {
  position: absolute; left: 50%; bottom: 2rem; transform: translateX(-50%);
  width: 24px; height: 38px; border: 1.5px solid var(--text-muted); border-radius: 12px; opacity: .55;
}
.scroll-cue span { position: absolute; left: 50%; top: 8px; width: 3px; height: 7px; border-radius: 2px; background: var(--text-muted); animation: scrollDot 1.8s infinite; }
@media (max-height: 680px), (max-width: 600px) { .scroll-cue { display: none; } }
@media (max-width: 600px) { .hero__chart { opacity: .6; height: 45%; } }

/* ---------- Sections ---------- */
.section { padding: clamp(5rem, 12vw, 9rem) 0; }
.section--tint { background: var(--surface-2); }
.section-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: clamp(2.5rem, 6vw, 4rem); }
.section-num { font-family: var(--font-serif); font-style: italic; font-size: 1.1rem; color: var(--accent); }
.section-head h2 { margin: 0; font-size: clamp(2rem, 5.2vw, 3.6rem); line-height: 1.05; letter-spacing: -.035em; }
.section-lede { max-width: 36em; margin: calc(-1 * clamp(1.5rem, 4vw, 2.5rem)) 0 2.5rem; color: var(--text-muted); font-size: 1.05rem; }

/* Reveal on scroll (only when JS is running) */
.js .reveal { opacity: 0; transform: translateY(36px); transition: opacity 1s var(--ease), transform 1s var(--ease); transition-delay: var(--d, 0s); }
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ---------- 01 Bento highlights ---------- */
.bento { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem; }
.tile {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 1.5rem;
  min-height: 240px; padding: clamp(1.5rem, 3vw, 2.25rem);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tile--wide { grid-column: span 4; flex-direction: row; align-items: flex-end; }
.tile--narrow { grid-column: span 2; }
.tile__label { margin: 0; font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.tile__stat { margin: .5rem 0; font-size: clamp(3.75rem, 9vw, 6.25rem); font-weight: 700; line-height: 1; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.tile__unit { margin-left: .35rem; font-size: .32em; font-weight: 600; letter-spacing: -.01em; color: var(--accent); }
.tile__text { margin: 0; max-width: 24em; color: var(--text-muted); }
.tile--navy { background: linear-gradient(145deg, var(--navy-900), var(--navy-700)); border-color: transparent; color: #EAF0F8; }
.tile--navy .tile__label, .tile--navy .tile__text { color: #A9B8CE; }
.tile--navy .tile__unit { color: var(--gold-400); }

.entity-grid { flex-shrink: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; width: min(100%, 220px); }
.entity-grid span {
  aspect-ratio: 1; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line);
  transform: scale(.8);
  transition: background-color .5s var(--ease), transform .5s var(--ease), border-color .5s;
  transition-delay: calc(var(--i) * 45ms + .3s);
}
.is-visible .entity-grid span { background: var(--navy-700); border-color: transparent; transform: none; }
.is-visible .entity-grid span:nth-child(3n) { background: var(--accent-2); }
[data-theme="dark"] .is-visible .entity-grid span { background: var(--navy-600); }
[data-theme="dark"] .is-visible .entity-grid span:nth-child(3n) { background: var(--gold-400); }

.bars { flex: 1; display: grid; gap: .9rem; min-width: min(100%, 280px); }
.bar { display: grid; grid-template-columns: 3.5rem 1fr 2.5rem; align-items: center; gap: .75rem; font-size: .8rem; color: #A9B8CE; }
.bar__track { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.bar__fill { display: block; height: 100%; width: 0; border-radius: inherit; background: #7E9CC7; transition: width 1.4s var(--ease) .4s; }
.bar__fill--gold { background: linear-gradient(90deg, var(--gold-500), var(--gold-400)); transition-delay: .8s; }
.is-visible .bar__fill { width: var(--w); }
.bar__val { text-align: right; font-weight: 600; color: #EAF0F8; font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
  .tile--wide, .tile--narrow { grid-column: span 6; }
  .tile--wide { flex-direction: column; align-items: stretch; }
  .tile { min-height: 0; }
}

/* ---------- 02 Profile: scroll-scrubbed text ---------- */
.scrub-text { max-width: 24em; margin: 0; font-size: clamp(1.6rem, 3.8vw, 2.9rem); font-weight: 600; line-height: 1.28; letter-spacing: -.025em; }
.scrub-text em { font-style: normal; color: var(--accent); }
.js .scrub-text .w { opacity: .16; transition: opacity .35s ease; }
.js .scrub-text .w.is-lit { opacity: 1; }
.profile-meta { margin-top: clamp(2.5rem, 6vw, 4rem); }
.profile-meta__label { margin: 0 0 .9rem; font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.pill-list { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.pill-list li { padding: .5rem 1rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .9rem; }

/* ---------- 03 Experience timeline ---------- */
.timeline { position: relative; max-width: 860px; padding-left: 2.5rem; }
.timeline__rail { position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--line); overflow: hidden; }
.timeline__fill { position: absolute; inset: 0; transform-origin: top; transform: scaleY(0); background: linear-gradient(var(--accent), var(--accent-2)); }
.job { position: relative; padding-bottom: 1.5rem; }
.job:last-child { padding-bottom: 0; }
.job__marker {
  position: absolute; left: calc(-2.5rem + 1px); top: 1.9rem;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
  transition: background-color .4s, border-color .4s, box-shadow .4s;
}
.job.is-reached .job__marker { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 20%, transparent); }
.job__card { padding: 1.6rem 1.75rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.job__top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.job__date { font-size: .82rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.badge { padding: .25rem .65rem; border-radius: 999px; background: var(--teal-100); color: var(--teal-600); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
[data-theme="dark"] .badge { background: rgba(63, 179, 160, .15); color: #6FD0BF; }
.job__company { margin: .45rem 0 .1rem; font-size: clamp(1.2rem, 2.4vw, 1.45rem); letter-spacing: -.02em; }
.job__role { margin: 0; color: var(--text-muted); }
.job__toggle { display: inline-flex; align-items: center; gap: .55rem; margin-top: 1rem; font-size: .88rem; font-weight: 500; color: var(--link); }
.plus { position: relative; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; }
.plus::before, .plus::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 1.5px; background: currentColor; transform: translate(-50%, -50%); transition: transform .4s var(--ease); }
.plus::after { transform: translate(-50%, -50%) rotate(90deg); }
[aria-expanded="true"] .plus::after { transform: translate(-50%, -50%) rotate(0deg); }
.job__details { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .55s var(--ease); }
.job.is-open .job__details { grid-template-rows: 1fr; }
.job__details > div { overflow: hidden; }
.job__details ul:not(.tag-row) { display: grid; gap: .6rem; margin: 1.1rem 0 0; padding: 0; list-style: none; }
.job__details li { position: relative; padding-left: 1.25rem; font-size: .95rem; color: var(--text-muted); }
.job__details ul:not(.tag-row) li::before { content: ""; position: absolute; left: 0; top: .62em; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); }

.tag-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.tag-row li { padding: .3rem .75rem !important; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .8rem; }

@media (max-width: 600px) {
  .timeline { padding-left: 1.75rem; }
  .job__marker { left: calc(-1.75rem + 1px); }
  .job__card { padding: 1.25rem; }
}

/* ---------- 04 Projects gallery ---------- */
.section--navy {
  color: #EAF0F8;
  background:
    radial-gradient(800px 400px at 85% 0%, rgba(205, 169, 84, .14), transparent 60%),
    linear-gradient(180deg, var(--navy-900), var(--navy-800));
}
[data-theme="dark"] .section--navy {
  background:
    radial-gradient(800px 400px at 85% 0%, rgba(205, 169, 84, .12), transparent 60%),
    linear-gradient(180deg, #0B1A31, #102443);
}
.section--navy .section-num { color: var(--gold-400); }
.section--navy .section-lede { color: #A9B8CE; }

.carousel__track {
  --side: max(1.25rem, calc((100vw - var(--container)) / 2));
  position: relative;
  display: flex; gap: 1.25rem;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-padding-inline: var(--side);
  padding: .75rem var(--side) 1.75rem;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.carousel__track::-webkit-scrollbar { display: none; }

.project-card {
  position: relative; overflow: hidden; isolation: isolate;
  flex: 0 0 clamp(270px, 31vw, 360px); min-height: 430px;
  display: flex; flex-direction: column; gap: 1.5rem;
  padding: 1.75rem; border-radius: 28px; text-align: left; scroll-snap-align: start;
  background: linear-gradient(160deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .025));
  border: 1px solid rgba(255, 255, 255, .1);
  transition: transform .5s var(--ease), border-color .3s;
}
.project-card::before {
  content: ""; position: absolute; z-index: -1; width: 320px; height: 320px; top: -140px; right: -120px; border-radius: 50%;
  background: var(--glow); opacity: .22; filter: blur(60px); transition: opacity .4s, transform .6s var(--ease);
}
.project-card:hover { transform: translateY(-6px); border-color: rgba(205, 169, 84, .45); }
.project-card:hover::before { opacity: .38; transform: scale(1.15); }
.project-card__num { font-family: var(--font-serif); font-style: italic; color: var(--gold-400); }
.project-card__icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; background: rgba(255, 255, 255, .08); color: var(--glow); }
.project-card__icon .i { width: 28px; height: 28px; stroke-width: 1.6; }
.project-card__body { display: grid; gap: .55rem; margin-top: auto; padding-right: 2.75rem; }
.project-card__title { font-size: 1.45rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.project-card__text { font-size: .95rem; color: #A9B8CE; }
.project-card__plus {
  position: absolute; right: 1.25rem; bottom: 1.25rem; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%; background: #EAF0F8; color: var(--navy-900);
  font-size: 1.4rem; line-height: 1; transition: transform .45s var(--ease), background-color .3s;
}
.project-card:hover .project-card__plus { transform: rotate(90deg); background: var(--gold-400); }

.carousel__controls { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.carousel__dots { display: flex; gap: .5rem; padding: .65rem .9rem; border-radius: 999px; background: rgba(255, 255, 255, .08); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.carousel__dots button { width: 8px; height: 8px; border-radius: 999px; background: rgba(234, 240, 248, .35); transition: width .45s var(--ease), background-color .3s; }
.carousel__dots button.is-active { width: 26px; background: #EAF0F8; }
.carousel__arrows { display: flex; gap: .5rem; }
.carousel__arrows button { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: rgba(255, 255, 255, .1); transition: background-color .2s, opacity .2s; }
.carousel__arrows button:hover:not(:disabled) { background: rgba(255, 255, 255, .2); }
.carousel__arrows button:disabled { opacity: .3; cursor: default; }

/* ---------- Modal ---------- */
.modal {
  width: min(720px, calc(100% - 2rem)); max-width: none; max-height: calc(100svh - 4rem);
  padding: 0; border: 0; border-radius: 28px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 30px 80px rgba(8, 20, 40, .35);
}
.modal::backdrop { background: rgba(11, 27, 51, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.modal[open] { animation: modalIn .55s var(--ease); }
.modal[open]::backdrop { animation: backdropIn .4s ease; }
.modal.is-closing { animation: modalOut .3s ease forwards; }
.modal__inner { position: relative; max-height: inherit; overflow: auto; padding: clamp(1.75rem, 5vw, 3rem); }
.modal__close { position: absolute; top: 1rem; right: 1rem; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); transition: transform .3s var(--ease); }
.modal__close:hover { transform: rotate(90deg); }
.modal__tag { margin: 0 0 .5rem; font-size: .78rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.modal__title { margin: 0 0 1.25rem; padding-right: 2.5rem; font-size: clamp(1.75rem, 4vw, 2.5rem); line-height: 1.1; letter-spacing: -.03em; }
.modal__metric:empty { display: none; }
.modal__metric { display: inline-flex; align-items: baseline; gap: .6rem; margin-bottom: 1.25rem; padding: .8rem 1.1rem; border-radius: 16px; background: var(--surface-2); }
.modal__metric strong { font-size: 1.75rem; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.modal__metric span { font-size: .9rem; color: var(--text-muted); }
.modal__summary { margin: 0 0 1.25rem; font-size: 1.08rem; color: var(--text-muted); }
.modal__points { display: grid; gap: .7rem; margin: 0; padding: 0; list-style: none; }
.modal__points li { position: relative; padding-left: 1.5rem; }
.modal__points li::before { content: ""; position: absolute; left: 0; top: .5em; width: 10px; height: 6px; border-left: 2px solid var(--accent-2); border-bottom: 2px solid var(--accent-2); transform: rotate(-45deg); }

@media (max-width: 600px) {
  /* Bottom sheet on phones */
  .modal { width: 100%; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 88svh; }
  .modal[open] { animation: sheetIn .5s var(--ease); }
  .modal.is-closing { animation: sheetOut .3s ease forwards; }
  .modal__inner { padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
}

/* ---------- 05 Expertise segmented control ---------- */
.segmented {
  position: relative; display: inline-flex; max-width: 100%; padding: 4px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented__pill {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0;
  border-radius: 999px; background: var(--surface); box-shadow: 0 2px 10px rgba(15, 35, 64, .12);
  transition: transform .5s var(--ease), width .5s var(--ease);
}
[data-theme="dark"] .segmented__pill { background: var(--navy-600); }
.segmented button {
  position: relative; z-index: 1; padding: .65rem 1.15rem; border-radius: 999px; white-space: nowrap;
  font-size: .9rem; font-weight: 500; color: var(--text-muted); transition: color .3s;
}
.segmented button[aria-selected="true"] { color: var(--text); }

.tab-panels { display: grid; margin-top: 2.5rem; }
.tab-panel {
  grid-area: 1 / 1; display: grid; grid-template-columns: 1fr 1.4fr; gap: 2rem; align-items: start;
  opacity: 0; visibility: hidden; transform: translateY(14px);
  transition: opacity .5s var(--ease), transform .5s var(--ease), visibility .5s;
}
.tab-panel.is-active { opacity: 1; visibility: visible; transform: none; }
.tab-panel__intro h3 { margin: 0 0 .5rem; font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: -.025em; }
.tab-panel__intro p { margin: 0; color: var(--text-muted); }
.chips { display: flex; flex-wrap: wrap; gap: .65rem; margin: 0; padding: 0; list-style: none; }
.chip {
  padding: .75rem 1.15rem; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-weight: 500; transition: border-color .25s, transform .25s var(--ease);
}
.chip:hover { border-color: var(--accent); transform: translateY(-2px); }
.tab-panel.is-active .chip { animation: chipIn .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms + 80ms); }
@media (max-width: 820px) { .tab-panel { grid-template-columns: 1fr; gap: 1.25rem; } }

/* ---------- 06 Qualifications ---------- */
.quals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.qual {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 2.5rem;
  min-height: 250px; padding: 2rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .25s ease-out, border-color .3s;
}
.qual::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(184, 145, 58, .16), transparent 45%);
}
.qual:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.qual:hover::before { opacity: 1; }
.qual__badge { font-family: var(--font-serif); font-size: 2.25rem; line-height: 1; color: var(--accent); }
.qual h3 { margin: 0 0 .3rem; font-size: 1.15rem; letter-spacing: -.01em; }
.qual p { margin: 0; font-size: .92rem; color: var(--text-muted); }
@media (max-width: 820px) { .quals { grid-template-columns: 1fr; } .qual { min-height: 0; } }

/* ---------- 07 Resume & articles ---------- */
.docs-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 1.25rem; align-items: start; }
.resume-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: .6rem;
  padding: clamp(1.75rem, 4vw, 2.5rem); border-radius: var(--radius);
  background: radial-gradient(500px 300px at 100% 0%, rgba(205, 169, 84, .22), transparent 60%),
              linear-gradient(150deg, var(--navy-900), var(--navy-700));
  color: #EAF0F8; box-shadow: var(--shadow);
}
.resume-card .eyebrow { color: var(--gold-400); }
.resume-card__icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 1rem; border-radius: 16px; background: rgba(255, 255, 255, .08); color: var(--gold-400); }
.resume-card__icon .i { width: 28px; height: 28px; stroke-width: 1.6; }
.resume-card h3 { margin: 0; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.025em; line-height: 1.15; }
.resume-card__text { margin: 0; color: #A9B8CE; }
.resume-card__actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }
.resume-card__updated { margin: .5rem 0 0; font-size: .8rem; color: #8195B2; }
.resume-card__updated:empty { display: none; }

.article-list { display: grid; gap: .75rem; }
.article-item {
  display: grid; grid-template-columns: 1fr auto; gap: .35rem 1.25rem; align-items: center;
  padding: 1.35rem 1.5rem; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .35s var(--ease), border-color .25s;
}
.article-item:hover { transform: translateY(-3px); border-color: var(--accent); }
.article-item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; font-size: .78rem; color: var(--text-muted); }
.article-item__type { padding: .2rem .6rem; border-radius: 999px; background: var(--gold-100); color: #7A5C1C; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
[data-theme="dark"] .article-item__type { background: rgba(205, 169, 84, .15); color: var(--gold-400); }
.article-item__title { grid-column: 1; font-size: 1.1rem; font-weight: 600; letter-spacing: -.015em; line-height: 1.3; }
.article-item__summary { grid-column: 1; font-size: .92rem; color: var(--text-muted); }
.article-item__arrow {
  grid-column: 2; grid-row: 1 / span 3; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--text);
  transition: transform .35s var(--ease), background-color .25s, color .25s;
}
.article-item:hover .article-item__arrow { transform: translateX(3px); background: var(--accent); color: #fff; }
.article-empty {
  display: grid; place-items: center; align-content: center; gap: .4rem; min-height: 220px; padding: 2rem; text-align: center;
  border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--text-muted);
}
.article-empty strong { font-size: 1.1rem; color: var(--text); }
@media (max-width: 820px) { .docs-grid { grid-template-columns: 1fr; } }

/* ---------- 08 Contact ---------- */
.section--contact { text-align: center; }
.section--contact .section-num { display: inline-block; margin-bottom: 1rem; }
.contact__title { margin: 0 0 1.25rem; font-size: clamp(2.75rem, 9vw, 6rem); line-height: 1; letter-spacing: -.045em; }
.contact__text { max-width: 30em; margin: 0 auto; font-size: 1.1rem; color: var(--text-muted); }
.contact__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; margin-top: 2.25rem; }
.copy-email {
  display: inline-flex; align-items: center; gap: .5rem; margin-top: 1.5rem;
  padding: .4rem .8rem; border-radius: 10px; font-size: .9rem; color: var(--text-muted);
  transition: color .2s, background-color .2s;
}
.copy-email:hover { color: var(--text); background: var(--surface-2); }
.copy-email .i { width: 16px; height: 16px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 1.75rem 0 calc(1.75rem + env(safe-area-inset-bottom)); font-size: .85rem; color: var(--text-muted); }
.footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.footer p { margin: 0; }
.footer a:hover { color: var(--text); }

/* ---------- Toast & back-to-top ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1.5rem + env(safe-area-inset-bottom)); z-index: 300;
  padding: .75rem 1.25rem; border-radius: 999px; background: var(--navy-900); color: #F4F7FB;
  font-size: .9rem; box-shadow: var(--shadow);
  opacity: 0; transform: translate(-50%, 20px); pointer-events: none;
  transition: opacity .4s var(--ease), transform .4s var(--ease);
}
[data-theme="dark"] .toast { background: var(--gold-400); color: var(--navy-900); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.to-top {
  position: fixed; right: 1.25rem; bottom: calc(1.25rem + env(safe-area-inset-bottom)); z-index: 80;
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text);
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(.9);
  transition: opacity .35s var(--ease), transform .35s var(--ease), visibility .35s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { border-color: var(--accent); }

/* ---------- Keyframes ---------- */
@keyframes rise { to { transform: translateY(0); } }
@keyframes fadeUp { to { opacity: 1; transform: none; } }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { to { transform: scale(1); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 122, 109, .45); }
  70% { box-shadow: 0 0 0 10px rgba(31, 122, 109, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 122, 109, 0); }
}
@keyframes drift { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(40px, -30px); } }
@keyframes scrollDot {
  0% { opacity: 0; transform: translate(-50%, 0); }
  40% { opacity: 1; }
  80% { opacity: 0; transform: translate(-50%, 12px); }
  100% { opacity: 0; }
}
@keyframes chipIn { from { opacity: 0; transform: translateY(12px); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(28px) scale(.97); } }
@keyframes modalOut { to { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes backdropIn { from { opacity: 0; } }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }

/* ---------- Accessibility: reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}
