:root {
  --bg: #f6f3ee;
  --surface: #fffdf9;
  --ink: #1c1a17;
  --muted: #6b655c;
  --line: #e2dcd2;
  --accent: #1f4e5f;
  --accent-ink: #ffffff;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1c1c19;
    --ink: #ece8e1;
    --muted: #a39d93;
    --line: #2f2e2a;
    --accent: #8cc2d3;
    --accent-ink: #10181b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 14px max(16px, calc((100vw - 960px) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.mark { font: 600 18px var(--serif); text-decoration: none; letter-spacing: .02em; }
.topbar nav { display: flex; gap: 20px; margin-right: auto; }
.topbar nav a { text-decoration: none; color: var(--muted); font-size: 14px; }
.topbar nav a:hover { color: var(--ink); }
.tools { display: flex; gap: 10px; align-items: center; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.lang button, .print {
  font: 500 13px var(--sans); color: var(--muted);
  background: none; border: 0; cursor: pointer;
  padding: 6px 10px; border-radius: 999px; min-height: 32px;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.print { border: 1px solid var(--line); }
.print:hover, .lang button:hover { color: var(--ink); }
.lang button[aria-pressed="true"]:hover { color: var(--bg); }

/* Layout */
main { max-width: 960px; margin: 0 auto; padding: 0 16px; }

.hero {
  padding: 96px 0 56px;
  display: grid; grid-template-columns: 1fr 190px; gap: 48px; align-items: center;
}
.hero-text { grid-row: 1; grid-column: 1; }
.portrait {
  grid-row: 1; grid-column: 2;
  width: 100%; height: auto; aspect-ratio: 1; object-fit: cover;
  border-radius: 50%; border: 1px solid var(--line);
  box-shadow: 0 0 0 8px var(--surface), 0 0 0 9px var(--line);
}
.eyebrow { color: var(--muted); font-size: 14px; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 20px; }
.hero h1 { font: 400 clamp(48px, 9vw, 96px)/0.98 var(--serif); letter-spacing: -0.02em; }
.role { font: 500 18px var(--sans); color: var(--accent); margin: 24px 0 0; }
.lede { font-size: 19px; max-width: 620px; color: var(--muted); margin: 16px 0 0; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px;
  border-radius: 999px; border: 1px solid var(--line); text-decoration: none;
  font-weight: 500; font-size: 15px; background: var(--surface);
  transition: border-color .15s, transform .15s;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.stats div { padding: 28px 20px 28px 0; }
.stats div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.stats strong { display: block; font: 400 40px/1 var(--serif); }
.stats span { display: block; color: var(--muted); font-size: 14px; margin-top: 8px; }

.block { padding: 72px 0 0; }
.block > h2 {
  font: 400 32px var(--serif); margin-bottom: 32px;
  display: flex; align-items: center; gap: 16px;
}
.block > h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Experience */
.org {
  display: grid; grid-template-columns: 240px 1fr; gap: 24px;
  padding: 28px 0; border-top: 1px solid var(--line);
}
.org:first-of-type { border-top: 0; padding-top: 0; }
.org h3 { font: 600 20px var(--serif); }
.meta { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.roles { list-style: none; margin: 0; padding: 0; }
.roles li { position: relative; padding: 0 0 22px 22px; border-left: 1px solid var(--line); }
.roles li:last-child { padding-bottom: 0; }
.roles li::before {
  content: ""; position: absolute; left: -5px; top: 8px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.roles li:first-child::before { background: var(--accent); }
.r-head { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.r-head h4 { font-size: 16px; }
.r-head time { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.roles p { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }

a.ext { text-decoration: none; background-image: linear-gradient(currentColor, currentColor); background-size: 0 1px; background-position: 0 100%; background-repeat: no-repeat; transition: background-size .2s; }
a.ext::after { content: "↗"; font: 400 .7em var(--sans); color: var(--muted); margin-left: .25em; vertical-align: .35em; }
a.ext:hover { background-size: 100% 1px; }
a.ext:hover::after { color: var(--accent); }
@media print { a.ext::after { content: none; } }

/* Education */
.edu { list-style: none; margin: 0; padding: 0; }
.edu li { display: grid; grid-template-columns: 80px 1fr; gap: 24px; padding: 16px 0; border-top: 1px solid var(--line); }
.edu li:first-child { border-top: 0; padding-top: 0; }
.edu time { color: var(--muted); font-size: 14px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.edu h4 { font-size: 16px; }
.edu p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.skills > div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.skills h4 { font: 600 17px var(--serif); margin-bottom: 8px; }
.skills p { margin: 0; color: var(--muted); font-size: 15px; }

.contact > p { color: var(--muted); font-size: 18px; margin: 0; }
.contact .cta { margin-top: 20px; }
.foot { max-width: 960px; margin: 96px auto 0; padding: 24px 16px 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

/* Projects */
.section-lede { color: var(--muted); margin: -16px 0 24px; max-width: 60ch; }
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; text-decoration: none; transition: border-color .15s;
}
a.card:hover { border-color: var(--accent); }
.card h4 { font: 600 18px var(--serif); }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card .link { margin-top: auto; padding-top: 8px; color: var(--accent); font-size: 14px; font-weight: 500; }
.tag { color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

/* World map */
.world { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px 24px 28px; }
.world-head { display: flex; gap: 28px; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.world-head strong { font: 400 32px/1 var(--serif); color: var(--ink); margin-right: 4px; }
.map { display: block; width: 100%; height: auto; overflow: visible; }
.map-dots { stroke: color-mix(in srgb, var(--muted) 50%, transparent); stroke-width: 3.8; stroke-linecap: round; fill: none; }
.map-arcs path {
  fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linecap: round; opacity: .75;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.1s cubic-bezier(.3,.7,.2,1) calc(var(--i) * 90ms);
}
.map.in .map-arcs path { stroke-dashoffset: 0; }
.map-dots.fine { stroke-width: 2.6; }
.map-inset-bg { fill: var(--surface); stroke: var(--line); }
.map-frame { fill: none; stroke: var(--muted); stroke-width: 1; }
.map-lead { fill: none; stroke: var(--muted); stroke-width: .8; stroke-dasharray: 2 3; opacity: .7; }
.map-labels.small text { font-size: 10.5px; stroke-width: 3px; }
.map-pins circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.map-home { fill: none; stroke: var(--accent); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(3.4); opacity: 0; } }
.map-labels text {
  font: 500 12.5px var(--sans); fill: var(--ink);
  paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round;
}
.regions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.regions h4 { font: 600 13px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.regions ul { list-style: none; margin: 0; padding: 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
@media (prefers-reduced-motion: reduce) {
  .map-arcs path { transition: none; stroke-dashoffset: 0; }
  .map-home { animation: none; }
}

/* Writing */
.book {
  display: grid; grid-template-columns: 220px 1fr; gap: 40px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 32px; margin-bottom: 32px;
}
.book-cover {
  width: 100%; max-width: 100%; height: auto; display: block; border-radius: 3px 8px 8px 3px;
  box-shadow: inset 6px 0 0 rgba(0,0,0,.18), 0 2px 4px rgba(0,0,0,.12), 0 18px 36px -12px rgba(0,0,0,.35);
  transform: rotate(-1.5deg);
}
.book-body { min-width: 0; }
.book h3 { font: 600 28px/1.15 var(--serif); margin: 8px 0 6px; }
.book p { margin: 0; color: var(--muted); max-width: 60ch; }
.book .book-sub { color: var(--ink); font-size: 14px; font-weight: 500; margin-bottom: 14px; }
.chapters {
  list-style: none; counter-reset: ch; margin: 20px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px;
}
.chapters li { counter-increment: ch; font-size: 14px; display: flex; gap: 10px; }
.chapters li::before { content: counter(ch, decimal-leading-zero); color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.book-quote { margin: 20px 0 0; padding-left: 14px; border-left: 2px solid var(--accent); font: italic 400 16px/1.5 var(--serif); }
.book-quote cite { font: 400 13px var(--sans); color: var(--muted); font-style: normal; }
.book .cta { align-items: center; margin-top: 24px; }
.btn { cursor: pointer; font-family: inherit; color: inherit; }
.btn.primary { color: var(--accent-ink); }
.book-meta { color: var(--muted); font-size: 13px; }
.price { font: 600 26px/1 var(--serif); }
.order-total { margin: 0; display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.order-total strong { font: 600 22px var(--serif); color: var(--ink); }
.pubs { border-top: 1px solid var(--line); padding-top: 16px; }

/* Order dialog */
.order {
  width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 60px -20px rgba(0,0,0,.45);
}
.order::backdrop { background: rgba(20,18,15,.55); backdrop-filter: blur(3px); }
.order-form { display: grid; gap: 14px; padding: 24px; }
.order-form header { display: flex; justify-content: space-between; align-items: center; }
.order-form h3 { font: 600 22px var(--serif); }
.order-form .x { border: 0; background: none; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; width: 44px; height: 44px; margin: -10px -12px -10px 0; }
.order-lede { margin: -4px 0 0; color: var(--muted); font-size: 15px; }
.order-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; }
.order-form input, .order-form textarea {
  font: 400 16px var(--sans); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
.order-form textarea { resize: vertical; }
.order-form input:focus, .order-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.order-form [aria-invalid="true"] { border-color: #c0392b; }
.order-form .row { display: grid; grid-template-columns: 1fr 96px; gap: 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; }
.order-status { margin: 0; font-size: 14px; min-height: 1.2em; color: var(--muted); }
.order-status.ok { color: var(--accent); font-weight: 500; }
.order-status.err { color: #c0392b; }
.order-actions { display: flex; justify-content: flex-end; gap: 10px; }
.order-actions button[disabled] { opacity: .6; cursor: progress; }

/* Responsive */
@media (max-width: 760px) {
  .topbar nav { display: none; }
  .topbar { justify-content: space-between; }
  .hero { padding: 40px 0 40px; grid-template-columns: 1fr; gap: 28px; }
  .portrait { grid-column: 1; width: 96px; }
  .hero-text { grid-row: 2; }
  .lede { font-size: 17px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div, .stats div + div { padding: 20px 12px; border-left: 0; }
  .stats div:nth-child(even) { border-left: 1px solid var(--line); }
  .stats div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .org { grid-template-columns: 1fr; gap: 16px; }
  .r-head { flex-direction: column; gap: 0; }
  .edu li { grid-template-columns: 1fr; gap: 2px; }
  .skills, .projects { grid-template-columns: 1fr; }
  .book { grid-template-columns: 1fr; gap: 24px; padding: 20px; }
  .book-cover { width: 140px; }
  .book h3 { font-size: 24px; }
  .chapters { grid-template-columns: 1fr; }
  .world { padding: 16px; }
  .map-labels { display: none; }
  .map-pins circle { stroke-width: 3; }
  .regions { grid-template-columns: repeat(2, 1fr); }
  .map-inset { display: none; }
  .block { padding-top: 56px; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Print → clean one-document CV */
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #ccc; --accent: #1f4e5f; }
  .topbar, .hero .cta, .foot, .book .cta, .order { display: none; }
  .book { grid-template-columns: 110px 1fr; gap: 20px; padding: 0; border: 0; }
  .book-cover { transform: none; box-shadow: none; }
  body { font-size: 11pt; }
  .hero { padding: 0 0 16px; grid-template-columns: 1fr 120px; gap: 24px; }
  .portrait { box-shadow: none; }
  .hero h1 { font-size: 36pt; }
  .block { padding-top: 24px; break-inside: avoid-page; }
  .org, .edu li, .card, .book, .world { break-inside: avoid; }
  .map-home { display: none; }
  .map-arcs path { stroke-dashoffset: 0; transition: none; }
  .card .link { display: none; }
  .btn { border: 0; padding: 0; min-height: 0; background: none; color: #000; }
  .btn.primary { background: none; color: #000; }
}
