/* ==========================================================================
   Nguyen Hong Quang — portfolio v2
   Design tokens, light-first with system dark mode and manual toggle.
   No framework. Only transform/opacity are animated.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef4f2;
  --border: #dfe6e8;
  --border-strong: #c9d1dd;

  /* Ink */
  --ink: #0b1220;
  --ink-2: #3b4454;
  --muted: #5b6475;
  --faint: #6b7485;

  /* Accent: teal. 0f766e on white = 5.9:1 */
  --accent: #0d8f84;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f0;
  --accent-line: #8fd3ca;

  /* Type */
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", var(--font-sans);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout */
  --container: 1120px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(11, 18, 32, 0.04), 0 8px 24px rgba(11, 18, 32, 0.06);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0f17;
  --surface: #111826;
  --surface-2: #161e2e;
  --border: #243043;
  --border-strong: #324057;
  --ink: #e8ecf2;
  --ink-2: #c3cad6;
  --muted: #9aa4b5;
  --faint: #8a94a6;
  --accent: #2dd4bf;
  --accent-ink: #0b0f17;
  --accent-soft: #10312d;
  --accent-line: #1f6f66;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17;
    --surface: #111826;
    --surface-2: #161e2e;
    --border: #1f2937;
    --border-strong: #2b3648;
    --ink: #e8ecf2;
    --ink-2: #c3cad6;
    --muted: #9aa4b5;
    --faint: #8a94a6;
    --accent: #2dd4bf;
    --accent-ink: #0b0f17;
    --accent-soft: #10312d;
    --accent-line: #1f6f66;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); margin: 0; letter-spacing: -0.01em; line-height: 1.15; }
