/* ========================================================================
 * how_section.css — RADICAL refresh #how (v1.0)
 *
 * Sticky-scroll scene-switcher: 3 vertically-stacked text rows on the left,
 * single sticky visualisation panel on the right that swaps between
 * 3 animated mini-scenes synced via IntersectionObserver.
 *
 * Scenes:
 *   1. typing-effect URL input → button highlight
 *   2. 6 horizontal animated bars (scan visualisation)
 *   3. big verdict number + verdict pill + particle burst
 *
 * Themes auto-work: only --accent / --accent-2 / --accent-3 / --bad
 * / --good / --warn / --surface / --text / --text-dim / --border / --muted.
 *
 * Mobile <=900px collapses to single column with simpler in-flow scenes;
 * mobile <=480px further reduces particle count / typing speed.
 * prefers-reduced-motion: reduce → all motion stops, scenes show final state.
 * ====================================================================== */

/* ---- Section base — override existing .section-how grid layout for #how */
.section-how.section-how--v2 {
    /* No additional inset; section is already padded by .section. */
    position: relative;
}
.section-how--v2 .section-title {
    margin-bottom: clamp(28px, 5vw, 56px);
}

/* ---- Sticky-scroll wrapper: 2 columns, sticky right, scrolling left -------
   Each .hxw-row reserves min-height ≈ 90vh so IntersectionObserver can
   reliably mark "active" while right column stays pinned. */
.hxw {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1.05fr;
    gap: clamp(24px, 5vw, 80px);
    align-items: start;
}

/* Left rail — vertically stacked text blocks; each row reserves viewport. */
.hxw-rail {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.hxw-row {
    min-height: 86vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(20px, 6vh, 80px) 0;
    position: relative;
    opacity: 0.4;
    transform: translateY(8px);
    transition: opacity .55s cubic-bezier(.4,.2,.2,1), transform .55s cubic-bezier(.4,.2,.2,1);
    will-change: opacity, transform;
}
.hxw-row.is-active {
    opacity: 1;
    transform: translateY(0);
}
/* Vertical indicator line on the left edge — thin progress mark of which
   scene is current. Mint-coloured for the active row. */
.hxw-row::before {
    content: "";
    position: absolute;
    left: -18px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 56px;
    border-radius: 2px;
    background: rgba(255,255,255,0.08);
    transition: background .35s ease, height .35s ease;
}
.hxw-row.is-active::before {
    background: linear-gradient(180deg, var(--accent), var(--accent-3));
    height: 86px;
    box-shadow: 0 0 16px rgba(var(--accent-3-rgb), 0.45);
}

.hxw-num {
    font: 800 13px/1 'Inter', system-ui, sans-serif;
    letter-spacing: 0.18em;
    color: var(--accent);
    text-transform: uppercase;
    margin: 0 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.hxw-num::after {
    content: "";
    width: 28px;
    height: 1.5px;
    background: linear-gradient(90deg, var(--accent), transparent);
    border-radius: 1px;
}
.hxw-title {
    font: 800 clamp(28px, 4.6vw, 48px)/1.08 'Inter', system-ui, sans-serif;
    letter-spacing: -0.025em;
    color: var(--text);
    margin: 0 0 14px;
}
.hxw-title .grad-text {
    background: var(--grad-hot);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}
.hxw-desc {
    font: 500 clamp(15px, 1.5vw, 18px)/1.55 'Inter', system-ui, sans-serif;
    color: var(--text-dim);
    margin: 0;
    max-width: 36ch;
}
.hxw-meta {
    margin-top: 18px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(var(--accent-3-rgb), 0.08);
    border: 1px solid rgba(var(--accent-3-rgb), 0.2);
    color: var(--accent-3);
    font: 600 12.5px/1 'Inter', system-ui, sans-serif;
    letter-spacing: 0.01em;
}
.hxw-meta-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-3);
    box-shadow: 0 0 0 4px rgba(var(--accent-3-rgb), 0.18);
    animation: hxwDotPulse 2s ease-in-out infinite;
}
@keyframes hxwDotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

/* ---- Right column: sticky viewport ---------------------------------------
   The sticky wrapper pins to viewport while the left scrolls past it.
   Inside we crossfade 3 absolutely-positioned scenes. */
