/* minhducvo.com, "Field Notes" direction. Tokens first, then layout, then components. */

:root {
  --bg: #FAF8F4;
  --surface: #FFFFFF;
  --text: #1C1B19;
  --muted: #6B675F;
  --rule: #E4DFD5;
  --accent: #B4462B;
  --accent-soft: rgba(180, 70, 43, 0.08);
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 12px 32px rgba(28, 27, 25, 0.06);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: 16px;
  --col: 680px;
  --wide: 1080px;
  --radius: 14px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211;
    --surface: #1B1A18;
    --text: #EDEAE3;
    --muted: #9A958B;
    --rule: #2C2A26;
    --accent: #E07A5B;
    --accent-soft: rgba(224, 122, 91, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211;
  --surface: #1B1A18;
  --text: #EDEAE3;
  --muted: #9A958B;
  --rule: #2C2A26;
  --accent: #E07A5B;
  --accent-soft: rgba(224, 122, 91, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--bg); }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; }
.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; }
.skip { position: absolute; left: var(--gutter); top: -100px; z-index: 100; background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; text-decoration: none; }
.skip:focus { top: 12px; color: var(--bg); }

.col { width: 100%; max-width: calc(var(--col) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.wide { width: 100%; max-width: calc(var(--wide) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }

.mono { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.02em; }
.num { font-family: var(--font-mono); font-size: 0.92em; font-weight: 500; color: var(--text); white-space: nowrap; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.site-header.scrolled { border-bottom-color: var(--rule); }
.site-header .wide { display: flex; align-items: center; gap: 12px; height: 60px; }
.mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.mark svg { width: 30px; height: 30px; border-radius: 8px; }
.mark span { font-variation-settings: "opsz" 24; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a { text-decoration: none; font-size: 0.88rem; color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.nav a:hover, .nav a[aria-current="true"] { color: var(--text); background: var(--accent-soft); }
.nav .section-link { display: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--text); cursor: pointer;
  font: inherit; padding: 0; transition: border-color 0.2s, transform 0.2s var(--ease);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }
.kbd { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600; }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-icon-moon { display: none; }
}
@media (min-width: 760px) { .nav .section-link { display: inline-block; } }

/* Hero */
.hero { padding-top: 72px; padding-bottom: 40px; }
.byline { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.byline .kicker { margin-bottom: 0; }
/* Optional portrait: shown only when assets/photo.{jpg,png,webp} exists (main.js probes for it). */
.portrait {
  flex: none; width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 1px var(--rule), 0 0 0 5px var(--bg), 0 0 0 6px var(--rule);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; filter: saturate(0.85); }
.portrait:not([hidden]) + .kicker::before { display: none; }
.kicker { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-bottom: 22px; }
.kicker::before { content: ""; width: 28px; height: 1px; background: var(--accent); }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: clamp(3.4rem, 15vw, 7.2rem);
  line-height: 0.92;
  letter-spacing: -0.035em;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  margin: 0 0 26px;
}
.hero h1 .dot { color: var(--accent); }
.headline {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 4.6vw, 1.85rem);
  line-height: 1.3;
  font-weight: 400;
  font-style: italic;
  font-variation-settings: "opsz" 48;
  letter-spacing: -0.01em;
  margin: 0 0 28px;
  max-width: 30ch;
}
.bio p { color: var(--text); }
.bio p + p { color: color-mix(in srgb, var(--text) 82%, var(--muted)); }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; list-style: none; }
.links a {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  padding: 9px 14px; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface);
  font-size: 0.9rem; font-weight: 500; transition: border-color 0.2s, transform 0.2s var(--ease), color 0.2s;
}
.links a:hover { border-color: var(--accent); transform: translateY(-1px); }
.links a.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.links a.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.links svg { width: 16px; height: 16px; flex: none; }

/* Sections */
section { padding: 56px 0; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 28px; }
.section-head .idx { color: var(--accent); }
.section-head h2 {
  font-family: var(--font-display); font-weight: 520; font-size: clamp(1.6rem, 5vw, 2.1rem);
  letter-spacing: -0.02em; line-height: 1.1; margin: 0; font-variation-settings: "opsz" 72;
}
.section-head .rule { flex: 1; height: 1px; background: var(--rule); align-self: center; }
h3 { font-family: var(--font-display); font-weight: 560; letter-spacing: -0.015em; font-variation-settings: "opsz" 36; }

/* Featured project */
.feature {
  background: var(--surface); border: 1px solid var(--rule); border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow); padding: 28px 20px; position: relative; overflow: visible;
}
.feature-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); margin-bottom: 14px; }
.badge { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.feature h3 { font-size: clamp(2.4rem, 9vw, 3.6rem); line-height: 1; margin: 0 0 12px; font-variation-settings: "opsz" 144; }
.feature .pitch { font-size: 1.12rem; max-width: 46ch; color: var(--text); margin-bottom: 26px; }
.figures { display: grid; grid-template-columns: 1fr; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 0 0 26px; }
.figure { position: relative; padding: 18px 0; }
.figure + .figure { border-top: 1px solid var(--rule); }
.figure .value {
  font-family: var(--font-display); font-weight: 500; font-size: clamp(1.9rem, 7vw, 2.5rem); line-height: 1.05;
  letter-spacing: -0.02em; font-variant-numeric: lining-nums tabular-nums; font-variation-settings: "opsz" 144;
}
.figure .value .to { font-style: italic; color: var(--muted); font-weight: 400; font-size: 0.6em; padding: 0 0.15em; }
.figure .label { color: var(--muted); margin-top: 6px; display: block; }
.fn {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600; line-height: 1;
  vertical-align: super; margin-left: 4px; padding: 3px 5px; border-radius: 6px; cursor: pointer;
  color: var(--accent); background: var(--accent-soft); border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}
.fn:hover, .fn[aria-expanded="true"] { border-color: var(--accent); }
.note {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% - 6px);
  background: var(--text); color: var(--bg); border-radius: 10px; padding: 12px 14px;
  font-size: 0.85rem; line-height: 1.5; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.note .mono { display: block; color: color-mix(in srgb, var(--bg) 70%, var(--text)); margin-bottom: 4px; font-size: 0.7rem; }
.note.open { opacity: 1; transform: none; pointer-events: auto; }
.feature-body { display: grid; gap: 22px; }
.bullets { list-style: none; display: grid; gap: 12px; }
.bullets li { position: relative; padding-left: 22px; }
.bullets li::before { content: ""; position: absolute; left: 2px; top: 0.72em; width: 9px; height: 1px; background: var(--accent); }
.more summary { cursor: pointer; color: var(--muted); list-style: none; display: inline-flex; gap: 8px; align-items: center; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+"; font-family: var(--font-mono); color: var(--accent); }
.more[open] summary::before { content: "\2212"; }
.more .bullets { margin-top: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.tags li { font-family: var(--font-mono); font-size: 0.74rem; padding: 4px 9px; border-radius: 6px; border: 1px solid var(--rule); color: var(--muted); }
.arrow-link { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; text-decoration: none; }
.arrow-link span { transition: transform 0.2s var(--ease); }
.arrow-link:hover span { transform: translateX(3px); }
.feature-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-top: 4px; }

/* Entry lists (projects, experience) */
.entries { list-style: none; }
.entry { display: grid; gap: 6px 28px; padding: 26px 0; border-top: 1px solid var(--rule); }
.entry:last-child { border-bottom: 1px solid var(--rule); }
.entry .when { color: var(--muted); }
.entry h3 { font-size: 1.4rem; margin: 0; line-height: 1.25; }
.entry h3 a { text-decoration: none; }
.entry .org { color: var(--muted); margin: 2px 0 10px; }
.entry .summary { margin-bottom: 14px; }
.entry .bullets { margin-bottom: 16px; }
.subhead { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 40px 0 0; padding-bottom: 12px; }
.ghost { color: var(--muted); padding: 22px 0 0; }

/* Awards */
.awards { list-style: none; counter-reset: award; }
.award { display: grid; grid-template-columns: 44px 1fr; gap: 0 12px; padding: 22px 0; border-top: 1px solid var(--rule); }
.award:last-child { border-bottom: 1px solid var(--rule); }
.award .n { font-family: var(--font-display); font-style: italic; font-size: 1.6rem; line-height: 1; color: var(--accent); font-variation-settings: "opsz" 72; }
.award h3 { font-size: 1.12rem; margin: 0 0 4px; line-height: 1.35; }
.award .result { margin: 0 0 6px; }
.award .context { color: var(--muted); font-size: 0.92rem; margin: 0 0 8px; }
.award .award-links { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; font-size: 0.9rem; }

/* Press */
.empty {
  border: 1px dashed var(--rule); border-radius: var(--radius); padding: 32px 22px; text-align: left;
  background: repeating-linear-gradient(-45deg, transparent 0 10px, var(--accent-soft) 10px 11px);
}
.empty .lead { font-family: var(--font-display); font-size: 1.4rem; font-style: italic; margin: 0 0 6px; font-variation-settings: "opsz" 48; }
.empty .mono { color: var(--muted); display: block; margin-top: 14px; }
.press-list { list-style: none; }
.press-item { padding: 20px 0; border-top: 1px solid var(--rule); }
.press-item:last-child { border-bottom: 1px solid var(--rule); }
.press-item h3 { font-size: 1.15rem; margin: 4px 0; }
.press-item blockquote { margin: 8px 0 0; color: var(--muted); font-style: italic; }

/* Contact */
.contact { padding-bottom: 96px; }
.contact .big {
  font-family: var(--font-display); font-size: clamp(2.2rem, 9vw, 3.6rem); line-height: 1.02; letter-spacing: -0.03em;
  margin: 0 0 18px; font-weight: 520; font-variation-settings: "opsz" 144;
}
.contact .email {
  display: inline-block; font-family: var(--font-display); font-size: clamp(1.15rem, 5vw, 1.7rem); font-style: italic;
  text-decoration: none; border-bottom: 1px solid var(--accent); padding-bottom: 2px; word-break: break-all;
}
.contact .links { margin-top: 26px; }

.site-footer { border-top: 1px solid var(--rule); padding: 26px 0 40px; color: var(--muted); }
.site-footer .wide { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-footer kbd { font-family: var(--font-mono); border: 1px solid var(--rule); border-radius: 5px; padding: 1px 6px; font-size: 0.75rem; color: var(--text); }

/* Command palette */
dialog.palette {
  width: min(560px, calc(100vw - 2 * var(--gutter))); max-height: min(520px, 80vh); padding: 0; border: 1px solid var(--rule);
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
  margin-top: 12vh;
}
dialog.palette::backdrop { background: rgba(18, 18, 17, 0.35); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.palette input {
  width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: transparent; color: var(--text);
  font: 500 1rem var(--font-mono); padding: 18px 20px; outline: none;
}
.palette ul { list-style: none; padding: 8px; max-height: 380px; overflow: auto; }
.palette li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 0.95rem; }
.palette li .mono { color: var(--muted); }
.palette li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.palette .hint { padding: 10px 20px; border-top: 1px solid var(--rule); color: var(--muted); }

/* Motion */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.hero .rise { opacity: 0; transform: translateY(18px); animation: rise 0.9s var(--ease) forwards; }
.hero .rise:nth-child(2) { animation-delay: 0.08s; }
.hero .rise:nth-child(3) { animation-delay: 0.16s; }
.hero .rise:nth-child(4) { animation-delay: 0.24s; }
.hero .rise:nth-child(5) { animation-delay: 0.32s; }
@keyframes rise { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal, .hero .rise { opacity: 1; transform: none; }
}

/* Wider screens */
@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .hero { padding-top: 112px; padding-bottom: 56px; }
  .feature { padding: 44px 44px 40px; }
  .figures { grid-template-columns: repeat(3, 1fr); }
  .figure { padding: 22px 20px 22px 0; }
  .figure + .figure { border-top: 0; border-left: 1px solid var(--rule); padding-left: 22px; }
  .entry { grid-template-columns: 150px 1fr; }
  .entry .when { padding-top: 5px; }
  .award { grid-template-columns: 64px 1fr; }
  .empty { padding: 40px 36px; }
}
@media (min-width: 960px) {
  section { padding: 72px 0; }
  .feature-body { grid-template-columns: 1.5fr 1fr; gap: 44px; align-items: start; }
  .feature-side { border-left: 1px solid var(--rule); padding-left: 28px; display: grid; gap: 20px; }
}

/* Resume page */
.resume-wrap { padding: 40px 0 80px; }
.resume-bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 22px; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--text); background: var(--text); color: var(--bg); font: 500 0.9rem var(--font-body);
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.sheet {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px 20px; max-width: 860px; margin: 0 auto;
}
.sheet header { border-bottom: 2px solid var(--text); padding-bottom: 18px; margin-bottom: 8px; }
.sheet h1 {
  font-family: var(--font-display); font-size: clamp(2.2rem, 8vw, 3.2rem); font-weight: 560; letter-spacing: -0.03em;
  line-height: 1; margin: 0 0 10px; font-variation-settings: "opsz" 144;
}
.sheet .r-headline { font-family: var(--font-display); font-style: italic; font-size: 1.15rem; margin: 0 0 14px; color: var(--muted); }
.r-contact { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.9rem; }
.r-contact a { word-break: break-all; }
.sheet h2 {
  font-family: var(--font-mono); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); margin: 30px 0 4px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}
