/* ==========================================================================
   William Pham — site styles
   ========================================================================== */

:root {
  --bg: #f5f3ee;
  --bg-elev: #fbfaf7;
  --bg-sunk: #eeebe4;
  --ink: #151514;
  --ink-2: #3b3a36;
  --muted: #75716a;
  --line: #e1ddd3;
  --line-2: #d2cdc1;
  --accent: #2b48d4;
  --accent-2: #1f37a8;
  --accent-soft: rgba(43, 72, 212, 0.08);
  --on-accent: #ffffff;
  --logo-tile: #ffffff;
  --shadow: 0 1px 2px rgba(20, 18, 12, 0.04), 0 8px 24px -12px rgba(20, 18, 12, 0.12);
  --shadow-lg: 0 2px 4px rgba(20, 18, 12, 0.04), 0 24px 60px -24px rgba(20, 18, 12, 0.28);
  --grain-opacity: 0.05;

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 14px;
  --radius-lg: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e0e0d;
  --bg-elev: #161614;
  --bg-sunk: #121211;
  --ink: #eeece6;
  --ink-2: #c9c6bd;
  --muted: #8d897f;
  --line: #262520;
  --line-2: #35332c;
  --accent: #8fa3ff;
  --accent-2: #b3c0ff;
  --accent-soft: rgba(143, 163, 255, 0.1);
  --on-accent: #0e0e0d;
  --logo-tile: #f4f2ec;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  --grain-opacity: 0.07;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  font-variation-settings: "SOFT" 100, "WONK" 0;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

/* Paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main { flex: 1; }

img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--accent); color: var(--on-accent); }

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 300;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
}
.skip-link:focus { top: 16px; }

/* ---------- Type ---------- */
.accent { color: var(--accent); }
.mono { font-family: var(--mono); }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow .idx { color: var(--accent); }

.display {
  font-family: var(--display);
  font-weight: 440;
  font-size: clamp(44px, 7.6vw, 96px);
  line-height: 1.02;
  letter-spacing: -0.03em;
}
.display em, .h2 em { font-style: normal; color: var(--accent); }

.h2 {
  font-family: var(--display);
  font-weight: 440;
  font-size: clamp(34px, 4.8vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.lede {
  font-size: clamp(17px, 1.6vw, 19px);
  line-height: 1.65;
  color: var(--ink-2);
  max-width: 62ch;
}

.link {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.35s var(--ease), color 0.2s;
  padding-bottom: 1px;
}
.link:hover { color: var(--accent); background-size: 100% 2px; }

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 14px var(--gutter);
  pointer-events: none;
}
.nav-inner {
  pointer-events: auto;
  max-width: calc(var(--wrap) - 2 * var(--gutter) + 24px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background-color 0.35s var(--ease), border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.nav.scrolled .nav-inner {
  background: color-mix(in srgb, var(--bg-elev) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  transition: transform 0.5s var(--ease), background-color 0.3s;
}
.brand:hover .brand-mark { transform: rotate(-12deg) scale(1.05); background: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
}
.nav-links a {
  position: relative;
  display: block;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s, background-color 0.2s;
}
.nav-links a:hover { color: var(--ink); background: var(--bg-sunk); }
.nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}

.nav-tools { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: background-color 0.2s, color 0.2s, transform 0.2s;
}
.icon-btn:hover { background: var(--bg-sunk); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.kbd-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 8px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}
.kbd-btn:hover { border-color: var(--line-2); color: var(--ink); background: var(--bg-elev); }
kbd, .kbd {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  color: var(--muted);
}

.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

@media (max-width: 720px) {
  .kbd-btn { display: none; }
  .brand-name { display: none; }
  .nav-links a { padding: 7px 11px; }
  .nav-inner { padding-left: 8px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.25s var(--ease), background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.25s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; transition: transform 0.3s var(--ease); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent); color: var(--on-accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:hover svg { transform: translateX(3px); }
.btn-ghost { border-color: var(--line-2); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); background: var(--bg-elev); }
.btn-sm { height: 38px; padding: 0 16px; font-size: 14px; }

/* ---------- Sections ---------- */
.section { padding: clamp(72px, 10vw, 128px) 0; }
.section + .section { border-top: 1px solid var(--line); }

.section-head {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px 48px;
  margin-bottom: clamp(36px, 5vw, 56px);
  align-items: start;
}
.section-head .eyebrow { padding-top: 14px; }
.about-grid > .eyebrow, .section-head > .eyebrow { align-self: start; }
.section-head p { color: var(--muted); max-width: 52ch; margin-top: 14px; }
@media (max-width: 820px) {
  .section-head { grid-template-columns: 1fr; gap: 12px; }
  .section-head .eyebrow { padding-top: 0; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: clamp(120px, 16vh, 168px) 0 clamp(56px, 8vw, 96px);
  overflow: hidden;
}
.hero .wrap { position: relative; z-index: 1; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.8fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: center;
}
.hero h1 { margin-bottom: 28px; }
.hero h1 { font-size: clamp(44px, 7vw, 88px); }
.hero h1 .line { display: block; white-space: nowrap; }
.hero .lede { margin-bottom: 36px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.portrait {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 4 / 5;
  background: var(--bg-sunk);
  box-shadow: var(--shadow-lg);
  transform: rotate(1.2deg);
  transition: transform 0.8s var(--ease);
}
.portrait:hover { transform: rotate(0deg) scale(1.01); }
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
@media (max-width: 880px) {
  .hero-grid { grid-template-columns: 1fr; }
  .portrait { max-width: 360px; order: -1; transform: rotate(-1.2deg); aspect-ratio: 1 / 1; }
  .portrait img { object-position: 50% 22%; }
}
@media (max-width: 480px) {
  .portrait { max-width: 100%; aspect-ratio: 5 / 4; }
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px 48px;
}
.about-body { display: grid; gap: 28px; }
.about-body p { font-size: clamp(18px, 1.9vw, 22px); line-height: 1.55; color: var(--ink-2); max-width: 40ch; }
.about-body p:first-child { color: var(--ink); }
.about-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.about-cols p { font-size: 16px; line-height: 1.7; max-width: 46ch; color: var(--ink-2); }
.facts { list-style: none; display: grid; gap: 0; }
.facts li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line-2);
  font-size: 14.5px;
}
.facts li:first-child { padding-top: 0; }
.facts li span:first-child { color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; padding-top: 2px; }
.facts li span:last-child { text-align: right; }
@media (max-width: 820px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-cols { grid-template-columns: 1fr; }
}

/* ---------- Experience ---------- */
.xp-group + .xp-group { margin-top: 56px; }
.xp-group-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.xp-group-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.xp-group-label .count { color: var(--accent); }

.xp-list { list-style: none; }
.xp-row {
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto 28px;
  align-items: center;
  gap: 20px;
  padding: 18px 12px;
  margin: 0 -12px;
  border-radius: var(--radius);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.25s var(--ease);
}
.xp-list li:last-child .xp-row { border-bottom-color: transparent; }
.xp-row:hover { background: var(--bg-elev); }
.xp-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--logo-tile);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8px;
  transition: transform 0.4s var(--ease);
}
.xp-row:hover .xp-logo { transform: scale(1.06) rotate(-3deg); }
.xp-logo img { width: 100%; height: 100%; object-fit: contain; }
.xp-main { min-width: 0; }
.xp-company {
  display: block;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.xp-role { display: block; color: var(--muted); font-size: 15px; margin-top: 2px; }
.xp-time {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}
.xp-arrow {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  transition: transform 0.35s var(--ease), color 0.2s, background-color 0.2s;
}
.xp-arrow svg { width: 14px; height: 14px; }
.xp-row:hover .xp-arrow { color: var(--on-accent); background: var(--accent); transform: rotate(-45deg); }

@media (max-width: 640px) {
  .xp-row { grid-template-columns: 48px minmax(0, 1fr) 24px; gap: 14px; }
  .xp-logo { width: 48px; height: 48px; border-radius: 12px; padding: 6px; }
  .xp-time { grid-column: 2; grid-row: 2; text-align: left; margin-top: -10px; }
  .xp-arrow { grid-column: 3; grid-row: 1 / span 2; }
  .xp-company { font-size: 16.5px; }
  .xp-role { font-size: 14px; }
}

/* ---------- Project cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 20px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  overflow: hidden;
  text-decoration: none;
  transition: transform 0.45s var(--ease), box-shadow 0.45s var(--ease), border-color 0.3s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--line-2); }
.card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-sunk);
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s var(--ease), filter 0.6s var(--ease);
  filter: saturate(0.9);
}
.card:hover .card-media img { transform: scale(1.05); filter: saturate(1.05); }
.card-context {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(12, 12, 11, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #f5f3ee;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.card-body { padding: 22px 22px 24px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.card-title { font-size: 19px; font-weight: 500; line-height: 1.3; letter-spacing: -0.012em; }
.card-desc { color: var(--muted); font-size: 15px; line-height: 1.6; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: var(--bg);
}
.card-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
}
.card-cta svg { width: 14px; height: 14px; transition: transform 0.3s var(--ease); }
.card:hover .card-cta svg { transform: translateX(4px); }

/* Featured card */
.card-feature { grid-column: 1 / -1; flex-direction: row; }
.card-feature .card-media { flex: 1.15; aspect-ratio: auto; min-height: 340px; }
.card-feature .card-body { flex: 1; padding: clamp(24px, 4vw, 44px); justify-content: center; gap: 16px; }
.card-feature .card-title { font-family: var(--display); font-weight: 440; font-size: clamp(26px, 3vw, 36px); line-height: 1.15; letter-spacing: -0.02em; }
.card-feature .tags { margin-top: 0; }
@media (max-width: 820px) {
  .card-feature { flex-direction: column; }
  .card-feature .card-media { min-height: 0; aspect-ratio: 16 / 10; }
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}
.chip {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s var(--ease);
}
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { font-family: var(--mono); font-size: 11px; opacity: 0.6; }
.card.is-hidden { display: none; }
.card.is-entering { animation: cardIn 0.5s var(--ease) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }

/* ---------- Page header ---------- */
.page-head {
  padding: clamp(128px, 18vh, 176px) 0 clamp(40px, 6vw, 64px);
  border-bottom: 1px solid var(--line);
}
.page-head .eyebrow { margin-bottom: 20px; }
.page-head .display { font-size: clamp(48px, 8.5vw, 108px); }
.page-head .lede { margin-top: 24px; }
.page-head-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

/* ---------- Resume ---------- */
.sheet-stage {
  position: relative;
  border-radius: 28px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg-sunk);
  padding: clamp(14px, 4vw, 40px) clamp(14px, 5vw, 64px) clamp(28px, 6vw, 72px);
}
.sheet-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
  flex-wrap: wrap;
  max-width: 860px;
  margin: 0 auto clamp(18px, 3vw, 32px);
}
.sheet-file {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.sheet-file-ico {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--accent);
}
.sheet-file-ico svg { width: 18px; height: 18px; }
.sheet-file-name { font-size: 15px; font-weight: 500; color: var(--ink); line-height: 1.3; }
.sheet-file-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet {
  position: relative;
  display: block;
  max-width: 860px;
  margin: 0 auto;
  background: #fff;
  border-radius: 6px;
  box-shadow:
    0 1px 1px rgba(20, 18, 12, 0.04),
    0 2px 4px rgba(20, 18, 12, 0.04),
    0 12px 24px -8px rgba(20, 18, 12, 0.10),
    0 40px 80px -24px rgba(20, 18, 12, 0.22);
  transition: transform 0.6s var(--ease), box-shadow 0.6s var(--ease);
  cursor: zoom-in;
}
.sheet:hover {
  transform: translateY(-4px);
  box-shadow:
    0 1px 1px rgba(20, 18, 12, 0.04),
    0 4px 8px rgba(20, 18, 12, 0.05),
    0 20px 40px -12px rgba(20, 18, 12, 0.14),
    0 60px 100px -30px rgba(20, 18, 12, 0.3);
}
.sheet img { width: 100%; height: auto; border-radius: 6px; }
.sheet-hint {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  pointer-events: none;
}
.sheet:hover .sheet-hint, .sheet:focus-visible .sheet-hint { opacity: 1; transform: none; }
@media (hover: none) {
  .sheet-hint { opacity: 1; transform: none; right: 10px; bottom: 10px; padding: 7px 12px; font-size: 12px; }
}
@media (max-width: 560px) {
  .sheet-actions { width: 100%; }
  .sheet-actions .btn { flex: 1; justify-content: center; }
}
.resume-aside {
  position: sticky;
  top: 100px;
  display: grid;
  gap: 24px;
  align-self: start;
  align-content: start;
}
.toc { list-style: none; display: grid; gap: 2px; }
.toc a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.toc a::before {
  content: "";
  width: 14px;
  height: 1px;
  background: var(--line-2);
  transition: width 0.3s var(--ease), background-color 0.2s;
}
.toc a:hover, .toc a.active { color: var(--ink); }
.toc a.active::before { width: 28px; background: var(--accent); }

.courses { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
.course-group h3 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
  margin-bottom: 8px;
}
.course-list { list-style: none; }
.course-list li {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  color: var(--ink-2);
  transition: color 0.2s, padding 0.3s var(--ease);
}
.course-list li:hover { color: var(--ink); padding-left: 6px; }
.course-code { font-family: var(--mono); font-size: 12.5px; color: var(--accent); padding-top: 2px; white-space: nowrap; }
.course-list li.is-extra { display: none; }
.courses.expanded .course-list li.is-extra { display: grid; }
.course-toggle { margin-top: 20px; }

@media (max-width: 640px) {
  .courses { grid-template-columns: 1fr; }
  .course-list li { grid-template-columns: 92px 1fr; }
}

/* ---------- Article ---------- */
.article-head { padding: clamp(128px, 18vh, 176px) 0 40px; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 36px;
  transition: color 0.2s;
}
.back svg { width: 14px; height: 14px; transition: transform 0.3s var(--ease); }
.back:hover { color: var(--ink); }
.back:hover svg { transform: translateX(-4px); }
.article-title {
  font-family: var(--display);
  font-weight: 440;
  font-size: clamp(40px, 6.6vw, 80px);
  line-height: 1;
  letter-spacing: -0.02em;
  max-width: 16ch;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}
.article-hero {
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 21 / 9;
  margin-bottom: 64px;
  background: var(--bg-sunk);
}
.article-hero img { width: 100%; height: 100%; object-fit: cover; }

.article-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 680px);
  gap: clamp(32px, 6vw, 80px);
  justify-content: start;
  padding-bottom: 96px;
}
.article-layout .resume-aside { top: 100px; }
@media (max-width: 900px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-layout .resume-aside { display: none; }
}

