/* ============================================================
   Ben Teh — Portfolio
   ============================================================ */

:root {
  --bg: #0b0f1a;
  --bg-alt: #111726;
  --surface: #161d2e;
  --surface-2: #1c2540;
  --text: #e7ecf5;
  --text-dim: #9aa6bd;
  --border: #263149;
  --brand: #5b8cff;
  --brand-2: #9d7bff;
  --accent: #33e1c0;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.55);
  --radius: 16px;
  --maxw: 1080px;
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: "Space Grotesk", var(--font);
}

:root[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-alt: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f0f4fb;
  --text: #16203a;
  --text-dim: #56617a;
  --border: #dde4f0;
  --shadow: 0 20px 50px -24px rgba(31, 45, 82, 0.25);
  /* The brand trio is tuned for a dark ground and fails WCAG on white:
     accent 1.66:1, brand 3.16:1, brand-2 3.13:1 — and these carry the
     metrics, the section labels, and every employer name. Same values the
     print block uses, so light-on-white is one palette everywhere. */
  --brand: #2a53c4;
  --brand-2: #6b3fd4;
  --accent: #0d7f6b;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--brand); color: #fff; }

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 0.95rem;
  padding: 12px 22px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.btn--sm { padding: 8px 16px; font-size: 0.85rem; }
.btn--primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; box-shadow: 0 12px 30px -12px rgba(91, 140, 255, 0.7);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -12px rgba(91, 140, 255, 0.85); }
.btn--ghost { border-color: var(--border); background: var(--surface); color: var(--text); }
.btn--ghost:hover { transform: translateY(-2px); border-color: var(--brand); }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  transition: background 0.3s ease, box-shadow 0.3s ease, backdrop-filter 0.3s ease;
}
.nav--scrolled {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 var(--border);
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.nav__brand { font-family: var(--display); font-weight: 700; font-size: 1.3rem; letter-spacing: -0.02em; }
.nav__brand span { color: var(--brand); }
.nav__links { display: flex; align-items: center; gap: 28px; }
.nav__links > a { font-size: 0.95rem; font-weight: 500; color: var(--text-dim); transition: color 0.2s; position: relative; }
.nav__links > a:hover { color: var(--text); }
.nav__links > a.active { color: var(--text); }
.nav__links > a.active::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -6px;
  height: 2px; border-radius: 1px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}
.nav__links .btn { color: #fff; }
.nav__links .btn--sm { color: var(--text); }

.theme-toggle {
  background: var(--surface); border: 1px solid var(--border);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  font-size: 1.05rem; display: grid; place-items: center;
  transition: transform 0.3s ease, border-color 0.2s;
}
.theme-toggle:hover { transform: rotate(20deg) scale(1.05); border-color: var(--brand); }

.nav__toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav__toggle span { width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: 0.3s; }
.nav__toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle.open span:nth-child(2) { opacity: 0; }
.nav__toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero { position: relative; min-height: 100vh; display: flex; align-items: center; overflow: hidden; }
.hero__bg {
  position: absolute; inset: 0; z-index: 0;
  /* One quiet wash, not three drifting colour blobs — the multi-blob glow is
     the most recognisable tell of a generated landing page. */
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 7%, transparent), transparent 60%);
}

/* dot-grid texture over the hero glow */
.hero__bg::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(color-mix(in srgb, var(--text) 14%, transparent) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, black 30%, transparent 75%);
  opacity: 0.5;
}

