/* Hero: story 1 (website build). Always dark, uses the site's dark tokens. */
:root {
  --hx-night: #0a101d; --hx-surface: #101a2c; --hx-ink: #e7eef8; --hx-mute: #95a3ba;
  --hx-line: #1e2b43; --hx-accent: #2dd4bf; --hx-hot: #fb923c; --hx-led: #34d399; --hx-err: #f87171;
  --hx-top: 0px; --hx-dock: 72px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--hx-night); color: var(--hx-ink); font: 400 17px/1.6 var(--sans); }

.hx {
  position: relative; overflow: hidden; isolation: isolate;
  height: calc(100vh - var(--hx-top)); min-height: 620px; max-height: 1100px;
  background:
    radial-gradient(ellipse 34% 44% at 70% 44%, rgba(45, 212, 191, .10), transparent 70%),
    repeating-linear-gradient(0deg, rgba(45, 212, 191, .045) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(90deg, rgba(45, 212, 191, .045) 0 1px, transparent 1px 48px),
    var(--hx-night);
}
@supports (height: 100svh) { .hx { height: calc(100svh - var(--hx-top)); } }

/* ---------- copy column ---------- */
.hx-shade { position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(90deg, rgba(10, 16, 29, .92) 0%, rgba(10, 16, 29, .55) 34%, transparent 52%); }
.hx-main { position: absolute; z-index: 4; left: clamp(16px, 7vw, 140px); bottom: calc(var(--hx-dock) + clamp(28px, 7vh, 80px));
  width: min(560px, 42vw); }
.hx-h1 { margin: 0; font-weight: 700; font-size: clamp(32px, 3.6vw, 60px); line-height: 1.06; letter-spacing: -.02em; color: #fff; }
.hx-h1a { display: block; }
.hx-rot { display: grid; overflow: hidden; padding-bottom: .1em; color: var(--hx-accent); }
.hx-w { grid-area: 1/1; white-space: nowrap; transform: translateY(105%); opacity: 0;
  transition: transform .7s cubic-bezier(.2, .7, 0, 1), opacity .4s; }
.hx-w.on { transform: none; opacity: 1; transition-delay: .12s; }
.hx-w.leave { transform: translateY(-105%); opacity: 0; transition: transform .45s cubic-bezier(.6, 0, .8, .4), opacity .35s; }

.hx-panels { display: grid; margin-top: clamp(16px, 2.6vh, 28px); }
.hx-panel { grid-area: 1/1; opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .45s, transform .45s, visibility 0s .45s; }
.hx-panel.on { opacity: 1; visibility: visible; transform: none; transition: opacity .5s .2s, transform .5s .2s, visibility 0s; }
.hx-k { margin: 0 0 6px; font: 600 13px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--hx-hot); }
.hx-lede { margin: 0; max-width: 46ch; color: var(--hx-mute); font-size: clamp(15px, 1.1vw, 18px); }
.hx-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.hx-chips a { display: inline-block; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--hx-ink);
  text-decoration: none; border: 1px solid rgba(231, 238, 248, .24); border-radius: 999px; transition: background-color .2s, color .2s; }
.hx-chips a:hover { background: var(--hx-ink); color: var(--hx-night); }
:focus-visible { outline: 2px solid var(--hx-accent); outline-offset: 3px; }

/* No JS: every panel readable, stacked */
html:not(.js) .hx-panels { display: block; }
html:not(.js) .hx-panel { opacity: 1; visibility: visible; transform: none; margin-bottom: 14px; }
html:not(.js) .hx-panel .hx-chips { display: none; }
html:not(.js) .hx-rot .hx-w:not(:first-child) { display: none; }
html:not(.js) .hx { height: auto; max-height: none; min-height: 100vh; }
html:not(.js) .hx-main { position: relative; left: auto; bottom: auto; padding: 48px 16px 120px clamp(16px, 7vw, 140px); }