.prose { font-size: 17.5px; line-height: 1.75; color: var(--ink-2); }
.prose > * + * { margin-top: 1.1em; }
.prose h2 {
  font-family: var(--display);
  font-weight: 440;
  font-size: clamp(28px, 3.2vw, 36px);
  line-height: 1.15;
  color: var(--ink);
  margin-top: 2.2em;
  letter-spacing: -0.01em;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 18px; font-weight: 600; color: var(--ink); margin-top: 1.8em; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose ul { padding-left: 0; list-style: none; display: grid; gap: 8px; }
.prose ul li { position: relative; padding-left: 22px; }
.prose ul li::before { content: ""; position: absolute; left: 2px; top: 0.85em; width: 8px; height: 1px; background: var(--accent); }
.prose pre {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  color: var(--ink);
}
.prose code { font-family: var(--mono); font-size: 0.86em; }
.prose pre .k { color: var(--accent); }
.prose pre .c { color: var(--muted); }
.prose .step {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: 6px;
}
.callout {
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 20px;
  font-family: var(--display);
  font-size: clamp(22px, 2.4vw, 26px);
  line-height: 1.35;
  color: var(--ink);
}
.equation {
  font-family: var(--display);
  font-size: clamp(20px, 2.6vw, 26px);
  text-align: center;
  padding: 28px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  overflow-x: auto;
}
.equation i { font-style: italic; font-weight: 500; }
.terms { display: grid; gap: 0; }
.terms div { display: grid; grid-template-columns: 160px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--line-2); }
.terms dt { color: var(--ink); font-weight: 600; font-size: 16px; }
.terms dd { font-size: 16px; }
@media (max-width: 560px) { .terms div { grid-template-columns: 1fr; gap: 2px; } }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 400; background: var(--bg-sunk); }
tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--mono); font-size: 14px; color: var(--ink); text-align: right; }
th.num { text-align: right; }

