:root {
  --bg: #f4f1ea;
  --bg-elev: #ebe6db;
  --fg: #1a1d23;
  --fg-muted: #5a5f6a;
  --fg-faint: #8a8f9a;
  --rule: #cfc8b8;
  --accent: #188b0b;
  --accent-soft: rgba(24, 139, 11, 0.12);
  --grid: rgba(26, 29, 35, 0.04);
  --shadow: 0 1px 0 rgba(26, 29, 35, 0.05);

  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 2px;
  --maxw: 640px;
}

/* Auto: follow system in "auto" mode */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0e1116;
    --bg-elev: #151921;
    --fg: #e8e6df;
    --fg-muted: #9aa0ad;
    --fg-faint: #5d6473;
    --rule: #2a2f3a;
    --accent: #53b015;
    --accent-soft: rgba(83, 176, 21, 0.14);
    --grid: rgba(232, 230, 223, 0.035);
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
  }
}

/* Manual dark override */
:root[data-theme="dark"] {
  --bg: #0e1116;
  --bg-elev: #151921;
  --fg: #e8e6df;
  --fg-muted: #9aa0ad;
  --fg-faint: #5d6473;
  --rule: #2a2f3a;
  --accent: #53b015;
  --accent-soft: rgba(83, 176, 21, 0.14);
  --grid: rgba(232, 230, 223, 0.035);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

/* Manual light override (forces light even if system is dark) */
:root[data-theme="light"] {
  --bg: #f4f1ea;
  --bg-elev: #ebe6db;
  --fg: #1a1d23;
  --fg-muted: #5a5f6a;
  --fg-faint: #8a8f9a;
  --rule: #cfc8b8;
  --accent: #188b0b;
  --accent-soft: rgba(24, 139, 11, 0.12);
  --grid: rgba(26, 29, 35, 0.04);
  --shadow: 0 1px 0 rgba(26, 29, 35, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-display);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
  /* faint grid — a quiet nod to charts and coordinates */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
}

/* subtle film grain overlay for texture */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.25;
  mix-blend-mode: overlay;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.35 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------------- top bar ---------------- */
.topbar {
  position: relative;
  z-index: 2;
  padding: 28px clamp(20px, 5vw, 56px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
}

.brand__mark {
  color: var(--accent);
  display: inline-flex;
  animation: slow-spin 40s linear infinite;
}

.brand__text {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}

.topbar__controls {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 120ms ease;
}

.pill:hover,
.pill:focus-visible {
  color: var(--fg);
  border-color: var(--fg-faint);
  outline: none;
}

.pill:active { transform: translateY(1px); }

.pill--icon {
  width: 34px;
  padding: 7px;
  position: relative;
}

.icon-sun, .icon-moon {
  position: absolute;
  inset: 0;
  margin: auto;
  transition: opacity 200ms ease, transform 300ms ease;
}

:root[data-theme="auto"] .icon-sun { opacity: 1; transform: rotate(0deg); }
:root[data-theme="auto"] .icon-moon { opacity: 0; transform: rotate(-40deg); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .icon-sun { opacity: 0; transform: rotate(40deg); }
  :root[data-theme="auto"] .icon-moon { opacity: 1; transform: rotate(0deg); }
}
:root[data-theme="light"] .icon-sun { opacity: 1; transform: rotate(0deg); }
:root[data-theme="light"] .icon-moon { opacity: 0; transform: rotate(-40deg); }
:root[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(40deg); }
:root[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0deg); }

/* ---------------- main stage ---------------- */
.stage {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(40px, 10vh, 120px) clamp(24px, 5vw, 56px) 80px;
  width: 100%;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 28px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  animation: rise 700ms ease-out both;
}

.eyebrow__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: pulse 2.4s ease-in-out infinite;
}

.name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(44px, 7vw, 76px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  display: inline-flex;
  align-items: baseline;
  gap: 0.38em;
  animation: rise 700ms 80ms ease-out both;
  font-variation-settings: "opsz" 144;
}

.name__logo {
  width: 0.86em;
  height: 0.86em;
  object-fit: contain;
  vertical-align: -0.06em;
}

.role {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--fg-muted);
  margin: 0 0 32px;
  letter-spacing: 0.01em;
  animation: rise 700ms 160ms ease-out both;
}

.bio {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.55;
  color: var(--fg);
  margin: 0 0 64px;
  max-width: 52ch;
  animation: rise 700ms 240ms ease-out both;
}

/* ---------------- contact block ---------------- */
.contact {
  animation: rise 700ms 320ms ease-out both;
}

.contact__label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.rule {
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.links li {
  border-bottom: 1px solid var(--rule);
}

.links a {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: baseline;
  gap: 16px;
  padding: 18px 4px;
  text-decoration: none;
  color: var(--fg);
  transition: color 180ms ease, padding 260ms ease, background 180ms ease;
  position: relative;
}

.links a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--accent);
  transition: width 260ms ease;
}

.links a:hover,
.links a:focus-visible {
  padding-left: 16px;
  outline: none;
  background: var(--accent-soft);
}

.links a:hover::before,
.links a:focus-visible::before {
  width: 3px;
}

.links__key {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.links__val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.links__arrow {
  font-family: var(--font-mono);
  color: var(--fg-faint);
  font-size: 16px;
  transition: transform 260ms ease, color 180ms ease;
}

.links a:hover .links__arrow,
.links a:focus-visible .links__arrow {
  color: var(--accent);
  transform: translateX(4px) translateY(-2px);
}

/* ---------------- footer ---------------- */
.footline {
  position: relative;
  z-index: 1;
  padding: 24px clamp(20px, 5vw, 56px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
  flex-wrap: wrap;
}

/* ---------------- animations ---------------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-soft); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

@keyframes slow-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------- responsive touchups ---------------- */
@media (max-width: 480px) {
  .links a {
    grid-template-columns: 90px 1fr auto;
    gap: 12px;
  }
  .links__val { font-size: 16px; }
  .footline { font-size: 10px; }
}