.hxw-stage {
    position: sticky;
    top: 90px;
    height: 78vh;
    min-height: 460px;
    max-height: 720px;
    border-radius: 24px;
    overflow: hidden;
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(var(--accent-rgb), 0.06), transparent 70%),
        linear-gradient(180deg, rgba(20, 22, 30, 0.85) 0%, rgba(10, 12, 18, 0.92) 100%);
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow:
        0 30px 80px -30px rgba(0,0,0,0.7),
        inset 0 1px 0 rgba(255,255,255,0.04);
}

.hxw-scene {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(20px, 4vw, 48px);
    opacity: 0;
    transform: translateY(12px) scale(0.985);
    transition:
        opacity .42s cubic-bezier(.4,.2,.2,1),
        transform .55s cubic-bezier(.4,.2,.2,1);
    pointer-events: none;
    will-change: opacity, transform;
}
.hxw-scene.is-active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ================ SCENE 1: typing URL input ============================== */
.hxw-s1 {
    flex-direction: column;
    gap: 22px;
}
.hxw-s1-window {
    width: min(100%, 480px);
    background: linear-gradient(180deg, #0f1219 0%, #0a0c12 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 18px 60px -20px rgba(0,0,0,0.6);
}
.hxw-s1-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.025);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.hxw-s1-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
}
.hxw-s1-dot:nth-child(1) { background: rgba(var(--accent-2-rgb), 0.5); }
.hxw-s1-dot:nth-child(2) { background: rgba(var(--accent-rgb), 0.5); }
.hxw-s1-dot:nth-child(3) { background: rgba(var(--accent-3-rgb), 0.5); }
.hxw-s1-titlebar-text {
    margin-left: 10px;
    font: 500 11px/1 'JetBrains Mono', 'SF Mono', monospace;
    color: var(--text-dim);
    opacity: 0.55;
    letter-spacing: 0.04em;
}
.hxw-s1-body {
    padding: 22px 20px 20px;
    font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
}
.hxw-s1-label {
    font-size: 11px;
    color: var(--accent-3);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin: 0 0 10px;
    opacity: 0.75;
}
.hxw-s1-input {
    min-height: 36px;
    padding: 10px 14px;
    background: rgba(var(--accent-3-rgb), 0.04);
    border: 1px solid rgba(var(--accent-3-rgb), 0.2);
    border-radius: 10px;
    font: 500 14px/1.4 'JetBrains Mono', 'SF Mono', monospace;
    color: var(--accent-3);
    word-break: break-all;
    position: relative;
    transition: border-color .25s ease, box-shadow .25s ease;
}
.hxw-s1-input.is-typing {
    border-color: rgba(var(--accent-3-rgb), 0.4);
    box-shadow: 0 0 0 4px rgba(var(--accent-3-rgb), 0.08);
}
.hxw-s1-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--accent-3);
    margin-left: 1px;
    vertical-align: -2px;
    animation: hxwBlink 0.9s steps(2, end) infinite;
}
@keyframes hxwBlink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}
.hxw-s1-btn-row {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
}
.hxw-s1-btn {
    padding: 11px 22px;
    border-radius: 12px;
    font: 700 14px/1 'Inter', system-ui, sans-serif;
    background: var(--accent);
    color: #0a0c12;
    border: 0;
    cursor: default;
    letter-spacing: 0.01em;
    transition: transform .2s ease, box-shadow .25s ease;
    box-shadow: 0 6px 18px -6px rgba(var(--accent-rgb), 0.55);
}
.hxw-s1-btn.is-armed {
    transform: scale(1.04);
    box-shadow:
        0 0 0 4px rgba(var(--accent-rgb), 0.18),
        0 10px 28px -8px rgba(var(--accent-rgb), 0.65);
}
.hxw-s1-btn.is-clicked {
    transform: scale(0.96);
    transition: transform 0.12s ease;
}
.hxw-s1-hint {
    margin-top: 12px;
    font: 500 12px/1.4 'Inter', system-ui, sans-serif;
    color: var(--muted);
    text-align: center;
    opacity: 0;
    transition: opacity .35s ease;
}
.hxw-s1-hint.is-visible { opacity: 0.8; }

