/* ── Page & 3D stage chrome ─────────────────────────────────────────── */

* { box-sizing: border-box; }

/* NOTE: no `scroll-behavior: smooth` here — it turns every programmatic
   scrollTo into an async animation and they cancel each other mid-flight,
   which made the 3D timeline jump around. Smooth scrolling is requested
   explicitly (behavior: "smooth") where it matters. */
html {
  /* browser scroll-anchoring fights the scroll-driven 3D timeline */
  overflow-anchor: none;
  scrollbar-width: thin;
  scrollbar-color: #45475a #11111b;
}

body {
  margin: 0;
  background: #0d0e16;
}

::selection { background: rgba(203, 166, 247, 0.35); }

.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; }

/* ── stage ── */

#stage { position: fixed; inset: 0; }
#stage canvas { position: absolute; inset: 0; }

#css3d-layer { position: absolute; inset: 0; pointer-events: none; }
#css3d-layer * { pointer-events: none; }
body.focused #css3d-layer #desktop,
body.focused #css3d-layer #desktop * { pointer-events: auto; }

/* runway that the closing act consumes before the content arrives */
#scroll-space { height: 260vh; }

/* in 3D mode the desktop element is adopted by the CSS3D layer;
   hide its original slot so it never flashes in normal flow */
body:not(.flat) #desktop-wrap { display: none; }

/* ── side menu ── */

/* menu + header only exist in the text act (or flat mode) */
#menu-btn, #overlay-top {
  opacity: 0;
  transition: opacity 0.45s ease;
}
#menu-btn { pointer-events: none; }
#overlay-top a { pointer-events: none !important; }
body.chrome-visible #menu-btn, body.flat #menu-btn,
body.chrome-visible #overlay-top, body.flat #overlay-top {
  opacity: 1;
}
body.chrome-visible #menu-btn, body.flat #menu-btn { pointer-events: auto; }
body.chrome-visible #overlay-top a, body.flat #overlay-top a { pointer-events: auto !important; }

body.chrome-visible #skip-link { opacity: 0; pointer-events: none; }

#menu-btn {
  position: fixed;
  top: 1rem;
  left: 1.25rem;
  z-index: 40;
  width: 44px;
  height: 40px;
  display: grid;
  place-content: center;
  gap: 5px;
  background: rgba(30, 30, 46, 0.75);
  border: 1px solid rgba(108, 112, 134, 0.35);
  backdrop-filter: blur(6px);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
#menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: #cdd6f4;
  transition: transform 0.25s, opacity 0.25s;
}
#menu-btn:hover { border-color: #cba6f7; }
#menu-btn:focus-visible { outline: 2px solid #cba6f7; outline-offset: 2px; }
body.menu-open #menu-btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.menu-open #menu-btn span:nth-child(2) { opacity: 0; }
body.menu-open #menu-btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

#side-menu {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 35;
  width: min(19rem, 82vw);
  background: #181825;
  border-right: 1px solid #313244;
  padding: 5.5rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
body.menu-open #side-menu { transform: translateX(0); }

#side-menu > a {
  color: #cdd6f4;
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.45rem 0;
  border-bottom: 1px solid #313244;
  transition: color 0.15s, padding-left 0.15s;
}
#side-menu > a::before { content: "· "; color: #cba6f7; }
#side-menu > a:hover { color: #cba6f7; padding-left: 0.4rem; }

.menu-foot {
  margin-top: auto;
  display: flex;
  gap: 1rem;
}
.menu-foot a { color: #6c7086; font-size: 0.8rem; text-decoration: none; }
.menu-foot a:hover { color: #89b4fa; }

#menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(13, 14, 22, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
body.menu-open #menu-backdrop { opacity: 1; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  #side-menu, #menu-backdrop, #menu-btn span { transition: none; }
  html { scroll-behavior: auto; }
}

/* ── overlay ── */

#overlay-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 1rem 1.5rem;
  z-index: 10;
  pointer-events: none;
}
#overlay-top a, #overlay-top .brand { pointer-events: auto; }

.brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: #a6adc8;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  background: rgba(24, 24, 37, 0.75);
  border: 1px solid rgba(108, 112, 134, 0.35);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
}
@media (max-width: 760px) { .brand { display: none; } }

