/*
 Theme Name:   Bricks Child Theme
 Theme URI:    https://bricksbuilder.io/
 Description:  bricks-base child theme. Global styling only (base layer, header/footer/resnav, plugins); component CSS lives in the components.
 Author:       Fervent Digital
 Template:     bricks
 Version:      1.1
 Text Domain:  bricks
*/

/* ==========================================================================
   bricks-base: base layer
   - Colours, font sizes and radii come from the Global styles phase
     (palette variables + tools/fluid-scale.py font-size tokens, values taken from Figma).
     Spacing is rem with breakpoint overrides; only font sizes are fluid (clamp).
     Nothing here hardcodes a design value; fallbacks only keep things working.
   - Native CSS nesting (as on all agency sites).
   - Global styling only. Block-specific CSS lives in the component (element settings, or the root's
     Custom CSS with %root%), so it only loads on pages that use the block (docs/09).
   ========================================================================== */

/* --- Motion: agency standard easing for every CSS transition (also a Bricks global variable, docs/03).
       GSAP uses expo.inOut (docs/10). --- */

:root {
    --anim: cubic-bezier(.25, .46, .45, .94);
}

/* --- Accessibility basics (missing on all example sites) ------------------ */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--focus, currentColor);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.visually-hidden {
    /* overflow: hidden is the standard screen-reader pattern here (no visible effect); elsewhere use clip (docs/02) */
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Anchor targets clear the sticky header (native jump when Lenis is off) */
:target,
[id] {
    scroll-margin-top: calc(var(--header-height, 0px) + 2rem);
}

/* --- Lenis (official lenis.css, v1.3.26). Required: .lenis-stopped also blocks native touch
       scrolling on mobile while the resnav is open (resnav.js calls lenis.stop()) --- */

html.lenis,
html.lenis body {
    height: auto;
}

.lenis:not(.lenis-autoToggle).lenis-stopped {
    overflow: clip;
}

.lenis :is([data-lenis-prevent], [data-lenis-prevent-wheel], [data-lenis-prevent-touch], [data-lenis-prevent-vertical], [data-lenis-prevent-horizontal]) {
    overscroll-behavior: contain;
}

.lenis.lenis-smooth iframe {
    pointer-events: none;
}

.lenis.lenis-autoToggle {
    transition-property: overflow;
    transition-duration: 1ms;
    transition-behavior: allow-discrete;
}

/* --- Document ------------------------------------------------------------- */

body {
    &.bricks-is-frontend.admin-bar {
        #brx-header.brx-sticky,
        #brx-header [data-sticky] {
            top: var(--wp-admin--admin-bar--height);
        }
    }

    /* Bricks' offcanvas is hidden in the builder canvas otherwise */
    &[data-builder-window] .brxe-offcanvas {
        opacity: 100%;
    }
}

a {
    text-underline-position: from-font;

    &:not([href]) {
        cursor: auto;
    }
}

h1, h2, h3, h4, h5, h6, .brxe-heading {
    text-wrap: balance;
    overflow-wrap: break-word;
}

p {
    text-wrap: pretty;
}

/* Accent words: write them as <strong> in the heading text (01: script font, 02: gradient).
   Set --font-accent / --color-accent in the Global styles phase; without them strong stays bold. */
:is(h1, h2, h3, h4, h5, h6, .brxe-heading) :is(strong, b) {
    font-family: var(--font-accent, inherit);
    color: var(--color-accent, inherit);
}

mark {
    background: none;
    color: var(--color-mark, inherit);
}

/* --- Section modes (global classes .bg / .bg-alt, see docs/09) ------------ */

.bg {
    color: var(--text-on-light, inherit);
}

.bg-alt {
    color: var(--text-on-dark, inherit);
}

/* --- Rich text (Bricks text element) -------------------------------------- */

.brxe-text {
    > * + * {
        margin-top: 1.5rem;
    }

    ul,
    ol {
        margin: 0;
        padding-left: 1.25em;

        li + li {
            margin-top: 0.75rem;
        }

        li::marker {
            color: var(--list-marker, currentColor);
        }
    }

    a {
        text-decoration: underline;
    }
}

/* --- Buttons (theme style sets colours/padding; JS module buttons.js adds the spans) --- */

