/* ============================================================
   Dr. Firdosh v2 · "One Substance, Six States"
   Editorial-first: content in normal flow, canvas as the stage.
   Text always owns its ground; the substance responds to the
   reader, never the other way round.
   ============================================================ */

:root {
  --purple: #5E3190;
  --magenta: #E72993;
  --bridge: #A0237A;
  --ink: #1F1B2E;
  --paper: #FAF8F4;
  --surface: #FFFFFF;
  --muted: #6B6675;

  /* theme-driven */
  --fg: var(--ink);
  --fg-soft: #57516b;
  --ground: 250, 248, 244;      /* rgb triplet of the current world */
  --rule: rgba(31, 27, 46, 0.14);
  --header-bg: rgba(250, 248, 244, 0.62);

  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Familjen Grotesk", system-ui, sans-serif;
  --grad: linear-gradient(100deg, var(--purple), var(--magenta));

  /* type scale: one clear ladder */
  --t-hero: clamp(3rem, 7.6vw, 5.8rem);
  --t-thesis: clamp(2rem, 4.6vw, 3.6rem);
  --t-claim: clamp(1.9rem, 4.2vw, 3.3rem);
  --t-section: clamp(2rem, 4.2vw, 3.2rem);
  --t-body: clamp(1rem, 1.35vw, 1.125rem);
}

[data-theme="dark"] {
  --fg: #F4F1F9;
  --fg-soft: #C3BBD4;
  --ground: 14, 10, 24;
  --rule: rgba(244, 241, 249, 0.16);
  --header-bg: rgba(14, 10, 24, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overscroll-behavior-y: none; overflow-x: clip; }

/* craft details that read as care */
:focus-visible { outline: 2px solid var(--magenta); outline-offset: 3px; border-radius: 4px; }
.skip {
  position: fixed; top: -4rem; left: 1rem; z-index: 300;
  background: var(--ink); color: #fff; padding: 0.6rem 1.1rem; border-radius: 8px;
  text-decoration: none; font-size: 0.9rem; transition: top 0.3s ease;
}
.skip:focus-visible { top: 1rem; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--fg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: color 0.8s ease;
}

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

/* ---------- canvas ---------- */
#stage {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}

/* ---------- city labels (globe chapter) ---------- */
.city-layer {
  position: fixed; inset: 0; z-index: 1;
  pointer-events: none; opacity: 0;
  transition: opacity 0.6s ease;
}
.city-label {
  position: absolute; left: 0; top: 0;
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.62rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: #cfc7e2; white-space: nowrap; opacity: 0;
  will-change: transform, opacity;
}
.city-label::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--grad); flex: 0 0 auto;
}
.city-label--major { font-weight: 700; color: #ffffff; font-size: 0.68rem; }
body.static .city-layer { display: none; }
@media (max-width: 640px) {
  .city-label { display: none; }
  .city-label--major { display: flex; }
}

/* ---------- grain ---------- */
.grain {
  position: fixed; inset: -50%;
  z-index: 3; pointer-events: none;
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  animation: grain-shift 1.4s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(2%, -1%); }
}

/* ---------- progress hairline ---------- */
.progress-hair {
  position: fixed; top: 0; left: 0; height: 2px; width: 100%;
  background: var(--grad); z-index: 40;
  transform: scaleX(0); transform-origin: left; /* scaleX: no per-frame layout */
}