.overlay-links { display: flex; gap: 0.5rem; }
.overlay-links a {
  color: #cdd6f4;
  background: rgba(49, 50, 68, 0.55);
  border: 1px solid rgba(108, 112, 134, 0.35);
  backdrop-filter: blur(6px);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
}
.overlay-links a:hover { border-color: #cba6f7; }
.overlay-links a:focus-visible { outline: 2px solid #cba6f7; outline-offset: 2px; }

.lang-btn {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color: #cba6f7;
  background: rgba(49, 50, 68, 0.55);
  border: 1px solid rgba(203, 166, 247, 0.45);
  backdrop-filter: blur(6px);
  font-size: 0.8rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}
.lang-btn:hover { border-color: #cba6f7; }
.lang-btn:focus-visible { outline: 2px solid #cba6f7; outline-offset: 2px; }
.menu-foot .lang-btn { margin-left: auto; padding: 0.2rem 0.7rem; font-size: 0.75rem; }
body.chrome-visible .overlay-links .lang-btn, body.flat .overlay-links .lang-btn { pointer-events: auto; }

#enter-hint, #back-hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 2rem;
  z-index: 10;
  background: rgba(30, 30, 46, 0.75);
  color: #cdd6f4;
  border: 1px solid rgba(203, 166, 247, 0.4);
  backdrop-filter: blur(8px);
  font-size: 0.85rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
  transition: opacity 0.3s;
}
#enter-hint:hover, #back-hint:hover { border-color: #cba6f7; }
#back-hint { font-size: 0.78rem; opacity: 0.85; }

#skip-link {
  position: fixed;
  right: 1.5rem;
  bottom: 2rem;
  z-index: 10;
  color: #6c7086;
  font-size: 0.75rem;
  text-decoration: none;
  border-bottom: 1px dotted #6c7086;
  transition: opacity 0.3s;
}
#skip-link:hover { color: #cdd6f4; }

.hidden { display: none !important; }

/* ── boot overlay (lives inside #desktop) ── */

#desktop { position: relative; }

#boot {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: #11111b;
  color: #a6e3a1;
  font-size: 15px;
  line-height: 1.7;
  padding: 40px 48px;
  white-space: pre-wrap;
  display: none;
}
#boot .b-dim { color: #6c7086; }
#boot .b-ok { color: #a6e3a1; }
#boot .b-mauve { color: #cba6f7; }
#boot.booting { display: block; }

/* screen off = pitch dark before boot */
#desktop.off > :not(#boot) { visibility: hidden; }
#desktop.off { background: #0a0a12; }

/* ── content (the text version) ── */

#content {
  position: relative;
  z-index: 5;
  background: #11111b;
  border-top: 1px solid #313244;
  color: #cdd6f4;
  font: 16.5px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 1rem 1.5rem 0;
}

.c-section { max-width: 44rem; margin: 0 auto; padding: 3rem 0 1rem; scroll-margin-top: 4rem; }

.c-section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.12em;
  color: #fab387;
  margin: 0 0 1rem;
}
.c-section h2 span { color: #6c7086; }

.c-section p { margin: 0.75rem 0; color: #a6adc8; }
.c-section strong { color: #cdd6f4; }
.c-section a { color: #89b4fa; }
.c-meta { font-size: 0.8rem; color: #cba6f7; }

.c-projects { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 640px) { .c-projects { grid-template-columns: 1fr; } }

.c-proj {
  display: block;
  background: #181825;
  border: 1px solid #313244;
  padding: 1rem 1.2rem;
  text-decoration: none;
  transition: border-color 0.15s;
}
.c-proj:hover { border-color: #89b4fa; }
.c-proj-name { color: #89b4fa; font-weight: 700; font-size: 0.95rem; }
.c-proj p { font-size: 0.88rem; margin: 0.5rem 0 0; }

.c-xp { list-style: none; margin: 0; padding: 0; }
.c-xp li {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid #313244;
}
.c-xp li:last-child { border-bottom: none; }
.c-xp-when { color: #cba6f7; font-size: 0.8rem; padding-top: 0.15rem; }
.c-xp div { color: #a6adc8; font-size: 0.95rem; }
@media (max-width: 560px) { .c-xp li { grid-template-columns: 1fr; gap: 0.2rem; } }

.c-links { line-height: 2; }

.c-footer {
  max-width: 44rem;
  margin: 2rem auto 0;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid #313244;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: #6c7086;
  font-size: 0.75rem;
}

.noscript {
  color: #cdd6f4;
  font-family: system-ui, sans-serif;
  padding: 4rem 2rem;
  text-align: center;
}
.noscript a { color: #89b4fa; }

/* ── flat mode (mobile / no WebGL) ── */

body.flat #stage,
body.flat #enter-hint,
body.flat #back-hint,
body.flat #skip-link,
body.flat #scroll-space { display: none; }

body.flat #content { border-top: none; }
body.flat .overlay-links { display: none; }
