:root {
  --bg: #0b1020;
  --fog: #0b1020;
  /* Nearly opaque instead of a backdrop blur: see .card. */
  --card: rgba(13, 20, 40, 0.88);
  --line: rgba(255, 255, 255, 0.1);
  --text: #e8ecf6;
  --muted: #9aa6c2;
  --accent: #5cc8ff;
  --accent-2: #ffb547;
  --radius: 18px;
}

* { box-sizing: border-box; }

/* Smooth anchor jumps only on the plain page. ⚠️ Never with snapping on: the
   browser's smooth scroll and the snap both pull the same scroll and the
   landing bounces (same finding as juntox/site/src/site.css). */
html:not(.cards-on) { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* Thin progress bar while the first models stream in. */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 3;
  pointer-events: none;
}
#loader span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease, opacity 0.6s ease;
}
#loader.done span { opacity: 0; }

main {
  position: relative;
  z-index: 1;
}

section {
  min-height: 115svh;
  display: flex;
  align-items: center;
  padding: 8vh 6vw;
}
section.hero { min-height: 100svh; }
section.wide { min-height: 100svh; justify-content: center; }

.card {
  max-width: 460px;
  padding: 28px 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  /* ⚠️ No backdrop-filter: blurring a canvas that redraws every frame is
     redone every frame, at full screen resolution, on the scene's GPU. */
}
.hero .card { max-width: 560px; background: transparent; border: 0; padding: 0; }
section.wide .card { max-width: 640px; width: 100%; }

/* ── Pinned cards (src/cards.js, only with WebGL) ──────────────────────────
   One section = one screen, the scroll always lands on one, and the card is
   fixed in place: never half off the top or bottom. */
html.cards-on { scroll-snap-type: y mandatory; }
.cards-on section {
  height: 100svh;
  min-height: 0;
  padding: 0;
  scroll-snap-align: start;
  /* No stopping between two cards, not even with a fast flick. */
  scroll-snap-stop: always;
}
.cards-on section .card {
  --base: translateY(-50%);
  position: fixed;
  top: 50%;
  left: 6vw;
  max-height: calc(100svh - 140px);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: var(--base) translateY(var(--dy, 0px));
  will-change: opacity, transform;
}
.cards-on section.wide .card { --base: translate(-50%, -50%); left: 50%; }
.cards-on section .card.is-on { visibility: visible; pointer-events: auto; }
/* The hero card has no padding: scrolling it would clip the first glyph. */
.cards-on section.hero .card { overflow: visible; }

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.02em;
}
/* It is a CV: the name is the headline. */
h1.name {
  font-size: clamp(42px, 6.4vw, 88px);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
}
.tagline {
  margin: 0 0 10px;
  font-size: clamp(19px, 2vw, 26px);
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
  max-width: 30ch;
}
h2 {
  margin: 0 0 12px;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.lead { color: var(--muted); font-size: 17px; margin: 0 0 28px; }

/* ── Name bar ─────────────────────────────────────────────────────────── */
#idbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  padding: 18px 6vw 16px;
  background: linear-gradient(to top, rgba(11, 16, 32, 0.92), rgba(11, 16, 32, 0));
  font-size: 17px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
#idbar b { font-size: 1.2em; font-weight: 700; letter-spacing: -0.01em; }
#idbar a { text-decoration: none; }
#idbar a:hover { text-decoration: underline; }
.at-hero #idbar { opacity: 0; transform: translateY(8px); pointer-events: none; }

ul { margin: 0; padding-left: 1.1em; }
li { margin: 6px 0; }
li::marker { color: var(--accent); }

code {
  font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent-2);
}

