/* ============================================================================
   POLISH LAYER (Phase 3)
   ----------------------------------------------------------------------------
   Theme-specific spotlight entrance animations, brass sextant custom
   cursor over the products section, DrawSVG threat-tape section
   dividers, and split-text wordmark reveals.

   Kept in a separate file so the core theme/spotlight CSS stays
   maintainable. Loaded last so its rules win the cascade.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1) SPOTLIGHT THEME ENTRANCES
   ----------------------------------------------------------------------------
   When a spotlight card becomes .is-active, its h3 wordmark gets a
   theme-specific reveal animation on top of the base slide-in transition.
   Animations are applied only while the entrance class is present —
   the JS adds + removes a one-shot class via setTimeout. */

/* Base wordmark reveal — applies to themes without a custom entrance.
   Cascading character entry without per-character JS. */
.spotlight__card.is-active h3 {
    animation: spotlight-wordmark-base 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}

@keyframes spotlight-wordmark-base {
    0%   { opacity: 0; transform: translateY(20px) scale(0.96); letter-spacing: 0.2em; filter: blur(6px); }
    50%  { opacity: 1; filter: blur(0); }
    100% { opacity: 1; transform: translateY(0) scale(1); letter-spacing: normal; filter: blur(0); }
}

/* --- Recon: CRT scanline reveal + phosphor flicker --------------------- */
.spotlight__card.is-active.theme-recon h3 {
    animation: recon-crt-reveal 1.1s steps(8, end) backwards;
    position: relative;
}

@keyframes recon-crt-reveal {
    0%   { opacity: 0; clip-path: inset(0 0 100% 0); filter: hue-rotate(90deg) brightness(0.6); }
    20%  { opacity: 1; clip-path: inset(45% 0 45% 0); filter: brightness(2.2); }
    24%  { opacity: 0.6; }
    28%  { opacity: 1; }
    32%  { opacity: 0.7; }
    40%  { clip-path: inset(0 0 0 0); filter: brightness(1); }
    100% { opacity: 1; clip-path: inset(0); filter: brightness(1); text-shadow: 0 0 18px rgba(0,255,102,0.45); }
}

/* --- IQualify: paper page-turn (3D rotateY) ---------------------------- */
.spotlight__card.is-active.theme-iqualify h3 {
    transform-origin: left center;
    animation: iqualify-page-turn 1.1s cubic-bezier(0.4, 0.0, 0.2, 1) backwards;
}

@keyframes iqualify-page-turn {
    0%   { opacity: 0; transform: perspective(800px) rotateY(-92deg); }
    60%  { opacity: 1; }
    100% { opacity: 1; transform: perspective(800px) rotateY(0deg); }
}

/* --- D20 Craps: dice-roll bounce --------------------------------------- */
.spotlight__card.is-active.theme-d20craps h3 {
    animation: d20-dice-roll 1.1s cubic-bezier(0.3, 1.4, 0.5, 1) backwards;
    transform-origin: center;
}

@keyframes d20-dice-roll {
    0%   { opacity: 0; transform: rotate(-360deg) scale(0.3); }
    50%  { opacity: 1; transform: rotate(-30deg) scale(1.12); }
    75%  { transform: rotate(8deg) scale(0.96); }
    100% { transform: rotate(0deg) scale(1); }
}