/* ---------- preloader ---------- */
.preloader {
  position: fixed; inset: 0; z-index: 100;
  background: var(--paper);
  display: grid; place-items: center;
  transition: opacity 0.9s ease, visibility 0.9s;
}
.preloader.done { opacity: 0; visibility: hidden; }
.pre-inner { text-align: center; }
.pre-drop-stage { position: relative; height: 110px; width: 110px; margin: 0 auto 1.2rem; }
.pre-drop {
  position: absolute; left: 50%; top: 0;
  width: 10px; height: 10px; margin-left: -5px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(45deg);
  background: var(--grad);
  animation: drop-fall 1.6s cubic-bezier(0.6, 0, 0.9, 0.4) infinite;
}
@keyframes drop-fall {
  0% { top: 0; opacity: 0; }
  15% { opacity: 1; }
  60% { top: 78px; opacity: 1; }
  70%, 100% { top: 78px; opacity: 0; }
}
.pre-ripple, .pre-ripple--2 {
  position: absolute; left: 50%; top: 84px;
  width: 12px; height: 5px; margin-left: -6px;
  border: 1.5px solid var(--bridge); border-radius: 50%;
  opacity: 0;
  animation: ripple 1.6s ease-out infinite;
  animation-delay: 0.9s;
}
.pre-ripple--2 { animation-delay: 1.1s; }
@keyframes ripple {
  0% { transform: scale(0.4); opacity: 0; }
  10% { opacity: 0.9; }
  100% { transform: scale(6); opacity: 0; }
}
.pre-name { font-family: var(--serif); font-size: 1.5rem; color: var(--ink); }
.pre-sub { font-size: 0.8rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 0.35rem; }

