/* =============================================================
   KOWSHIK // DEEP SPACE
   The interface is meant to disappear. No cards, no borders,
   no glass. Typography on darkness.
   ============================================================= */

:root{
  --ink:#ffffff;
  --dim:rgba(255,255,255,.46);
  --faint:rgba(255,255,255,.26);
  --accent:#9ec9ff;
  --ease:cubic-bezier(.22,.61,.36,1);
  --slow:1.6s;
}

*{margin:0;padding:0;box-sizing:border-box}

html,body{
  height:100%;
  background:#000;
  color:var(--ink);
  font-family:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
}

body{cursor:none}
@media (hover:none){body{cursor:auto}}

canvas#gl{position:fixed;inset:0;width:100%;height:100%;display:block}

/* ---------- shared layer behaviour ---------- */
.layer{
  position:fixed;inset:0;
  pointer-events:none;
  z-index:10;
}

/* ---------- typography primitives ---------- */
.eyebrow{
  font-size:10px;
  letter-spacing:.42em;
  font-weight:500;
  color:var(--accent);
  text-transform:uppercase;
}
.meta{
  font-size:10px;
  letter-spacing:.34em;
  color:var(--faint);
  text-transform:uppercase;
}
h1,h2{font-weight:200;letter-spacing:-.03em;line-height:.94}

/* ---------- BOOT / TITLE ---------- */
#boot{
  display:flex;align-items:center;justify-content:center;
  text-align:center;
  transition:opacity 2.4s var(--ease);
}
#boot .name{
  font-size:clamp(2.6rem,8vw,7.5rem);
  font-weight:200;
  letter-spacing:.16em;
  opacity:0;
  filter:blur(14px);
  transform:scale(1.06);
  transition:opacity 3.4s var(--ease),filter 3.4s var(--ease),transform 5s var(--ease);
}
#boot .name.in{opacity:1;filter:blur(0);transform:scale(1)}
#boot .tag{
  margin-top:2.4rem;
  font-size:10px;letter-spacing:.5em;color:var(--dim);
  opacity:0;transition:opacity 2.2s var(--ease) .4s;
}
#boot .tag.in{opacity:1}
#boot.out{opacity:0}

/* the threshold: understated, a word and a thin line */
#boot .enter{
  margin-top:5.2rem;
  display:inline-block;
  pointer-events:none;
  opacity:0;
  transform:translateY(8px);
  transition:opacity 2.2s var(--ease),transform 2.2s var(--ease);
}
#boot .enter.in{opacity:.72;transform:none;pointer-events:auto;cursor:none}
#boot .enter span{
  display:block;
  font-size:10px;letter-spacing:.62em;color:#fff;
  transition:letter-spacing .8s var(--ease),opacity .5s var(--ease);
  padding-left:.62em;
}
#boot .enter i{
  display:block;height:1px;margin-top:14px;
  background:rgba(255,255,255,.42);
  transform:scaleX(.55);transform-origin:50% 50%;
  transition:transform .9s var(--ease),background .6s var(--ease);
}
#boot .enter.in:hover{opacity:1}
#boot .enter.in:hover span{letter-spacing:.82em}
#boot .enter.in:hover i{transform:scaleX(1);background:rgba(255,255,255,.85)}
#boot .enter.go{opacity:0;transform:translateY(-6px);transition:opacity .7s var(--ease),transform .7s var(--ease)}

/* skip — discoverable, never loud */
#skip{
  position:fixed;right:38px;bottom:32px;z-index:22;
  font-size:9px;letter-spacing:.32em;color:rgba(255,255,255,.16);
  pointer-events:none;opacity:0;cursor:none;
  transition:opacity 1.6s var(--ease),color .5s var(--ease);
}
#skip.on{opacity:1;pointer-events:auto}
#skip:hover{color:rgba(255,255,255,.65)}

@media (max-width:820px){
  #boot .enter{margin-top:3.4rem}
  #boot .enter span{font-size:11px}
  #skip{right:22px;bottom:26px}
}

/* ---------- INIT readout (bottom-left, tiny) ---------- */
#init{
  position:fixed;left:34px;bottom:30px;z-index:12;
  font-size:9.5px;letter-spacing:.3em;color:var(--faint);
  line-height:2.1;pointer-events:none;
  transition:opacity 1.4s var(--ease);
}
#init .ok{color:var(--accent)}
#init.out{opacity:0}

