/* ---------- Tokens (palette + type after microsoft.design) ---------- */
:root {
  /* Warm off-white background, near-black ink, soft warm gray muted */
  --bg: #ECECEA;
  --bg-elev: #ffffff;
  --ink: #272727;
  --ink-soft: #3a3a3a;
  --muted: #6A6A69;
  --line: rgba(39, 39, 39, 0.12);
  /* Microsoft Fluent blue as a single restrained accent */
  --accent: #0067C0;
  --accent-ink: #ffffff;

  /* Prefer system Segoe (Windows/Edge), fall back to Inter from Google Fonts */
  --font-sans: "Segoe UI Variable", "Segoe UI", "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;

  --maxw: 1280px;
  --gutter: clamp(20px, 5vw, 56px);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1A1A;
    --bg-elev: #1A1A1A;
    --ink: #ECECEA;
    --ink-soft: #d8d8d6;
    --muted: #9a9a98;
    --line: rgba(236, 236, 234, 0.14);
    --accent: #4CC2FF;
    --accent-ink: #1A1A1A;
  }
}

/* Explicit dark theme via toggle (overrides system preference) */
:root[data-theme="dark"] {
  --bg: #1A1A1A;
  --bg-elev: #1A1A1A;
  --ink: #ECECEA;
  --ink-soft: #d8d8d6;
  --muted: #9a9a98;
  --line: rgba(236, 236, 234, 0.14);
  --accent: #4CC2FF;
  --accent-ink: #1A1A1A;
}

/* Smooth color transitions when toggling themes */
html, body, .site-header, .nav__cta, .theme-toggle {
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease), border-color 0.35s var(--ease);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: clamp(17px, 1vw + 0.6rem, 19px);
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga", "kern", "onum";
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

::selection { background: var(--accent); color: var(--accent-ink); }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--bg);
  padding: 10px 14px; border-radius: 8px; z-index: 1000;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px var(--gutter);
  transition: background 0.4s var(--ease), backdrop-filter 0.4s var(--ease), border-color 0.4s var(--ease);
  border-bottom: 1px solid transparent;
}
.site-header.is-scrolled {
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom-color: var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand__mark {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
  transition: filter 0.35s var(--ease), transform 0.35s var(--ease);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand__mark { filter: invert(1); }
}
:root[data-theme="dark"] .brand__mark { filter: invert(1); }
:root[data-theme="light"] .brand__mark { filter: none; }
.brand__name {
  font-size: 15px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
  pointer-events: none;
}
.site-header.is-scrolled .brand__name {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  .brand__name { transition: none; transform: none; }
}

.nav {
  display: inline-flex;
  gap: 14px;
  align-items: center;
  margin-left: auto;
  font-size: 13px;
}
.nav a { color: var(--ink-soft); white-space: nowrap; transition: color 0.2s var(--ease); }
.nav a:hover { color: var(--ink); }
.nav__cta {
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--ink);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.nav a.nav__cta:hover {
  color: var(--ink);
  background: color-mix(in oklab, var(--ink) 6%, transparent);
  border-color: var(--ink);
}

@media (min-width: 820px) {
  .nav { gap: 28px; font-size: 14px; }
  .nav__cta { padding: 8px 14px; }
}

.theme-toggle {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  position: relative;
  overflow: hidden;
}
.theme-toggle:hover {
  background: color-mix(in oklab, var(--ink) 8%, transparent);
}
.theme-toggle__icon {
  position: absolute;
  inset: 0;
  margin: auto;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.theme-toggle__icon--sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
.theme-toggle__icon--moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}
:root[data-theme="dark"] .theme-toggle__icon--sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}
:root[data-theme="dark"] .theme-toggle__icon--moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__icon--sun {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
  }
  :root:not([data-theme="light"]) .theme-toggle__icon--moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .theme-toggle__icon { transition: none; }
}

/* ---------- Hero ---------- */
main { padding-top: 0; }

.hero {
  min-height: 100svh;
  padding: clamp(110px, 18vh, 180px) var(--gutter) clamp(60px, 10vh, 110px);
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  gap: clamp(28px, 4vw, 48px);
}

@media (min-width: 820px) {
  .hero {
    grid-template-columns: auto auto;
    justify-content: center;
    column-gap: clamp(32px, 5vw, 72px);
  }
}

.hero__figure {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  width: 100%;
}

@media (max-width: 819px) {
  .hero__figure {
    justify-content: center;
  }
}

.hero__mark {
  display: block;
  width: auto;
  height: auto;
  max-width: clamp(240px, 30vw, 380px);
  max-height: min(78svh, 600px);
  transform-origin: 50% 100%;
  animation:
    hero-fade-in 900ms ease-out both,
    hero-mark-idle 7s ease-in-out 900ms infinite;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero__mark { filter: invert(1); }
}
:root[data-theme="dark"] .hero__mark { filter: invert(1); }
:root[data-theme="light"] .hero__mark { filter: none; }

@keyframes hero-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes hero-mark-idle {
  0%   { transform: translateY(0)      rotate(0deg); }
  25%  { transform: translateY(-2.5px) rotate(-0.35deg); }
  50%  { transform: translateY(0)      rotate(0deg); }
  75%  { transform: translateY(-1.5px) rotate(0.3deg); }
  100% { transform: translateY(0)      rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .hero__mark { animation: none; opacity: 1; transform: none; }
}

.hero__content {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2vh, 24px);
  justify-self: start;
  max-width: 620px;
  width: 100%;
}

@media (max-width: 819px) {
  .hero__content {
    justify-self: center;
    text-align: center;
    align-items: center;
  }
}

