/* Digi Coral: cinematic hero engine (v5). Decorative only: every .cine lives inside an aria-hidden .hero-scene.
   Structure: canvas data-sphere (cine.js) + kinetic ghost word + 3D device that morphs between browser and phone
   while it plays a sequence of story chapters. Chapter animations use the .k-* vocabulary below and only run on
   the active chapter (.is-on), so they restart every time a chapter comes back. */

.hero-scene:has(.cine) { max-width: 620px; }
.hero-scene:has(.cine)::before { inset: 4% 2%; }
.cine { --mx: 0; --my: 0; --dur: 4s; position: relative; width: 100%; aspect-ratio: 600 / 480; isolation: isolate; }
.cine-field { position: absolute; inset: -9%; width: 118%; height: 118%; z-index: -2; pointer-events: none; }

/* Kinetic ghost word behind the device */
.cine-word { position: absolute; inset: -2% -4% auto; height: 34%; z-index: -1; overflow: hidden; pointer-events: none; }
.cine-word span { position: absolute; left: 0; right: 0; top: 0; text-align: center; font: 900 clamp(56px, 9.4vw, 132px)/1 var(--font); letter-spacing: -.04em; text-transform: uppercase; color: transparent; -webkit-text-stroke: 1.5px rgba(37, 99, 235, .2); opacity: 0; transform: translateY(70%); transition: transform .9s cubic-bezier(.7, 0, .2, 1), opacity .6s ease; }
.cine-word span.is-on { opacity: 1; transform: none; }
.cine-word span.is-past { opacity: 0; transform: translateY(-70%); }

/* Device */
.cine-stage { position: absolute; inset: 0; perspective: 1400px; }
.cine-device { position: absolute; left: 50%; top: 47%; width: 90%; height: 70%; border-radius: 20px; background: #fff; border: 1px solid #dfe6f5;
  box-shadow: 0 2px 0 #fff inset, 0 40px 80px -30px rgba(11, 26, 58, .35), 0 18px 40px -20px rgba(37, 99, 235, .35);
  transform: translate(-50%, -50%) rotateY(calc(var(--mx) * 9deg)) rotateX(calc(var(--my) * -7deg));
  transition: width .95s cubic-bezier(.7, 0, .2, 1), height .95s cubic-bezier(.7, 0, .2, 1), border-radius .95s ease; transform-style: preserve-3d; overflow: hidden; will-change: transform; }