.r-item { padding: 14px 0 4px; break-inside: avoid; }
.r-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 16px; }
.r-row h3 { font-size: 1.12rem; margin: 0; }
.r-row h3 a { text-decoration: none; }
.r-row .mono { color: var(--muted); }
.r-sub { color: var(--muted); margin: 2px 0 8px; font-size: 0.95rem; }
.sheet .bullets { gap: 6px; font-size: 0.95rem; margin-bottom: 6px; }
.r-tech, .r-links { color: var(--muted); margin: 6px 0 0; }
.r-plain { list-style: none; display: grid; gap: 6px; font-size: 0.95rem; padding-top: 10px; }
.r-plain strong { font-weight: 600; }
@media (min-width: 640px) { .sheet { padding: 52px 56px; } }

.sheet section { padding: 0; }
.r-item p { font-size: 0.95rem; }

@media print {
  @page { margin: 14mm 14mm; }
  :root, :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --text: #111; --muted: #444; --rule: #ccc; --accent: #8a3520; --shadow: none;
    color-scheme: light;
  }
  body { font-size: 10pt; line-height: 1.4; background: #fff; }
  .site-header, .site-footer, .resume-bar, .skip, dialog { display: none !important; }
  .resume-wrap { padding: 0; }
  .sheet { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .sheet h1 { font-size: 26pt; }
  .sheet h2 { margin-top: 14pt; }
  a { text-decoration: none; color: inherit; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .r-item { break-inside: auto; padding-top: 8pt; }
  .r-row, .sheet h2 { break-after: avoid; }
  .sheet li, .r-plain li { break-inside: avoid; }
  .sheet .bullets, .r-plain, .r-item p, .r-sub { font-size: 9.5pt; }
  .sheet .bullets { gap: 2pt; }
  .r-row h3 { font-size: 11.5pt; }
  .sheet .mono { font-size: 8pt; }
}
