/* ============================================================
   Son Huynh · hardware × AI
   Palette: ink / wafer paper / schematic blue. No gradients.
   Type: Archivo (display, expanded) · Archivo (body) · IBM Plex Mono (data)
   ============================================================ */

:root {
  --ink: #14171a;
  --ink-soft: #3c4145;
  --paper: #f2f3f1;
  --paper-raised: #fafaf8;
  --muted: #6e756f;
  --line: #d7d9d3;
  --accent: #2839e8;
  --font-sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  --nav-h: 72px;
  --gutter: clamp(20px, 4vw, 56px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: var(--paper); }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; }

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

/* ---------- utility type ---------- */

.mono {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--accent);
  flex: none;
}

.display {
  font-stretch: 112%;
  font-weight: 540;
  letter-spacing: -0.028em;
  line-height: 1.02;
}

/* blinking cursor block */
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ---------- loader ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: clamp(20px, 4vw, 48px);
  transition: transform 0.7s var(--ease-out);
}

.loader.is-done { transform: translateY(-101%); }

.loader-name {
  font-stretch: 112%;
  font-weight: 540;
  letter-spacing: -0.02em;
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  line-height: 1;
}

.loader-count {
  font-family: var(--font-mono);
  font-size: clamp(2.4rem, 9vw, 6rem);
  font-weight: 400;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.loader-count sup {
  font-size: 0.3em;
  vertical-align: super;
  color: var(--accent);
}

/* ---------- page transition wipe ---------- */

.wipe {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: var(--ink);
  transform: translateY(101%);
  pointer-events: none;
}

.wipe.is-in {
  transition: transform 0.45s var(--ease-out);
  transform: translateY(0);
}

/* ---------- nav ---------- */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  transition: transform 0.4s var(--ease-out);
}

.nav.is-hidden { transform: translateY(-100%); }

.nav-brand {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 36px);
}

.nav-link {
  font-size: 0.92rem;
  font-weight: 460;
  position: relative;
  padding: 4px 0;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 1.5px;
  width: 100%;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.35s var(--ease-out);
}

.nav-link:hover::after,
.nav-link[aria-current="page"]::after {
  transform: scaleX(1);
  transform-origin: left;
}

.nav-cta {
  font-size: 0.88rem;
  font-weight: 500;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 20px;
  border-radius: 999px;
  transition: background 0.25s ease;
}

.nav-cta:hover { background: var(--accent); }

/* mobile menu */
.nav-toggle {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 8px;
}

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 var(--gutter);
  gap: 8px;
  transform: translateY(-101%);
  transition: transform 0.5s var(--ease-out);
}

.mobile-menu.is-open { transform: translateY(0); }

.mobile-menu a {
  font-stretch: 112%;
  font-weight: 540;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.mobile-menu a span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  vertical-align: super;
  margin-right: 12px;
}

/* ---------- layout shell ---------- */

.page {
  position: relative;
  z-index: 2;
  background: var(--paper);
  padding-top: var(--nav-h);
}

.section {
  padding: clamp(72px, 10vw, 140px) var(--gutter);
  border-bottom: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: clamp(36px, 6vw, 72px);
}

.section-title {
  font-stretch: 112%;
  font-weight: 540;
  letter-spacing: -0.028em;
  line-height: 1.05;
  font-size: clamp(1.9rem, 4.6vw, 3.4rem);
}

/* ---------- reveal ---------- */

[data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  transition-delay: var(--d, 0s);
}

[data-reveal].is-in {
  opacity: 1;
  transform: translateY(0);
}

/* hero line mask reveal */
.line {
  display: block;
  overflow: hidden;
}

.line-inner {
  display: block;
  transform: translateY(112%);
  transition: transform 0.9s var(--ease-out);
  transition-delay: var(--d, 0s);
}

.is-loaded .line-inner { transform: translateY(0); }

/* ---------- hero ---------- */

.hero {
  min-height: calc(97svh - var(--nav-h));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(72px, 8vw, 110px) var(--gutter) 0;
  border-bottom: 1px solid var(--line);
}

.hero-status {
  margin-bottom: clamp(20px, 3vw, 32px);
}

.hero-title {
  font-stretch: 112%;
  font-weight: 540;
  letter-spacing: -0.032em;
  line-height: 0.98;
  font-size: clamp(2.6rem, 8.2vw, 7.2rem);
  text-wrap: balance;
  max-width: 18ch;
}

.hero-title em {
  font-style: normal;
  color: var(--accent);
}

.hero-sub {
  margin-top: clamp(24px, 3.5vw, 40px);
  max-width: 52ch;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--ink-soft);
  display: flex;
  gap: 16px;
}

.hero-sub::before {
  content: "";
  flex: none;
  width: 40px;
  height: 1.5px;
  background: var(--ink);
  margin-top: 0.75em;
}

/* signature waveform: clock edges -> spike train */
.hero-wave {
  margin-top: clamp(40px, 6vw, 80px);
  position: relative;
}

