/*
  Design system (kept honest, no hidden magic)
  Palette: Fog (bg), Ink (text), Signal orange (the ONE accent), Deep navy (one contrast band)
  Type: Bricolage Grotesque (display), Be Vietnam Pro (body, full Vietnamese), JetBrains Mono (numbers, metadata)
  Shape: one radius everywhere (--r)
  Signature: the ledger line, "label ........ value", reused for results, education and certificates
  Z-index scale: nav 20
*/
:root {
  --bg: #e8ecf0;
  --surface: #f4f6f8;
  --ink: #101b26;
  --muted: #475663;
  --line: #c7cfd7;
  --line-strong: #8d9aa6;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--bg));
  --band: #12202d;
  --band-ink: #e8eef3;
  --band-muted: #a9b8c5;
  --r: 10px;
  --display: "Bricolage Grotesque", "Be Vietnam Pro", system-ui, sans-serif;
  --body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --z-nav: 20;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d141b;
    --surface: #141d26;
    --ink: #e8edf1;
    --muted: #9aa8b5;
    --line: #263340;
    --line-strong: #5a6b7a;
    --accent: #ff8a4c;
    --accent-ink: #1b0e05;
    --accent-soft: color-mix(in srgb, var(--accent) 13%, var(--bg));
    --band: #172431;
    --band-ink: #e8eef3;
    --band-muted: #a3b2bf;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d141b;
  --surface: #141d26;
  --ink: #e8edf1;
  --muted: #9aa8b5;
  --line: #263340;
  --line-strong: #5a6b7a;
  --accent: #ff8a4c;
  --accent-ink: #1b0e05;
  --accent-soft: color-mix(in srgb, var(--accent) 13%, var(--bg));
  --band: #172431;
  --band-ink: #e8eef3;
  --band-muted: #a3b2bf;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.7 var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 650; letter-spacing: -0.02em; margin: 0; line-height: 1.1; }
p { margin: 0 0 1rem; max-width: 66ch; }
ul { margin: 0; padding: 0; list-style: none; }
b, strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding-inline: 20px; }
.section { padding-block: clamp(64px, 9vw, 120px) 0; }
.section > .wrap > h2 { font-size: clamp(1.9rem, 4.2vw, 3rem); margin-bottom: clamp(28px, 4vw, 48px); max-width: 20ch; }

/* ---------- Buttons and chips ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 0 22px;
  border-radius: var(--r); border: 1.5px solid var(--ink);
  background: transparent; color: var(--ink);
  font: 600 0.95rem/1 var(--body); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: transform 0.25s var(--ease), background 0.2s, color 0.2s, border-color 0.2s;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn:active { transform: translateY(1px) scale(0.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn i { font-size: 1.15em; transition: transform 0.25s var(--ease); }
.btn:hover i.ph-arrow-right, .btn:hover i.ph-arrow-up-right { transform: translateX(3px); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips li {
  font: 500 0.78rem/1 var(--mono); color: var(--muted);
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r); background: transparent;
}
.iconbtn {
  text-decoration: none;
  display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r); background: transparent; color: var(--ink);
  font: 600 0.8rem/1 var(--mono); cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.iconbtn:hover { border-color: var(--accent); color: var(--accent); }
.iconbtn i { font-size: 1.2rem; }
#navCv { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; border-bottom: 1.5px solid var(--accent); padding-bottom: 1px; }
.link-arrow:hover { color: var(--accent); }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { font: 700 1.25rem/1 var(--display); letter-spacing: -0.03em; text-decoration: none; margin-right: auto; }
.brand span { color: var(--accent); }
.nav-links { display: flex; gap: 4px; }
.nav-links a { padding: 8px 12px; border-radius: var(--r); font-size: 0.9rem; font-weight: 500; color: var(--muted); text-decoration: none; transition: color 0.2s, background 0.2s; }
.nav-links a:hover, .nav-links a[aria-current="true"] { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.nav .btn { min-height: 40px; padding: 0 16px; font-size: 0.88rem; }
.tools { display: flex; gap: 6px; }
@media (max-width: 960px) { .nav-links { display: none; } }
@media (max-width: 520px) { .nav .btn { display: none; } }

/* ---------- Hero ---------- */
.hero {
  min-height: calc(100dvh - 64px);
  display: flex; align-items: center;
  padding-block: 40px 56px;
}
.hero-in { display: flow-root; width: 100%; }
/* The photo sits inside the text flow: floated right, text hugs the circle */
.avatar { float: right; margin: 8px 0 20px clamp(16px, 4vw, 48px); width: clamp(132px, 25vw, 340px); aspect-ratio: 1; shape-outside: circle(50%); position: relative; }
.avatar::before { content: ""; position: absolute; inset: 12px -12px -12px 12px; border: 1.5px solid var(--accent); border-radius: 50%; }
.avatar img { position: relative; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: var(--surface); }
.eyebrow { font: 500 0.88rem/1.4 var(--mono); color: var(--muted); margin: 0 0 20px; max-width: none; }
.hero h1 { font-size: clamp(2.6rem, 6.2vw, 4.75rem); line-height: 1.03; letter-spacing: -0.04em; font-weight: 700; margin-bottom: 28px; text-wrap: balance; }
.hero h1 em { font-style: normal; color: var(--accent); text-decoration: underline; text-decoration-thickness: 0.06em; text-underline-offset: 0.12em; }
.hero .sub { font-size: clamp(1.1rem, 1.9vw, 1.35rem); line-height: 1.55; color: var(--muted); max-width: 44ch; margin-bottom: 32px; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 12px; }
@media (max-width: 800px) { .hero { min-height: 0; padding-block: 40px 24px; } .avatar { margin-right: 12px; } }