.hero__inner { position: relative; z-index: 1; padding: 120px 24px 100px; }
.hero__eyebrow { color: var(--brand); font-weight: 600; letter-spacing: 0.04em; margin-bottom: 12px; }
.hero__title {
  font-family: var(--display); font-weight: 700; letter-spacing: -0.03em;
  font-size: clamp(2.8rem, 8vw, 5.5rem); line-height: 1.02;
  color: var(--text);
}
.hero__role {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.3rem, 3.5vw, 2.1rem); color: var(--text-dim);
  margin-top: 6px; display: flex; align-items: center;
}
.hero__cursor { display: inline-block; width: 3px; height: 1.1em; background: var(--brand); margin-left: 6px; animation: blink 1.1s steps(1) infinite; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.hero__meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin-top: 14px; font-size: 0.95rem; font-weight: 500; color: var(--text-dim);
}
.hero__meta-sep { color: var(--border); }
.hero__tagline { max-width: 620px; margin-top: 22px; font-size: 1.1rem; color: var(--text-dim); }
.hero__cta { display: flex; gap: 14px; margin-top: 34px; flex-wrap: wrap; }
.hero__badges { display: flex; gap: 12px; margin-top: 40px; flex-wrap: wrap; }
.badge {
  font-size: 0.85rem; font-weight: 500; color: var(--text-dim);
  background: var(--surface); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 999px;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.badge:hover { transform: translateY(-2px); border-color: var(--brand); color: var(--text); }

.hero__scroll { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 1; }
.hero__scroll span {
  display: block; width: 26px; height: 42px; border: 2px solid var(--text-dim); border-radius: 14px; position: relative;
}
.hero__scroll span::after {
  content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 8px; background: var(--brand); border-radius: 2px; animation: scroll 1.6s ease infinite;
}
@keyframes scroll { 0% { opacity: 0; top: 8px; } 40% { opacity: 1; } 80% { opacity: 0; top: 22px; } }

/* ---------- Sections ---------- */
.section { padding: 96px 0; position: relative; }
/* Deliberate compression and expansion — an even beat everywhere is the
   surest sign nobody made a decision. */
#projects { padding-top: 132px; }
#experience { padding-top: 112px; }
#education { padding: 76px 0; }
.about__stats { align-content: start; }
.section--alt { background: var(--bg-alt); }
.section__head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 48px; }
.section__num { font-family: var(--display); color: var(--brand); font-weight: 600; font-size: 1rem; opacity: 0.8; }
.section__title { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; font-size: clamp(1.5rem, 2.4vw, 1.9rem); position: relative; padding-bottom: 12px; }
.section__title::after {
  content: "";
  position: absolute; left: 2px; bottom: 0;
  width: 34px; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; align-items: center; }