.hero-wave svg {
  display: block;
  width: 100%;
  height: clamp(70px, 10vw, 120px);
}

.hero-wave .wave-path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
}

.hero-wave .wave-dot { fill: var(--accent); }

.hero-wave-labels {
  display: flex;
  justify-content: space-between;
  padding: 10px 0 28px;
  color: var(--muted);
}

/* ---------- work rows (index) ---------- */

.work-list { border-top: 1px solid var(--line); }

.work-row {
  display: grid;
  grid-template-columns: minmax(48px, 90px) 1fr auto;
  align-items: baseline;
  gap: clamp(14px, 3vw, 40px);
  padding: clamp(24px, 3.6vw, 44px) 0;
  border-bottom: 1px solid var(--line);
  position: relative;
  transition: padding-left 0.35s var(--ease-out);
}

.work-row:hover { padding-left: 14px; }

.work-index {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  transition: color 0.25s ease;
}

.work-row:hover .work-index { color: var(--accent); }

.work-main { min-width: 0; display: block; }

.work-name {
  display: block;
  font-stretch: 112%;
  font-weight: 540;
  letter-spacing: -0.024em;
  line-height: 1.08;
  font-size: clamp(1.5rem, 3.6vw, 2.7rem);
}

.work-desc {
  display: block;
  margin-top: 10px;
  max-width: 62ch;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.work-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  text-align: right;
}

.work-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.work-link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.3s ease, transform 0.3s var(--ease-out);
}

.work-row:hover .work-link {
  opacity: 1;
  transform: translateX(0);
}

.work-more {
  margin-top: clamp(28px, 4vw, 44px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 0.95rem;
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: 3px;
}

.work-more:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- capabilities ---------- */

.cap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.cap-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: clamp(22px, 3vw, 36px) clamp(18px, 2.4vw, 28px);
  min-height: 168px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  transition: background 0.3s ease;
}

.cap-cell:hover { background: var(--paper-raised); }

.cap-cell .mono { color: var(--accent); }

.cap-name {
  font-weight: 540;
  font-stretch: 108%;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.cap-note {
  font-size: 0.88rem;
  color: var(--muted);
}

/* ---------- about teaser / statement ---------- */

.statement {
  font-stretch: 108%;
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.3;
  font-size: clamp(1.35rem, 2.9vw, 2.2rem);
  max-width: 30ch;
  text-wrap: balance;
}

.statement em {
  font-style: normal;
  color: var(--accent);
}

.statement-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: clamp(28px, 5vw, 64px);
  align-items: end;
}

.statement-aside {
  max-width: 34ch;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.statement-aside .work-more { margin-top: 18px; }

/* ---------- case studies (projects page) ---------- */

.case {
  padding: clamp(64px, 9vw, 120px) var(--gutter);
  border-bottom: 1px solid var(--line);
}

.case-head {
  display: grid;
  grid-template-columns: minmax(48px, 90px) 1fr;
  gap: clamp(14px, 3vw, 40px);
  align-items: baseline;
}

.case-index {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
}

.case-title {
  font-stretch: 112%;
  font-weight: 540;
  letter-spacing: -0.026em;
  line-height: 1.02;
  font-size: clamp(2rem, 5.4vw, 4rem);
  max-width: 16ch;
}

.case-body {
  display: grid;
  grid-template-columns: minmax(48px, 90px) minmax(0, 60ch) 1fr;
  gap: clamp(14px, 3vw, 40px);
  margin-top: clamp(24px, 3.6vw, 40px);
}

.case-copy p + p { margin-top: 1em; }
.case-copy { color: var(--ink-soft); }

.case-side {
  justify-self: end;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: flex-end;
  text-align: right;
  min-width: 180px;
}

.case-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 240px;
}

.case-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(20px, 4vw, 56px);
  margin-top: clamp(28px, 4vw, 44px);
  padding-top: clamp(18px, 2.5vw, 26px);
  border-top: 1px solid var(--line);
  grid-column: 2 / 4;
}

.case-body .case-metrics { grid-column: 2 / 4; }