/* ---------- Ledger (signature) ---------- */
.ledger-groups { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 6vw, 88px); }
.ledger-groups h3 { font-size: 1.15rem; margin-bottom: 18px; color: var(--accent); }
.ledger li { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; }
.ledger .dots { flex: 1; min-width: 16px; border-bottom: 1.5px dotted var(--line-strong); transform: translateY(-4px); }
.ledger .val { font: 600 1.05rem/1.2 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.ledger .lab { color: var(--muted); max-width: 70%; line-height: 1.4; }
@media (max-width: 800px) { .ledger-groups { grid-template-columns: 1fr; } }

/* ---------- About ---------- */
.about-pull { font: 700 clamp(1.7rem, 3.6vw, 2.7rem)/1.12 var(--display); letter-spacing: -0.03em; max-width: 22ch; margin-bottom: 28px; }
.about-copy { max-width: 66ch; font-size: 1.05rem; }
.band {
  background: var(--band); color: var(--band-ink);
  margin-top: clamp(56px, 8vw, 96px);
  padding-block: clamp(48px, 7vw, 88px);
}
.band-grid { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: clamp(28px, 6vw, 88px); align-items: start; }
.band h2 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); position: sticky; top: 96px; }
.does { display: grid; gap: clamp(26px, 3.4vw, 40px); }
.does h3 { font-size: 1.35rem; margin-bottom: 8px; color: var(--band-ink); }
.does p { color: var(--band-muted); margin: 0; max-width: 56ch; }
.does li { padding-left: 18px; border-left: 2px solid var(--accent); }
@media (max-width: 800px) { .band-grid { grid-template-columns: 1fr; } .band h2 { position: static; } }

/* ---------- Case study ---------- */
.case { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: clamp(28px, 6vw, 80px); padding-bottom: clamp(40px, 6vw, 72px); }
.case-head { align-self: start; position: sticky; top: 96px; }
.case-head h3 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 10px; }
.case-head .role { font: 400 0.84rem/1.5 var(--mono); color: var(--muted); margin-bottom: 14px; }
.case-head p { color: var(--muted); }
.case-head .chips { margin: 18px 0 22px; }
.case-body > div { padding: 22px 0 26px; border-top: 1.5px solid var(--line); }
.case-body > div:first-child { padding-top: 0; border-top: 0; }
.case-body h4 { font-size: 1.1rem; margin-bottom: 10px; }
.case-body .outcome h4 { color: var(--accent); }
.case-body .bullets li { position: relative; padding-left: 20px; margin-bottom: 10px; max-width: 66ch; }
.case-body .bullets li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 8px; height: 1.5px; background: var(--accent); }
.case-body .outcome p { font-size: 1.12rem; line-height: 1.6; margin: 0; }
.note { font-size: 0.86rem; color: var(--muted); margin: 14px 0 0; }
@media (max-width: 800px) { .case { grid-template-columns: 1fr; } .case-head { position: static; } }