.wip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px dashed var(--line-2);
  font-style: italic;
  color: var(--muted);
}

/* Simulator */
.sim {
  margin: 2.4em 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  padding: clamp(18px, 3vw, 28px);
  box-shadow: var(--shadow);
}
.sim-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.sim-head h3 { margin: 0; font-size: 17px; }
.sim-note { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin-bottom: 18px; }
.sim-chart { position: relative; width: 100%; height: 240px; }
.sim-chart canvas { width: 100%; height: 100%; display: block; }
.sim-controls { display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; align-items: center; margin-top: 18px; }
.sim-controls label { display: grid; gap: 10px; font-size: 14px; color: var(--ink-2); }
.sim-controls label span { display: flex; justify-content: space-between; }
.sim-controls output { font-family: var(--mono); color: var(--ink); }
.sim-stats { display: flex; gap: 24px; }
.stat { display: grid; gap: 2px; }
.stat .v { font-family: var(--display); font-weight: 500; letter-spacing: -0.02em; font-size: 30px; line-height: 1; color: var(--ink); }
.stat .l { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p, 20%), var(--line-2) var(--p, 20%)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: var(--line-2); }
input[type="range"]::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7.5px; border-radius: 50%; background: var(--bg-elev); border: 2px solid var(--accent); box-shadow: var(--shadow); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--bg-elev); border: 2px solid var(--accent); }
@media (max-width: 560px) {
  .sim-controls { grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: clamp(64px, 9vw, 112px) 0 32px;
  position: relative;
  background: var(--bg);
}
.footer-cta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  padding-bottom: clamp(48px, 7vw, 80px);
}
.footer-cta .h2 { font-size: clamp(40px, 7vw, 88px); line-height: 1; }
.footer-cta p { color: var(--muted); margin-top: 20px; max-width: 46ch; }
.email-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-family: var(--mono);
  font-size: clamp(13px, 1.6vw, 15px);
  color: var(--ink);
  transition: border-color 0.2s, background-color 0.2s;
  max-width: 100%;
}
.email-btn:hover { border-color: var(--ink); background: var(--bg-elev); }
.email-btn .addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-btn .copy-ico {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--bg);
  transition: background-color 0.2s, transform 0.3s var(--ease);
}
.email-btn:hover .copy-ico { background: var(--accent); color: var(--on-accent); transform: scale(1.06); }
.email-btn .copy-ico svg { width: 14px; height: 14px; }
.social { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 24px;
  flex-wrap: wrap;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.footer-bottom nav { display: flex; gap: 18px; }
.footer-bottom a { text-decoration: none; transition: color 0.2s; }
.footer-bottom a:hover { color: var(--ink); }
.live-clock { display: inline-flex; align-items: center; gap: 8px; }
.live-clock::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #3fb66b; }

@media (max-width: 720px) {
  .footer-cta { grid-template-columns: 1fr; }
  .social { justify-content: flex-start; }
}

/* ---------- Command palette ---------- */
.cmdk {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 14vh 16px 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.cmdk.open { display: flex; animation: fadeIn 0.18s ease both; }
.cmdk-panel {
  width: 100%;
  max-width: 560px;
  border-radius: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.24s var(--ease) both;
}
.cmdk-input-row { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.cmdk-input-row svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.cmdk input {
  flex: 1;
  height: 56px;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
.cmdk input::placeholder { color: var(--muted); }
.cmdk-list { list-style: none; max-height: 360px; overflow-y: auto; padding: 8px; }
.cmdk-group { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 6px; }
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
  color: var(--ink-2);
  cursor: pointer;
}
.cmdk-item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.cmdk-item .hint { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.cmdk-item.active { background: var(--bg-sunk); color: var(--ink); }
.cmdk-item.active svg { color: var(--accent); }
.cmdk-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }
.cmdk-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 6px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(-8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 600;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  transition: transform 0.4s var(--ease), opacity 0.3s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 16px; height: 16px; color: #5ad08a; }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: 0.08s; }
.reveal[data-delay="2"] { transition-delay: 0.16s; }
.reveal[data-delay="3"] { transition-delay: 0.24s; }
.reveal[data-delay="4"] { transition-delay: 0.32s; }

.rise { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.rise > span { display: inline-block; transform: translateY(105%); animation: rise 1.1s var(--ease) forwards; }
.rise.d1 > span { animation-delay: 0.1s; }
.rise.d2 > span { animation-delay: 0.2s; }
@keyframes rise { to { transform: none; } }
.fade-up { opacity: 0; animation: fadeUp 1s var(--ease) forwards; }
.fade-up.d2 { animation-delay: 0.25s; }
.fade-up.d3 { animation-delay: 0.4s; }
.fade-up.d4 { animation-delay: 0.55s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.no-js .reveal { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0s !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .rise > span { transform: none; }
  .fade-up { opacity: 1; }
}

/* ---------- 404 ---------- */
.nf {
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 120px var(--gutter) 64px;
}
.nf .display { font-size: clamp(96px, 20vw, 220px); }
.nf p { color: var(--muted); max-width: 44ch; margin: 16px auto 32px; }