/* ================ SCENE 2: scanning bars ================================= */
.hxw-s2 {
    flex-direction: column;
    gap: 18px;
    align-items: stretch;
}
.hxw-s2-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 4px 4px;
}
.hxw-s2-title {
    font: 700 13px/1 'Inter', system-ui, sans-serif;
    color: var(--text);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.hxw-s2-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 8px;
    background: rgba(var(--accent-3-rgb), 0.08);
    border: 1px solid rgba(var(--accent-3-rgb), 0.2);
    border-radius: 999px;
    font: 600 11px/1 'JetBrains Mono', monospace;
    color: var(--accent-3);
}
.hxw-s2-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-3);
    animation: hxwDotPulse 1.2s ease-in-out infinite;
}
.hxw-s2-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
}
.hxw-s2-bar-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 6px;
}
.hxw-s2-bar-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    grid-column: 1 / -1;
    font: 500 12.5px/1.3 'Inter', system-ui, sans-serif;
    color: var(--text-dim);
}
.hxw-s2-bar-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.hxw-s2-bar-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-2);
    box-shadow: 0 0 8px var(--accent-2);
    opacity: 0;
    transition: opacity .25s ease;
}
.hxw-s2-bar-row.is-scanning .hxw-s2-bar-dot { opacity: 1; }
.hxw-s2-bar-val {
    font: 700 13px/1 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    min-width: 3ch;
    text-align: right;
}
.hxw-s2-bar-row.is-scanning .hxw-s2-bar-val { color: var(--accent-2); }
.hxw-s2-bar-track {
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    overflow: hidden;
    grid-column: 1 / -1;
    position: relative;
}
.hxw-s2-bar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 3px;
    transition: width 1s cubic-bezier(.65,0,.35,1);
    position: relative;
}
.hxw-s2-bar-fill::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 24px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    opacity: 0;
    transition: opacity .25s ease;
}
.hxw-s2-bar-row.is-scanning .hxw-s2-bar-fill::after { opacity: 1; animation: hxwShimmer 1.2s ease-in-out infinite; }
@keyframes hxwShimmer {
    0% { transform: translateX(-30px); }
    100% { transform: translateX(30px); }
}
.hxw-s2-counter {
    margin: 8px auto 0;
    font: 500 12px/1.4 'JetBrains Mono', monospace;
    color: var(--muted);
    text-align: center;
}
.hxw-s2-counter b {
    color: var(--accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ================ SCENE 3: verdict with particle burst =================== */
.hxw-s3 {
    flex-direction: column;
    gap: 26px;
    position: relative;
}
.hxw-s3-orbit {
    position: relative;
    width: clamp(220px, 30vw, 320px);
    height: clamp(220px, 30vw, 320px);
    display: grid;
    place-items: center;
}
.hxw-s3-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px dashed rgba(255,255,255,0.08);
    animation: hxwRotate 18s linear infinite;
}
.hxw-s3-ring--inner {
    inset: 18%;
    border-color: rgba(255,255,255,0.12);
    animation-duration: 12s;
    animation-direction: reverse;
}
@keyframes hxwRotate {
    to { transform: rotate(360deg); }
}
.hxw-s3-num {
    font: 900 clamp(72px, 11vw, 132px)/1 'Inter', system-ui, sans-serif;
    letter-spacing: -0.04em;
    background: var(--grad-hot);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    font-variant-numeric: tabular-nums;
    transition: transform .6s cubic-bezier(.34,1.56,.64,1);
    position: relative;
    z-index: 2;
}
.hxw-s3-num.is-good {
    background: linear-gradient(135deg, var(--good) 0%, var(--accent-3) 100%);
    background-clip: text;
    -webkit-background-clip: text;
}
.hxw-s3-num-suffix {
    font-size: 0.45em;
    font-weight: 700;
    margin-left: 4px;
    opacity: 0.85;
    vertical-align: 0.4em;
}
.hxw-s3-pill {
    padding: 11px 22px 11px 18px;
    border-radius: 999px;
    font: 700 14.5px/1 'Inter', system-ui, sans-serif;
    letter-spacing: 0.01em;
    background: linear-gradient(135deg, rgba(var(--accent-2-rgb), 0.16), rgba(var(--accent-2-rgb), 0.08));
    color: var(--bad);
    border: 1px solid rgba(var(--accent-2-rgb), 0.32);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 26px -10px rgba(var(--accent-2-rgb), 0.5);
    transition:
        background .4s ease,
        color .4s ease,
        border-color .4s ease,
        box-shadow .4s ease,
        transform .4s cubic-bezier(.34,1.56,.64,1);
}
.hxw-s3-pill::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 4px rgba(var(--accent-2-rgb), 0.18);
}
.hxw-s3-pill.is-good {
    background: linear-gradient(135deg, rgba(56, 224, 168, 0.16), rgba(56, 224, 168, 0.08));
    color: var(--good);
    border-color: rgba(56, 224, 168, 0.32);
    box-shadow: 0 8px 26px -10px rgba(56, 224, 168, 0.5);
}
.hxw-s3-pill.is-good::before {
    box-shadow: 0 0 0 4px rgba(56, 224, 168, 0.18);
}
.hxw-s3-pill.is-changing {
    transform: scale(0.92);
}
.hxw-s3-caption {
    font: 500 12.5px/1.4 'Inter', system-ui, sans-serif;
    color: var(--muted);
    text-align: center;
    max-width: 28ch;
    margin: 0;
}