.about__text p { margin-bottom: 18px; color: var(--text-dim); font-size: 1.05rem; }
.about__text strong { color: var(--text); font-weight: 600; }
.about__lead { font-size: 1.22rem !important; line-height: 1.6; color: var(--text) !important; }
.about__more[hidden] { display: none; }
.readmore {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; padding: 0;
  font-family: var(--font); font-size: 0.98rem; font-weight: 600; color: var(--brand);
  transition: gap 0.2s ease;
}
.readmore:hover { gap: 10px; }
.readmore span { transition: transform 0.3s ease; }
.readmore[aria-expanded="true"] span { transform: rotate(90deg); }
.about__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat { border-top: 1px solid var(--border); padding: 16px 0 0; }
.stat__num {
  display: block; font-family: var(--display); font-weight: 700;
  font-size: clamp(2.2rem, 3.2vw, 3rem); line-height: 1;
  color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.stat__suffix { font-size: 0.6em; vertical-align: baseline; }
.stat__label { font-size: 0.82rem; color: var(--text-dim); display: block; margin-top: 6px; }

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.skill-card--wide { grid-column: 1 / -1; }
.skill-card { border-top: 1px solid var(--border); padding: 20px 0 0; }
.skill-card h3 { font-family: var(--display); font-size: 1.2rem; margin-bottom: 8px; }
.skill-card p { color: var(--text-dim); font-size: 0.95rem; margin-bottom: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags span {
  font-size: 0.78rem; font-weight: 500; color: var(--brand);
  background: none;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  padding: 5px 11px; border-radius: 999px;
}

/* ---------- Achievements ---------- */
.achievements { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.ach {
  display: flex; align-items: baseline; gap: 22px;
  border-top: 1px solid var(--border); padding: 20px 0 0;
}
.ach__stat {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(2rem, 2.8vw, 2.7rem); line-height: 1;
  color: var(--accent); flex-shrink: 0; min-width: 112px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
/* Word anchors where there is no number — keeps the grid's logic intact
   without falling back on emoji. */
.ach__stat--word {
  font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--brand); position: relative; top: -0.15em;
}
.ach__text { color: var(--text-dim); font-size: 0.98rem; }
.ach__text strong { color: var(--text); font-weight: 600; }

/* ---------- Process ---------- */
.section__lead {
  color: var(--text-dim); font-size: 1.05rem; max-width: 620px; margin: -28px 0 32px;
}
.process { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; counter-reset: step; }
.process__step { border-top: 1px solid var(--border); padding: 20px 0 0; position: relative; }
.process__num {
  font-family: var(--display); font-weight: 700; font-size: 0.85rem;
  color: var(--brand); letter-spacing: 0.06em; display: block; margin-bottom: 10px;
}
.process__step h3 { font-family: var(--display); font-size: 1.05rem; margin-bottom: 8px; }
.process__step p { color: var(--text-dim); font-size: 0.92rem; }

/* ---------- Problem / Action / Result ---------- */
.par { margin-bottom: 18px; }
.par dt {
  font-family: var(--display); font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--brand);
  margin-bottom: 4px;
}
.par dt:not(:first-child) { margin-top: 14px; }
.par dd { margin: 0; color: var(--text-dim); font-size: 0.96rem; }
.par dd strong { color: var(--text); font-weight: 600; }

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; align-items: start; }
.project {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow);
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.project:hover { transform: translateY(-2px); border-color: var(--brand); }
.project__tag {
  display: inline-block; font-size: 0.78rem; font-weight: 600; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 24%, transparent);
  padding: 4px 12px; border-radius: 999px; margin-bottom: 14px;
}
.project__title { font-family: var(--display); font-size: 1.3rem; margin-bottom: 10px; }
.project__desc { color: var(--text-dim); font-size: 0.96rem; margin-bottom: 18px; }
.project__metrics { display: flex; flex-wrap: wrap; gap: 24px; margin-bottom: 18px; }
.project__metrics span { font-size: 0.85rem; color: var(--text-dim); }
.project__metrics b { display: block; font-family: var(--display); font-size: 1.5rem; color: var(--accent); }
.project--wide { grid-column: 1 / -1; }
.project--placeholder { border-style: dashed; background: transparent; }
.project--placeholder:hover { transform: none; }
.project--placeholder .project__tag { color: var(--text-dim); background: var(--surface-2); border-color: var(--border); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline__item { position: relative; padding-bottom: 32px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
  position: absolute; left: -28px; top: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}
.timeline__dot--current {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 8%, transparent); }
}
.pill-now {
  display: inline-block; margin-left: 8px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase; vertical-align: middle;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 2px 8px; border-radius: 999px;
}
/* Same chip, neutral — flags unpaid/community work without competing with "Current" */
.pill-vol {
  display: inline-block; margin-left: 8px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase; vertical-align: middle;
  color: var(--text-dim); background: color-mix(in srgb, var(--text-dim) 12%, transparent);
  border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px;
}
.timeline__card { padding: 2px 0 0; }
.timeline__meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.timeline__date { font-family: var(--display); font-size: 0.82rem; font-weight: 600; color: var(--brand); }
.timeline__loc { font-size: 0.82rem; color: var(--text-dim); }
.timeline__role { font-family: var(--display); font-size: 1.2rem; }
.timeline__org { color: var(--brand-2); font-weight: 600; font-size: 0.95rem; margin: 2px 0 10px; }
.timeline__desc { color: var(--text-dim); font-size: 0.95rem; }