/* ---------- header ---------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center; gap: 1.5rem;
  transform: translateY(0);
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), background 0.8s ease;
  padding: max(0.9rem, env(safe-area-inset-top))
           max(clamp(1.2rem, 4vw, 3rem), env(safe-area-inset-right))
           0.9rem
           max(clamp(1.2rem, 4vw, 3rem), env(safe-area-inset-left));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: var(--header-bg);
}
.site-header.tucked { transform: translateY(-110%); }
.site-header:focus-within { transform: translateY(0); }
.brand-logo { display: block; height: 38px; width: auto; }
[data-theme="dark"] .brand-logo { filter: brightness(0) invert(1) opacity(0.92); }
.site-nav { display: flex; gap: 1.6rem; margin-left: auto; }
.site-nav a {
  color: var(--fg-soft); text-decoration: none; font-size: 0.88rem; font-weight: 500;
  transition: color 0.3s;
}
.site-nav a:hover { color: var(--fg); }
.btn-pill {
  font-size: 0.85rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  color: #fff; background: var(--grad);
  padding: 0.55rem 1.2rem; border-radius: 999px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.btn-pill:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(160, 35, 122, 0.35); }

/* ---------- menu pill (mobile: the single header control) ---------- */
.menu-btn {
  display: none; align-items: center; gap: 0.55rem; flex: 0 0 auto;
  border: none; cursor: pointer; z-index: 70;
  padding: 0.62rem 1.15rem; border-radius: 999px;
  background: var(--grad); color: #fff;
  font-family: var(--sans);
  box-shadow: 0 4px 18px rgba(160, 35, 122, 0.3);
}
.mb-lines { position: relative; width: 15px; height: 10px; flex: 0 0 auto; }
.mb-lines i {
  position: absolute; left: 0; right: 0; height: 2px; border-radius: 2px;
  background: #fff;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), top 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), bottom 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.mb-lines i:first-child { top: 0; }
.mb-lines i:last-child { bottom: 0; }
body.menu-open .mb-lines i:first-child { top: 4px; transform: rotate(45deg); }
body.menu-open .mb-lines i:last-child { bottom: 4px; transform: rotate(-45deg); }
.mb-label { font-size: 0.82rem; font-weight: 600; letter-spacing: 0.02em; }

.menu {
  position: fixed; inset: 0; z-index: 25;
  background: var(--ink); color: #F2EEF7;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(76px + env(safe-area-inset-top)) clamp(1.4rem, 7vw, 3rem) calc(1.8rem + env(safe-area-inset-bottom));
  opacity: 0; visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s;
  overscroll-behavior: contain;
}
body.menu-open .menu { opacity: 1; visibility: visible; }
body.menu-open { overflow: hidden; }
body.menu-open .site-header { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; transform: none; }
body.menu-open .brand-logo { filter: brightness(0) invert(1) opacity(0.92); }
body.menu-open .site-nav { display: none; }

.menu-nav { overflow-y: auto; }
.menu-nav > *, .menu-foot > * {
  opacity: 0; transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
body.menu-open .menu-nav > *, body.menu-open .menu-foot > * { opacity: 1; transform: none; }

.menu-tag {
  font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: #8f87a3; margin: 1.1rem 0 0.5rem;
}
.menu-tag:first-child { margin-top: 0; }
.menu a { color: #F2EEF7; text-decoration: none; }
.menu-ch {
  display: flex; align-items: baseline; gap: 0.85rem;
  font-family: var(--serif); font-size: clamp(1.4rem, 6vw, 1.9rem);
  line-height: 1.15; padding: 0.32rem 0;
}
.menu-ch i {
  font-style: italic; font-size: 0.85rem; flex: 0 0 1.6rem;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.menu-ch:active, .menu-link:active { opacity: 0.7; }
.menu-link {
  display: block; font-family: var(--serif);
  font-size: clamp(1.15rem, 4.6vw, 1.4rem); padding: 0.26rem 0;
}
.menu-foot { padding-top: 1.2rem; border-top: 1px solid rgba(242, 241, 249, 0.14); }
.menu-mail { font-family: var(--serif); font-size: clamp(1.2rem, 5vw, 1.5rem); display: inline-block; margin-bottom: 0.4rem; }
.menu-clocks { font-size: 0.82rem; color: #8f87a3; }

/* ---------- chapter rail ---------- */
.rail {
  position: fixed; left: 1.4rem; top: 50%; transform: translateY(-50%);
  z-index: 20; display: flex; flex-direction: column; gap: 1.05rem;
  opacity: 0; pointer-events: none; transition: opacity 0.6s ease;
}
.rail.visible { opacity: 1; pointer-events: auto; }
.rail a {
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none; color: var(--fg-soft);
}
.rail-tick {
  width: 16px; height: 2px; border-radius: 2px;
  background: var(--fg-soft); opacity: 0.45;
  transition: width 0.35s ease, opacity 0.35s ease, background 0.35s ease;
}
.rail-label {
  font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase;
  opacity: 0; transform: translateX(-4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
}
.rail a:hover .rail-label { opacity: 0.85; transform: none; }
.rail a.active .rail-tick { width: 30px; opacity: 1; background: var(--grad); }
.rail a.active .rail-label { opacity: 1; transform: none; color: var(--fg); }

/* ============================================================
   THE STORY FLOW - normal scroll, canvas behind
   ============================================================ */

/* Deterministic legibility: every text block sits on its own
   editorial ground, a gradient band of the current world colour.
   Contrast never depends on where a particle happens to be. */
.hero-copy, .chapter-copy, .thesis-line {
  position: relative; z-index: 2;
}
.chapter-copy::before, .hero-copy::before {
  content: "";
  position: absolute; inset: -3.5rem -4.5rem -3.5rem -6vw; z-index: -1;
  background: linear-gradient(90deg,
    rgba(var(--ground), 0.94) 0%,
    rgba(var(--ground), 0.82) 62%,
    rgba(var(--ground), 0) 100%);
  /* soft top/bottom edges: the band breathes, never a hard rectangle */
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 18%, #000 82%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 18%, #000 82%, transparent 100%);
  transition: background 0.8s ease;
}
.thesis-line::before {
  content: "";
  position: absolute; inset: -3.5rem -5rem; z-index: -1;
  border-radius: 4rem;
  background: radial-gradient(ellipse at 50% 50%,
    rgba(var(--ground), 0.88) 0%,
    rgba(var(--ground), 0.55) 60%,
    rgba(var(--ground), 0) 100%);
  transition: background 0.8s ease;
}

/* ---------- hero ---------- */
.hero {
  position: relative; z-index: 2;
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 7rem clamp(1.4rem, 6vw, 6rem) 4rem;
}
.hero-copy { max-width: 38rem; }
.eyebrow {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.78rem; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--fg-soft); margin-bottom: 1.2rem;
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--grad); display: inline-block; }
.eyebrow .sep { opacity: 0.5; }
.hero-headline {
  font-family: var(--serif); font-weight: 400;
  font-size: var(--t-hero);
  line-height: 1.02; letter-spacing: -0.015em;
  margin-bottom: 1.4rem;
}

/* ---------- line-mask reveals (hero, thesis) ---------- */
.lm { display: block; overflow: hidden; padding-bottom: 0.06em; margin-bottom: -0.06em; }
.lmi { display: inline-block; transform: translateY(118%); transition: transform 1.1s cubic-bezier(0.2, 0.7, 0.1, 1); }
.lm:nth-child(2) .lmi { transition-delay: 0.1s; }
.lm:nth-child(3) .lmi { transition-delay: 0.2s; }
.lm-host { opacity: 1 !important; transform: none !important; }
.lm-host.in .lmi { transform: none; }

/* ---------- word cascade (chapter claims, JS-split) ---------- */
.w { display: inline-block; opacity: 0; transform: translateY(0.55em); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: var(--d, 0s); }
.rv.in .w { opacity: 1; transform: none; }
.hero-headline .accent em {
  font-style: italic;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { font-size: var(--t-body); color: var(--fg-soft); max-width: 32rem; margin-bottom: 1.8rem; }
.hero-ctas { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 2.4rem; }
.btn-primary, .btn-ghost {
  text-decoration: none; font-weight: 600; font-size: 0.95rem;
  padding: 0.8rem 1.6rem; border-radius: 999px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.btn-primary { color: #fff; background: var(--grad); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(160, 35, 122, 0.4); }
.btn-ghost { color: var(--fg); border: 1px solid color-mix(in srgb, var(--fg) 30%, transparent); }
.btn-ghost:hover { background: color-mix(in srgb, var(--fg) 7%, transparent); }
.scroll-cue {
  position: absolute; left: 50%; bottom: calc(1.4rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  font-size: 0.7rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--fg-soft);
}
.scroll-cue-line {
  width: 1px; height: 44px;
  background: linear-gradient(to bottom, var(--fg-soft), transparent);
  animation: cue 2s ease-in-out infinite;
  transform-origin: top;
}
@keyframes cue { 0%, 100% { transform: scaleY(0.4); opacity: 0.4; } 50% { transform: scaleY(1); opacity: 1; } }

/* ---------- thesis ---------- */
.thesis {
  position: relative; z-index: 2;
  min-height: 84vh;
  display: grid; place-items: center;
  padding: 4rem clamp(1.4rem, 6vw, 6rem);
  text-align: center;
}
.thesis-line {
  font-family: var(--serif); font-weight: 400;
  font-size: var(--t-thesis); line-height: 1.18;
}
.thesis-line em { font-style: italic; }
.grad-text {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  font-style: italic;
}

/* ---------- chapters ---------- */
.chapter {
  position: relative; z-index: 2;
  min-height: 140vh;
  display: flex; align-items: center;
  padding: 0 clamp(1.4rem, 6vw, 6rem);
}
.chapter-copy { max-width: 34rem; }
.chapter-ghost {
  position: absolute; top: 50%; right: clamp(3rem, 9vw, 9rem);
  transform: translateY(-54%);
  font-family: var(--serif); font-style: italic;
  font-size: clamp(11rem, 24vw, 20rem); line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px color-mix(in srgb, var(--fg) 22%, transparent);
  z-index: 1; pointer-events: none; user-select: none;
}
.chapter-eyebrow {
  font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--fg-soft); margin-bottom: 1rem;
}
.chapter-claim {
  font-family: var(--serif); font-weight: 400;
  font-size: var(--t-claim); line-height: 1.1;
  margin-bottom: 1.1rem;
  text-wrap: balance;
}
.chapter-body { color: var(--fg-soft); font-size: var(--t-body); max-width: 33rem; text-wrap: pretty; }
.section-title { text-wrap: balance; }
.lede, .section-lede { text-wrap: pretty; }

/* ---------- reveal (once; never fades back out) ---------- */
.rv { opacity: 0; transform: translateY(26px); transition: opacity 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }
.rv.in { opacity: 1; transform: none; }

/* ============================================================
   PAPER SECTIONS - same editorial language, no cards
   ============================================================ */
.paper-section {
  position: relative; z-index: 5;
  background: var(--paper); color: var(--ink);
  padding: clamp(5rem, 12vh, 8rem) clamp(1.4rem, 6vw, 6rem);
}
.paper-section .section-tag {
  font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--bridge); margin-bottom: 1rem;
}
.section-title {
  font-family: var(--serif); font-weight: 400;
  font-size: var(--t-section); line-height: 1.1;
  color: var(--ink); margin-bottom: 1.3rem;
}
.section-title em { font-style: italic; color: var(--purple); }
.section-lede { color: var(--muted); max-width: 38rem; }
.section-head { margin-bottom: 3rem; max-width: 44rem; }

/* stats: editorial band, hairline rules, no cards */
.stats {
  list-style: none;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2.6rem 3rem;
  max-width: 62rem;
}
.stat { border-top: 1px solid rgba(31, 27, 46, 0.18); padding-top: 1.1rem; }
.stat-num { font-family: var(--serif); font-size: clamp(2.4rem, 4vw, 3.4rem); line-height: 1; display: block; color: var(--ink); margin-bottom: 0.45rem; }
.stat-num .currency, .stat-num .plus { font-size: 0.55em; }
.stat-num--word em { font-style: italic; }
.stat--gradient .stat-num {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-label { color: var(--muted); font-size: 0.92rem; display: block; max-width: 16rem; }

/* approach: numbered editorial rows */
.areas {
  list-style: none;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2.4rem 4rem;
  max-width: 62rem;
}
.area {
  display: flex; gap: 1.3rem; align-items: baseline;
  border-top: 1px solid rgba(31, 27, 46, 0.18); padding-top: 1.2rem;
}
.area-num {
  font-family: var(--serif); font-style: italic; font-size: 1.1rem;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  flex: 0 0 auto;
}
.area h3 { font-family: var(--serif); font-weight: 400; font-size: 1.45rem; margin-bottom: 0.4rem; color: var(--ink); line-height: 1.25; }
.area p { color: var(--muted); font-size: 0.95rem; }

/* writing: editorial features */
.publications {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3rem 4rem;
  max-width: 62rem;
}
.pub { border-top: 1px solid rgba(31, 27, 46, 0.18); padding-top: 1.3rem; }
.pub--featured { border-top: 2px solid; border-image: linear-gradient(100deg, var(--purple), var(--magenta)) 1; }
.pub-tag { font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--bridge); }
.pub-title { font-family: var(--serif); font-weight: 400; font-size: 2rem; color: var(--ink); margin: 0.4rem 0 0.5rem; }
.pub-blurb { color: var(--muted); font-size: 0.96rem; margin-bottom: 0.9rem; }
.pub-cta { color: var(--purple); font-weight: 600; text-decoration: none; }
.pub-cta:hover { color: var(--magenta); }

/* contact: the email is the hero */
.contact-mail {
  display: inline-block;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 4.6vw, 3.4rem);
  color: var(--ink); text-decoration: none;
  border-bottom: 2px solid transparent;
  background: linear-gradient(100deg, var(--purple), var(--magenta)) bottom left / 0% 2px no-repeat;
  transition: background-size 0.45s ease;
  margin-bottom: 1.6rem;
  word-break: break-word;
}
.contact-mail:hover { background-size: 100% 2px; }
.contact-links { display: flex; gap: 2.5rem; flex-wrap: wrap; }
.contact-links a { color: var(--muted); text-decoration: none; font-size: 0.95rem; border-bottom: 1px solid rgba(31, 27, 46, 0.2); padding-bottom: 2px; transition: color 0.3s, border-color 0.3s; }
.contact-links a:hover { color: var(--purple); border-color: var(--purple); }

/* ---------- availability badge ---------- */
.avail {
  display: flex; width: fit-content; align-items: center; gap: 0.6rem;
  font-size: 0.85rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1.1rem;
}
.contact-mail { display: block; width: fit-content; }
.avail-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--grad);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(231, 41, 147, 0.45); }
  70% { box-shadow: 0 0 0 11px rgba(231, 41, 147, 0); }
  100% { box-shadow: 0 0 0 0 rgba(231, 41, 147, 0); }
}

/* ---------- header nav: current section ---------- */
.site-nav a { position: relative; padding-bottom: 3px; }
.site-nav a::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 100%; height: 2px; border-radius: 2px;
  background: var(--grad);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.site-nav a.active::after, .site-nav a:hover::after { transform: scaleX(1); }
.site-nav a.active { color: var(--fg); }

/* ---------- custom cursor (fine pointers only) ---------- */
@media (pointer: fine) {
  body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }
}
.cursor-dot, .cursor-ring {
  position: fixed; top: 0; left: 0; z-index: 200; pointer-events: none;
  border-radius: 50%; opacity: 0; transition: opacity 0.3s ease;
}
body.has-cursor .cursor-dot, body.has-cursor .cursor-ring { opacity: 1; }
.cursor-dot {
  width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px;
  background: var(--grad);
}
.cursor-ring {
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 1.5px solid color-mix(in srgb, var(--fg) 45%, transparent);
  transition: opacity 0.3s ease, border-color 0.3s ease, width 0.25s ease, height 0.25s ease, margin 0.25s ease;
}
.cursor-ring.on {
  width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-color: var(--magenta);
}