/* ---------- System map ---------- */
.map { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(20px, 3vw, 36px); margin-bottom: clamp(48px, 7vw, 88px); }
.map h3 { font-size: 1.5rem; margin-bottom: 4px; }
.map .hint { color: var(--muted); font-size: 0.92rem; margin-bottom: 20px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.tab { min-height: 44px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: var(--r); background: transparent; color: var(--ink); font: 600 0.9rem/1 var(--body); cursor: pointer; transition: border-color 0.2s, background 0.2s, color 0.2s; }
.tab:hover { border-color: var(--ink); }
.tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.steps { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; }
.step { position: relative; padding: 0 12px 0 0; display: flex; }
.step button {
  position: relative; width: 100%; text-align: left; cursor: pointer;
  background: transparent; color: var(--ink); border: 1.5px solid var(--line); border-radius: var(--r);
  padding: 14px 12px; min-height: 84px; height: 100%; font: 500 0.9rem/1.3 var(--body);
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--ease);
}
.step button:hover { border-color: var(--ink); }
.step .n { display: block; font: 500 0.74rem/1 var(--mono); color: var(--muted); margin-bottom: 10px; }
.step.passed button { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.step.passed .n { color: var(--accent); }
.step.active button { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-3px); }
.step.active .n { color: var(--accent); }
.step:not(:last-child)::after {
  content: ""; position: absolute; right: 0; top: 50%; width: 12px; height: 1.5px; background: var(--line-strong);
  transition: background 0.3s;
}
.step.passed:not(:last-child)::after { background: var(--accent); }
.detail { margin-top: 22px; padding: 18px 20px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--r) var(--r) 0; min-height: 5.5rem; }
.detail h4 { font-size: 1.15rem; margin-bottom: 6px; }
.detail p { margin: 0; }
@media (max-width: 800px) {
  .steps { grid-auto-flow: row; gap: 0; }
  .step { padding: 0 0 12px 0; }
  .step button { min-height: 0; }
  .step:not(:last-child)::after { right: auto; left: 22px; top: auto; bottom: 0; width: 1.5px; height: 12px; }
}

/* ---------- BrownVN ---------- */
.brown { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: clamp(28px, 6vw, 80px); padding-top: clamp(40px, 6vw, 72px); border-top: 1.5px solid var(--line); }
.brown h3 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 10px; }
.brown .role { font: 400 0.84rem/1.5 var(--mono); color: var(--muted); margin-bottom: 14px; }
.figures { display: flex; gap: 32px; margin: 8px 0 22px; }
.figures b { display: block; font: 600 clamp(2.2rem, 4.4vw, 3.2rem)/1 var(--mono); letter-spacing: -0.04em; color: var(--accent); }
.figures span { font-size: 0.86rem; color: var(--muted); }
.brown .bullets li { position: relative; padding-left: 20px; margin-bottom: 12px; max-width: 66ch; }
.brown .bullets li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 8px; height: 1.5px; background: var(--accent); }
.brown .chips { margin: 20px 0; }
@media (max-width: 800px) { .brown { grid-template-columns: 1fr; } }

/* ---------- Timeline ---------- */
.rail { position: relative; margin-left: 4px; }
.rail::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 1.5px; background: var(--line-strong); }
.entry { position: relative; padding: 0 0 clamp(36px, 5vw, 56px) clamp(26px, 4vw, 48px); }
.entry:last-child { padding-bottom: 0; }
.entry::before { content: ""; position: absolute; left: -5px; top: 9px; width: 11px; height: 11px; background: var(--bg); border: 2px solid var(--accent); border-radius: 3px; }
.entry.major::before { background: var(--accent); }
.entry-date { font: 500 0.84rem/1.4 var(--mono); color: var(--muted); margin-bottom: 6px; }
.entry h3 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); margin-bottom: 4px; }
.entry .meta { color: var(--muted); font-size: 0.92rem; margin-bottom: 12px; }
.entry .bullets li { position: relative; padding-left: 20px; margin-bottom: 10px; max-width: 70ch; }
.entry .bullets li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 8px; height: 1.5px; background: var(--accent); }
.entry details { margin-top: 18px; max-width: 70ch; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.entry summary { cursor: pointer; padding: 14px 18px; font: 600 0.95rem/1.3 var(--body); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; }
.entry summary::-webkit-details-marker { display: none; }
.entry summary i { transition: transform 0.25s var(--ease); }
.entry details[open] summary i { transform: rotate(45deg); }
.entry details ul { padding: 0 18px 8px; }
.entry details li { position: relative; padding-left: 20px; margin-bottom: 12px; }
.entry details li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 8px; height: 1.5px; background: var(--accent); }

