/* ==========================================================================
   Chris Nguyen — portfolio
   One stylesheet for every page. Monochrome palette; gold lives only in the logo.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #f9f9f9;
  --bg-alt: #f3f3f3;
  --card: #ffffff;
  --card-sunk: #ececec;
  --ink: #000000;
  --ink-2: #474747;
  --ink-3: #777777;
  --line: rgb(0 0 0 / 0.08);
  --invert-bg: #000000;
  --invert-ink: #f9f9f9;
  --invert-ink-2: rgb(249 249 249 / 0.62);
  --nav-bg: rgb(249 249 249 / 0.72);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 12px 32px rgb(0 0 0 / 0.06);
  --gold: #c8963e;
  --logo-ink: #1f2a33;

  --font-display: "Inter Tight", "Inter", system-ui, -apple-system, sans-serif;
  --font-text: "Inter", system-ui, -apple-system, sans-serif;

  --radius: 20px;
  --radius-sm: 12px;
  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --section: clamp(88px, 11vw, 144px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

:root.dark {
  --bg: #000000;
  --bg-alt: #0e0e0e;
  --card: #161616;
  --card-sunk: #222222;
  --ink: #f5f5f5;
  --ink-2: #b4b4b4;
  --ink-3: #8e8e8e;
  --line: rgb(255 255 255 / 0.1);
  --invert-bg: #f5f5f5;
  --invert-ink: #000000;
  --invert-ink-2: rgb(0 0 0 / 0.6);
  --nav-bg: rgb(0 0 0 / 0.66);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.5);
  --logo-ink: #f5f5f5;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600; transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: calc(var(--wrap) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: var(--section) 0; }
.section--alt { background: var(--bg-alt); }

/* ---------- Type ---------- */
.display, .h1, .h2, .h3 { font-family: var(--font-display); font-weight: 600; color: var(--ink); }
.display { font-size: clamp(44px, 7.4vw, 96px); line-height: 1.02; letter-spacing: -0.04em; }
.h1 { font-size: clamp(38px, 5.4vw, 72px); line-height: 1.04; letter-spacing: -0.035em; }
.h2 { font-size: clamp(30px, 3.6vw, 48px); line-height: 1.08; letter-spacing: -0.03em; }
.h3 { font-size: clamp(21px, 1.9vw, 26px); line-height: 1.2; letter-spacing: -0.02em; }
.lede { font-size: clamp(18px, 1.6vw, 22px); line-height: 1.5; color: var(--ink-2); letter-spacing: -0.01em; }
.eyebrow {
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-3);
}
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); }

.section-head { display: grid; gap: 16px; max-width: 720px; margin-bottom: clamp(40px, 5vw, 64px); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 22px; border-radius: 999px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap;
  transition: transform .2s var(--ease), background-color .2s var(--ease), opacity .2s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--ink); color: var(--bg); }
.btn--primary:hover { opacity: 0.82; }
.btn--secondary { background: var(--card-sunk); color: var(--ink); }
.btn--secondary:hover { background: color-mix(in srgb, var(--card-sunk) 80%, var(--ink) 8%); }
.btn--invert { background: var(--invert-ink); color: var(--invert-bg); }
.btn--invert:hover { opacity: 0.85; }
.btn--ghost-invert { background: rgb(128 128 128 / 0.2); color: var(--invert-ink); }
.btn--ghost-invert:hover { background: rgb(128 128 128 / 0.3); }
.btn--lg { min-height: 52px; padding: 0 28px; font-size: 16px; }

.link-arrow {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px;
}
.link-arrow svg { transition: transform .25s var(--ease); }
.link-arrow:hover svg, a:hover > .link-arrow svg, a:hover .link-arrow svg { transform: translate(2px, -2px); }