/* footer: content rises as the footer enters (reveal parallax) */
.site-footer {
  position: relative; z-index: 5; background: var(--ink); color: #CFC9DC;
  padding: 3.5rem clamp(1.4rem, 6vw, 6rem);
  overflow: hidden;
}
.footer-inner {
  display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  will-change: transform;
}
.clock-sep { opacity: 0.45; padding: 0 0.3ch; }
[data-clock] { font-variant-numeric: tabular-nums; color: #fff; }

/* the operator's watch row: live dials, day/night aware */
.world-clocks { display: flex; gap: clamp(1.2rem, 3vw, 2.2rem); flex-wrap: wrap; align-items: flex-start; }
.wclock { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.wclock svg { width: 48px; height: 48px; overflow: visible; }
.wc-face {
  fill: rgba(250, 248, 244, 0.06);
  stroke: rgba(207, 201, 220, 0.45); stroke-width: 1;
  transition: fill 0.6s ease, stroke 0.6s ease;
}
.wclock.is-night .wc-face { fill: rgba(10, 7, 18, 0.75); stroke: rgba(207, 201, 220, 0.25); }
.wc-pip { fill: var(--magenta); }
.wc-hour, .wc-min {
  stroke: #E8E3F2; stroke-width: 2; stroke-linecap: round;
  transform-origin: 24px 24px;
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.wc-hour { stroke-width: 2.4; }
.wclock.is-night .wc-hour, .wclock.is-night .wc-min { stroke: #9d93b8; }
.wc-sec {
  stroke: var(--magenta); stroke-width: 1;
  transform-origin: 24px 24px;
  transition: transform 1s linear; /* smooth continuous sweep */
}
.wc-hub { fill: var(--magenta); }
.wc-city { font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: #8f87a3; margin-top: 0.2rem; }
.wc-time { font-size: 0.78rem; color: #fff; font-variant-numeric: tabular-nums; }
.wclock.is-night .wc-time { color: #b9b0cf; }
.toTop { display: inline-block; margin-top: 0.9rem; color: #CFC9DC; text-decoration: none; font-size: 0.85rem; border-bottom: 1px solid rgba(207, 201, 220, 0.35); padding-bottom: 2px; transition: color 0.3s, border-color 0.3s; }
.toTop:hover { color: #fff; border-color: var(--magenta); }
.footer-name { font-family: var(--serif); font-size: 1.3rem; color: #fff; }
.footer-tag { font-size: 0.9rem; opacity: 0.8; }
.footer-key { color: #8f87a3; margin-right: 0.5rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; }
.footer-meta a { color: #fff; text-decoration: none; }
.footer-end { font-size: 0.85rem; opacity: 0.7; }
.footer-colophon { margin-top: 0.3rem; font-style: italic; }

/* ---------- static / reduced-motion fallback ---------- */
body.static #stage, body.static .preloader, body.static .rail,
body.static .scroll-cue, body.static .progress-hair { display: none; }
body.static .rv { opacity: 1; transform: none; transition: none; }
body.static .lmi, body.static .w { opacity: 1; transform: none; transition: none; }
body.static .hero, body.static .chapter { min-height: 0; padding-top: 14vh; padding-bottom: 14vh; }
body.static .thesis { min-height: 0; padding: 12vh clamp(1.4rem, 6vw, 6rem); }
body.static { color: var(--ink); }
body.static .site-header { background: rgba(250, 248, 244, 0.85); }

/* ---------- responsive ---------- */
@media (min-width: 1101px) {
  /* clear the chapter rail's expanded labels */
  .chapter { padding-left: clamp(15rem, 16vw, 17rem); }
}
@media (min-width: 1700px) {
  /* ultrawide: keep the measure anchored, not glued to the left edge */
  .hero, .thesis { padding-left: 12vw; padding-right: 12vw; }
  .chapter { padding-left: 20vw; }
  .paper-section { padding-left: 14vw; padding-right: 14vw; }
}
@media (max-width: 1100px) {
  .rail { display: none; }
}
@media (max-width: 760px) {
  .site-nav { display: none; }
  .btn-pill { display: none; }
  .menu-btn { display: inline-flex; }
  /* floating chips instead of a heavy bar */
  .site-header {
    gap: 0.7rem;
    background: transparent;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    padding-top: max(0.7rem, env(safe-area-inset-top));
    padding-bottom: 0.7rem;
  }
  .brand {
    display: block;
    background: rgba(var(--ground), 0.72);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    padding: 0.5rem 0.9rem; border-radius: 999px;
  }
  body.menu-open .brand { background: rgba(255, 255, 255, 0.06); }
}
@media (max-width: 640px) {
  .brand-logo { height: 30px; }

  /* hero: text owns the top, the substance settles into the lower half */
  .hero { padding-top: 5.6rem; justify-content: flex-start; }
  .hero-copy { margin-top: 1.2rem; }
  .hero-ctas .btn-ghost { display: none; }
  .hero-ctas .btn-primary { padding: 0.85rem 1.9rem; }

  /* chapters: substance on top, copy anchored to the bottom band */
  .chapter { min-height: 118vh; align-items: flex-end; padding-bottom: 15vh; }
  .chapter-copy::before, .hero-copy::before {
    inset: -2.2rem -1.5rem;
    background: linear-gradient(180deg,
      rgba(var(--ground), 0) 0%,
      rgba(var(--ground), 0.88) 14%,
      rgba(var(--ground), 0.94) 100%);
    border-radius: 1.5rem;
    -webkit-mask-image: none; mask-image: none;
  }
  .hero-copy::before {
    background: linear-gradient(0deg,
      rgba(var(--ground), 0) 0%,
      rgba(var(--ground), 0.88) 14%,
      rgba(var(--ground), 0.94) 100%);
  }
  .chapter-ghost { font-size: 7.5rem; top: 22%; left: auto; right: 1.1rem; }

  .thesis { min-height: 76vh; }
  .cursor-dot, .cursor-ring { display: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 2rem 1.6rem; }
  .areas, .publications { grid-template-columns: 1fr; gap: 2rem; }
  .paper-section { padding: 4.5rem 1.3rem; }
  .contact-links { flex-direction: column; gap: 1rem; }
  .grain { opacity: 0.11; }
}