/* ---------- University bento (thesis + voucher + homestay + hospital) ---------- */
.bento { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cell { border: 1px solid var(--line); border-radius: var(--r); padding: clamp(20px, 2.6vw, 30px); display: flex; flex-direction: column; gap: 10px; transition: border-color 0.25s, transform 0.3s var(--ease); }
.cell:hover { border-color: var(--ink); transform: translateY(-2px); }
.cell h3 { font-size: clamp(1.3rem, 2.2vw, 1.7rem); }
.cell .date { font: 500 0.8rem/1.4 var(--mono); color: var(--muted); }
.cell .cs { color: var(--muted); font-weight: 500; margin: 0; }
.cell p { margin: 0; font-size: 0.97rem; }
.cell .chips { margin-top: auto; padding-top: 6px; }
.cell .link-arrow { align-self: flex-start; font-size: 0.92rem; }
.cell.thesis { grid-column: 1 / -1; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); justify-content: flex-start; }
.cell.thesis h3 { font-size: clamp(1.8rem, 3.2vw, 2.5rem); }
.cell.thesis p { font-size: 1.02rem; }
.cell.hospital, .cell.voucher { background: var(--surface); }
.cell-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.cell.thesis p { max-width: 80ch; }
.cell.hospital { grid-column: 1 / -1; }
.cell.hospital p { max-width: 80ch; }
@media (max-width: 800px) { .bento { grid-template-columns: 1fr; } .cell.thesis, .cell.hospital { grid-column: auto; } }

/* ---------- Skills strata ---------- */
.strata { display: grid; gap: 10px; }
.layer { display: grid; grid-template-columns: minmax(150px, 190px) 1fr; gap: 18px; align-items: center; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); margin-left: calc(var(--step) * 28px); }
.layer h3 { font: 650 1rem/1.25 var(--display); letter-spacing: -0.01em; }
.layer.edge { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.layer.edge h3 { color: var(--accent); }
.layer .chips li { background: var(--bg); }
.business { margin-top: 28px; padding: 20px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); display: grid; grid-template-columns: minmax(150px, 190px) 1fr; gap: 18px; align-items: center; }
.business h3 { font: 650 1rem/1.25 var(--display); }
.skills-intro { color: var(--muted); margin-top: -20px; margin-bottom: 28px; }
@media (max-width: 800px) { .layer, .business { grid-template-columns: 1fr; margin-left: 0; gap: 10px; } }

/* ---------- Education ---------- */
.edu { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(28px, 6vw, 88px); }
.edu h3 { font-size: 1.5rem; margin-bottom: 4px; }
.edu .meta { color: var(--muted); margin-bottom: 16px; max-width: 34ch; }
.cert-group { margin-bottom: 26px; }
.cert-group h4 { font-size: 1rem; color: var(--accent); margin-bottom: 8px; }
.cert-group li { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; }
.cert-group .dots { flex: 1; min-width: 12px; border-bottom: 1.5px dotted var(--line-strong); transform: translateY(-4px); }
.cert-group .by { font: 400 0.82rem/1.3 var(--mono); color: var(--muted); text-align: right; }
.cert-group a { text-decoration-color: var(--line-strong); }
.edu .cols-title { font-size: 1.5rem; margin-bottom: 16px; }
@media (max-width: 800px) { .edu { grid-template-columns: 1fr; } .cert-group li { flex-wrap: wrap; } .cert-group .dots { display: none; } .cert-group .by { text-align: left; width: 100%; } }

/* ---------- Contact ---------- */
.contact { padding-block: clamp(72px, 10vw, 140px) clamp(48px, 6vw, 72px); }
.contact h2 { font-size: clamp(2rem, 5vw, 3.8rem); max-width: 24ch; line-height: 1.03; letter-spacing: -0.035em; margin-bottom: 22px; }
.contact p { font-size: 1.1rem; color: var(--muted); max-width: 52ch; margin-bottom: 28px; }
.contact-links { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-top: 30px; }
.contact-links a { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; min-height: 44px; font-weight: 500; }
.contact-links a:hover { color: var(--accent); }
.contact-links i { font-size: 1.25rem; }
footer { border-top: 1px solid var(--line); padding-block: 22px; color: var(--muted); font-size: 0.85rem; }

/* ---------- Motion (hierarchy on load, sequence on scroll). Off for reduced motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .hero .eyebrow, .js .hero h1, .js .hero .sub, .js .hero .cta, .js .hero .avatar {
    opacity: 0; transform: translateY(18px); animation: rise 0.8s var(--ease) forwards;
  }
  .js .hero h1 { animation-delay: 0.08s; }
  .js .hero .sub { animation-delay: 0.18s; }
  .js .hero .cta { animation-delay: 0.28s; }
  @keyframes rise { to { opacity: 1; transform: none; } }
  .js .rv { opacity: 0; transform: translateY(20px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); transition-delay: var(--d, 0s); }
  .js .rv.in { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media print { .js .rv { opacity: 1; transform: none; } }