.bricks-button {
    min-height: var(--button-height, 3rem);
    transition: all var(--anim) 0.3s;

    &.sm {
        min-height: var(--button-height-sm, 2.5rem);
    }

    svg {
        flex-shrink: 0;

        path {
            transition: stroke var(--anim) 0.3s, fill var(--anim) 0.3s;
        }
    }

    /* Rolling text hover (01): .btn-text-container > .btn-text */
    &.bricks-background-primary,
    &.bricks-background-secondary {
        position: relative;
        overflow: clip;

        .btn-text-container {
            display: block;
            overflow: clip;
        }

        .btn-text {
            display: block;
            transition: transform var(--anim) 0.3s;
            text-shadow: 0 2.5em 0 currentColor;
        }

        &:hover .btn-text {
            transform: translateY(-2.5em);
        }
    }

    /* Split icon button (01 .btn-icon): text box + icon box */
    &.btn-icon {
        gap: 0.25rem;

        .btn-icon__icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            aspect-ratio: 1;
            height: 100%;
        }
    }
}

/* --- Link with arrow box (01 .link-arrow; two icons, one slides out, one in) --- */

.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;

    > .brxe-div,
    > .brxe-block {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: clip;
        transition: background-color var(--anim) 0.3s;

        > .brxe-icon {
            transition: transform var(--anim) 0.3s;

            &:last-child {
                position: absolute;
                transform: translateX(-200%);
            }
        }
    }

    &:hover > :is(.brxe-div, .brxe-block) > .brxe-icon {
        &:first-child {
            transform: translateX(200%);
        }

        &:last-child {
            transform: translateX(0);
        }
    }
}

/* --- Breadcrumbs (01: truncate long items, title added by JS if needed) --- */

.brxe-breadcrumbs .item {
    max-width: 22rem;
    overflow: clip;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color var(--anim) 0.3s;
}

/* --- Cards: article root, title is a link in a <p>, stretched over the card (docs/05, docs/09) --- */

article:has(.card__link) {
    position: relative;
}

.card__link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Other links/buttons in the card stay clickable and focusable above the stretched link */
article:has(.card__link) :is(a, button, summary, input, select, textarea):not(.card__link) {
    position: relative;
    z-index: 2;
}

/* --- FAQ / disclosure: native details + summary (docs/05) ------------------ */

details > summary {
    cursor: pointer;
    list-style: none;

    &::-webkit-details-marker {
        display: none;
    }

    /* a heading inside summary (question in the outline) keeps summary's layout */
    > :is(h2, h3, h4, h5, h6) {
        display: inline;
        margin: 0;
        font: inherit;
    }
}

/* --- Header states: native Bricks sticky header adds .scrolling (docs/09 "Sticky header") --- */

#brx-header {
    transition: background-color var(--anim) 0.3s, transform var(--anim) 0.3s, box-shadow var(--anim) 0.3s;

    &.scrolling {
        /* project-specific scrolled styles that the template's sticky settings can't express */
    }
}

/* --- Resnav: default mobile menu (01 pattern, docs/09 "Header and resnav", resnav.js) ---
   Header bar stays visible; one toggle opens and closes; the panel fades in below the bar.
   Tree: .header-bar > … > [data-resnav-toggle] (swap + Bricks Toggle) and
         Nav Nested > Offcanvas.resnav > .brx-offcanvas-inner > nav menu (+ button)
   Colours, radius, label text and icons come from the design (element settings). */

#brx-header {
    /* The bar is the containing block of the fixed panel: top/height below are relative to the bar */
    .header-bar {
        contain: layout;
    }

    /* Toggle: Bricks Toggle stretched over the visible button, so one element opens and closes */
    [data-resnav-toggle] {
        position: relative;
        cursor: pointer;

        > .brxe-toggle {
            position: absolute;
            inset: 0;
            z-index: 1;
            width: 100%;
            height: 100%;
            padding: 0;
            border: 0;
            background: none;

            /* hamburger off: the swap shows the state (remove when the design uses Bricks' own icon) */
            .brxa-wrap {
                display: none;
            }
        }
    }

    /* Swap: first child = closed state, last child = open state (labels "Menu"/"Sluit" or two icons) */
    .resnav-toggle__swap {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: clip;

        > * {
            transition: color var(--anim) 0.3s, transform var(--anim) 0.3s;
        }

        > :last-child {
            position: absolute;
            transform: translateY(-2.5em);
        }
    }

    [data-resnav-toggle]:is(.is-open, :has(> .brxe-toggle.is-active)) .resnav-toggle__swap {
        > :first-child {
            transform: translateY(2.5em);
        }

        > :last-child {
            transform: translateY(0);
        }
    }

    /* Panel: Offcanvas with class .resnav, opens below the bar (gap = --resnav-gap) */
    .resnav {
        --resnav-gap: 0.5rem;

        position: fixed;
        top: calc(100% + var(--resnav-gap));
        left: 0;
        width: 100%;
        height: calc((100svh - 100%) - var(--resnav-gap));
        max-height: calc((100svh - 100%) - var(--resnav-gap));
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--anim) 0.3s, visibility var(--anim) 0.3s;

        &.brx-open {
            opacity: 100%;
            pointer-events: auto;
        }

        .brx-offcanvas-inner {
            position: relative;
            overflow: visible;
            transform: none;
        }

        /* Sub levels (mega menu template in the mobile nav menu): panel over the menu, with a
           heading from data-title (resnav.js) and a [data-back] button in the template */
        .brxe-nav-menu .brx-has-megamenu {
            .brx-submenu-toggle button {
                display: none;
            }

            .brx-megamenu {
                top: calc(-1 * var(--resnav-pad-block, 2rem));
                left: calc(-1 * var(--resnav-pad-inline, 1.5rem)) !important;
                right: calc(-1 * var(--resnav-pad-inline, 1.5rem)) !important;
                width: unset;
                min-width: unset !important;

                .brx-submenu-toggle button {
                    display: none;
                }

                .bricks-nav-menu > .menu-item-has-children {
                    position: unset;

                    > .sub-menu {
                        position: absolute !important;
                        inset: 0 0 auto 0;
                        min-width: unset !important;
                        max-height: calc(100svh - var(--header-height, 0px));
                        padding: var(--resnav-pad-block, 2rem) var(--resnav-pad-inline, 1.5rem);
                        overflow: hidden auto; /* scroll panel: clip can't be combined with auto (docs/02) */
                        transition: opacity var(--anim) 0.3s, visibility var(--anim) 0.3s;

                        &::before {
                            content: attr(data-title);
                            display: block;
                            margin-bottom: 2rem;
                        }

                        /* third level is always open inside its panel */
                        > .menu-item > .sub-menu {
                            position: static;
                            opacity: 100%;
                            visibility: visible;
                            background: transparent;
                        }
                    }
                }
            }
        }
    }
}