/* --- Drifter: HUD radar sweep ------------------------------------------ */
.spotlight__card.is-active.theme-drifter h3 {
    animation: drifter-radar-sweep 1.1s ease-out backwards;
    background-image: linear-gradient(
        90deg,
        transparent 0,
        transparent 40%,
        var(--pt-accent, #5fc1ff) 50%,
        transparent 60%,
        transparent 100%
    );
    background-size: 250% 100%;
    background-clip: text;
    -webkit-background-clip: text;
}

@keyframes drifter-radar-sweep {
    0%   { opacity: 0; background-position: 200% 0; letter-spacing: 0.18em; }
    40%  { opacity: 1; background-position: 100% 0; letter-spacing: 0.1em; }
    100% { opacity: 1; background-position: 0% 0; letter-spacing: 0.05em; }
}

/* --- SourceIQ: phosphor scan bar reveal -------------------------------- */
.spotlight__card.is-active.theme-sourceiq h3 {
    animation: sourceiq-phosphor-scan 1s cubic-bezier(0.4, 0.0, 0.2, 1) backwards;
    position: relative;
}

@keyframes sourceiq-phosphor-scan {
    0%   { opacity: 0; clip-path: inset(0 100% 0 0); text-shadow: 0 0 0 transparent; }
    50%  { text-shadow: 0 0 22px rgba(0, 255, 136, 0.6), 0 0 8px rgba(0, 255, 136, 0.8); }
    100% { opacity: 1; clip-path: inset(0); text-shadow: 0 0 10px rgba(0, 255, 136, 0.3); }
}

/* --- EDD-i: terminal type-out (clip-path L→R) -------------------------- */
.spotlight__card.is-active.theme-eddi h3 {
    animation: eddi-terminal-type 1.2s steps(20, end) backwards;
}

@keyframes eddi-terminal-type {
    0%   { opacity: 0; clip-path: inset(0 100% 0 0); }
    100% { opacity: 1; clip-path: inset(0); }
}

/* --- Ostraq: ledger-stamp slam ----------------------------------------- */
.spotlight__card.is-active.theme-ostraq h3 {
    animation: ostraq-stamp-slam 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

@keyframes ostraq-stamp-slam {
    0%   { opacity: 0; transform: scale(1.6) translateY(-30px); filter: blur(8px); }
    60%  { opacity: 1; filter: blur(0); }
    100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

/* --- ConManagement: spotlight iris-open --------------------------------- */
.spotlight__card.is-active.theme-conmgmt h3 {
    animation: conmgmt-iris-open 1s cubic-bezier(0.4, 0.0, 0.2, 1) backwards;
    -webkit-mask: radial-gradient(circle at center, #000 0%, #000 var(--iris, 100%), transparent calc(var(--iris, 100%) + 1%));
            mask: radial-gradient(circle at center, #000 0%, #000 var(--iris, 100%), transparent calc(var(--iris, 100%) + 1%));
}

@keyframes conmgmt-iris-open {
    0%   { opacity: 0; --iris: 0%; }
    100% { opacity: 1; --iris: 110%; }
}

/* --- Roc: blood drip rise from below ----------------------------------- */
.spotlight__card.is-active.theme-roc h3 {
    animation: roc-blood-rise 1.1s cubic-bezier(0.4, 0.0, 0.2, 1) backwards;
}

@keyframes roc-blood-rise {
    0%   { opacity: 0; transform: translateY(60px) scale(0.85); color: var(--pt-accent-2, #a01828); filter: drop-shadow(0 0 22px rgba(160, 24, 40, 0.7)); }
    60%  { opacity: 1; }
    100% { opacity: 1; transform: translateY(0) scale(1); color: var(--pt-accent-4, #d8b4fe); filter: drop-shadow(0 0 18px rgba(168, 85, 247, 0.4)); }
}

/* --- Trench Defense: stencil-spray reveal ------------------------------ */
.spotlight__card.is-active.theme-trench h3 {
    animation: trench-stencil-spray 0.8s cubic-bezier(0.5, 0, 0.5, 1) backwards;
    text-shadow:
        2px 0 0 rgba(184, 163, 120, 0.4),
        -2px 0 0 rgba(184, 163, 120, 0.4),
        0 2px 0 rgba(184, 163, 120, 0.4);
}

@keyframes trench-stencil-spray {
    0%   { opacity: 0; filter: blur(8px) contrast(0.3); transform: scale(1.05); }
    30%  { opacity: 0.6; filter: blur(3px) contrast(0.7); }
    60%  { opacity: 0.9; filter: blur(1px) contrast(1.1); }
    100% { opacity: 1; filter: blur(0) contrast(1); transform: scale(1); }
}

/* Reduced motion overrides everything */
@media (prefers-reduced-motion: reduce) {
    .spotlight__card.is-active h3,
    .spotlight__card.is-active.theme-recon h3,
    .spotlight__card.is-active.theme-iqualify h3,
    .spotlight__card.is-active.theme-d20craps h3,
    .spotlight__card.is-active.theme-drifter h3,
    .spotlight__card.is-active.theme-sourceiq h3,
    .spotlight__card.is-active.theme-eddi h3,
    .spotlight__card.is-active.theme-ostraq h3,
    .spotlight__card.is-active.theme-conmgmt h3,
    .spotlight__card.is-active.theme-roc h3,
    .spotlight__card.is-active.theme-trench h3 {
        animation: none !important;
    }
}

/* ----------------------------------------------------------------------------
   2) BRASS SEXTANT CURSOR over the products section
   ----------------------------------------------------------------------------
   Hide the native cursor when inside .individual-products. A JS-controlled
   #cursor-sextant element follows the mouse via transform translate3d.
   Its color shifts to the hovered theme's accent (CSS custom property
   --sextant-accent set by JS on hover). Mobile/touch users get no cursor
   (we leave the native one) — only desktop pointer-fine devices opt in. */

@media (pointer: fine) {
    .individual-products,
    .individual-products * {
        cursor: none;
    }

    /* Links + buttons inside the section still need a visual affordance —
       we'll express it via the sextant cursor's color shift, but also
       ensure focus rings still work for keyboard users. */
    .individual-products a:focus-visible,
    .individual-products button:focus-visible {
        outline: 2px solid var(--tt-caution, #fac638);
        outline-offset: 3px;
    }
}

.sextant-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    transform: translate3d(-100px, -100px, 0);
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.05s linear;
    color: var(--sextant-accent, #fac638);
}

.sextant-cursor.is-visible {
    opacity: 1;
}

.sextant-cursor svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 8px currentColor) drop-shadow(0 2px 4px rgba(0,0,0,0.6));
    transition: transform 0.3s ease;
}

.sextant-cursor.is-pointer svg {
    transform: scale(1.25);
}

/* Hide on touch / coarse pointer */
@media (pointer: coarse), (hover: none) {
    .sextant-cursor { display: none; }
    .individual-products,
    .individual-products * { cursor: auto !important; }
}

/* ----------------------------------------------------------------------------
   3) DRAWSVG THREAT-TAPE SECTION DIVIDERS
   ----------------------------------------------------------------------------
   A thin yellow/black stripe drawn left-to-right on scroll-into-view.
   Used between major page sections. The "draw" is achieved via a clip-path
   inset animation triggered when the .is-drawn class is added by JS. */

.tape-rule {
    position: relative;
    height: 18px;
    margin: 0;
    overflow: hidden;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 1.4s cubic-bezier(0.7, 0, 0.3, 1);
    background-image: repeating-linear-gradient(
        -45deg,
        #fac638 0,
        #fac638 14px,
        #0a0908 14px,
        #0a0908 28px
    );
    border-top: 1px solid rgba(250, 198, 56, 0.6);
    border-bottom: 1px solid rgba(250, 198, 56, 0.6);
}

.tape-rule::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.18) 50%, transparent 100%);
}

.tape-rule.is-drawn {
    clip-path: inset(0 0 0 0);
}

@media (prefers-reduced-motion: reduce) {
    .tape-rule {
        clip-path: inset(0);
        transition: none;
    }
}

/* ----------------------------------------------------------------------------
   4) TYPEWRITER on hero tagline
   ----------------------------------------------------------------------------
   JS hides the original text, then types it back out one char at a time.
   The blinking caret is CSS. */

.typewriter {
    display: inline;
    white-space: pre-wrap;
}

.typewriter__caret {
    display: inline-block;
    width: 0.55ch;
    margin-left: 1px;
    background: currentColor;
    height: 1em;
    vertical-align: -0.18em;
    animation: typewriter-blink 1s steps(1) infinite;
}

@keyframes typewriter-blink {
    0%, 50%   { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ----------------------------------------------------------------------------
   5) SPLIT-TEXT wordmark cascade on scroll-into-view
   ----------------------------------------------------------------------------
   JS wraps each character of card h3 wordmarks in <span class="char">N</span>
   then sets staggered animation-delays via inline style. CSS handles the
   actual character animation. */

.featured-card h3 .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(14px) rotate(-6deg);
    transition:
        opacity 0.45s cubic-bezier(0.2, 0.7, 0.2, 1),
        transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.featured-card.is-in-view h3 .char {
    opacity: 1;
    transform: translateY(0) rotate(0);
}

/* Preserve whitespace tokens between word fragments */
.featured-card h3 .char-space {
    display: inline-block;
    width: 0.28em;
}

@media (prefers-reduced-motion: reduce) {
    .featured-card h3 .char {
        opacity: 1 !important;
        transform: none !important;
    }
}
