:root {
  --night: #020209;
  --ink: #eae6dc;
  --ink-2: rgba(234, 230, 220, 0.62);
  --ink-3: rgba(234, 230, 220, 0.38);
  --gold: #c9893e;
  --gold-2: #e9c48c;
  --line: rgba(233, 196, 140, 0.16);
  --glass: rgba(6, 6, 16, 0.72);
  --fd: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --fb: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--fb);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
a { color: inherit; }
button { font: inherit; color: inherit; }

#scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------------------------------------------------------- overlays */

.ui { position: fixed; z-index: 10; }
.fade { opacity: 0; transition: opacity 0.9s ease; pointer-events: none; }
.fade.on { opacity: 1; pointer-events: auto; }

#wordmark {
  top: 28px; left: 34px;
  font-family: var(--fd);
  font-size: 22px; letter-spacing: 0.02em;
  line-height: 1.1;
  text-decoration: none;
}
#wordmark em { font-style: italic; color: var(--gold-2); }
#wordmark small {
  display: block;
  font-family: var(--fb);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3); margin-top: 6px;
}

#nav {
  top: 30px; right: 34px;
  display: flex; gap: 6px;
}
#nav a {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-2); text-decoration: none;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
#nav a:hover { color: var(--ink); border-color: var(--line); }
#nav a.is-active { color: var(--night); background: var(--gold-2); border-color: var(--gold-2); }

#skip {
  top: 30px; right: 34px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(6, 6, 16, 0.4);
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: opacity 0.6s ease, color 0.3s, border-color 0.3s;
}
#skip:hover { color: var(--ink); border-color: var(--gold-2); }

#hint {
  left: 50%; bottom: 30px;
  transform: translateX(-50%);
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
#hint b { font-weight: 400; color: var(--ink-2); }

#clock {
  left: 34px; bottom: 30px;
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  cursor: help;
}
#clock b { font-weight: 400; color: var(--ink-2); font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .clock-note { display: none; } }

/* Captions of the intro */
.cap {
  position: fixed; z-index: 9;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.1s ease, letter-spacing 1.4s ease;
  font-family: var(--fd);
  font-size: clamp(22px, 3.2vw, 34px);
  font-weight: 300; font-style: italic;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  width: min(90vw, 700px);
}
.cap.on { opacity: 1; letter-spacing: 0.06em; }
.cap-hero {
  font-style: normal; color: var(--ink); width: min(92vw, 900px);
  padding: 60px 40px;
  background: radial-gradient(ellipse at center, rgba(2, 2, 9, 0.55) 0%, rgba(2, 2, 9, 0.25) 45%, rgba(2, 2, 9, 0) 70%);
  text-shadow: 0 2px 28px rgba(2, 2, 9, 0.95), 0 0 2px rgba(2, 2, 9, 0.8);
}
.cap-hero h1 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(56px, 10vw, 128px);
  line-height: 0.95;
  letter-spacing: -0.01em;
}
.cap-hero h1 em { font-style: italic; color: var(--gold-2); }
.cap-hero p {
  margin: 22px 0 0;
  font-family: var(--fb);
  font-size: 11px; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--ink-2);
}

/* ------------------------------------------------------------ labels */

#labels { position: fixed; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 0 10px;
  background: none; border: 0;
  cursor: pointer;
  opacity: 0;
  transform-origin: 50% 100%;
  will-change: transform, opacity;
  text-align: center;
}
.lbl-txt {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-shadow: 0 1px 14px rgba(2, 2, 9, 0.95), 0 0 3px rgba(2, 2, 9, 0.8);
}
.lbl-name {
  font-family: var(--fd);
  font-size: 24px; font-weight: 400; letter-spacing: 0.02em;
  color: var(--ink);
  transition: color 0.3s;
}
.lbl-sub {
  font-size: 9.5px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--ink-3);
  transition: color 0.3s;
}
.lbl-dot {
  order: 2;
  width: 1px; height: 22px;
  background: linear-gradient(to bottom, rgba(233, 196, 140, 0), var(--gold-2));
  opacity: 0.55;
  transition: opacity 0.3s, height 0.3s;
}
.lbl.is-hover .lbl-name { color: var(--gold-2); }
.lbl.is-hover .lbl-sub { color: var(--ink-2); }
.lbl.is-hover .lbl-dot { opacity: 1; height: 30px; }
.lbl-moon .lbl-name { font-size: 17px; }
.lbl-moon .lbl-sub { font-size: 8.5px; }
.lbl-moon .lbl-dot { height: 14px; }

/* ------------------------------------------------------------ panels */