body.bricks-is-frontend.admin-bar #brx-header .resnav {
    height: calc((100svh - 100%) - var(--resnav-gap) - var(--wp-admin--admin-bar--height, 0px));
    max-height: calc((100svh - 100%) - var(--resnav-gap) - var(--wp-admin--admin-bar--height, 0px));
}

/* Builder: show the panel so it can be edited */
body[data-builder-window] #brx-header .resnav {
    opacity: 100%;
    pointer-events: auto;
}

/* --- Native slider easing: Bricks' Nested Slider (Splide) sets its transition inline with its own curve;
       the agency easing wins here. Duration = the slider's "speed" setting (300 ms, docs/10). --- */

.brxe-slider-nested .splide__list,
.brxe-slider-nested .splide__slide {
    transition-timing-function: var(--anim) !important;
}

/* --- Sliders to the window edge (docs/09 "Sliders and marquees: edges") ---
   Global class .slider-bleed on the Nested Slider (or a marquee/scroll track) that sits inside the container.
   The slider keeps the container width (so Splide calculates the design's card widths), but its slides stay
   visible beyond it up to the window edge; the section cuts them off at the window (overflow-x: clip).
   A side that has content next to it (text column, image) is cut at the slider's own edge instead:
   add .slider-bleed--clip-start (cut on the left) or .slider-bleed--clip-end (cut on the right). */

.slider-bleed,
.slider-bleed .splide__track,
.slider-bleed .brxe-slider-nested {
    overflow: visible;
}

.slider-bleed--clip-start {
    clip-path: inset(-100vh -100vw -100vh 0);
}

.slider-bleed--clip-end {
    clip-path: inset(-100vh 0 -100vh -100vw);
}

/* cut off at the window edge, never a horizontal page scroll: only main and the section root clip
   (never the container or wrappers in between, or the slides would be cut at the container again) */
main:has(.slider-bleed),
main > :has(.slider-bleed) {
    overflow-x: clip;
}

/* --- Marquee (marquee.js, [data-marquee] on the loop wrapper) ------------- */

[data-marquee] {
    display: flex;
    flex-wrap: nowrap;
    width: max-content;

    > * {
        flex-shrink: 0;
        will-change: transform;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* No animation: let the row scroll instead */
    :has(> [data-marquee]) {
        overflow-x: auto;
    }
}

/* --- Gravity Forms (Orbital) base: keep accessibility features ------------ */

.gform_wrapper.gform-theme {
    --gf-color-primary: var(--color-primary, #000);
    --gf-ctrl-border-color: var(--border, currentColor);
    --gf-ctrl-label-color-primary: var(--text, inherit);
    --gf-radius: var(--radius-s, 0.25rem);

    /* Required legend and validation messages stay visible (all example sites hid them) */
    .gform_required_legend {
        font-size: var(--font-size-s, 0.875rem);
    }
}

/* ==========================================================================
   Project globals only (header/footer details, plugin styling, site-wide patterns).
   NOT component CSS: that goes in the component itself (docs/09 step 4).
   ========================================================================== */
