:root {
  --bg: #f3eee3;
  --card: #fbf8f2;
  --raised: #e8e1d2;
  --text: #23201a;
  --text-2: #4a4439;
  --muted: #6b6355;
  --line: rgba(35, 32, 26, 0.1);
  --accent: #3f5a2a;
  --accent-ink: #f6f3ea;
  --accent-text: #3f5a2a;
  --chip: #e3e8d6;
  --chip-ink: #2b3f1c;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --card: #1c1a18; --raised: #262421;
    --text: #efe9de; --text-2: #c9c2b5; --muted: #aaa398;
    --line: rgba(239, 233, 222, 0.08);
    --accent: #a9c48c; --accent-ink: #1a2410; --accent-text: #b5cf98;
    --chip: #262b20; --chip-ink: #c9dbb3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --card: #1c1a18; --raised: #262421;
  --text: #efe9de; --text-2: #c9c2b5; --muted: #aaa398;
  --line: rgba(239, 233, 222, 0.08);
  --accent: #a9c48c; --accent-ink: #1a2410; --accent-text: #b5cf98;
  --chip: #262b20; --chip-ink: #c9dbb3;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--chip); color: var(--chip-ink); }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { margin: 0; font-weight: 400; text-wrap: balance; }
p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; list-style: none; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 32px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; padding: 8px 12px; background: var(--card); border-radius: 8px; z-index: 10; }
.skip:focus { top: 16px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Nav */
.nav { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 24px; padding-bottom: 24px; }
.brand { font-size: 17px; font-weight: 600; text-decoration: none; }
.links { display: flex; gap: 24px; font-size: 15px; margin-left: auto; }
.links a { color: var(--text-2); text-decoration: none; transition: color 160ms var(--ease); }
.links a:hover { color: var(--text); }
.tools { display: flex; align-items: center; gap: 8px; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--raised); border-radius: 10px; }
.seg button {
  font: 500 13px var(--sans); color: var(--muted); background: transparent; border: 0;
  height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--line); background: transparent; color: var(--text-2); cursor: pointer;
  transition: background-color 160ms var(--ease);
}
.icon-btn:hover { background: var(--raised); }
.icon-btn .ic-sun { display: none; }
:root[data-theme="dark"] .icon-btn .ic-sun { display: block; }
:root[data-theme="dark"] .icon-btn .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .ic-sun { display: block; }
  :root:not([data-theme="light"]) .icon-btn .ic-moon { display: none; }
}

/* Hero */
.hero { display: flex; align-items: center; gap: 56px; padding-top: 72px; padding-bottom: 80px; }
.portrait { width: 280px; height: 280px; border-radius: 50%; object-fit: cover; flex: none; background: var(--raised); }
.hero-text { flex: 1; min-width: 0; animation: rise 500ms var(--ease) both; }
.hero h1 { font-family: var(--serif); font-size: clamp(44px, 6.4vw, 76px); line-height: 1; letter-spacing: -0.01em; }
.lead { margin-top: 24px; font-size: 18px; line-height: 1.6; color: var(--muted); max-width: 38rem; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; height: 48px; padding: 0 22px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  font-size: 15px; font-weight: 500; text-decoration: none;
  transition: background-color 160ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { background: var(--raised); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent); filter: brightness(1.08); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .hero-text { animation: none; } }