/* Particle burst — radial 24 dots, staggered fly-out.
   Generated by JS on cycle-start. Pure CSS keyframe. */
.hxw-s3-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}
.hxw-s3-particle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    background: var(--accent);
    box-shadow: 0 0 12px currentColor, 0 0 24px currentColor;
    filter: blur(0.3px);
}
.hxw-s3-particle.is-firing {
    /* v0.26.2 polish: longer & more cinematic — 1.6s, easeOutExpo,
       fade gradient (mint→transparent) via opacity stepping. */
    animation: hxwParticle 1.6s cubic-bezier(.16,1,.3,1) forwards;
}
@keyframes hxwParticle {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) translate(0, 0) scale(0.25);
        filter: blur(0px) brightness(1.4);
    }
    12% {
        opacity: 1;
        transform: translate(-50%, -50%) translate(calc(var(--px, 0) * 0.18), calc(var(--py, 0) * 0.18)) scale(1);
        filter: blur(0px) brightness(1.4);
    }
    60% {
        opacity: 0.7;
        filter: blur(0.5px) brightness(1.05);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) translate(var(--px, 0), var(--py, 0)) scale(0.45);
        filter: blur(2px) brightness(0.85);
    }
}

/* ---- Mobile collapse (<=900px): single column, scenes stack in-flow ------- */
@media (max-width: 900px) {
    .hxw {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .hxw-row {
        min-height: auto;
        padding: 14px 0 22px;
        opacity: 1;
        transform: none;
    }
    .hxw-row::before { display: none; }
    .hxw-stage {
        position: relative !important;
        top: auto !important;
        height: clamp(360px, 80vw, 480px);
        min-height: 360px;
        max-height: 520px;
    }
    /* On mobile, scenes still crossfade but reside under each row OR rendered
       once in a sticky panel below — keep sticky-light: panel under each row. */
    .hxw-stage--mobile-after-row {
        margin: 14px 0 28px;
    }
    .hxw-row + .hxw-stage--mobile-after-row {
        margin-top: -6px;
    }
    .hxw-num { margin-bottom: 8px; }
    .hxw-title { font-size: clamp(24px, 6.5vw, 32px); }
    .hxw-desc { font-size: 15px; max-width: none; }
}
/* v0.25.96: 720 и уже — ещё меньше padding/H2 */
@media (max-width: 720px) {
    .hxw { gap: 14px; }
    .hxw-row { padding: 10px 0 18px; }
    .hxw-stage { height: clamp(300px, 76vw, 420px); min-height: 300px; }
    .hxw-title { font-size: clamp(22px, 6vw, 28px); margin: 0 0 10px; }
    .hxw-num { font-size: 12px; margin: 0 0 8px; }
    .hxw-desc { font-size: 14.5px; }
    .hxw-meta { margin-top: 12px; padding: 5px 11px; font-size: 12px; }
}
@media (max-width: 480px) {
    .hxw-s1-window { max-width: 100%; }
    .hxw-s1-input { font-size: 12.5px; }
    .hxw-s2-bars { gap: 9px; }
    .hxw-s2-bar-meta { font-size: 12px; }
    .hxw-s3-num { font-size: clamp(60px, 17vw, 90px); }
    .hxw-s3-pill { font-size: 13px; }
}

/* ---- Reduced motion: kill all transitions / animations ------------------- */
@media (prefers-reduced-motion: reduce) {
    .hxw-row,
    .hxw-scene,
    .hxw-s1-input,
    .hxw-s1-btn,
    .hxw-s2-bar-fill,
    .hxw-s3-num,
    .hxw-s3-pill,
    .hxw-s3-ring,
    .hxw-s3-particle,
    .hxw-meta-dot,
    .hxw-s2-status::before {
        transition: none !important;
        animation: none !important;
    }
    .hxw-row { opacity: 1; transform: none; }
    .hxw-scene { opacity: 0; transform: none; }
    .hxw-scene.is-active { opacity: 1; }
    .hxw-s1-caret { opacity: 1 !important; }
    .hxw-s2-bar-fill { width: var(--final-w, 50%) !important; }
}

/* ════════════════════════════════════════════════════════════════════════
 * WIDE-SCREEN POLISH (v0.26.x) — how-section wide-monitor polish.
 *
 * Цель: stage был capped clamp(360px, 50vw, 600px) — на 1920px viewport
 * получалось 600px, что выглядело маленьким относительно широкой
 * левой колонки с большим H3. Bump до 700 (1440+) / 800 (1720+).
 * Также bump padding/font scenes для крупных экранов.
 * ════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1100px) {
    .hxw-stage {
        height: 72vh;
        max-height: 720px;
        min-height: 520px;
    }
    .hxw-row {
        min-height: 80vh;
    }
    .hxw-title {
        font-size: clamp(32px, 4vw, 52px);
        margin: 0 0 16px;
    }
    .hxw-desc {
        font-size: 17px;
        max-width: 42ch;
    }
}

@media (min-width: 1440px) {
    .hxw-stage {
        height: 68vh;
        max-height: 760px;
        min-height: 560px;
        border-radius: 28px;
    }
    .hxw-row {
        min-height: 76vh;
    }
    .hxw-title {
        font-size: clamp(38px, 3.6vw, 60px);
        line-height: 1.05;
    }
    .hxw-desc {
        font-size: 18px;
        line-height: 1.6;
        max-width: 44ch;
    }
    .hxw-num {
        font-size: 14px;
    }
    .hxw-meta {
        font-size: 13.5px;
        padding: 7px 14px;
        margin-top: 22px;
    }

    /* Scene 3 verdict number — крупнее на широких */
    .hxw-s3-num {
        font-size: clamp(96px, 8vw, 140px);
    }
    .hxw-s3-pill {
        font-size: 16px;
        padding: 8px 18px;
    }
    .hxw-s3-caption {
        font-size: 15px;
    }

    /* Scene 1 typing window — крупнее */
    .hxw-s1-window {
        width: min(100%, 540px);
    }
    .hxw-s1-input {
        font-size: 16px;
    }
    .hxw-s1-btn {
        font-size: 16px;
        padding: 13px 22px;
    }

    /* Scene 2 scanning bars */
    .hxw-s2-head {
        margin-bottom: 18px;
    }
    .hxw-s2-title {
        font-size: 16px;
    }
}

@media (min-width: 1720px) {
    .hxw-stage {
        height: 64vh;
        max-height: 800px;
        min-height: 600px;
        border-radius: 32px;
    }
    .hxw-row {
        min-height: 72vh;
    }
    .hxw-title {
        font-size: clamp(44px, 3.2vw, 68px);
    }
    .hxw-desc {
        font-size: 19px;
        max-width: 46ch;
    }
    .hxw-s3-num {
        font-size: clamp(112px, 7vw, 160px);
    }
    .hxw-s1-window {
        width: min(100%, 600px);
    }
}

/* Wide-screen reduced motion stays in line */
@media (min-width: 1100px) and (prefers-reduced-motion: reduce) {
    .hxw-stage {
        animation: none !important;
    }
}