.icon { width: 16px; height: 16px; flex: none; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.logo svg { width: 22px; height: 28px; }
.logo .logo-ink { fill: var(--logo-ink); }
.logo .logo-gold { fill: var(--gold); }

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  transition: background-color .3s var(--ease), box-shadow .3s var(--ease);
}
.nav.is-scrolled {
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 var(--line);
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 24px; }
.nav__links { display: none; align-items: center; gap: 4px; }
.nav__links a {
  position: relative; padding: 8px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 500; color: var(--ink-2);
  transition: color .2s var(--ease), background-color .2s var(--ease);
}
.nav__links a:hover { color: var(--ink); }
.nav__links a[aria-current="true"], .nav__links a[aria-current="page"] { color: var(--ink); background: var(--card-sunk); }
.nav__actions { display: flex; align-items: center; gap: 6px; }
.nav__cta { display: none; min-height: 36px; padding: 0 16px; font-size: 14px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 999px; color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.icon-btn:hover { background: var(--card-sunk); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.lang-btn { width: auto; padding: 0 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }

.theme-toggle .i-sun { display: none; }
:root.dark .theme-toggle .i-sun { display: block; }
:root.dark .theme-toggle .i-moon { display: none; }

.menu-btn .bar { transition: transform .3s var(--ease), opacity .2s var(--ease); transform-origin: center; }
.menu-open .menu-btn .bar-1 { transform: translateY(3px) rotate(45deg); }
.menu-open .menu-btn .bar-2 { transform: translateY(-3px) rotate(-45deg); }

@media (min-width: 900px) {
  .nav__links { display: flex; }
  .nav__cta { display: inline-flex; }
  .menu-btn { display: none; }
}

/* Mobile menu */
.menu {
  position: fixed; inset: 0; z-index: 49; background: var(--bg);
  padding: 96px var(--gutter) 40px; display: flex; flex-direction: column; gap: 32px;
  opacity: 0; visibility: hidden; transition: opacity .3s var(--ease), visibility 0s linear .3s;
}
.menu-open .menu { opacity: 1; visibility: visible; transition: opacity .3s var(--ease); }
.menu-open { overflow: hidden; }
.menu-open .nav { background: var(--bg); box-shadow: none; }
.menu:focus { outline: none; }
.menu__links { display: grid; gap: 4px; }
.menu__links a {
  font-family: var(--font-display); font-size: 34px; font-weight: 600; letter-spacing: -0.03em;
  padding: 6px 0; color: var(--ink);
}
.menu__foot { margin-top: auto; display: grid; gap: 12px; }
@media (min-width: 900px) { .menu { display: none; } }

/* ---------- Hero ---------- */
.hero { padding: calc(64px + clamp(48px, 8vw, 112px)) 0 var(--section); }
.hero__grid { display: grid; gap: clamp(40px, 6vw, 72px); align-items: end; }
.hero__copy { display: grid; gap: 24px; }
.hero__copy .lede { max-width: 580px; }
.hero__portrait {
  position: relative; border-radius: var(--radius); overflow: hidden; background: var(--card-sunk);
  aspect-ratio: 4 / 5; max-width: 420px; width: 100%;
}
.hero__portrait img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 899px) {
  .hero__portrait { aspect-ratio: 1; }
}
@media (min-width: 900px) {
  .hero__grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
  .hero__portrait { justify-self: end; }
}

.routes { display: grid; gap: 12px; margin-top: 16px; max-width: 640px; }
@media (min-width: 600px) { .routes { grid-template-columns: 1fr 1fr; } }
.route {
  display: grid; gap: 4px; padding: 20px 22px; border-radius: var(--radius-sm);
  background: var(--card); box-shadow: var(--shadow);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.route:hover { transform: translateY(-2px); }
.route--primary { background: var(--ink); color: var(--bg); box-shadow: none; }
.route__label { font-size: 13px; font-weight: 500; opacity: 0.62; }
.route__title { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }

.facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
  margin-top: clamp(56px, 7vw, 96px); padding-top: 28px; box-shadow: 0 -1px 0 var(--line);
}
.fact__value { font-family: var(--font-display); font-weight: 600; font-size: clamp(28px, 3.4vw, 44px); letter-spacing: -0.035em; line-height: 1; }
.fact__label { margin-top: 8px; font-size: 14px; color: var(--ink-2); line-height: 1.4; }

/* ---------- Work ---------- */
.work-grid { display: grid; gap: 20px; }
@media (min-width: 760px) { .work-grid { grid-template-columns: 1fr 1fr; } }
.work-card {
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden;
  background: var(--card); box-shadow: var(--shadow);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease);
}
a.work-card:hover { transform: translateY(-4px); }
.work-card__media { aspect-ratio: 16 / 11; background: var(--card-sunk); overflow: hidden; }
.work-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
a.work-card:hover .work-card__media img { transform: scale(1.03); }
:root.dark .work-card__media img { filter: brightness(0.86); }
.work-card__body { display: grid; gap: 10px; padding: 24px 24px 28px; }
.work-card__top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.work-card__meta { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.metrics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.metric {
  padding: 6px 12px; border-radius: 999px; background: var(--card-sunk);
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
}

.more { margin-top: 20px; display: grid; gap: 12px; }
@media (min-width: 600px) { .more { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .more { grid-template-columns: repeat(4, 1fr); } }
.more-item {
  display: grid; gap: 6px; padding: 22px 24px; border-radius: var(--radius-sm); background: var(--card);
  transition: transform .3s var(--ease);
}
.more-item:hover { transform: translateY(-2px); }
.more-item__title { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.more-item p { font-size: 15px; color: var(--ink-2); line-height: 1.5; }
.more-item--invert { background: var(--ink); color: var(--bg); }
.more-item--invert p { color: var(--bg); opacity: 0.65; }

/* ---------- Experience ---------- */
.exp-grid { display: grid; gap: 48px; }
@media (min-width: 900px) {
  .exp-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.9fr); gap: 72px; }
  .exp-grid .section-head { position: sticky; top: 112px; align-self: start; margin-bottom: 0; }
}
.roles { display: grid; }
.role { display: grid; gap: 8px; padding: 32px 0; box-shadow: 0 -1px 0 var(--line); }
.role:first-child { padding-top: 0; box-shadow: none; }
.role__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.role__org { font-size: 15px; font-weight: 500; color: var(--ink-3); }
.role__when { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.role__now {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink);
}
.role__now::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }
.role p { color: var(--ink-2); max-width: 640px; }
.education { margin-top: 8px; padding: 24px; border-radius: var(--radius-sm); background: var(--card); display: grid; gap: 4px; }