.panel {
  position: fixed; z-index: 12;
  top: 0; left: 0; bottom: 0;
  width: min(540px, 100%);
  background: var(--glass);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  transform: translateX(-102%);
  transition: transform 0.85s var(--ease), visibility 0s linear 0.85s;
  visibility: hidden;
  overflow: hidden auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(233, 196, 140, 0.25) transparent;
}
.panel.is-open { transform: none; visibility: visible; transition-delay: 0s; }
.panel-in { padding: 96px 52px 64px; min-height: 100%; }
.panel-close {
  position: absolute; top: 26px; right: 26px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: none;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: color 0.3s, border-color 0.3s, transform 0.3s;
}
.panel-close:hover { color: var(--ink); border-color: var(--gold-2); transform: rotate(90deg); }
.panel-close svg { width: 14px; height: 14px; }

.eyebrow {
  display: flex; align-items: center; gap: 12px;
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--gold-2);
  margin-bottom: 22px;
}
.eyebrow::before { content: ''; width: 28px; height: 1px; background: var(--gold); }
.panel h2 {
  font-family: var(--fd);
  font-weight: 300;
  font-size: clamp(38px, 4.4vw, 52px);
  line-height: 1.02; letter-spacing: -0.01em;
  margin: 0 0 26px;
}
.panel h2 em { font-style: italic; color: var(--gold-2); }
.panel p { font-size: 15px; line-height: 1.75; color: var(--ink-2); margin: 0 0 18px; }
.panel p strong { font-weight: 400; color: var(--ink); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 30px; }
.fact { padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; }
.fact b { display: block; font-size: 9.5px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-3); font-weight: 400; margin-bottom: 8px; }
.fact span { font-size: 13px; color: var(--ink); }

.projects { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.proj {
  display: block;
  padding: 20px 22px;
  border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none;
  transition: border-color 0.3s, background 0.3s, transform 0.3s var(--ease);
}
.proj:hover { border-color: rgba(233, 196, 140, 0.45); background: rgba(233, 196, 140, 0.05); transform: translateX(4px); }
.proj-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.proj-idx { font-size: 10px; letter-spacing: 0.24em; color: var(--ink-3); }
.proj-go { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-2); }
.proj-name { font-family: var(--fd); font-size: 28px; line-height: 1.1; }
.proj-type { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin: 4px 0 10px; }
.proj p { font-size: 13.5px; line-height: 1.65; margin: 0 0 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }

.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 28px; margin-top: 10px; }
.skill b { display: block; font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold-2); font-weight: 400; margin-bottom: 12px; }
.skill ul { list-style: none; margin: 0; padding: 0; }
.skill li { font-size: 14px; color: var(--ink-2); padding: 6px 0; border-bottom: 1px solid rgba(234, 230, 220, 0.07); }

.steps { counter-reset: step; margin-top: 8px; }
.step { display: grid; grid-template-columns: 44px 1fr; gap: 16px; padding: 20px 0; border-top: 1px solid var(--line); }
.step:last-child { border-bottom: 1px solid var(--line); }
.step-n { font-family: var(--fd); font-size: 30px; color: var(--gold-2); line-height: 1; }
.step h3 { margin: 0 0 8px; font-family: var(--fd); font-weight: 400; font-size: 24px; }
.step p { font-size: 13.5px; margin: 0; }

.contact-links { display: flex; flex-direction: column; gap: 10px; margin-top: 30px; }
.clink {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px;
  border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none;
  transition: border-color 0.3s, background 0.3s;
}
.clink:hover { border-color: rgba(233, 196, 140, 0.45); background: rgba(233, 196, 140, 0.05); }
.clink b { font-family: var(--fd); font-weight: 400; font-size: 22px; }
.clink span { font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-3); }
.email { font-family: var(--fd); font-size: clamp(22px, 3vw, 30px); color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); transition: border-color 0.3s; }
.email:hover { border-color: var(--gold-2); }
.foot { margin-top: 48px; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); }

/* -------------------------------------------------------------- gate */

