/* ==========================================================================
   Shadowblade — "After Effects" cinematic layer (PREVIEW, additive).
   Everything is scoped to html.aefx (set by js/fx-ae.js) and skips the
   AC museum (data-hub="ac-museum"), which keeps its own Animus look.
   Motion uses transform/opacity where possible; infinite loops honor the
   flame toggle (--fx-play) and prefers-reduced-motion.
   ========================================================================== */

/* ---------- Type system ---------- */
html.aefx:not([data-hub="ac-museum"]) {
  --font-body: "Spectral", Georgia, serif;          /* readable long-form serif */
  --font-hud: "Chakra Petch", "Rajdhani", sans-serif; /* angular motion-graphics HUD */
  --font-head: "Inter", system-ui, sans-serif;                       /* 900-weight trailer titles */
  --ae-hot: #dfe6ff;
  --ae-edge: rgba(255,178,30,.42);
  --ae-ease: cubic-bezier(.16, 1, .3, 1);
  --ae-snap: cubic-bezier(.7, 0, .2, 1);
}
html.aefx:not([data-hub="ac-museum"]) body { font-size: 1.06rem; line-height: 1.7; letter-spacing: .005em; }
html.aefx .lede { font-size: 1.04rem; color: #dfe6ff; }
html.aefx .books-kicker,
html.aefx .news-kicker {
  font-family: var(--font-hud) !important; font-weight: 600; letter-spacing: .34em !important;
  text-transform: uppercase; color: #38e8ff !important;
  display: flex; align-items: center; justify-content: center; gap: .7em;
}
html.aefx .books-kicker::before, html.aefx .books-kicker::after,
html.aefx .news-kicker::before, html.aefx .news-kicker::after {
  content: ""; height: 1px; width: 2.2em;
  background: linear-gradient(90deg, transparent, var(--ember));
}
html.aefx .books-kicker::after, html.aefx .news-kicker::after { transform: scaleX(-1); }

/* ---------- Kinetic headings (split into letters by JS) ---------- */
html.aefx .section h2.ae-kin {
  font-family: var(--font-head); font-weight: 900; letter-spacing: .14em;
  animation: none; transform: none; text-shadow: none; position: relative;
  color: var(--h-color, #dfe6ff);
}
.ae-word { display: inline-block; white-space: nowrap; }
.ae-ch {
  display: inline-block; will-change: transform, opacity;
  opacity: 0; transform: var(--ch-from, translate3d(0, .55em, 0) rotateX(70deg) scale(1.2));
  filter: blur(var(--ch-blur, 6px));
  text-shadow: var(--ch-shadow, 0 0 10px rgba(255,178,30,.8), 0 0 28px rgba(255,178,30,.5), 0 2px 0 #0c1024);
  transition: opacity .55s var(--ae-ease), transform .8s var(--ch-ease, var(--ae-ease)), filter .6s ease;
  transition-delay: calc(var(--i, 0) * var(--ch-gap, 34ms));
}
.ae-kin.ae-in .ae-ch { opacity: 1; transform: none; filter: none; }
/* Glint wave: each letter flashes white-hot in sequence, then rests. */
.ae-kin.ae-live .ae-ch { animation: aeGlint 6.5s linear infinite; animation-delay: calc(1.2s + var(--i, 0) * 45ms); animation-play-state: var(--fx-play); }
@keyframes aeGlint {
  0%, 9%, 100% { color: inherit; }
  3% { color: #fff; text-shadow: 0 0 6px #fff, 0 0 18px var(--glint, #ffc56a), 0 0 42px var(--glint, rgba(255,178,30,.9)); }
}
/* Underline slash that draws under each title */
.ae-kin::after {
  content: ""; display: block; height: 2px; width: min(14rem, 60%); margin: .5rem auto 0;
  background: linear-gradient(90deg, transparent, var(--ember), #dfe6ff, var(--ember), transparent);
  transform: scaleX(0); transition: transform 1s var(--ae-ease) .35s; box-shadow: 0 0 12px rgba(255,178,30,.8);
}
.ae-kin.ae-in::after { transform: scaleX(1); }

/* ---------- Windows: neutral base. Each section draws its OWN window in css/variety.css ---------- */
html.aefx .panel.ae-win { backdrop-filter: none; isolation: isolate; }
html.aefx .panel.ae-win::before { display: none; } /* style.css ember bar; sections re-add their own */
html.aefx .ae-win.ae-pending { opacity: 0; }
html.aefx .ae-win.ae-open > * { animation: aeRise .8s var(--ae-ease) both; }
html.aefx .ae-win.ae-open > :nth-child(2) { animation-delay: .14s; }
html.aefx .ae-win.ae-open > :nth-child(3) { animation-delay: .22s; }
html.aefx .ae-win.ae-open > :nth-child(4) { animation-delay: .3s; }
html.aefx .ae-win.ae-open > :nth-child(n+5) { animation-delay: .38s; }
@keyframes aeWinOpen {
  0% { opacity: 0; clip-path: inset(49% 0 49% 0); transform: scale(.97); filter: brightness(2.2) saturate(1.4); }
  35% { opacity: 1; clip-path: inset(30% 0 30% 0); }
  100% { opacity: 1; clip-path: inset(-40px -40px -40px -40px); transform: none; filter: none; }
}
@keyframes aeRise { from { opacity: 0; transform: translate3d(0, 18px, 0); } to { opacity: 1; transform: none; } }

/* ---------- Cards: holo sheen + staggered drop-in ---------- */
html.aefx .card { overflow: hidden; }
html.aefx .card::after {
  content: ""; position: absolute; inset: -40% -60%; pointer-events: none;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 220, 160, .28) 49%, rgba(255, 255, 255, .5) 50%, rgba(255,178,30,.2) 52%, transparent 58%);
  transform: translate3d(-60%, 0, 0); transition: transform .9s var(--ae-ease);
}
html.aefx .card:hover::after, html.aefx .card:focus-visible::after { transform: translate3d(60%, 0, 0); }
html.aefx .card h3 { font-family: var(--font-hud); font-weight: 700; letter-spacing: .1em; }
html.aefx .ae-win.ae-open .hub-cards .card { animation: aeCardIn .7s var(--ae-ease) both; animation-delay: calc(.35s + var(--ci, 0) * 60ms); }
@keyframes aeCardIn { from { opacity: 0; transform: translate3d(0, 24px, 0) scale(.9) rotateX(25deg); } to { opacity: 1; transform: none; } }

/* ---------- Atmosphere: camera push, god rays, grain, bokeh, progress ---------- */
html.aefx .bg-image { animation: aePush 38s ease-in-out infinite alternate; animation-play-state: var(--fx-play); will-change: transform; }
@keyframes aePush { from { transform: scale(1.02) translate3d(0, 0, 0); } to { transform: scale(1.12) translate3d(-1.2%, -1%, 0); } }
.ae-rays {
  position: fixed; left: 50%; top: 38%; width: 150vmax; height: 150vmax; margin: -75vmax 0 0 -75vmax; z-index: -1; pointer-events: none; opacity: .16;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(56,232,255,.0) 0deg 7deg, rgba(56,232,255,.35) 9deg, rgba(56,232,255,0) 12deg 19deg);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #080b1a 0, transparent 50%); mask-image: radial-gradient(circle at 50% 50%, #080b1a 0, transparent 50%);
  animation: aeSpin 90s linear infinite; animation-play-state: var(--fx-play); will-change: transform;
}
@keyframes aeSpin { to { transform: rotate(360deg); } }
.ae-grain {
  position: fixed; inset: -64px; z-index: 70; pointer-events: none; opacity: .045;
  background-image: var(--ae-noise); background-size: 128px 128px;
  animation: aeGrain .5s steps(4) infinite; animation-play-state: var(--fx-play);
}
@keyframes aeGrain { 0% { transform: translate3d(0, 0, 0); } 25% { transform: translate3d(-32px, 18px, 0); } 50% { transform: translate3d(22px, -40px, 0); } 75% { transform: translate3d(-12px, 30px, 0); } }
.ae-bokeh { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.ae-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 95; pointer-events: none;
  background: linear-gradient(90deg, var(--crimson), var(--ember), #dfe6ff); box-shadow: 0 0 10px #ffb21e;
  transform-origin: 0 50%; transform: scaleX(var(--ae-p, 0));
}
html[data-hub="ac-museum"] .ae-rays, html[data-hub="ac-museum"] .ae-grain,
html[data-hub="ac-museum"] .ae-bokeh, html[data-hub="ac-museum"] .ae-progress,
html[data-hub="ac-museum"] .ae-wipe { display: none !important; }
html[data-flame="off"] .ae-bokeh, html[data-flame="off"] .ae-rays { visibility: hidden; }

/* ---------- Intro gate: kinetic title, light streak, slash out ---------- */
html.aefx .intro-mark { font-family: "Inter", system-ui, sans-serif; font-weight: 900; letter-spacing: .22em; animation: none; position: relative; color: #ffb21e; }
html.aefx .intro-mark .ae-ch { transition-duration: .9s, 1.2s, .9s; transition-delay: calc(.25s + var(--i, 0) * 70ms); transform: translate3d(0, -.8em, 0) scale(2.2); }
html.aefx .intro.ae-in .intro-mark .ae-ch { opacity: 1; transform: none; filter: none; }
html.aefx .intro.ae-in .intro-mark .ae-ch { animation: aeGlint 4.5s linear infinite; animation-delay: calc(2s + var(--i, 0) * 60ms); }
.ae-streak {
  position: absolute; left: -30%; right: -30%; top: 50%; height: 2px; margin-top: -1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(56,232,255,.0) 20%, #fff 50%, rgba(56,232,255,0) 80%, transparent);
  box-shadow: 0 0 30px 6px rgba(255,178,30,.6); opacity: 0; transform: scaleX(0);
}
.intro.ae-in .ae-streak { animation: aeStreak 1.6s var(--ae-ease) 1.1s both; }
@keyframes aeStreak { 0% { opacity: 0; transform: scaleX(0); } 30% { opacity: 1; transform: scaleX(1); } 100% { opacity: 0; transform: scaleX(1.4) scaleY(.3); } }
html.aefx .btn-enter { font-family: var(--font-hud); font-weight: 700; letter-spacing: .4em; font-size: .92rem; overflow: hidden; padding: 1rem 2.1rem; clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px); }
html.aefx .btn-enter::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%);
  transform: translate3d(-120%, 0, 0); animation: aeBtnSweep 2.8s ease-in-out infinite 2.4s; animation-play-state: var(--fx-play);
}
@keyframes aeBtnSweep { 0% { transform: translate3d(-120%, 0, 0); } 45%, 100% { transform: translate3d(120%, 0, 0); } }
html.aefx .intro .btn-enter { opacity: 0; transform: translateY(14px); transition: opacity .8s ease 1.5s, transform .8s var(--ae-ease) 1.5s; }
html.aefx .intro.ae-in .btn-enter { opacity: 1; transform: none; }

/* ---------- Transitions: blade wipe between chambers, flash on enter ---------- */
.ae-wipe { position: fixed; inset: 0; z-index: 99; pointer-events: none; overflow: hidden; visibility: hidden; }
.ae-wipe::before { /* the blade */
  content: ""; position: absolute; top: -50%; bottom: -50%; left: 50%; width: 160vmax; margin-left: -80vmax;
  background: linear-gradient(90deg, transparent 0 38%, rgba(22,40,79,.95) 44%, #080b1a 47% 53%, rgba(22,40,79,.95) 56%, transparent 62%);
  transform: rotate(-24deg) translate3d(-120%, 0, 0);
}
.ae-wipe::after { /* the hot edge */
  content: ""; position: absolute; top: -50%; bottom: -50%; left: 50%; width: 6px; margin-left: -3px;
  background: #fff4dc; box-shadow: 0 0 24px 8px #ffb21e, 0 0 80px 20px rgba(255,178,30,.6);
  transform: rotate(-24deg) translate3d(-80vmax, 0, 0);
}
.ae-wipe.go { visibility: visible; }
.ae-wipe.go::before { animation: aeBlade .8s var(--ae-snap) both; }
.ae-wipe.go::after { animation: aeEdgeCut .8s var(--ae-snap) both; }
@keyframes aeBlade { from { transform: rotate(-24deg) translate3d(-120%, 0, 0); } to { transform: rotate(-24deg) translate3d(120%, 0, 0); } }
@keyframes aeEdgeCut { from { transform: rotate(-24deg) translate3d(-80vmax, 0, 0); } to { transform: rotate(-24deg) translate3d(80vmax, 0, 0); } }
.ae-flash { position: fixed; inset: 0; z-index: 98; pointer-events: none; background: radial-gradient(circle at 50% 30%, #fff6e0, rgba(255,178,30,.6) 30%, transparent 70%); opacity: 0; }
.ae-flash.go { animation: aeFlash .9s ease-out both; }
@keyframes aeFlash { 0% { opacity: 0; } 12% { opacity: .9; } 100% { opacity: 0; } }

/* ---------- Cinematic home entrance (after Enter, or ?entered=1) ---------- */
.ae-letterbox i { position: fixed; left: 0; right: 0; height: 13vh; background: #080b1a; z-index: 97; pointer-events: none; transition: transform 1.1s var(--ae-snap) 1.1s; }
.ae-letterbox i:first-child { top: 0; } .ae-letterbox i:last-child { bottom: 0; }
body.ae-cine-done .ae-letterbox i:first-child { transform: translateY(-101%); }
body.ae-cine-done .ae-letterbox i:last-child { transform: translateY(101%); }
.ae-flare { /* anamorphic lens flare sweeping the logo */
  position: absolute; top: 46%; left: 0; width: 100%; height: 0; z-index: 3; pointer-events: none;
}
.ae-flare::before { content: ""; position: absolute; left: -10%; width: 120%; top: -1px; height: 2px; background: linear-gradient(90deg, transparent, rgba(120, 180, 255, .0) 10%, rgba(255, 210, 160, .9) 50%, transparent 90%); box-shadow: 0 0 18px 3px rgba(56,232,255,.6); opacity: 0; }
.ae-flare::after { content: ""; position: absolute; top: -60px; width: 120px; height: 120px; margin-left: -60px; left: 0; border-radius: 50%; background: radial-gradient(circle, #fff 0, rgba(255, 220, 160, .9) 12%, rgba(255,178,30,.35) 35%, transparent 68%); opacity: 0; }
body.ae-cine .ae-flare::before { animation: aeFlareLine 1.8s ease-out .5s both; }
body.ae-cine .ae-flare::after { animation: aeFlareBall 1.8s var(--ae-snap) .5s both; }
@keyframes aeFlareLine { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
@keyframes aeFlareBall { 0% { left: -5%; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: 105%; opacity: 0; } }
body.ae-cine .logo { animation: aeLogoIn 1.6s var(--ae-ease) .2s both; }
body.ae-cine .logo-kicker { animation: aeRise 1s var(--ae-ease) .9s both; }
body.ae-cine .hero-art { animation: aeArtIn 1.8s var(--ae-ease) .5s both; }
@keyframes aeLogoIn { 0% { opacity: 0; letter-spacing: .5em; filter: blur(14px) brightness(3); transform: scale(1.25); } 60% { filter: blur(0) brightness(1.6); } 100% { opacity: 1; letter-spacing: normal; filter: none; transform: none; } }
@keyframes aeArtIn { from { opacity: 0; transform: scale(1.18) translate3d(0, 30px, 0); filter: brightness(2.4) blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.ae-shock { position: absolute; left: 50%; top: 40%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; border: 2px solid rgba(255, 200, 140, .9); box-shadow: 0 0 30px rgba(255,178,30,.8), inset 0 0 20px rgba(255,178,30,.6); opacity: 0; pointer-events: none; z-index: 3; }
body.ae-cine .ae-shock { animation: aeShock 1.4s cubic-bezier(.1, .7, .2, 1) 1.15s both; }
@keyframes aeShock { 0% { opacity: 1; transform: scale(.2); } 100% { opacity: 0; transform: scale(18); } }

/* ---------- Back bar + buttons ---------- */
html.aefx .btn-back { font-family: var(--font-hud); font-weight: 700; letter-spacing: .26em; clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px); padding: .6rem 1.1rem; }
html.aefx .btn-fan { font-family: var(--font-hud); font-weight: 700; letter-spacing: .14em; }

/* ---------- Modals: book window + lightbox ---------- */
html.aefx .book-modal { transition: opacity .35s ease, visibility .45s; }
html.aefx .book-modal-backdrop { background: radial-gradient(ellipse at 50% 100%, rgba(22,40,79,.55), rgba(5,7,16,.9) 70%); }
html.aefx .book-modal-panel {
  border-radius: 4px 4px 0 0; border-color: var(--ae-edge);
  transform: translate3d(0, 60px, 0) scale(.94); clip-path: inset(45% 0 45% 0); filter: brightness(2);
  transition: transform .7s var(--ae-ease), clip-path .6s var(--ae-ease), filter .7s ease;
}
html.aefx .book-modal.is-open .book-modal-panel { transform: none; clip-path: inset(-30px -30px 0 -30px); filter: none; }
html.aefx .book-modal:not(.is-open) .book-modal-panel { transition-duration: .3s, .3s, .3s; transition-timing-function: var(--ae-snap); }
html.aefx .book-modal-title { font-family: var(--font-head); font-weight: 900; letter-spacing: .04em; }
html.aefx .book-modal-desc { font-family: var(--font-body); font-size: 1.05rem; line-height: 1.75; color: #dfe6ff; }
html.aefx .book-modal.is-open .book-modal-coverwrap { animation: aeArtIn .9s var(--ae-ease) .2s both; }
html.aefx .book-modal.is-open .book-modal-meta > * { animation: aeRise .7s var(--ae-ease) both; animation-delay: .3s; }
html.aefx .lightbox { background: radial-gradient(ellipse at 50% 50%, rgba(60, 8, 0, .85), rgba(5,7,16,.95) 70%); transition: opacity .35s ease, visibility .35s; }
html.aefx .lightbox-figure { transform: scale(.86) rotateX(14deg); opacity: 0; filter: brightness(2.2) blur(6px); transition: transform .7s var(--ae-ease), opacity .4s, filter .6s; }
html.aefx .lightbox.is-open .lightbox-figure { transform: none; opacity: 1; filter: none; }
html.aefx .album-view.ae-open .album-inner { animation: aeWinOpen .9s var(--ae-ease) both; }
@media (min-width: 700px) {
  html.aefx .book-modal-panel { border-radius: 4px; border-bottom: 1px solid var(--ae-edge); }
}

/* ---------- Phone budget ---------- */
@media (max-width: 700px) {
  .ae-rays, .ae-grain { display: none; } /* phone budget: no full-screen overlays */
  html.aefx .bg-image { animation: none; }
  .ae-tag { font-size: .54rem; top: 7px; left: 10px; letter-spacing: .2em; }
  html.aefx .section h2.ae-kin { letter-spacing: .08em; }
  .ae-c { width: 16px; height: 16px; }
}

/* ---------- Reduced motion: everything visible, nothing moves ---------- */
@media (prefers-reduced-motion: reduce) {
  .ae-rays, .ae-grain, .ae-bokeh, .ae-letterbox, .ae-wipe, .ae-flash, .ae-flare, .ae-shock, .ae-boot { display: none !important; }
  .ae-ch { opacity: 1 !important; transform: none !important; filter: none !important; }
  html.aefx .ae-win.ae-pending { opacity: 1; }
  html.aefx .intro .btn-enter { opacity: 1; transform: none; }
  html.aefx .book-modal-panel, html.aefx .lightbox-figure { transform: none; clip-path: none; filter: none; opacity: 1; }
}