p { margin: 0; }
code, .mono { font-family: var(--font-mono); font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.skip-link { position: absolute; left: 16px; top: -48px; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 8px; z-index: 100; font-weight: 600; }
.skip-link:focus { top: 16px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
@media (min-width: 768px) { .container { padding: 0 32px; } }

.section, .hero, [id] { scroll-margin-top: 80px; }
.section { padding: 72px 0; }
@media (min-width: 768px) { .section { padding: 104px 0; } }
.section-alt { background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section + .section:not(.section-alt) { border-top: 1px solid var(--border); }

.eyebrow { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 12px; }
.section-title { font-size: clamp(28px, 4vw, 36px); font-weight: 700; }
.section-lead { color: var(--muted); font-size: 17px; max-width: 640px; margin-top: 12px; }

/* --------------------------------------------------------------------------
   Header / nav
   -------------------------------------------------------------------------- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.nav-links { display: none; gap: 24px; list-style: none; margin: 0; padding: 0; }
.nav-links a { color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--ink); }
@media (min-width: 768px) { .nav-links { display: flex; } }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { border-color: var(--border-strong); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 22px; border-radius: 999px; font-weight: 600; font-size: 15px; text-decoration: none; border: 1px solid transparent; cursor: pointer; transition: transform .18s ease, background-color .18s ease, border-color .18s ease; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--ink-2); text-decoration: none; }
.btn-link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 6px; font-weight: 500; }
.btn-link:hover { text-decoration-color: var(--accent); }

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero { padding: 56px 0 40px; }
@media (min-width: 900px) { .hero { padding: 96px 0 56px; min-height: calc(100vh - 64px); display: flex; align-items: center; } }
.hero-grid { display: grid; gap: 40px; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: minmax(0, 1fr) 320px; gap: 64px; } }
.hero-id { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; font-weight: 500; }
.hero-id strong { color: var(--ink); font-weight: 600; }
.hero-id .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.hero-title { font-size: clamp(38px, 6vw, 64px); font-weight: 700; letter-spacing: -0.025em; line-height: 1.02; margin-top: 24px; max-width: 14ch; }
.hero-sub { font-size: clamp(17px, 2vw, 20px); color: var(--muted); margin-top: 24px; max-width: 580px; }
.hero-sub strong { color: var(--ink); font-weight: 600; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center; margin-top: 32px; }
.hero-photo { justify-self: center; width: min(280px, 70vw); }
@media (min-width: 900px) { .hero-photo { width: 320px; } }
.hero-photo img { aspect-ratio: 3 / 4; object-fit: cover; border-radius: 24px; border: 1px solid var(--border); box-shadow: var(--shadow); }

.proof { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--border); margin-top: 48px; }
@media (min-width: 900px) { .proof { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.proof-item { padding: 24px 24px 0 0; }
.proof-value { font-family: var(--font-display); font-size: clamp(28px, 3.4vw, 40px); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.proof-value.accent { color: var(--accent); }
.proof-label { color: var(--muted); font-size: 14px; margin-top: 4px; }
.proof-note { color: var(--faint); font-size: 12.5px; margin-top: 18px; max-width: 760px; }
.proof-note a { color: var(--muted); }

/* --------------------------------------------------------------------------
   Experience timeline
   -------------------------------------------------------------------------- */
.timeline { margin-top: 40px; border-top: 1px solid var(--border); }
.tl-item { display: grid; gap: 12px; padding: 28px 0; border-bottom: 1px solid var(--border); }
@media (min-width: 768px) { .tl-item { grid-template-columns: 180px 1fr; gap: 32px; } }
.tl-when { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.tl-when.current { color: var(--accent); }
.tl-role { font-size: 20px; font-weight: 600; }
.tl-role span { color: var(--muted); font-weight: 500; }
.tl-body { color: var(--ink-2); margin-top: 8px; max-width: 760px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--muted); background: var(--surface); }

/* --------------------------------------------------------------------------
   Cards (case studies, capabilities)
   -------------------------------------------------------------------------- */
.grid { display: grid; gap: 20px; margin-top: 40px; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card { display: flex; flex-direction: column; gap: 14px; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: inherit; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
a.card:hover { transform: translateY(-2px); border-color: var(--accent-line); box-shadow: var(--shadow); text-decoration: none; }
.card-kicker { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.card-title { font-size: 21px; font-weight: 600; line-height: 1.25; }
.card-text { color: var(--muted); font-size: 15px; }
.card-metrics { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--ink-2); }
.card-metrics strong { color: var(--ink); }
.card-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.card-icon svg { width: 20px; height: 20px; }

/* --------------------------------------------------------------------------
   Stack
   -------------------------------------------------------------------------- */
.stack { display: grid; gap: 28px 40px; margin-top: 36px; }
@media (min-width: 700px) { .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stack h3 { font-family: var(--font-sans); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.stack p { color: var(--ink-2); font-size: 15px; margin-top: 8px; }

/* --------------------------------------------------------------------------
   Contact / footer
   -------------------------------------------------------------------------- */
.contact { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-end; justify-content: space-between; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.footer { border-top: 1px solid var(--border); padding: 24px 0 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; color: var(--faint); font-size: 13px; }

/* Sticky contact bar: visible on every page, every scroll position */
body { padding-bottom: 56px; }
.contact-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
.contact-bar .container { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.contact-bar .who { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-bar .who strong { color: var(--ink); font-weight: 600; }
.contact-bar .links { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.contact-bar .links a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.contact-bar .links a:hover { background: var(--surface-2); color: var(--ink); }
.contact-bar .links a.primary { color: var(--accent); font-weight: 600; }
.contact-bar .links svg { width: 16px; height: 16px; }
.contact-bar .label { display: none; }
@media (min-width: 640px) { .contact-bar .label { display: inline; } .contact-bar .links a { padding: 0 12px; } }
@media (max-width: 420px) { .contact-bar .who span { display: none; } }
@media print { .contact-bar { display: none; } body { padding-bottom: 0; } }

/* --------------------------------------------------------------------------
   Case study pages
   -------------------------------------------------------------------------- */
.case { max-width: 880px; margin: 0 auto; padding: 56px 20px 96px; display: flex; flex-direction: column; gap: 56px; }
@media (min-width: 768px) { .case { padding: 72px 32px 112px; } }
.case-kicker { font-family: var(--font-mono); font-size: 13px; color: var(--accent); }
.case-title { font-size: clamp(32px, 5vw, 46px); font-weight: 700; letter-spacing: -0.02em; margin-top: 16px; }
.case-meta { color: var(--muted); font-size: 16px; margin-top: 16px; }
.case-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 28px; }
@media (min-width: 700px) { .case-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; }
.stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat-value.accent { color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.case h2 { font-family: var(--font-mono); font-size: 13px; font-weight: 500; letter-spacing: 0.04em; color: var(--muted); }
.case .prose { font-size: 17px; color: var(--ink-2); margin-top: 14px; }
.case ol { margin: 14px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; color: var(--ink-2); }
.case ol strong { color: var(--ink); }
.case-nav { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }

/* Architecture diagram (stacked boxes, CSS only) */
.arch { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 20px; margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.arch-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; text-align: center; margin-bottom: 8px; }
.node { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px; text-align: center; min-width: 220px; }
.node strong { display: block; font-size: 14px; color: var(--ink); }
.node span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.node.hot { background: var(--accent-soft); border: 2px solid var(--accent); }
.node.band { width: 100%; max-width: 600px; background: var(--surface-2); }
.arrow { width: 20px; height: 20px; color: var(--border-strong); }
.arch-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.arch-col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.arch-side { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: 100%; margin-top: 12px; padding-top: 16px; border-top: 1px dashed var(--border-strong); }
.arch-side .node { min-width: 0; padding: 10px 14px; }
.arch-note { color: var(--muted); font-size: 15px; margin-top: 14px; }
.arch-group { border: 2px solid var(--accent); border-radius: 14px; padding: 16px; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.arch-group > strong { font-size: 14px; }


/* Charts rendered from measured values (inline SVG, theme-aware) */
.chart { margin: 18px 0 0; padding: 20px 20px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.chart svg { width: 100%; height: auto; display: block; font-family: var(--font-sans); }
.chart .bar-before { fill: var(--border-strong); }
.chart .bar-after { fill: var(--accent); }
.chart .lbl { fill: var(--ink-2); font-size: 13px; }
.chart .val { fill: var(--ink); font-size: 13px; font-weight: 600; }
.chart .val-after { fill: var(--accent); font-size: 13px; font-weight: 600; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart figcaption { margin-top: 10px; font-size: 12.5px; color: var(--faint); }
.chart-grid { display: grid; gap: 16px; }
.chart svg { max-width: 720px; }
.chart .legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.chart .legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.chart .legend .b { background: var(--border-strong); } .chart .legend .a { background: var(--accent); }

/* Results table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 16px; }
table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 12px 16px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
td { padding: 12px 16px; border-top: 1px solid var(--border); color: var(--ink-2); vertical-align: top; }
td.v { color: var(--ink); font-weight: 600; }
td.src { color: var(--faint); }

/* Links box */
.links-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.links-box .row { display: flex; flex-wrap: wrap; gap: 12px; }

/* --------------------------------------------------------------------------
   Micro-interactions: reveal on scroll (CSS does the motion, JS flips a class)
   -------------------------------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

/* Embedded demo facade: nothing loads until the user clicks */
.embed { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2) center / cover no-repeat; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .hero-actions, .theme-toggle, .case-nav { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}