/* ---------- dock ---------- */
.hx-dock { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; height: var(--hx-dock);
  display: flex; padding: 0 clamp(16px, 7vw, 140px); gap: 4px; border-top: 1px solid var(--hx-line);
  background: rgba(10, 16, 29, .7); backdrop-filter: blur(6px); overflow-x: auto; scrollbar-width: none; }
.hx-dock::-webkit-scrollbar { display: none; }
.hx-tab { position: relative; flex: 1 0 auto; min-width: 104px; display: flex; flex-direction: column; justify-content: center;
  padding: 0 12px; border: 0; background: none; color: var(--hx-mute); font: 600 14px/1.3 var(--sans); text-align: left; cursor: pointer; }
.hx-tab b { font: 500 11px/1.4 var(--mono); color: inherit; opacity: .7; }
.hx-tab::before { content: ""; position: absolute; left: 12px; right: 12px; top: -1px; height: 2px; background: var(--hx-line); }
.hx-tab::after { content: ""; position: absolute; left: 12px; right: 12px; top: -1px; height: 2px; background: var(--hx-hot);
  transform: scaleX(0); transform-origin: left; }
.hx-tab:hover, .hx-tab.on { color: #fff; }
.hx-tab.on::after { transform: scaleX(1); }
.hx.playing .hx-tab.on::after { animation: hx-fill var(--hx-dur, 7s) linear forwards; }
.hx.paused .hx-tab.on::after { animation-play-state: paused; }
@keyframes hx-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.hx-tab.soon { cursor: default; opacity: .4; }

/* ---------- scene ---------- */
.hx-scene { position: absolute; z-index: 1; top: 0; right: 0; bottom: var(--hx-dock); width: 60%;
  display: grid; place-items: center; padding: 40px clamp(16px, 4vw, 64px); }
.hx-box { position: relative; width: min(640px, 100%); aspect-ratio: 4 / 3; }
.hx-box * { transition-timing-function: cubic-bezier(.3, .7, .2, 1); }

/* device: monitor <-> phone, one element */
.dev { position: absolute; left: 4%; top: 2%; width: 92%; height: 66%;
  border: 10px solid #1c2a44; border-radius: 14px; background: #0d1626; box-shadow: 0 30px 60px rgba(0, 0, 0, .45);
  transition: left .9s, top .9s, width .9s, height .9s, border-radius .9s, border-width .9s; }
.dev::after { content: ""; position: absolute; left: 50%; top: calc(100% + 10px); width: 24%; height: 18%; transform: translateX(-50%);
  background: linear-gradient(#1c2a44, #16213a); clip-path: polygon(40% 0, 60% 0, 66% 70%, 100% 80%, 100% 100%, 0 100%, 0 80%, 34% 70%);
  transition: opacity .4s; }
.scr { position: absolute; inset: 0; overflow: hidden; border-radius: 4px; background: #0f1a2d; transition: background-color .9s; }

.phone .dev { left: 37%; top: 0; width: 26%; height: 92%; border-width: 7px; border-radius: 26px; }
.phone .dev::after { opacity: 0; }
.phone .scr { border-radius: 18px; }
.side .dev { left: 0; top: 10%; width: 60%; height: 50%; }
.side .dev::after { height: 16%; }

/* blocks: shared */
.b { position: absolute; left: 4%; border: 1px dashed rgba(149, 163, 186, .55); border-radius: 3px; background: transparent;
  opacity: 0; transform: translateY(-14px);
  transition: left .9s, top .9s, width .9s, height .9s, background-color .9s, border-color .9s, border-radius .9s, opacity .35s, transform .35s; }
.tag { position: absolute; left: 4px; top: 1px; font: 500 9px/1.2 var(--mono); font-style: normal; color: var(--hx-mute); transition: opacity .4s; }

/* stage 1: plain document flow, everything stacked */
.b-nav { top: 3%; width: 92%; height: 8%; }
.b-h1  { top: 14%; width: 60%; height: 8%; }
.b-p   { top: 25%; width: 82%; height: 6%; }
.b-img { top: 34%; width: 40%; height: 18%; }
.b-form{ top: 55%; width: 62%; height: 12%; }
.b-c1  { top: 70%; width: 50%; height: 7%; }
.b-c2  { top: 79%; width: 50%; height: 7%; }
.b-c3  { top: 88%; width: 50%; height: 7%; }
.d1 .b-nav, .d2 .b-h1, .d3 .b-p, .d4 .b-img, .d5 .b-form, .d6 .b-c1, .d7 .b-c2, .d8 .b-c3 { opacity: 1; transform: none; }

/* stage 2: CSS, styled desktop layout */
.css .b { opacity: 1; transform: none; border-style: solid; border-color: transparent; border-radius: 6px; }
.css .tag { opacity: 0; }
.css .scr { background: #f6f9fc; }
.css .b-nav { left: 0; top: 0; width: 100%; height: 10%; border-radius: 0; background: #0f766e; }
.css .b-h1  { left: 6%; top: 17%; width: 42%; height: 12%; background: #0d1726; }
.css .b-p   { left: 6%; top: 32%; width: 36%; height: 5%; background: #b9c7d6; }
.css .b-img { left: 54%; top: 16%; width: 40%; height: 46%; background: linear-gradient(135deg, #2dd4bf, #c2410c); }
.css .b-form{ left: 6%; top: 41%; width: 42%; height: 21%; background: #fff; border-color: #dbe3ec; }
.css .b-c1, .css .b-c2, .css .b-c3 { top: 70%; width: 28%; height: 23%; background: #fff; border-color: #dbe3ec; }
.css .b-c1 { left: 6%; } .css .b-c2 { left: 36%; } .css .b-c3 { left: 66%; }

.phone.css .b-nav { height: 7%; }
.phone.css .b-h1  { left: 7%; top: 10%; width: 86%; height: 7%; }
.phone.css .b-p   { left: 7%; top: 19%; width: 70%; height: 3%; }
.phone.css .b-img { left: 7%; top: 25%; width: 86%; height: 17%; }
.phone.css .b-form{ left: 7%; top: 45%; width: 86%; height: 19%; }
.phone.css .b-c1, .phone.css .b-c2, .phone.css .b-c3 { left: 7%; width: 86%; height: 8%; }
.phone.css .b-c1 { top: 67%; } .phone.css .b-c2 { top: 77%; } .phone.css .b-c3 { top: 87%; }

/* nav details + form internals */
.logo, .burger { position: absolute; top: 50%; transform: translateY(-50%); opacity: 0; transition: opacity .5s .5s; }
.logo { left: 4%; width: 12%; height: 34%; border-radius: 3px; background: #ccfbf1; }
.burger { right: 4%; width: 18px; display: grid; gap: 3px; }
.burger b { height: 2px; background: #fff; border-radius: 2px; }
.css .logo, .css .burger { opacity: 1; }
.b-form { display: flex; flex-direction: column; justify-content: center; gap: 7%; padding: 0 6%; }
.in, .btn { display: block; height: 18%; border-radius: 3px; opacity: 0; transition: opacity .5s .5s, border-color .3s, box-shadow .3s; }
.in { border: 1px solid #b9c7d6; background: #fff; overflow: hidden; }
.btn { width: 34%; background: #c2410c; color: #fff; font: 600 9px/1 var(--sans); display: grid; place-items: center; }
.css .in, .css .btn { opacity: 1; }
.ty { display: block; padding: 0 5px; font: 500 9px/1.9 var(--mono); font-style: normal; color: #0d1726; white-space: nowrap; }
.err .in2 { border-color: var(--hx-err); box-shadow: 0 0 0 2px rgba(248, 113, 113, .35); animation: hx-shake .35s; }
.ok .in1, .ok .in2 { border-color: var(--hx-led); box-shadow: 0 0 0 2px rgba(52, 211, 153, .3); }
.press .btn { transform: scale(.94); filter: brightness(1.15); }
@keyframes hx-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.thanks { position: absolute; inset: 0; display: grid; place-items: center; font: 700 11px/1.2 var(--sans); color: #047857;
  background: #ecfdf5; border-radius: 6px; opacity: 0; transition: opacity .5s; }
.done .thanks { opacity: 1; }

/* stage 3: JS cursor + drawer */
.drawer { position: absolute; right: 0; top: 10%; width: 34%; height: 60%; background: #0d1726; padding: 6%;
  display: grid; align-content: start; gap: 10%; transform: translateX(105%); transition: transform .5s; }
.drawer b { height: 6px; border-radius: 3px; background: #2dd4bf; opacity: .8; }
.drawer b:nth-child(2n) { width: 70%; }
.menu .drawer { transform: none; }
.cur { position: absolute; left: 60%; top: 60%; width: 14px; height: 20px; z-index: 3; opacity: 0;
  background: #fff; clip-path: polygon(0 0, 0 78%, 26% 60%, 46% 100%, 60% 94%, 40% 56%, 76% 56%);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); transition: left .6s, top .6s, opacity .3s; }
.curon .cur { opacity: 1; }
.cur::after { content: ""; position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--hx-hot); opacity: 0; }
.click .cur::after { animation: hx-ping .45s; }
@keyframes hx-ping { from { opacity: 1; transform: scale(.3); } to { opacity: 0; transform: scale(1.6); } }

/* stage 4: PHP server + packets */
.srv { position: absolute; left: 68%; top: 6%; width: 32%; height: 62%; border-radius: 10px; background: #101a2c;
  border: 1px solid var(--hx-line); padding: 4%; opacity: 0; transform: translateX(30px); transition: opacity .6s .3s, transform .6s .3s; }
.srv-top { display: flex; justify-content: space-between; align-items: center; font: 700 12px/1 var(--mono); color: var(--hx-accent);
  padding-bottom: 8px; border-bottom: 1px solid var(--hx-line); }
.srv-top i { width: 8px; height: 8px; border-radius: 50%; background: var(--hx-led); box-shadow: 0 0 8px var(--hx-led); }
.log { margin: 10px 0 0; padding: 0; list-style: none; font: 500 10px/2 var(--mono); color: var(--hx-mute); }
.log li { opacity: 0; transform: translateX(-6px); transition: opacity .3s, transform .3s; }
.log li:last-child { color: var(--hx-led); }
.srv-on .srv { opacity: 1; transform: none; }
.l1 .log li:nth-child(1), .l2 .log li:nth-child(2), .l3 .log li:nth-child(3), .l4 .log li:nth-child(4), .l5 .log li:nth-child(5) { opacity: 1; transform: none; }
.pkt { position: absolute; top: 34%; padding: 3px 8px; border-radius: 4px; font: 700 10px/1.2 var(--mono); color: #0a101d;
  opacity: 0; pointer-events: none; }
.pkt-out { left: 40%; background: var(--hx-hot); }
.pkt-back { left: 66%; top: 44%; background: var(--hx-led); }
.out .pkt-out { animation: hx-fly-r 1s forwards; }
.back .pkt-back { animation: hx-fly-l 1s forwards; }
@keyframes hx-fly-r { 0% { opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateX(240%); } }
@keyframes hx-fly-l { 0% { opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateX(-280%); } }

/* code card, typed per stage */
.code { position: absolute; left: 0; bottom: 0; width: 56%; max-height: 34%; margin: 0; padding: 10px 12px; overflow: hidden;
  border-radius: 8px; background: rgba(16, 26, 44, .92); border: 1px solid var(--hx-line); box-shadow: 0 16px 32px rgba(0, 0, 0, .4);
  font: 500 11px/1.55 var(--mono); color: #cfe3f5; white-space: pre; z-index: 4; }
.code code::after { content: "▍"; color: var(--hx-hot); animation: hx-blink 1s steps(1) infinite; }
.side .code { left: 32%; width: 66%; bottom: 0; }
@keyframes hx-blink { 50% { opacity: 0; } }
.code .k { color: #2dd4bf; } .code .s { color: #fb923c; }

/* ---------- small screens: scene above, copy below ---------- */
@media (max-width: 860px) {
  :root { --hx-dock: 60px; }
  .hx { height: auto; max-height: none; min-height: 100svh; display: flex; flex-direction: column; padding-bottom: var(--hx-dock); }
  .hx-scene { position: relative; width: 100%; bottom: auto; padding: 24px 16px 0; }
  .hx-box { width: min(480px, 100%); }
  .hx-shade { display: none; }
  .hx-main { position: relative; left: auto; bottom: auto; width: auto; padding: 18px 16px 28px; }
  .hx-tab { min-width: 92px; font-size: 13px; }
  .hx-dock { padding: 0 8px; }
  .code { font-size: 9px; padding: 7px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .hx *, .hx *::before, .hx *::after { transition: none !important; animation: none !important; }
  .code code::after { content: ""; }
}
.phone .code { width: 35%; }
html:not(.js) .code, html:not(.js) .hx-dock { display: none; }
@media (max-width: 860px) { .code { max-height: 28%; width: 62%; } .side .code { left: 34%; width: 66%; } }

/* ---------- 3D layer (hero3d.js) ---------- */
.hx-gl { position: absolute; z-index: 1; left: 0; right: 0; top: 0; bottom: var(--hx-dock); opacity: 0; transition: opacity .9s; }
.hx-gl canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; outline: none; }
.hx--drag .hx-gl canvas { cursor: grabbing; }
.hx--gl .hx-gl { opacity: 1; }
.hx--gl .hx-scene { pointer-events: none; z-index: 3; }
.hx--gl .dev, .hx--gl .srv, .hx--gl .pkt { opacity: 0 !important; visibility: hidden; transition: opacity .5s, visibility 0s .5s; }
.hx--gl .code { left: auto; right: -2%; bottom: -15%; width: 42%; }
.hx--gl.hx .hx-scene .code { opacity: .96; }
.hx-hint { position: absolute; z-index: 4; right: clamp(16px, 4vw, 64px); bottom: calc(var(--hx-dock) + 16px); margin: 0;
  font: 500 12px/1.4 var(--mono); color: var(--hx-mute); opacity: 0; transition: opacity .6s 1s; pointer-events: none; }
.hx--gl .hx-hint { opacity: .8; }
@media (max-width: 860px) { .hx-gl { bottom: auto; } .hx-hint { display: none; } .hx--gl .code { width: 60%; } }
.hx--gl .side .code { right: auto; left: 4%; width: 46%; }

/* Logo header (transparent, overlays the hero) */
.site-top { position: absolute; top: 0; left: 0; right: 0; z-index: 20; padding: 14px 20px; pointer-events: none; }
.site-logo { display: inline-block; pointer-events: auto; border-radius: 6px; }
.site-logo img { display: block; width: 170px; height: auto; }
.site-logo:focus-visible { outline: 2px solid #c98a52; outline-offset: 4px; }
@media (max-width: 600px) { .site-logo img { width: 130px; } .site-top { padding: 10px 16px; } }

/* ---------- phones: no overlaps (2026-10-25) ----------
   The WebGL canvas starts under the header (hero3d.js adds the scene's top padding),
   the code card stays inside the scene box instead of spilling over the H1, and the
   panel copy swaps in sequence (old fades out, then new fades in) instead of crossfading. */
@media (max-width: 860px) {
  .hx--gl .code, .hx--gl .side .code { left: auto; right: 0; bottom: 0; width: 58%; max-height: 30%; }
  .hx-panel { transform: none; transition: opacity .18s, visibility 0s .18s; }
  .hx-panel.on { transition: opacity .3s .22s, visibility 0s .22s; }
}