.proof {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.stats {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 28px;
  margin-bottom: 32px;
}
.stats li { margin: 0; }
.stats b {
  display: block;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
  color: var(--accent-2);
}
.stats span { color: var(--muted); font-size: 14px; }

.scroll-hint {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  animation: nudge 2.4s ease-in-out infinite;
  display: inline-block;
}
@keyframes nudge { 50% { transform: translateY(6px); } }

a { color: var(--accent); }

.projects, .contact { list-style: none; padding: 0; }
.group {
  margin: 22px 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.projects li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.projects a, .projects .name { font-weight: 600; text-decoration: none; }
.projects span:last-child { color: var(--muted); }
.contact li { margin: 10px 0; font-size: 18px; }

#ask { display: flex; gap: 10px; margin-top: 8px; }
#ask input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
}
#ask input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#ask button {
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #04121c;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#ask button:disabled { opacity: 0.5; cursor: wait; }
#ask-answer { min-height: 1.5em; margin: 14px 0; }
#ask-answer.error { color: var(--accent-2); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }

/* Without WebGL the canvas is useless: drop it and let the page be a plain CV. */
.no-webgl #world { display: none; }
.no-webgl section { min-height: auto; }

/* Phones: the scene owns the top of the screen, the card sits at the bottom. */
@media (max-width: 760px) {
  section { align-items: flex-end; padding: 6vh 16px; }
  /* Phones: the scene owns the top, every card sits at the bottom. */
  .cards-on section .card,
  .cards-on section.wide .card {
    --base: none;
    top: auto;
    bottom: 64px;
    left: 16px;
    right: 16px;
    width: auto;
    max-height: 60svh;
  }
  /* The hero has no bar under it, and the name needs the room. On a phone it
     also gets the card background: without it the text sat on the avatar. */
  .cards-on section.hero .card {
    bottom: 16px;
    max-height: 72svh;
    padding: 20px 22px;
    background: var(--card);
    border: 1px solid var(--line);
  }
  .hero .eyebrow { display: none; }
  h1.name { font-size: 38px; margin-bottom: 12px; }
  .tagline { font-size: 18px; }
  .lead { font-size: 15px; margin-bottom: 18px; }
  .stats { gap: 12px 18px; margin-bottom: 0; }
  .stats b { font-size: 28px; }
  .stats span { font-size: 13px; line-height: 1.3; display: block; }
  .scroll-hint { display: none; }
  #idbar { padding: 14px 16px 12px; font-size: 15px; gap: 0 12px; }
  /* Its own clearance: the bar holds two lines on a narrow phone. */
  main { padding-bottom: 56px; }
  section.hero { align-items: center; }
  .card { max-width: none; width: 100%; padding: 22px; }
  .projects li { grid-template-columns: 1fr; gap: 2px; }
  #ask { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html:not(.cards-on) { scroll-behavior: auto; }
  .scroll-hint { animation: none; }
}

/* ── Phone remote (src/remote.js, control.html) ─────────────────────────── */
.remote-open {
  padding: 12px 18px;
  border: 1px solid rgba(92, 200, 255, 0.5);
  border-radius: 999px;
  background: rgba(92, 200, 255, 0.12);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.remote-open:hover { background: rgba(92, 200, 255, 0.22); }

/* The remote button lives bottom-right on every screen of the tour (desktop). */
#remote-fab {
  position: fixed;
  right: 24px;
  bottom: 14px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(92, 200, 255, 0.18);
  /* Solid, not backdrop-filter: a blur over a canvas that changes every frame
     is re-computed every frame, on the same GPU the scene needs. */
  background: rgba(14, 22, 46, 0.92);
}
#remote-fab i { display: none; }
#remote-fab.live { border-color: rgba(124, 242, 176, 0.5); background: rgba(11, 16, 32, 0.85); }
#remote-fab.live i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7cf2b0;
  box-shadow: 0 0 0 0 rgba(124, 242, 176, 0.6);
  animation: live 1.6s ease-out infinite;
}
@keyframes live { 70% { box-shadow: 0 0 0 8px rgba(124, 242, 176, 0); } }

#remote-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0e1530;
  color: var(--text);
  text-align: center;
}
#remote-dialog::backdrop { background: rgba(3, 5, 12, 0.78); }
#remote-dialog h2 { font-size: 24px; }
.remote-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
}
.remote-qr {
  width: 220px;
  height: 220px;
  margin: 18px auto 10px;
  padding: 10px;
  border-radius: 14px;
  background: #fff;
}
.remote-qr svg { display: block; width: 100%; height: 100%; }
.remote-link { display: block; font-size: 13px; word-break: break-all; }
.remote-status { margin: 14px 0 4px; color: var(--muted); }
.remote-status.ok { color: #7cf2b0; font-weight: 600; }

/* Emergency: a red pulse over the scene and a banner with the measured latency. */
#sos {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
/* Only the red glow pulses; the banner stays fully readable. */
#sos::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255, 40, 40, 0) 40%, rgba(255, 40, 40, 0.45) 100%);
}
.sos #sos { opacity: 1; }
.sos #sos::before { animation: sos-pulse 0.8s ease-in-out infinite; }
@keyframes sos-pulse { 50% { opacity: 0.35; } }
.sos-banner {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 22px;
  border-radius: 14px;
  background: #b3121b;
  color: #fff;
  text-align: center;
  box-shadow: 0 10px 40px rgba(255, 40, 40, 0.4);
}
.sos-banner b { font-size: 18px; }
.sos-banner span { font-size: 14px; opacity: 0.9; }

@media (max-width: 760px) {
  /* On a phone the visitor already holds the remote. */
  .remote-open { display: none !important; }
}

/* ── Top-right shortcuts (every screen) ──────────────────────────────────── */
#quick {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(92, 200, 255, 0.4);
  border-radius: 999px;
  background: rgba(14, 22, 46, 0.92);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 8px 30px rgba(92, 200, 255, 0.12);
}
.chip:hover { border-color: rgba(92, 200, 255, 0.85); }
/* The CV chip leads (amber, with the photo). */
.chip--cv {
  padding-left: 6px;
  border-color: rgba(255, 181, 71, 0.45);
  box-shadow: 0 8px 30px rgba(255, 181, 71, 0.15);
}
.chip--cv:hover { border-color: rgba(255, 181, 71, 0.8); }
.chip--cv img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: block; }

@media (max-width: 760px) {
  #quick { top: 12px; right: 12px; gap: 6px; }
  .chip { height: 36px; padding: 0 12px; font-size: 14px; gap: 8px; }
  .chip--cv { padding-left: 4px; }
  .chip--cv img { width: 26px; height: 26px; }
}