/* ---------- WORLD LABELS (projected into space) ---------- */
#labels{position:fixed;inset:0;z-index:11;pointer-events:none}
.label{
  position:absolute;
  transform:translate(-50%,-50%);
  pointer-events:auto;
  cursor:none;
  white-space:nowrap;
  opacity:0;
  transition:opacity .9s var(--ease);
}
.label .ring{
  display:block;width:9px;height:9px;margin:0 auto 12px;
  border:1px solid rgba(255,255,255,.5);border-radius:50%;
  transition:transform .5s var(--ease),border-color .5s var(--ease),background .5s var(--ease);
}
.label .nm{
  font-size:10px;letter-spacing:.34em;color:rgba(255,255,255,.62);
  transition:color .4s var(--ease),letter-spacing .6s var(--ease);
}
.label .sub{
  display:block;margin-top:7px;
  font-size:8.5px;letter-spacing:.28em;color:rgba(255,255,255,.2);
  opacity:0;transition:opacity .5s var(--ease);
}
.label.on{opacity:1}
.label.hot .ring{transform:scale(1.9);border-color:#fff;background:rgba(255,255,255,.14)}
.label.hot .nm{color:#fff;letter-spacing:.42em}
.label.hot .sub{opacity:1}
.label.visited .ring{background:rgba(255,255,255,.30)}

/* ---------- WORLD CONTENT (spatial typography, no card) ---------- */
#world{
  z-index:14;
  display:flex;align-items:center;
  padding:0 clamp(34px,6vw,110px);
  opacity:0;visibility:hidden;
  /* visibility must flip instantly on show, and only after the fade on hide */
  transition:opacity 1.2s var(--ease),visibility 0s linear 1.2s;
}
#world.on{opacity:1;visibility:visible;transition:opacity 1.2s var(--ease),visibility 0s}
#world:before{
  content:"";position:absolute;inset:0;
  background:linear-gradient(100deg,rgba(0,0,0,.86) 0%,rgba(0,0,0,.6) 34%,transparent 62%);
  opacity:0;transition:opacity 1.4s var(--ease);
}
#world.on:before{opacity:1}
#world .col{
  position:relative;max-width:min(520px,44vw);
  max-height:86vh;overflow-y:auto;overflow-x:hidden;
  scrollbar-width:none;padding-right:6px;
}
#world .col::-webkit-scrollbar{width:0;display:none}
/* content follows the panel's own visibility, never a stale transitioned value */
#world.on .col, #world.on .col *{visibility:visible}

#world .idx{font-size:9.5px;letter-spacing:.42em;color:var(--faint)}
#world h2{
  margin:18px 0 0;
  font-size:clamp(2.4rem,6.4vw,5.4rem);
  font-weight:200;letter-spacing:-.035em;
}
#world .kind{margin-top:16px;font-size:9.5px;letter-spacing:.4em;color:var(--accent)}
#world .line{margin-top:26px;font-size:13px;line-height:1.95;color:rgba(255,255,255,.74);font-weight:300}
#world .body{margin-top:16px;font-size:13px;line-height:1.95;color:rgba(255,255,255,.5);font-weight:300}

#world .facts{margin-top:26px;display:grid;grid-template-columns:1fr 1fr;gap:20px 30px}
#world .fact b{display:block;font-size:8.5px;letter-spacing:.3em;color:var(--faint);font-weight:500;margin-bottom:8px}
#world .fact span{font-size:12px;color:rgba(255,255,255,.72);font-weight:300;line-height:1.5}

#world .go{
  margin-top:38px;display:inline-flex;align-items:center;gap:14px;
  font-size:9.5px;letter-spacing:.34em;color:var(--accent);
  text-decoration:none;pointer-events:auto;cursor:none;
  opacity:.85;transition:opacity .4s var(--ease),gap .4s var(--ease);
}
#world .go:hover{opacity:1;gap:22px}
#world .go.disabled{color:var(--faint);pointer-events:none}
#world .links{margin-top:34px;display:flex;flex-wrap:wrap;gap:14px 34px}
#world .links .go{margin-top:0}

#world .head{display:flex;align-items:center;gap:22px;margin-top:14px;flex-wrap:wrap}
#world .head > div{min-width:0;flex:1 1 auto}
#world .head h2{margin:0;font-size:clamp(2rem,4.6vw,3.4rem)}
#world .head .kind{margin-top:12px}
#world .head .portrait{margin:0;flex:0 0 auto}

#world .portrait{
  display:block;
  width:86px;height:auto;
  image-rendering:pixelated;
  image-rendering:crisp-edges;
  opacity:.92;
  filter:drop-shadow(0 0 26px rgba(120,170,220,.16));
}
@media (max-width:820px){ #world .portrait{width:78px;margin:16px 0 2px} }

/* staggered reveal */
#world .col > *{opacity:0;transform:translateY(16px);transition:opacity 1.1s var(--ease),transform 1.1s var(--ease)}
#world.on .col > *{opacity:1;transform:none}
#world.on .col > *:nth-child(1){transition-delay:.05s}
#world.on .col > *:nth-child(2){transition-delay:.14s}
#world.on .col > *:nth-child(3){transition-delay:.22s}
#world.on .col > *:nth-child(4){transition-delay:.30s}
#world.on .col > *:nth-child(5){transition-delay:.38s}
#world.on .col > *:nth-child(6){transition-delay:.46s}
#world.on .col > *:nth-child(7){transition-delay:.54s}

/* ---------- RETURN ---------- */
#ret{
  position:fixed;top:36px;right:38px;z-index:16;
  font-size:9.5px;letter-spacing:.34em;color:var(--dim);
  pointer-events:auto;cursor:none;
  opacity:0;visibility:hidden;
  transition:opacity .8s var(--ease),color .4s var(--ease);
}
#ret.on{opacity:1;visibility:visible}
#ret:hover{color:#fff}