.hero__name {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(48px, 7vw, 96px);
  line-height: 0.95;
  letter-spacing: -0.045em;
  margin: 0 0 0 -0.05em;
  color: var(--ink);
  white-space: nowrap;
}

.hero__tagline {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(22px, 2.6vw, 36px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
  max-width: 38ch;
  color: var(--ink);
}
.hero__tagline em {
  font-style: normal;
  font-weight: inherit;
  color: var(--ink);
}

/* ---------- Sections ---------- */
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(80px, 12vh, 160px) var(--gutter);
}

.section--split {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(28px, 5vw, 64px);
}
@media (min-width: 900px) {
  .section--split {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
  .section--split-reverse > figure { order: 2; }
  .section--split-reverse .section__body { order: 1; }
}

/* ---------- Work hero (heart motif) ---------- */
.work__hero {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: visible;
}
.work__heart {
  display: block;
  width: 100%;
  height: auto;
  max-width: clamp(220px, 32vw, 420px);
  color: var(--ink);
  transform-origin: center;
  will-change: transform, opacity;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.08));
}
:root[data-theme="dark"] .work__heart {
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.4));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .work__heart {
    filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.4));
  }
}

@keyframes work-heart-drop {
  /* Starts overlaid on the heart the hero person is cradling in his hands
     (left column, around viewport coords (367, 383) at scroll=0), then
     falls diagonally down-right into its resting spot in #work. Offsets
     are expressed in % of the heart's own box (~410x346 at default size),
     so they stay roughly anchored across viewport widths. */
  0% {
    transform: translate(-139%, -232%) scale(0.34) rotate(-10deg);
    opacity: 1;
  }
  78% {
    transform: translate(2%, 4%) scale(1.06) rotate(8deg);
    opacity: 1;
  }
  100% {
    transform: translate(0, 0) scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes work-heart-handoff {
  0% {
    transform: translate(0, 0) scale(1) rotate(0);
    opacity: 1;
  }
  60% {
    opacity: 1;
  }
  100% {
    /* drifts toward bottom-left, where the compass will appear next */
    transform: translate(-55%, 70%) scale(0.45) rotate(-32deg);
    opacity: 0;
  }
}

/* Scroll-driven animation is wired up in script.js via a scroll handler.
   Why JS and not `animation-timeline: scroll()`?  Chrome skips painting
   elements whose layout box is far offscreen, so the CSS-driven transform
   never appears over the hero's hands at scrollY = 0. Writing the
   transform inline from JS forces paint and works in every browser. */
.work__heart {
  /* Start anchored over the hero person's hands but hidden — the heart
     fades in lightly as the user begins scrolling. JS overrides this on
     the first scroll tick. */
  transform: translate(-139%, -232%) scale(0.34) rotate(-10deg);
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .work__heart {
    animation: none;
    transform: none;
    opacity: 1;
  }
}

/* ---------- Training hero (compass motif) ---------- */
.training__hero {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: visible;
}
.training__compass {
  display: block;
  width: 100%;
  height: auto;
  max-width: clamp(180px, 24vw, 300px);
  color: var(--ink);
  transform-origin: center;
  will-change: transform, opacity;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.08));
}
:root[data-theme="dark"] .training__compass {
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.4));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .training__compass {
    filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.4));
  }
}

@keyframes training-compass-arrive {
  0% {
    /* enters from the upper-right, where the heart left off */
    transform: translate(55%, -70%) scale(0.45) rotate(140deg);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  75% {
    transform: translate(-2%, 4%) scale(1.04) rotate(-6deg);
    opacity: 1;
  }
  100% {
    transform: translate(0, 0) scale(1) rotate(0);
    opacity: 1;
  }
}

@supports (animation-timeline: view()) {
  .training__compass {
    opacity: 0;
    animation: training-compass-arrive linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 55%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .training__compass {
    animation: none;
    transform: none;
    opacity: 1;
  }
}

.lede {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(24px, 2.4vw + 0.3rem, 34px);
  line-height: 1.25;
  letter-spacing: -0.018em;
  margin: 0 0 20px;
  color: var(--ink);
}
.section__body p {
  color: var(--ink-soft);
  max-width: 52ch;
  font-size: clamp(18px, 1.1vw + 0.6rem, 22px);
  line-height: 1.5;
}
.section__body p.lede {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(26px, 2.4vw + 0.5rem, 36px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* ---------- Contact ---------- */
.section--contact {
  text-align: center;
}
.contact__inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(20px, 2.4vw, 28px);
}
.contact__lede {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(26px, 2.4vw + 0.5rem, 36px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.contact__lede em {
  font-style: normal;
  font-weight: inherit;
  color: var(--ink);
}
.contact__copy {
  max-width: 46ch;
  margin: 0;
  font-size: clamp(16px, 1.2vw, 18px);
  line-height: 1.6;
  color: var(--muted);
}
.contact__actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  font-weight: 500;
  font-size: 15px;
  transition: transform 0.25s var(--ease), background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.btn:hover {
  transform: translateY(-2px);
  border-color: var(--ink);
  background: color-mix(in oklab, var(--ink) 6%, transparent);
}
.btn svg { transition: transform 0.25s var(--ease); }
.btn:hover svg { transform: translate(2px, -2px); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px var(--gutter);
  font-size: 13px;
  color: var(--muted);
}
.site-footer__row {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  justify-content: center;
  text-align: center;
}

/* Avoid sub-pixel jitter on iOS for backdrop blur */
@supports not (backdrop-filter: blur(1px)) {
  .site-header.is-scrolled { background: var(--bg); }
}
