/* TOM.DEV intro merge — the intro rig lands exactly on the hero rig.
   Final geometry copies hero.css (--fx, --feet, figure/lamp/pool rules);
   the initial centered composition is expressed as transform offsets that
   transition to identity at exit, so the handoff is pixel-perfect.
   Art: assets/hero60/K0.webp (his real character). Everything else is code. */

.ix{display:none; position:fixed; inset:0; z-index:60; overflow:hidden; background:transparent}
.ix.on{display:block}
.ix-bg{position:absolute; inset:0; background:#04060c; transition:opacity .9s ease}
.ix.exit .ix-bg{opacity:0}
.ix.fade{opacity:0; transition:opacity .3s ease}

/* The whole rig (lamp, cone, pool, feet shadow, character) is one unit.
   It sits at the hero's exact geometry, and the centered intro composition
   is a single transform on this wrapper: translate + scale about the
   character's feet, so lamp, cone, pool and figure share one axis by
   construction and the travel ends on identity = the hero geometry.
   Percentages here resolve against the wrapper, which is the viewport. */
.ix-rig{position:absolute; inset:0; z-index:2;
  --ix-oy:calc(95vh + 8px); --ix-dy:calc(-17vh - 8px); --ix-s:.753;
  transform-origin:var(--fx) var(--ix-oy);
  transform:translate(calc(50% - var(--fx)), var(--ix-dy)) scale(var(--ix-s));
  transition:transform 1.15s cubic-bezier(.3,.6,.2,1)}
.ix.exit .ix-rig{transform:translate(0, 0) scale(1)}

/* ---------- lamp: final = hero lamp ---------- */
.ix-lamp{position:absolute; left:var(--fx); top:-14px; width:1px; z-index:2; transform:translateX(-50%)}
.ix-cord{position:absolute; left:-.5px; top:0; width:1px; height:40px; background:rgba(150,165,190,.26)}
.ix-shade{position:absolute; left:calc(var(--shade-w) / -2); top:24px; width:var(--shade-w); height:42px;
  border-radius:var(--shade-w) var(--shade-w) 10px 10px / 54px 54px 8px 8px;
  background:linear-gradient(180deg,#232b3d 0%,#121827 55%,#0b1019 100%);
  box-shadow:inset 0 1px 0 rgba(200,214,238,.14), 0 16px 30px rgba(0,0,0,.6)}
.ix-glow{position:absolute; left:50%; top:60px; transform:translateX(-50%);
  width:calc(var(--shade-w) - 26px); height:16px; border-radius:50%;
  background:radial-gradient(closest-side,#fff8e2 0%,#ffe0a6 38%,#ffc268 66%,rgba(255,170,80,.35) 86%,rgba(255,170,80,0) 100%);
  box-shadow:0 0 40px 10px rgba(255,186,96,.32), 0 0 84px 26px rgba(255,170,70,.14);
  filter:brightness(.28) blur(.4px); transition:filter 1.1s ease}
.ix.lit .ix-glow{filter:brightness(1)}
.ix-cone{position:absolute; left:calc(min(880px,52vw) / -2); top:62px;
  width:min(880px,52vw); height:calc(95vh - 50px);
  clip-path:polygon(43% 0%, 57% 0%, 100% 100%, 0% 100%);
  background:linear-gradient(180deg,rgba(255,222,168,.46) 0%,rgba(255,199,118,.30) 14%,rgba(255,183,96,.15) 40%,rgba(255,176,88,.05) 62%,rgba(255,170,80,0) 86%);
  -webkit-mask-image:linear-gradient(to right,transparent 0%,#000 26%,#000 74%,transparent 100%);
  mask-image:linear-gradient(to right,transparent 0%,#000 26%,#000 74%,transparent 100%);
  filter:blur(26px); opacity:0; transform:scaleY(.04); transform-origin:50% 0;
  transition:opacity .9s cubic-bezier(.33,.05,.2,1) .15s, transform 1.2s cubic-bezier(.3,.6,.2,1) .15s}
.ix.lit .ix-cone{opacity:1; transform:scaleY(1)}

/* ---------- pool: final = hero pool ---------- */
.ix-pool{position:absolute; left:var(--fx); bottom:calc(var(--feet) - 46px);
  width:min(560px,42vw); height:92px; border-radius:50%;
  background:radial-gradient(closest-side,rgba(255,214,150,.92) 0%,rgba(255,190,104,.60) 26%,rgba(255,168,72,.28) 52%,rgba(255,150,50,.08) 72%,rgba(255,150,50,0) 100%);
  filter:blur(11px); opacity:0; z-index:1;
  transform:translateX(-50%);
  transition:opacity .9s ease .3s}
.ix.lit .ix-pool{opacity:1}

/* ---------- character: final = hero figure ---------- */
.ix-fig{position:absolute; left:var(--fx); bottom:calc(5vh - 8px);
  height:85vh; aspect-ratio:507/1398; z-index:2;
  transform-origin:50% 100%;
  --art-dx:-2px;
  transform:translateX(-50%) translateX(var(--art-dx));
  filter:brightness(.13) saturate(.85);
  transition:transform 1.15s cubic-bezier(.3,.6,.2,1), filter 1.1s cubic-bezier(.33,.05,.2,1) .2s}
.ix-fig img{width:100%; height:100%; object-fit:contain; display:block; -webkit-user-drag:none; user-select:none}
.ix.lit .ix-fig{filter:brightness(1.04) saturate(1.04)}
.ix.exit .ix-fig{transform:translateX(-50%)}  /* art correction resolves during the travel */

.ix-foot{position:absolute; left:var(--fx); bottom:calc(var(--feet) - 15px);
  width:min(250px,19vw); height:26px; border-radius:50%; z-index:1;
  background:radial-gradient(closest-side,rgba(4,6,12,.62),rgba(4,6,12,.28) 55%,rgba(4,6,12,0) 78%);
  filter:blur(7px);
  transform:translateX(-50%)}

/* ---------- name, below the character, never over the legs ---------- */
.ix-name{position:absolute; left:50%; bottom:6.5vh; transform:translateX(-50%); text-align:center; z-index:5; transition:opacity .4s ease}
.ix.exit .ix-name{opacity:0}
.ix-mark{font-weight:800; font-size:clamp(30px,4.2vw,52px); letter-spacing:.05em; direction:ltr}
.ix-mark span{display:inline-block; color:var(--paper); opacity:0; transform:translateY(14px);
  transition:opacity .45s ease, transform .55s cubic-bezier(.2,.7,.2,1.1)}
.ix-mark span.a,.ix-mark span.d{color:var(--amber)}
.ix.named .ix-mark span{opacity:1; transform:none}
.ix.named .ix-mark span:nth-child(1){transition-delay:0s}
.ix.named .ix-mark span:nth-child(2){transition-delay:.05s}
.ix.named .ix-mark span:nth-child(3){transition-delay:.10s}
.ix.named .ix-mark span:nth-child(4){transition-delay:.15s}
.ix.named .ix-mark span:nth-child(5){transition-delay:.20s}
.ix.named .ix-mark span:nth-child(6){transition-delay:.25s}
.ix.named .ix-mark span:nth-child(7){transition-delay:.30s}
.ix-tag{color:var(--muted); font-size:clamp(12px,1.4vw,16px); margin-top:8px; opacity:0; transform:translateY(8px);
  transition:opacity .5s ease .4s, transform .55s ease .4s}
.ix.named .ix-tag{opacity:1; transform:none}

/* ---------- skip ---------- */
.ix-skip{position:absolute; left:22px; bottom:20px; z-index:6; font-family:inherit; font-size:13px;
  color:#7b8498; background:rgba(10,14,24,.55); border:1px solid #232b3f; border-radius:999px;
  padding:8px 18px; cursor:pointer; transition:color .2s, border-color .2s}
.ix-skip:hover{color:var(--paper); border-color:var(--amber)}
html[dir="ltr"] .ix-skip{left:auto; right:22px}

/* ---------- mobile ---------- */
@media (max-width:820px){
  .ix-rig{--ix-oy:62vh; --ix-dy:12vh; --ix-s:1.13}
  .ix-cord{height:18px}
  .ix-shade{top:16px; height:30px}
  .ix-glow{top:44px; height:12px}
  .ix-cone{left:-50vw; top:46px; width:100vw; height:calc(60.4vh - 44px); filter:blur(16px)}
  .ix-fig{top:16vh; bottom:auto; height:46vh; --art-dx:-1px}  /* art correction resolves during the travel */
  .ix-pool{bottom:calc(var(--feet) - 34px); width:min(350px,86vw); height:56px; filter:blur(10px)}
  .ix-foot{bottom:calc(var(--feet) - 8px); width:min(150px,40vw); height:16px}
  .ix-name{bottom:9vh}
}

/* While the intro plays, the hero's own rig stays invisible so the
   traveling character is the only one on screen. */
.stage.pre .figure, .stage.pre .lamp, .stage.pre .lamp-pool, .stage.pre .foot-shadow { opacity:0 !important; }

/* The hero copy is revealed by motion.js independently of the light, so it
   would show through while the character is still travelling. Keep it hidden
   until the handoff; at snap the headline animates in as usual. */
.stage.pre .copy { opacity:0 !important; }
.ix.exit .ix-name { transition:opacity .28s ease; }

/* ================= DAY INTRO =================
   Same sequence and geometry as night. Only color and opacity change, and
   every final value equals the hero's own day value (theme.css), so the
   handoff stays exact. The page background is set by data-theme in <head>
   (theme.js), so the right look is there from the first paint. */
html[data-theme="light"] .ix-bg{background:radial-gradient(120% 90% at 50% 78%,#fffaf0 0%,#f6f1e7 55%,#ece3d1 100%)}
html[data-theme="light"] .ix-shade{background:linear-gradient(180deg,#d9d2c3,#bdb5a3);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.5), 0 16px 30px rgba(60,50,30,.18)}
html[data-theme="light"] .ix-cord{background:#9a927f}
html[data-theme="light"] .ix-glow{
  background:radial-gradient(closest-side,#fffdf4 0%,#fdf0cd 38%,#f9df9f 66%,rgba(250,220,150,.3) 86%,rgba(250,220,150,0) 100%);
  box-shadow:0 0 40px 10px rgba(253,236,190,.4), 0 0 84px 26px rgba(250,225,160,.16);
  filter:brightness(.7) blur(.4px); opacity:.58}
html[data-theme="light"] .ix.lit .ix-glow{filter:brightness(1)}
html[data-theme="light"] .ix-cone{
  background:linear-gradient(180deg,rgba(255,246,222,.62) 0%,rgba(255,234,190,.36) 14%,rgba(255,222,160,.17) 40%,rgba(255,214,150,.06) 62%,rgba(255,210,140,0) 86%)}
html[data-theme="light"] .ix.lit .ix-cone{opacity:.58}
html[data-theme="light"] .ix-pool{
  background:radial-gradient(closest-side,rgba(255,240,200,.95) 0%,rgba(255,228,170,.55) 26%,rgba(255,214,140,.24) 52%,rgba(255,205,125,.07) 72%,rgba(255,205,125,0) 100%)}
html[data-theme="light"] .ix.lit .ix-pool{opacity:.58}
html[data-theme="light"] .ix-foot{background:radial-gradient(closest-side,rgba(60,50,30,.25),transparent)}
/* unlit start: a dim, cool-dark silhouette on cream, then it warms up */
html[data-theme="light"] .ix-fig{filter:brightness(.55) saturate(.8)}
html[data-theme="light"] .ix.lit .ix-fig{filter:none}
html[data-theme="light"] .ix-skip{color:#4d586f;background:rgba(246,241,231,.7);border-color:rgba(30,40,70,.18)}
html[data-theme="light"] .ix-skip:hover{color:#1b2233;border-color:var(--amber)}