.metric b {
  display: block;
  font-stretch: 112%;
  font-weight: 540;
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.metric span {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.repo-link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  white-space: nowrap;
}

.repo-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

/* ---------- about page ---------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}

.about-portrait {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
}

.about-portrait img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  filter: grayscale(100%) contrast(1.05);
  transition: filter 0.5s ease;
}

.about-portrait:hover img { filter: grayscale(0%); }

.about-portrait figcaption {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.about-copy p {
  color: var(--ink-soft);
  max-width: 58ch;
}

.about-copy p + p { margin-top: 1.1em; }

.about-copy .statement { margin-bottom: clamp(24px, 3vw, 36px); max-width: 24ch; }

/* fact table (education / experience) */

.fact-list { border-top: 1px solid var(--line); }

.fact-row {
  display: grid;
  grid-template-columns: minmax(120px, 200px) 1fr auto;
  gap: clamp(14px, 3vw, 40px);
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

.fact-when {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

.fact-what b {
  font-weight: 540;
  font-stretch: 108%;
  font-size: 1.05rem;
  display: block;
}

.fact-what span { color: var(--muted); font-size: 0.9rem; }

.fact-note {
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 34ch;
  text-align: right;
}

/* skills chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  padding: 8px 14px;
  border-radius: 999px;
}

/* ---------- photography ---------- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(16px, 2.5vw, 32px);
}

.photo {
  position: relative;
  overflow: hidden;
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s var(--ease-out);
}

.photo:hover img { transform: scale(1.03); }

.ph-a { grid-column: 1 / 8; }
.ph-b { grid-column: 8 / 13; margin-top: clamp(40px, 8vw, 120px); }
.ph-c { grid-column: 3 / 11; }
.ph-d { grid-column: 1 / 13; }

.ph-a .photo { aspect-ratio: 4 / 3; }
.ph-b .photo { aspect-ratio: 4 / 5; }
.ph-c .photo { aspect-ratio: 16 / 9; }
.ph-d .photo { aspect-ratio: 3 / 2; }

.photo-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 0;
  color: var(--muted);
}

.photo-note {
  margin-top: clamp(48px, 7vw, 88px);
  max-width: 44ch;
  color: var(--ink-soft);
}

/* ---------- contact page ---------- */

.contact-hero {
  padding: clamp(80px, 12vw, 160px) var(--gutter) clamp(64px, 9vw, 120px);
  border-bottom: 1px solid var(--line);
}

.contact-email {
  display: inline-block;
  margin-top: clamp(28px, 4vw, 44px);
  font-stretch: 112%;
  font-weight: 540;
  letter-spacing: -0.03em;
  line-height: 1;
  font-size: clamp(1.5rem, 4.6vw, 4rem);
  border-bottom: 3px solid var(--ink);
  padding-bottom: 8px;
  transition: color 0.25s ease, border-color 0.25s ease;
  overflow-wrap: anywhere;
}

.contact-email:hover { color: var(--accent); border-color: var(--accent); }

.contact-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(24px, 4vw, 48px);
}

.contact-col .mono { color: var(--muted); margin-bottom: 14px; display: block; }

.contact-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 460;
  transition: color 0.2s ease;
}

.contact-item:hover { color: var(--accent); }

.contact-item .mono { color: var(--accent); margin: 0; }

/* ---------- parallax footer ---------- */

.footer-spacer { height: 0; }

.footer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--ink);
  color: var(--paper);
  padding: clamp(56px, 8vw, 100px) var(--gutter) clamp(24px, 3vw, 36px);
  display: flex;
  flex-direction: column;
  gap: clamp(40px, 7vw, 90px);
  min-height: 70svh;
  justify-content: space-between;
}

.footer-cta-label { color: #8b9190; }

.footer-email {
  display: inline-block;
  margin-top: 18px;
  font-stretch: 112%;
  font-weight: 540;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-size: clamp(1.6rem, 5.4vw, 4.6rem);
  overflow-wrap: anywhere;
  position: relative;
}

.footer-email::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  height: 3px;
  width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.45s var(--ease-out);
}

.footer-email:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 32px;
  align-items: flex-start;
}

.footer-col .mono { color: #8b9190; display: block; margin-bottom: 12px; }

.footer-col a {
  display: block;
  padding: 3px 0;
  font-size: 0.95rem;
  color: var(--paper);
  width: fit-content;
  position: relative;
}

.footer-col a:hover { color: #b9bfbd; }

.footer-status {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b9190;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  border-top: 1px solid #2c3134;
  padding-top: 20px;
  justify-content: space-between;
}

.footer-status .t-accent { color: var(--accent); }

/* ============================================================
   responsive
   ============================================================ */

@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-toggle { display: block; }

  .work-row { grid-template-columns: minmax(36px, 52px) 1fr; }
  .work-meta {
    grid-column: 2;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    margin-top: 12px;
  }
  .work-link { display: none; }

  .case-head { grid-template-columns: minmax(36px, 52px) 1fr; }
  .case-body { grid-template-columns: 1fr; }
  .case-body > .case-copy { grid-column: 1; }
  .case-side {
    justify-self: start;
    align-items: flex-start;
    text-align: left;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .case-tags { justify-content: flex-start; }
  .case-metrics { grid-column: 1; }

  .statement-wrap { grid-template-columns: 1fr; align-items: start; }

  .about-grid { grid-template-columns: 1fr; }
  .about-portrait { position: static; max-width: 420px; }

  .fact-row { grid-template-columns: 1fr; gap: 6px; }
  .fact-note { text-align: left; max-width: 58ch; }

  .ph-a, .ph-b, .ph-c, .ph-d { grid-column: 1 / 13; margin-top: 0; }

  .footer { min-height: auto; }
}

/* ============================================================
   reduced motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  [data-reveal],
  .line-inner {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .loader, .wipe { transition: none; }
  .cursor { animation: none; }
  .photo img, .work-row { transition: none; }
}