/* ---------- Skills ---------- */
.skills-grid { display: grid; gap: 20px; }
@media (min-width: 600px) { .skills-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .skills-grid { grid-template-columns: repeat(4, 1fr); } }
.skill-col { padding: 28px; border-radius: var(--radius); background: var(--card); display: grid; gap: 20px; align-content: start; }
.skill-col ul { display: grid; gap: 12px; }
.skill-col li { font-size: 16px; }
.award { display: grid; gap: 2px; }
.award strong { font-weight: 600; letter-spacing: -0.01em; }
.award span { font-size: 14px; color: var(--ink-2); }

/* ---------- About ---------- */
.about-grid { display: grid; gap: 48px; }
@media (min-width: 900px) { .about-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 72px; align-items: start; } }
.quote { font-family: var(--font-display); font-weight: 500; font-size: clamp(26px, 3vw, 40px); line-height: 1.22; letter-spacing: -0.022em; }
.about-copy { display: grid; gap: 24px; }
.interests { display: flex; flex-wrap: wrap; gap: 8px; }
.interests li { padding: 8px 14px; border-radius: 999px; background: var(--card); font-size: 14px; font-weight: 500; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photos figure { border-radius: var(--radius-sm); overflow: hidden; background: var(--card-sunk); aspect-ratio: 1; }
.photos figure:first-child { grid-column: span 2; aspect-ratio: 16 / 11; }
.photos figure:not(:first-child) { aspect-ratio: 4 / 5; }
.photos img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); transition: filter .6s var(--ease); }
.photos figure:hover img { filter: grayscale(0); }
.photos figure:first-child img { transform: scale(1.06); transform-origin: 0 50%; }

/* ---------- Contact ---------- */
.contact {
  border-radius: calc(var(--radius) + 8px); background: var(--invert-bg); color: var(--invert-ink);
  padding: clamp(48px, 8vw, 112px) clamp(24px, 6vw, 96px); text-align: center;
  display: grid; justify-items: center; gap: 24px;
}
.contact .h1 { color: var(--invert-ink); max-width: 820px; }
.contact p { color: var(--invert-ink-2); max-width: 560px; }
.contact__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 8px; }
.contact__social { display: flex; gap: 24px; margin-top: 8px; font-size: 15px; font-weight: 500; }
.contact__social a { color: var(--invert-ink-2); transition: color .2s var(--ease); }
.contact__social a:hover { color: var(--invert-ink); }

/* ---------- Footer ---------- */
.footer { padding: 40px 0 48px; }
.footer__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; font-size: 14px; color: var(--ink-3); }
.footer__links { display: flex; gap: 24px; }
.footer__links a:hover { color: var(--ink); }

/* ---------- Freelance ---------- */
.tabs {
  display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--card-sunk);
  overflow-x: auto; scrollbar-width: none; max-width: 100%; width: max-content;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; min-height: 40px; padding: 0 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--ink-2);
  transition: background-color .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.1); }

.case { display: grid; gap: 40px; margin-top: 32px; }
@media (min-width: 960px) { .case { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 56px; align-items: start; } }
.gallery { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--card); aspect-ratio: 4 / 3; touch-action: pan-y; }
.gallery img { width: 100%; height: 100%; object-fit: contain; }
.gallery__btn {
  position: absolute; top: 50%; translate: 0 -50%;
  width: 44px; height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--nav-bg); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: var(--ink); box-shadow: var(--shadow); transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.gallery__btn:active { transform: scale(0.94); }
.gallery__btn[disabled] { opacity: 0; pointer-events: none; }
.gallery__btn--prev { left: 14px; }
.gallery__btn--next { right: 14px; }
.gallery__btn svg { width: 18px; height: 18px; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.dot { display: block; width: 8px; height: 8px; border-radius: 999px; background: var(--ink); opacity: 0.2; transition: opacity .25s var(--ease), width .3s var(--ease); }
.dot[aria-current="true"] { opacity: 1; width: 22px; }
.dot-hit { padding: 10px 2px; }
@media (hover: none) { .gallery__btn { display: none; } }

.case__info { display: grid; gap: 28px; }
.case__info dl { display: grid; gap: 20px; margin: 0; }
.case__info dt { font-size: 13px; font-weight: 600; color: var(--ink-3); margin-bottom: 4px; }
.case__info dd { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 6px 12px; border-radius: 999px; background: var(--card-sunk); font-size: 13px; font-weight: 600; }

/* ---------- Reveal (only when JS + motion allowed) ---------- */
.js-motion [data-reveal] { opacity: 0; transform: translateY(24px); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
