/**
 * About page — Why we built Blok scroll-fall graph.
 *
 * Scoped styles for the .sfg (Scroll Fall Graph) split comparison:
 *   Left  — muted geometric shapes tumbling into a chaotic pile.
 *   Right — brand-gradient pixel bloks snapping into a 4×4 larger Block.
 *
 * Layout mirrors .blok-difference (1fr auto 1fr grid with "vs" badge).
 * Motion is scroll-driven via assets/js/scroll-fall-graph.js — CSS only
 * handles the breathing glow on landed bloks + the ambient orbs.
 *
 * Enqueued only on is_page_template( 'template-about.php' ).
 */

/* =====================================================================
   WRAPPER
   ===================================================================== */
.sfg {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: var(--sp-6);
    box-sizing: border-box;
    isolation: isolate;
}

/* =====================================================================
   AMBIENT ORBS (decorative background)
   ===================================================================== */
.sfg__bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.sfg__orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(56px);
    opacity: 0.45;
    animation: sfg-orb 14s ease-in-out infinite alternate;
}

.sfg__orb--purple {
    width: 220px;
    height: 220px;
    left: 2%;
    top: 6%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.50), transparent 70%);
}

.sfg__orb--pink {
    width: 200px;
    height: 200px;
    right: 4%;
    top: 2%;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.40), transparent 70%);
    animation-delay: -4s;
}

.sfg__orb--orange {
    width: 180px;
    height: 180px;
    left: 45%;
    bottom: -8%;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.35), transparent 70%);
    animation-delay: -8s;
}

@keyframes sfg-orb {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(16px, -12px, 0) scale(1.12); }
}

/* =====================================================================
   SPLIT GRID — 1fr auto 1fr with "vs" badge (mirrors .blok-difference)
   ===================================================================== */
.sfg__grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--sp-4);
    align-items: stretch;
}

@media (max-width: 880px) {
    .sfg__grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   HALVES — left (sad) vs. right (happy)
   ===================================================================== */
.sfg__half {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    border-radius: var(--r-xl);
    padding: var(--sp-4);
    border: 1px solid var(--color-border-soft);
}

.sfg__half--left {
    background: linear-gradient(180deg,
        rgba(74, 74, 88, 0.04) 0%,
        rgba(74, 74, 88, 0.10) 100%);
}

.sfg__half--right {
    background: linear-gradient(135deg,
        rgba(139, 92, 246, 0.10) 0%,
        rgba(249, 115, 22, 0.08) 100%);
    border-color: rgba(236, 72, 153, 0.25);
    position: relative;
}

/* Gradient border ring on the right half (happy side) — reuses blok-difference pattern */
.sfg__half--right::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: var(--grad-brand);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* =====================================================================
   LABELS
   ===================================================================== */
.sfg__label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px 14px;
    border-radius: var(--r-full);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    align-self: flex-start;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.sfg__label--left {
    background: rgba(74, 74, 88, 0.12);
    border: 1px solid var(--color-border-soft);
    color: var(--color-text-muted);
}

.sfg__label--right {
    background: var(--color-bg-glass);
    border: 1px solid rgba(236, 72, 153, 0.25);
    color: var(--color-purple-300);
}

.sfg__label-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.sfg__label--left .sfg__label-icon { color: var(--color-danger); }
.sfg__label--right .sfg__label-icon { color: var(--color-success); }

/* =====================================================================
   "VS" BADGE — reuses .blok-difference__vs styling
   ===================================================================== */
.sfg__vs {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    min-width: 32px;
}

@media (max-width: 880px) {
    .sfg__vs { padding: var(--sp-1) 0; }
}

/* =====================================================================
   STAGES — the falling area in each half
   ===================================================================== */
.sfg__stage {
    position: relative;
    height: 280px;
    overflow: hidden;
    border-radius: var(--r-lg);
}

.sfg__stage--left {
    /* Cool/desaturated — "sad" mood. Subtle pile zone at the bottom. */
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(74, 74, 88, 0.06) 70%,
        rgba(74, 74, 88, 0.12) 100%);
}

.sfg__stage--right {
    /* Warm/brand — "happy" mood. Faint grid landing zone. */
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(139, 92, 246, 0.04) 60%,
        rgba(139, 92, 246, 0.08) 100%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

/* Subtle ground line on both stages */
.sfg__stage::after {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 12%;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--color-border-soft) 50%,
        transparent 100%);
    pointer-events: none;
}

/* =====================================================================
   FALLING ITEMS — base styles
   ===================================================================== */
.sfg-item {
    will-change: transform;
    /* JS sets: transform: translate(x,y) rotate(deg); */
}

.sfg-item__svg {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* LEFT shapes — absolutely positioned (final heap position via inline style) */
.sfg-item--shape {
    position: absolute;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
}

/* RIGHT bloks — CSS Grid handles final position; transform offsets from there */
.sfg__grid-bloks {
    --sfg-blok-size: 30px;
    display: grid;
    grid-template-columns: repeat(4, var(--sfg-blok-size));
    grid-template-rows: repeat(4, var(--sfg-blok-size));
    gap: 3px;
    position: relative;
    z-index: 1;
    margin-bottom: 16px;
}

.sfg-item--blok {
    width: var(--sfg-blok-size);
    height: var(--sfg-blok-size);
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.40));
}

/* Breathing glow on landed bloks — "alive/happy" feel.
   The inner <g> gets this animation. Only runs when bloks are in place
   (JS adds .is-landed to the stage when progress >= 1). */
.sfg-blok__inner {
    transform-box: fill-box;
    transform-origin: 50% 50%;
}

.sfg__stage--right.is-landed .sfg-blok__inner {
    animation: sfg-breathe 4s ease-in-out infinite;
}

@keyframes sfg-breathe {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.88; }
}

/* =====================================================================
   OFFSCREEN — pause animations when graph is scrolled out of view
   ===================================================================== */
.sfg.is-offscreen .sfg__orb,
.sfg.is-offscreen .sfg__stage--right.is-landed .sfg-blok__inner {
    animation-play-state: paused;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 880px) {
    /* Let the visual container grow to fit the stacked split — mirrors
       the .blok-story__visual--interactive pattern from team-walk.css.
       Desktop aspect-ratio (1.1/1) is preserved above 880px. */
    .blok-story__visual--auto-height {
        aspect-ratio: auto;
        align-items: stretch;
        justify-content: stretch;
    }

    .sfg__stage { height: 200px; }
    .sfg__grid-bloks { --sfg-blok-size: 26px; gap: 2px; }
    .sfg__half { padding: var(--sp-3); }
    .sfg__grid { gap: var(--sp-3); }
}

@media (max-width: 540px) {
    .sfg { padding: var(--sp-3); }
    .sfg__stage { height: 140px; }
    .sfg__grid-bloks { --sfg-blok-size: 20px; gap: 2px; margin-bottom: 8px; }
    .sfg__label { font-size: 0.7rem; padding: 4px 8px; }
    .sfg__half { padding: var(--sp-2); }
    .sfg__vs { padding: var(--sp-1) 0; font-size: var(--fs-xs); }
}

/* =====================================================================
   REDUCED MOTION — orbs freeze, breathing freezes, items snap landed.
   JS detects reduced-motion and sets all items to their final positions
   without attaching scroll listeners. The static composition still tells
   the story: chaotic pile vs. clean 4×4 Block.
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
    .sfg__orb { animation: none; }
    .sfg__stage--right.is-landed .sfg-blok__inner { animation: none; }
}