.cine-device[data-shape="phone"] { width: 39%; height: 94%; border-radius: 34px; border-color: #0b1a3a; border-width: 6px; }
.cine-chrome { position: absolute; inset: 0 0 auto; height: 34px; display: flex; align-items: center; gap: 6px; padding: 0 14px; background: linear-gradient(#f7f9fd, #eef2fa); border-bottom: 1px solid #e6ebf5; transition: height .6s ease, background .6s ease; }
.cine-chrome i { width: 9px; height: 9px; border-radius: 50%; background: #d4dbe9; flex: none; transition: opacity .3s ease; }
.cine-chrome i:first-child { background: #f97316; }
.cine-url { flex: 1; margin-left: 10px; height: 20px; border-radius: 10px; background: #fff; border: 1px solid #e3e8f3; font: 650 11px/18px var(--font); color: #5b6478; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .3s ease; }
.cine-device[data-shape="phone"] .cine-chrome { height: 24px; background: #fff; border-bottom-color: transparent; justify-content: center; }
.cine-device[data-shape="phone"] .cine-chrome i, .cine-device[data-shape="phone"] .cine-url { opacity: 0; width: 0; padding: 0; margin: 0; border: 0; }
.cine-device[data-shape="phone"] .cine-chrome::after { content: ""; width: 64px; height: 14px; border-radius: 8px; background: #0b1a3a; }
.cine-screen { position: absolute; inset: 34px 0 0; overflow: hidden; transition: inset .6s ease; }
.cine-device[data-shape="phone"] .cine-screen { inset: 24px 0 0; }
.cine-ch { position: absolute; inset: 0; opacity: 0; transform: translateX(8%) scale(.97); transition: opacity .5s ease, transform .8s cubic-bezier(.2, .7, .2, 1); }
.cine-ch.is-on { opacity: 1; transform: none; transition-delay: .25s; }
.cine-ch.is-past { opacity: 0; transform: translateX(-8%) scale(.97); }
.cine-ch svg { width: 100%; height: 100%; display: block; }
.cine-ch .sf, .cine-word, .cine-hud { font-family: var(--font); }
.cine-glare { position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(600px circle at calc(50% + var(--mx) * 40%) calc(30% + var(--my) * 40%), rgba(255, 255, 255, .55), transparent 40%); mix-blend-mode: soft-light; }
.cine-shadow { position: absolute; left: 18%; right: 18%; bottom: -1%; height: 7%; border-radius: 50%; background: radial-gradient(closest-side, rgba(11, 26, 58, .22), transparent); filter: blur(6px); z-index: -1;
  transform: translateX(calc(var(--mx) * 14px)); }

/* HUD: chapter index, label, progress */
.cine-hud { position: absolute; left: 4%; bottom: -3%; display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 999px; background: rgba(255, 255, 255, .86); border: 1px solid #e3e8f3; box-shadow: 0 10px 30px -14px rgba(11, 26, 58, .3); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.cine-idx { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #2563eb; color: #fff; font-size: 12px; font-weight: 800; }
.cine-label { font-size: 13px; font-weight: 750; color: #0b1a3a; white-space: nowrap; }
.cine-bar { width: 64px; height: 4px; border-radius: 4px; background: #e6ebf5; overflow: hidden; }
.cine-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #2563eb, #f97316); transform-origin: left; transform: scaleX(0); }
.cine-bar.run i { animation: cineBar var(--dur) linear both; }
@keyframes cineBar { to { transform: scaleX(1); } }

/* ---------- Chapter animation vocabulary ---------- */
.cine-ch .k { transform-box: fill-box; transform-origin: center; }
.cine-ch .d1 { animation-delay: .35s !important; } .cine-ch .d2 { animation-delay: .55s !important; } .cine-ch .d3 { animation-delay: .75s !important; }
.cine-ch .d4 { animation-delay: .95s !important; } .cine-ch .d5 { animation-delay: 1.15s !important; } .cine-ch .d6 { animation-delay: 1.35s !important; }
.cine-ch .d7 { animation-delay: 1.6s !important; } .cine-ch .d8 { animation-delay: 1.85s !important; } .cine-ch .d9 { animation-delay: 2.1s !important; }
.cine-ch .d10 { animation-delay: 2.4s !important; } .cine-ch .d11 { animation-delay: 2.7s !important; } .cine-ch .d12 { animation-delay: 3s !important; }
.cine-ch .k-draw { stroke-dasharray: 1; stroke-dashoffset: 0; }
.cine-ch .k-grow { transform-origin: 50% 100%; } .cine-ch .k-growx, .cine-ch .k-wipe { transform-origin: 0 50%; }
.cine-ch .k-needle { stroke-dasharray: 60 60; }

.cine-ch.is-on .k-pop { animation: kPop .65s cubic-bezier(.34, 1.56, .64, 1) both; }
.cine-ch.is-on .k-rise { animation: kRise .7s cubic-bezier(.2, .7, .2, 1) both; }
.cine-ch.is-on .k-drop { animation: kDrop .8s cubic-bezier(.34, 1.4, .64, 1) both; }
.cine-ch.is-on .k-slide { animation: kSlide .7s cubic-bezier(.2, .7, .2, 1) both; }
.cine-ch.is-on .k-slider { animation: kSlideR .7s cubic-bezier(.2, .7, .2, 1) both; }
.cine-ch.is-on .k-fade { animation: kFade .8s ease both; }
.cine-ch.is-on .k-draw { animation: kDraw 1.1s cubic-bezier(.6, 0, .2, 1) both; }
.cine-ch.is-on .k-type { animation: kType 1.1s steps(22) both; }
.cine-ch.is-on .k-wipe { animation: kGrowX .8s cubic-bezier(.6, 0, .2, 1) both; }
.cine-ch.is-on .k-grow { animation: kGrow .8s cubic-bezier(.34, 1.3, .64, 1) both; }
.cine-ch.is-on .k-growx { animation: kGrowX .9s cubic-bezier(.6, 0, .2, 1) both; }
.cine-ch.is-on .k-climb { animation: kClimb 1.3s cubic-bezier(.7, 0, .2, 1) both; }
.cine-ch.is-on .k-sink { animation: kSink 1.3s cubic-bezier(.7, 0, .2, 1) both; }
.cine-ch.is-on .k-cursor { animation: kCursor 1.1s cubic-bezier(.6, 0, .2, 1) both; }
.cine-ch.is-on .k-click { animation: kClick .9s ease-out both; }
.cine-ch.is-on .k-fly { animation: kFly 1s cubic-bezier(.2, .7, .2, 1) both; }
.cine-ch.is-on .k-flyout { animation: kFlyOut 1s cubic-bezier(.7, 0, .8, .4) both; }
.cine-ch.is-on .k-needle { animation: kNeedle 1.6s cubic-bezier(.34, 1.3, .64, 1) both; }
.cine-ch.is-on .k-float { animation: kFloat 3s ease-in-out infinite; }
.cine-ch.is-on .k-heart { animation: kHeart 2.2s ease-out infinite; }
.cine-ch.is-on .k-ring { animation: kRing 1.8s ease-out infinite; }
.cine-ch.is-on .k-pulse { animation: kPulse 1.6s ease-in-out infinite; }
.cine-ch.is-on .k-shake { animation: kShake 1.2s ease-in-out infinite; }
.cine-ch.is-on .k-spin { animation: kSpin 6s linear infinite; }
.cine-ch.is-on .k-scan { animation: kScan 2.4s ease-in-out infinite alternate; }
.cine-ch.is-on .k-blink { animation: kBlink 1s steps(1) infinite; }
.cine-ch.is-on .k-travel { animation: kTravel 1.4s linear infinite; }
.cine-ch.is-on .k-close { animation: kClose .6s cubic-bezier(.34, 1.56, .64, 1) both; }
.cine-ch.is-on .k-dash { animation: kDash 1s linear infinite; }

@keyframes kPop { from { transform: scale(0); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes kRise { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes kDrop { from { transform: translateY(-70px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes kSlide { from { transform: translateX(-30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes kSlideR { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes kFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes kDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes kType { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes kGrow { from { transform: scaleY(0); } to { transform: none; } }
@keyframes kGrowX { from { transform: scaleX(0); } to { transform: none; } }
@keyframes kClimb { 0%, 25% { transform: translateY(150px); } to { transform: none; } }
@keyframes kSink { 0%, 25% { transform: translateY(-52px); } to { transform: none; } }
@keyframes kCursor { from { transform: translate(70px, 60px); opacity: 0; } 30% { opacity: 1; } to { transform: none; opacity: 1; } }
@keyframes kClick { 0% { transform: scale(.2); opacity: 0; } 12% { opacity: .9; } to { transform: scale(2.4); opacity: 0; } }
@keyframes kFly { from { transform: translate(-150px, -70px) rotate(-18deg) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes kFlyOut { from { transform: none; opacity: 1; } to { transform: translate(170px, -90px) rotate(-12deg) scale(.4); opacity: 0; } }
@keyframes kNeedle { from { transform: rotate(-118deg); } to { transform: rotate(52deg); } }
@keyframes kFloat { 50% { transform: translateY(-7px); } }
@keyframes kHeart { 0% { transform: translateY(0) scale(.3); opacity: 0; } 18% { transform: translateY(-14px) scale(1); opacity: 1; } 100% { transform: translateY(-120px) scale(.8); opacity: 0; } }
@keyframes kRing { from { transform: scale(.5); opacity: .7; } to { transform: scale(1.9); opacity: 0; } }
@keyframes kPulse { 50% { transform: scale(1.08); } }
@keyframes kShake { 0%, 50%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-14deg); } 20%, 40% { transform: rotate(14deg); } }
@keyframes kSpin { to { transform: rotate(360deg); } }
@keyframes kScan { from { transform: translateY(0); } to { transform: translateY(170px); } }
@keyframes kBlink { 50% { opacity: 0; } }
@keyframes kTravel { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 80% { opacity: 1; } to { transform: translateY(26px); opacity: 0; } }
@keyframes kClose { from { transform: translateY(-10px); } to { transform: none; } }
@keyframes kDash { to { stroke-dashoffset: -20; } }

/* Depth layers inside the screen follow the cursor */
.cine .z1 { transform: translate(calc(var(--mx) * -4px), calc(var(--my) * -4px)); }
.cine .z2 { transform: translate(calc(var(--mx) * 8px), calc(var(--my) * 8px)); }

@media (max-width: 560px) {
  .cine-hud { bottom: -6%; padding: 6px 12px 6px 6px; }
  .cine-idx { width: 26px; height: 26px; font-size: 11px; }
  .cine-label { font-size: 12px; }
  .cine-chrome { height: 28px; } .cine-screen { inset: 28px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cine-device, .cine-ch, .cine-word span, .cine-chrome, .cine-screen { transition: none !important; }
  .cine-ch .k, .cine-bar i { animation: none !important; }
  .cine-ch .fx { display: none; }
  .cine-bar i { transform: none; }
  .cine-device { transform: translate(-50%, -50%); }
  .cine .z1, .cine .z2, .cine-shadow { transform: none; }
}

/* ---------- v6: WebGL stages ---------- */
/* Homepage "sculpture" mode: the 3D scene is the hero; the device story is the no-WebGL fallback. */
.cine-sculpt .cine-stage { display: none; }
.no-gl .cine-sculpt .cine-stage { display: block; }
.cine-sculpt .cine-field { inset: -16%; width: 132%; height: 132%; }
.cine-sculpt .cine-word { inset: 30% -8% auto; height: 40%; }
.cine-sculpt .cine-word span { top: 50%; margin-top: -.5em; -webkit-text-stroke-color: rgba(37, 99, 235, .16); }
.cine-sculpt .cine-hud { left: 50%; translate: -50% 0; bottom: -4%; }
.cine.gl-on .cine-field { inset: -14%; width: 128%; height: 128%; }
.cine-sculpt.gl-on .cine-field { inset: -18%; width: 136%; height: 136%; }

/* CTA band sculpture (sits under the copy, above the dot texture) */
.cta-band .gl-cta { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

/* Area pages: sculpture behind the schematic map */
.hero-map { position: relative; isolation: isolate; }
.hero-map .gl-ambient { position: absolute; inset: -16%; width: 132%; height: 132%; z-index: -1; pointer-events: none; }

@media (max-width: 860px) {
  .cta-band .gl-cta { opacity: .55; }
}

/* Story pages with WebGL: layered composition, device front-left, 3D sculpture rising behind at upper right */
.cine.gl-on:not(.cine-sculpt) .cine-device { left: 43%; top: 57%; width: 76%; height: 60%; }
.cine.gl-on:not(.cine-sculpt) .cine-device[data-shape="phone"] { left: 40%; width: 34%; height: 82%; }
@media (max-width: 560px) {
  .cine.gl-on:not(.cine-sculpt) .cine-device { left: 46%; width: 82%; height: 62%; }
  .cine.gl-on:not(.cine-sculpt) .cine-device[data-shape="phone"] { left: 44%; width: 38%; }
}
@media (max-width: 860px) {
  .cine-sculpt.gl-on .cine-field { inset: 0 -10% -6%; width: 120%; height: 106%; }
  .cine.gl-on .cine-field { inset: 0 -8% -6%; width: 116%; height: 106%; }
  .hero-map .gl-ambient { inset: 0 -10%; width: 120%; height: 100%; }
}