/* ---------- CONSTELLATION INDEX (near-invisible nav) ---------- */
#nav{
  position:fixed;left:50%;bottom:30px;transform:translateX(-50%);
  z-index:15;display:flex;gap:20px;align-items:center;
  opacity:0;transition:opacity 1.2s var(--ease);
}
#nav.on{opacity:1}
#nav button{
  width:22px;height:22px;padding:0;border:0;background:none;
  display:grid;place-items:center;pointer-events:auto;cursor:none;
}
#nav button i{
  width:3px;height:3px;border-radius:50%;
  background:rgba(255,255,255,.28);
  transition:transform .45s var(--ease),background .45s var(--ease);
}
#nav button:hover i{transform:scale(2.4);background:#fff}
#nav button.cur i{background:var(--accent);transform:scale(1.9)}
#nav button.seen i{background:rgba(255,255,255,.55)}

/* ---------- HINT ---------- */
#hint{
  position:fixed;left:50%;bottom:74px;transform:translateX(-50%);
  z-index:15;font-size:9px;letter-spacing:.34em;color:rgba(255,255,255,.22);
  opacity:0;transition:opacity 1.4s var(--ease);white-space:nowrap;
}
#hint.on{opacity:1}

/* ---------- SOUND ---------- */
#snd{
  position:fixed;left:34px;top:36px;z-index:16;
  font-size:9px;letter-spacing:.3em;color:var(--faint);
  pointer-events:auto;cursor:none;opacity:0;
  transition:opacity 1.2s var(--ease),color .4s var(--ease);
}
#snd.on{opacity:1}
#snd:hover{color:#fff}

/* ---------- CURSOR ---------- */
#cur{
  position:fixed;left:0;top:0;z-index:60;pointer-events:none;
  width:26px;height:26px;margin:-13px 0 0 -13px;
  border:1px solid rgba(255,255,255,.42);border-radius:50%;
  transition:width .3s var(--ease),height .3s var(--ease),
             margin .3s var(--ease),border-color .3s var(--ease),opacity .3s;
  mix-blend-mode:difference;
}
#cur.hot{width:44px;height:44px;margin:-22px 0 0 -22px;border-color:#fff}
#cur.press{width:18px;height:18px;margin:-9px 0 0 -9px}
#curdot{
  position:fixed;left:0;top:0;z-index:60;pointer-events:none;
  width:3px;height:3px;margin:-1.5px 0 0 -1.5px;border-radius:50%;
  background:#fff;mix-blend-mode:difference;
}
@media (hover:none){#cur,#curdot{display:none}}

/* ---------- ENDING ---------- */
#end{
  z-index:40;background:#000;
  display:flex;align-items:center;justify-content:center;flex-direction:column;
  opacity:0;visibility:hidden;
  transition:opacity 3s var(--ease);
}
#end.on{opacity:1;visibility:visible}
#end .n{font-size:clamp(2rem,6vw,4.4rem);font-weight:200;letter-spacing:.18em}
#end .v{margin-top:2.6rem;font-size:9.5px;letter-spacing:.5em;color:var(--dim)}

/* ---------- FALLBACK (no WebGL2) ---------- */
#fallback{
  position:fixed;inset:0;z-index:50;overflow-y:auto;
  display:none;padding:8vh 7vw;
  background:
    radial-gradient(1100px 620px at 72% 18%,rgba(60,90,150,.20),transparent 62%),
    radial-gradient(900px 700px at 18% 82%,rgba(120,80,170,.14),transparent 60%),
    #000;
}
#fallback.on{display:block}
#fallback h1{font-size:clamp(2.4rem,7vw,5rem);letter-spacing:.1em;font-weight:200}
#fallback .t{margin-top:1.4rem;font-size:10px;letter-spacing:.5em;color:var(--dim)}
#fallback section{margin-top:5rem;max-width:660px}
#fallback h2{font-size:1.6rem;font-weight:200;letter-spacing:-.01em}
#fallback p{margin-top:1rem;font-size:13.5px;line-height:1.95;color:rgba(255,255,255,.58);font-weight:300}
#fallback dl{margin-top:1.6rem;display:grid;grid-template-columns:auto 1fr;gap:10px 26px}
#fallback dt{font-size:8.5px;letter-spacing:.3em;color:var(--faint)}
#fallback dd{font-size:12.5px;color:rgba(255,255,255,.74);font-weight:300}

/* ---------- SR-only semantic content (SEO + a11y) ---------- */
.sr{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width:820px){
  #world{align-items:flex-end;padding-bottom:16vh}
  #world .col{max-width:100%}
  #world:before{background:linear-gradient(0deg,rgba(0,0,0,.92) 0%,rgba(0,0,0,.7) 42%,transparent 78%)}
  #world .facts{grid-template-columns:1fr 1fr;gap:16px 20px}
  #init{left:22px;bottom:88px}
  #snd{left:22px;top:26px}
  #ret{top:26px;right:22px}
  #hint{bottom:66px;font-size:8.5px}
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion:reduce){
  *{transition-duration:.35s !important}
  #boot .name{filter:none;transform:none}
}