/* ---------- Education & Languages ---------- */
.edu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.edu { border-top: 1px solid var(--border); padding: 20px 0 0; }
.edu__subtitle { font-family: var(--display); font-size: 1.15rem; margin-bottom: 20px; }
.edu__item + .edu__item { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.edu__item h4 { font-size: 1.1rem; margin-bottom: 4px; }
.edu__school { color: var(--brand-2); font-weight: 600; margin-bottom: 8px; }
.edu__note { color: var(--text-dim); font-size: 0.92rem; }
.lang { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.lang li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lang li span { font-weight: 500; }
.lang__lvl { font-style: normal; font-size: 0.8rem; font-weight: 600; padding: 4px 12px; border-radius: 999px; }
.lvl-5 { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.lvl-4 { color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); }
.lvl-3 { color: var(--brand-2); background: color-mix(in srgb, var(--brand-2) 14%, transparent); }
.lvl-2 { color: var(--text-dim); background: var(--surface-2); }

/* ---------- Contact ---------- */
.contact {
  text-align: center; max-width: 680px; margin: 0 auto;
  padding: 56px 40px; border-radius: 24px;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, color-mix(in srgb, var(--brand) 55%, transparent), color-mix(in srgb, var(--brand-2) 55%, transparent), color-mix(in srgb, var(--accent) 45%, transparent)) border-box;
  box-shadow: 0 30px 80px -30px color-mix(in srgb, var(--brand) 35%, transparent);
}
.contact .section__num { display: block; margin-bottom: 8px; }
.contact .section__title::after { left: 50%; transform: translateX(-50%); }
.contact__lead { color: var(--text-dim); font-size: 1.1rem; margin: 18px 0 32px; }
.contact__actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.contact__where {
  margin-top: 18px; font-size: 0.92rem; color: var(--text-dim); line-height: 1.9;
}
.contact__where a { color: var(--text); border-bottom: 1px solid var(--border); transition: border-color 0.2s, color 0.2s; }
.contact__where a:hover { color: var(--brand); border-color: var(--brand); }
.contact__links { display: flex; gap: 22px; justify-content: center; margin-top: 28px; }
.contact__links a { color: var(--text-dim); font-weight: 500; transition: color 0.2s; }
.contact__links a:hover { color: var(--brand); }

/* ---------- Footer ---------- */
.footer { padding: 32px 0; border-top: 1px solid var(--border); }
.footer__inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.footer p { color: var(--text-dim); font-size: 0.9rem; }
.footer__top { font-size: 0.9rem; color: var(--text-dim); transition: color 0.2s; }
.footer__top:hover { color: var(--brand); }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .nav__toggle { display: flex; }
  .nav__links {
    position: fixed; inset: 68px 0 auto 0; flex-direction: column; gap: 18px;
    background: var(--bg-alt); padding: 28px 24px; border-bottom: 1px solid var(--border);
    transform: translateY(-120%); transition: transform 0.35s ease; align-items: flex-start;
  }
  .nav__links.open { transform: translateY(0); }
  .about { grid-template-columns: 1fr; gap: 32px; }
  .skills { grid-template-columns: 1fr; }
  .achievements { grid-template-columns: 1fr; }
  .process { grid-template-columns: 1fr 1fr; }
  .projects { grid-template-columns: 1fr; }
  .section__lead { margin-top: -16px; }
  .edu-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .about__stats { grid-template-columns: 1fr 1fr; }
  .process { grid-template-columns: 1fr; }
  .section { padding: 72px 0; }
  .contact { padding: 40px 22px; }
  .hero__cta, .contact__actions { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ============================================================
   Print — the site doubles as the résumé.
   Ctrl/Cmd+P → Save as PDF. Keep this in sync with the layout.
   ============================================================ */
@page { size: A4; margin: 14mm 12mm; }

@media print {
  /* Always paper-light, whatever theme is on screen */
  :root, :root[data-theme="light"], :root[data-theme="dark"] {
    --bg: #fff; --bg-alt: #fff; --surface: #fff; --surface-2: #f4f6fa;
    --text: #10182b; --text-dim: #47536b; --border: #c8d0de;
    --brand: #2a53c4; --brand-2: #6b3fd4; --accent: #0d7f6b;
    --shadow: none;
  }

  * { animation: none !important; transition: none !important; box-shadow: none !important; }

  body { background: #fff; color: var(--text); font-size: 10.2pt; line-height: 1.45; }
  .container { max-width: none; padding: 0; }

  /* Screen-only furniture */
  .nav, .hero__bg, .hero__scroll, .hero__cursor, .theme-toggle,
  .nav__toggle, .readmore, .footer__top, .hero__cta { display: none !important; }

  /* Everything revealed — print never runs the scroll observer */
  .reveal { opacity: 1 !important; transform: none !important; }
  .about__more[hidden] { display: block !important; }

  /* Hero → résumé masthead */
  .hero { min-height: 0; display: block; padding: 0; border-bottom: 2px solid var(--brand); }
  .hero__inner { padding: 0 0 10pt; }
  .hero__eyebrow { display: none; }
  .hero__title {
    -webkit-text-fill-color: var(--text); color: var(--text);
    background: none; font-size: 26pt; line-height: 1.1;
  }
  .hero__role { font-size: 13pt; color: var(--brand); margin-top: 2pt; }
  .hero__tagline { font-size: 10pt; margin-top: 6pt; max-width: none; }
  .hero__badges { margin-top: 8pt; gap: 6pt; }
  .badge { font-size: 8.5pt; padding: 2pt 7pt; }

  /* Sections tighten up; no alternating bands on paper */
  .section, .section--alt { padding: 12pt 0 0; background: #fff; break-inside: auto; }
  .section__head { margin-bottom: 8pt; }
  .section__title { font-size: 14pt; padding-bottom: 4pt; break-after: avoid; }
  .section__title::after { height: 2px; width: 34pt; }
  .section__num { font-size: 8pt; }

  /* Cards: never split one across a page break */
  /* On screen these are ruled cells, not cards; on paper a light box reads
     better and keeps them from splitting across a page break. */
  .skill-card, .project, .ach, .edu, .timeline__card, .stat, .process__step {
    break-inside: avoid; page-break-inside: avoid;
    border: 1px solid var(--border); border-top: 1px solid var(--border);
    padding: 9pt 11pt;
  }
  .skill-card h3, .project__title, .edu__subtitle { font-size: 11pt; }
  .project__desc, .skill-card p, .ach__text, .timeline__desc { font-size: 9.4pt; }

  /* Grids stay multi-column on paper — A4 is narrower than the 820px
     breakpoint, so without this the mobile single-column rules win and
     the PDF balloons by ~2 pages. */
  .about { grid-template-columns: 1.5fr 1fr; gap: 14pt; }
  .skills, .achievements, .edu-grid { grid-template-columns: 1fr 1fr; gap: 9pt; }
  .process { grid-template-columns: 1fr 1fr; gap: 9pt; }
  .process__step { break-inside: avoid; border: 1px solid var(--border); padding: 8pt 10pt; }
  .process__step h3 { font-size: 10pt; }
  .process__step p, .par dd { font-size: 9.2pt; }
  .par dt { font-size: 7.4pt; }
  .section__lead { font-size: 9.4pt; margin: 0 0 8pt; }
  .hero__meta { font-size: 9.4pt; margin-top: 5pt; gap: 6pt; }
  .contact__where { font-size: 9pt; margin-top: 6pt; }
  .projects { grid-template-columns: 1fr; gap: 9pt; }
  .skill-card--wide, .project--wide { grid-column: 1 / -1; }
  .about__stats { gap: 7pt; }
  .project__metrics { gap: 14pt; }
  .project__metrics b { font-size: 12pt; }
  .stat__num { font-size: 15pt; }
  .ach__stat { font-size: 13pt; min-width: 48pt; }
  .ach__stat--word { font-size: 8.5pt; }
  .stat__suffix { font-size: 0.6em; }

  /* Timeline */
  .timeline { padding-left: 14pt; }
  .timeline__item { padding-bottom: 8pt; break-inside: avoid; }
  .timeline__dot { left: -14pt; width: 8pt; height: 8pt; border-width: 2px; }
  .timeline__role { font-size: 10.6pt; }

  /* Contact: plain block, and expose the real addresses */
  .contact { border: 1px solid var(--border); box-shadow: none; padding: 12pt; max-width: none; }
  .contact__actions { display: none; }
  .contact__links { gap: 14pt; }
  .contact__links a::after { content: " (" attr(href) ")"; font-size: 8pt; color: var(--text-dim); }

  .footer { padding: 8pt 0 0; }

  /* The screen's deliberate spacing rhythm uses ID selectors, which outrank
     the .section class rule above — reset them or the PDF inherits ~2 pages
     of screen whitespace. */
  #projects, #experience, #education { padding: 12pt 0 0; }

  /* Page-break discipline between major blocks */
  #projects, #experience { break-before: auto; }
  #education, #contact { break-inside: avoid; }
}