#gate {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: var(--night);
  transition: opacity 1.2s ease, visibility 0s linear 1.2s;
}
#gate.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.gate-in { text-align: center; padding: 24px; }
.gate-name {
  font-family: var(--fd); font-weight: 300;
  font-size: clamp(36px, 5vw, 58px); line-height: 1; letter-spacing: 0.01em;
}
.gate-name em { font-style: italic; color: var(--gold-2); }
.gate-sub { margin-top: 12px; font-size: 10px; letter-spacing: 0.32em; text-transform: uppercase; color: var(--ink-3); }
.gate-btn {
  position: relative;
  margin: 56px auto 0;
  width: 108px; height: 108px;
  border-radius: 50%;
  border: 1px solid rgba(233, 196, 140, 0.55);
  background: none;
  color: var(--ink);
  font-family: var(--fd); font-size: 21px; letter-spacing: 0.1em;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.4s, color 0.4s, border-color 0.4s, transform 0.5s var(--ease);
}
.gate-btn:hover, .gate-btn:focus-visible { background: var(--gold-2); color: var(--night); border-color: var(--gold-2); transform: scale(1.05); outline: none; }
.gate-btn > span:last-child { position: relative; }
.gate-ring {
  position: absolute; inset: -1px;
  border-radius: 50%;
  border: 1px solid rgba(233, 196, 140, 0.5);
  animation: gate-ring 2.8s ease-out infinite;
  pointer-events: none;
}
@keyframes gate-ring { 0% { transform: scale(1); opacity: 0.8; } 100% { transform: scale(1.75); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .gate-ring { animation: none; } }
.gate-note { margin-top: 32px; font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-3); }
.gate-quiet {
  background: none; border: 0; padding: 0 0 1px;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s;
}
.gate-quiet:hover { color: var(--ink); border-color: var(--gold-2); }
.gate-track { margin-top: 46px; font-family: var(--fd); font-style: italic; font-size: 15px; color: var(--ink-3); }

/* ------------------------------------------------------------- sound */

#sound {
  right: 34px; bottom: 22px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(6, 6, 16, 0.35);
  cursor: pointer;
  display: grid; place-items: center;
  backdrop-filter: blur(8px);
  transition: border-color 0.3s, opacity 0.9s ease;
}
#sound:hover { border-color: var(--gold-2); }
.eq { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { display: block; width: 2px; height: 4px; border-radius: 1px; background: var(--ink-3); transition: background 0.3s; }
#sound.is-on .eq i { background: var(--gold-2); animation: eq 1.1s ease-in-out infinite; }
#sound.is-on .eq i:nth-child(2) { animation-delay: -0.35s; }
#sound.is-on .eq i:nth-child(3) { animation-delay: -0.7s; }
#sound.is-on .eq i:nth-child(4) { animation-delay: -0.2s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }

/* ------------------------------------------------------------ mobile */

@media (max-width: 899px) {
  #wordmark { top: 20px; left: 20px; font-size: 19px; }
  #wordmark small { display: none; }
  #skip { top: 18px; right: 64px; padding: 8px 13px; }
  #sound { top: 16px; right: 16px; bottom: auto; width: 38px; height: 38px; }
  .gate-btn { width: 96px; height: 96px; margin-top: 44px; }
  #nav {
    top: auto; bottom: 18px; left: 50%; right: auto;
    transform: translateX(-50%);
    padding: 5px; gap: 0;
    border: 1px solid var(--line); border-radius: 999px;
    background: rgba(6, 6, 16, 0.55);
    backdrop-filter: blur(10px);
    max-width: calc(100vw - 32px);
  }
  #nav a { padding: 8px 9px; font-size: 9.5px; letter-spacing: 0.12em; }
  #hint { bottom: 76px; font-size: 10px; }
  #clock { left: auto; right: 18px; top: 62px; bottom: auto; font-size: 9px; }
  .lbl-name { font-size: 19px; }
  .lbl-sub { display: none; }
  .lbl-moon .lbl-name { font-size: 14px; }

  .panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; height: 64vh;
    border-right: 0; border-top: 1px solid var(--line);
    border-radius: 22px 22px 0 0;
    transform: translateY(104%);
  }
  .panel-in { padding: 64px 24px 48px; }
  .panel-close { top: 16px; right: 16px; width: 38px; height: 38px; }
  .panel h2 { font-size: 34px; }
  .facts, .skills { grid-template-columns: 1fr; }
  .cap-hero h1 { font-size: 15vw; }
}

/* ----------------------------------------------------- no WebGL / no JS */

.no-webgl #scene, .no-webgl #labels, .no-webgl .cap, .no-webgl #skip, .no-webgl #hint, .no-webgl #gate, .no-webgl #sound,
html:not(.is-3d) #gate { display: none !important; }
.no-webgl body, html:not(.is-3d) body { overflow: auto; }
.no-webgl .panel, html:not(.is-3d) .panel {
  position: static; transform: none; visibility: visible;
  width: min(720px, 100%); margin: 0 auto; border: 0; background: none; backdrop-filter: none;
}
.no-webgl #wordmark, .no-webgl #nav, html:not(.is-3d) #wordmark, html:not(.is-3d) #nav { opacity: 1; pointer-events: auto; }