/* Countries + figures */
.countries { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.countries li { display: flex; flex-direction: column; gap: 6px; padding: 24px; background: var(--card); border-radius: 16px; }
.countries strong { font-size: 17px; font-weight: 500; line-height: 1.35; margin-top: 2px; }
.countries li > span:last-child { font-size: 14px; color: var(--muted); line-height: 1.5; }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 40px; padding: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.figures div { display: flex; flex-direction: column-reverse; gap: 4px; }
.figures dd { font-family: var(--serif); font-size: 48px; line-height: 1; font-variant-numeric: tabular-nums; }
.figures div:last-child dd { color: var(--accent-text); }
.figures dt { font-size: 14px; color: var(--muted); }

/* Sections */
.block { padding-top: 96px; }
.display { font-family: var(--serif); font-size: clamp(36px, 4.4vw, 48px); line-height: 1.05; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 64px; padding-top: 96px; }
.prose { display: flex; flex-direction: column; gap: 16px; color: var(--text-2); max-width: 65ch; }

.why { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 32px; border-top: 1px solid var(--line); }
.why > div { padding: 24px 32px 24px 0; border-bottom: 1px solid var(--line); }
.why > div:nth-child(even) { padding: 24px 0 24px 32px; border-left: 1px solid var(--line); }
.why h3 { font-size: 18px; font-weight: 500; margin-bottom: 8px; }
.why p { font-size: 15px; color: var(--muted); }

.cases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 32px; }
.cases article { display: flex; flex-direction: column; gap: 8px; padding: 24px; background: var(--card); border-radius: 16px; }
.cases h3 { font-size: 19px; font-weight: 500; line-height: 1.3; }
.cases p { font-size: 15px; color: var(--text-2); flex: 1; }
.cases .chips { margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { font-size: 13px; line-height: 1; padding: 7px 10px; border-radius: 6px; background: var(--raised); color: var(--text-2); }
.chips.moss li { background: var(--chip); color: var(--chip-ink); }

.skills { margin-top: 32px; border-top: 1px solid var(--line); }
.skills > div { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 12px 32px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.skills dt { font-size: 15px; font-weight: 500; padding-top: 3px; }

.timeline { margin-top: 32px; border-top: 1px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 32px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.timeline time { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.timeline h3 { font-size: 17px; font-weight: 500; line-height: 1.4; }
.timeline p { font-size: 15px; color: var(--muted); margin-top: 4px; max-width: 70ch; }
.older summary {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; cursor: pointer; list-style: none;
  font-size: 15px; font-weight: 500; color: var(--accent-text); padding: 8px 0;
}
.older summary::-webkit-details-marker { display: none; }
.older summary .ic { transition: transform 200ms var(--ease); }
.older[open] summary .ic { transform: rotate(180deg); }
.older .timeline { margin-top: 8px; }

.certs { display: flex; flex-direction: column; }
.certs li { display: flex; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
.certs li:last-child { border-bottom: 1px solid var(--line); }
.certs .ic { color: var(--accent-text); margin-top: 3px; }
.certs strong { display: block; font-size: 16px; font-weight: 500; line-height: 1.4; }
.certs span { font-size: 14px; color: var(--muted); }
.edu { grid-column: 2; font-size: 14px; color: var(--muted); margin-top: -40px; }

.contact { padding-top: 120px; padding-bottom: 96px; }
.contact .display { max-width: 16em; }
.channels { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.channels a {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 18px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line); text-decoration: none; font-size: 15px;
  transition: background-color 160ms var(--ease);
}
.channels a:hover { background: var(--raised); }
.channels .ic { color: var(--muted); }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* Responsive */
@media (max-width: 960px) {
  .countries, .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cases { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; gap: 24px; }
  .edu { grid-column: 1; margin-top: 0; }
}
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .links { display: none; }
  .hero { flex-direction: column; align-items: flex-start; gap: 32px; padding-top: 32px; padding-bottom: 56px; }
  .portrait { width: 160px; height: 160px; }
  .lead { font-size: 17px; }
  .block, .split { padding-top: 72px; }
  .cases, .why { grid-template-columns: 1fr; }
  .why > div, .why > div:nth-child(even) { padding: 20px 0; border-left: 0; }
  .skills > div, .timeline li { grid-template-columns: 1fr; gap: 8px; }
  .countries li { padding: 20px; }
  .figures dd { font-size: 40px; }
  .contact { padding-top: 88px; padding-bottom: 64px; }
  .channels a { width: 100%; word-break: break-all; }
}

/* ---------- Motion ---------- */

.js .hero h1 .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.js .hero h1 .w > span { display: inline-block; transform: translateY(105%); animation: line-up 800ms var(--ease) forwards; animation-delay: calc(var(--i) * 45ms + 150ms); }
@keyframes line-up { to { transform: translateY(0); } }
.js .portrait { animation: photo-in 1100ms var(--ease) both; }
@keyframes photo-in { from { clip-path: circle(0% at 50% 60%); transform: scale(1.06); } to { clip-path: circle(50% at 50% 50%); transform: scale(1); } }
.js .hero-text { animation: none; }
.js .hero .lead, .js .hero .actions { opacity: 0; transform: translateY(10px); animation: fade-up 700ms var(--ease) forwards; }
.js .hero .lead { animation-delay: 550ms; }
.js .hero .actions { animation-delay: 750ms; }
@keyframes fade-up { to { opacity: 1; transform: none; } }

.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity 700ms var(--ease), transform 700ms var(--ease); transition-delay: var(--d, 0ms); }
.js .reveal.is-in { opacity: 1; transform: none; }

.tilt { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 400ms var(--ease), background-color 160ms var(--ease); }
.js .tilt.is-in { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
.tilt::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 300ms var(--ease);
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.35), transparent 40%); }
.tilt:hover::before { opacity: 1; }
:root[data-theme="dark"] .tilt::before { background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.05), transparent 40%); }
.cases article, .countries li { position: relative; }

.timeline { position: relative; }
.timeline::before { content: ""; position: absolute; left: 0; top: 0; width: 2px; height: 100%; background: var(--accent-text); transform-origin: top; transform: scaleY(var(--progress, 0)); opacity: 0.5; }
.timeline li { padding-left: 20px; }

.magnetic { transition: transform 300ms var(--ease), background-color 160ms var(--ease); will-change: transform; }

@media (prefers-reduced-motion: reduce) {
  .js .portrait, .js .hero h1 .w > span, .js .hero .lead, .js .hero .actions { animation: none; opacity: 1; transform: none; clip-path: none; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .timeline::before { transform: none; }
}
@media (max-width: 720px) { .timeline li { padding-left: 16px; } }
