/* =============================================================================
 * pages/why-tahfiz-abroad.css — visual layer for the persuasion page.
 *
 * Three additions on top of the existing layout/utilities:
 *
 *   1. .why-pattern — a faint Islamic-geometric overlay on the two ice-mist
 *      sections (S2 "A proven method" and S4 "A path that continues"). The
 *      pattern SVG lives at /assets/img/why-pattern.svg and is used as a
 *      CSS mask; the visible colour comes from a palette token via
 *      color-mix, so the pattern inherits the site's palette. The overlay
 *      composes the SVG mask with a diagonal gradient fade — the pattern
 *      reads as a quiet corner texture, not a busy wallpaper.
 *
 *   2. .why-blob — one soft, blurred radial-gradient blob in S2 that
 *      drifts slowly on scroll (driven by js/pages/why-tahfiz-abroad.js).
 *      pointer-events: none, sits behind content; pure decoration.
 *
 *   3. .why-row--photo-left — modifier on .grid--2-col that swaps the
 *      visual order on desktop only (photo first, text second) while
 *      preserving DOM order (text-first) for mobile + accessibility.
 *      Used in S3 for visual asymmetry against S2 + S4.
 *
 * Tone constraint: the audience is anxious parents — everything here is
 * subtle. Pattern opacity 5%, motion 80px drift with 1.5s smoothing,
 * reduced-motion fully kills the JS effect and hides the blob via CSS.
 *
 * Hex audit: zero hex literals. All colour is via palette tokens +
 * color-mix(). The SVG mask source uses stroke="black" (CSS keyword) but
 * only its alpha reaches the page — the visible colour is set here via
 * background-color on the masked layer.
 *
 * Tuning notes (single source of truth):
 *   - Pattern opacity:    .why-pattern::before { opacity: 0.05 }  → try 0.03–0.06
 *   - Pattern density:    mask-size: 120px 120px                  → smaller = denser
 *   - Pattern coverage:   linear-gradient(... transparent 70%)    → bigger % = more visible area
 *   - Blob tint depth:    var(--color-accent) 25%                 → 0–40%
 *   - Blob blur amount:   filter: blur(60px)
 *   - Motion distance:    see js/pages/why-tahfiz-abroad.js (y: 80)
 *   - Motion smoothing:   see js/pages/why-tahfiz-abroad.js (scrub: 1.5)
 * =========================================================================== */


/* -- Pattern overlay ------------------------------------------------------- */

.why-pattern {
    position: relative;
    overflow: hidden;       /* clip pattern + blob to the section's bounds */
    isolation: isolate;     /* fresh stacking context for layered fx */
}

.why-pattern::before {
    content: "";
    position: absolute;
    inset: 0;

    /* The visible colour comes from background-color (a palette token).
       The SVG mask shapes it into the geometric pattern; the gradient
       second mask fades the pattern out diagonally. */
    background-color: var(--color-primary);

    /* Compose: pattern (repeat) × gradient (no-repeat, fade) via intersect. */
    -webkit-mask-image:
        url("../../img/why-pattern.svg"),
        linear-gradient(to bottom left, black 0%, transparent 70%);
    -webkit-mask-size: 120px 120px, 100% 100%;
    -webkit-mask-repeat: repeat, no-repeat;
    -webkit-mask-position: 0 0, 0 0;
    -webkit-mask-composite: source-in;

    mask-image:
        url("../../img/why-pattern.svg"),
        linear-gradient(to bottom left, black 0%, transparent 70%);
    mask-size: 120px 120px, 100% 100%;
    mask-repeat: repeat, no-repeat;
    mask-position: 0 0, 0 0;
    mask-composite: intersect;

    opacity: 0.05;          /* subtle texture, not foreground */
    pointer-events: none;
    z-index: 0;
}

/* Ensure section content (the .container) sits above the ::before overlay. */
.why-pattern > .container {
    position: relative;
    z-index: 1;
}


/* -- Decorative blob ------------------------------------------------------- */
/*
   Sits as a direct child of the .why-pattern section, ABOVE its ::before
   pattern (which is z-index: 0) but BELOW the .container content
   (z-index: 1). The blob's halo extends past the visible edge via the
   negative top/right offsets, giving the impression of light coming from
   beyond the section frame.
*/

.why-blob {
    position: absolute;
    top: -120px;
    right: -120px;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        color-mix(in srgb, var(--color-accent) 25%, transparent) 0%,
        transparent 70%
    );
    filter: blur(60px);
    pointer-events: none;
    z-index: 0;
    will-change: transform;     /* hint compositor; the JS animates transform only */
}


/* -- .why-row: heading+photo row for S2 and S3 ----------------------------- */
/*
   Page-scoped 2-column layout that pairs the H2+intro with a photo. Used at
   the top of S2 and S3 above their 3-up card grids.

   WHY NOT REUSE .grid--2-col DIRECTLY: the standard .grid--2-col activates
   2 columns at >=768px, but .grid--3-col only activates 3 columns at
   >=1024px. Reusing .grid--2-col on the heading row would produce a
   medium-width range (768-1023px) where the heading is half-width while
   the cards below are still stacked 1-column full-width — a visible
   "narrow heading, wide cards" mismatch.

   .why-row sidesteps this by keeping the heading row single-column UNTIL
   1024px — the same breakpoint at which the .grid--3-col below it
   becomes multi-column. So at every viewport width the heading row and
   the card grid below it share the same column structure (both 1-col
   under 1024px, both multi-col at 1024px+) and the same outer left edge
   at the container's content edge.

   .why-row--photo-left modifier: on desktop, swaps the visual order so
   the figure occupies the LEFT column and the text the RIGHT. DOM order
   stays text-first for mobile and screen-reader reading order. Used on
   S3 for visual asymmetry against S2 + S4 (which both have photo right).
*/

.why-row {
    display: grid;
    grid-template-columns: 1fr;     /* mobile + medium: stacked 1-col */
    gap: var(--space-7);
    align-items: center;
}

@media (min-width: 1024px) {
    .why-row {
        grid-template-columns: 1fr 1fr;     /* desktop: 2-col, synced with .grid--3-col */
    }

    .why-row--photo-left > figure {
        order: -1;                          /* photo jumps to col 1 visually */
    }
}


/* -- Reduced-motion safety net --------------------------------------------- */
/*
   The page JS already short-circuits on prefers-reduced-motion. This rule
   is belt-and-braces: if the JS fails to load or the user changed their
   preference mid-session, the blob is hidden via CSS so reduced-motion
   users never see the blurred halo. The pattern overlay is purely static
   and stays visible — it has no motion of its own.
*/

@media (prefers-reduced-motion: reduce) {
    .why-blob { display: none; }
}
