/* The styles the named behaviours need.

   In @layer haya-defaults with the rest of the product's defaults, so a
   site's own tokens and a page's own styles both win over them (CMS-L11 —
   and the reason that matters is that an unlayered rule beats a layered one
   whatever the load order, which cost this product a silently ignored font
   choice once already).

   Everything here is written so that the absence of the script leaves the
   page readable: the pending state is added by JavaScript, never by the
   server, so a section is visible unless something is actively animating
   it. */

@layer haya-defaults {
#storefront-navigation-progress:not([hidden]) {
    position: fixed;
    inset: 0 0 auto;
    block-size: 3px;
    z-index: 1001;
    pointer-events: none;
    overflow: hidden;
}

#storefront-navigation-progress::before {
    content: "";
    display: block;
    block-size: 100%;
    inline-size: 38%;
    background: var(--color-primary, #0077cc);
    animation: storefront-navigation-progress 950ms ease-in-out infinite alternate;
}

@keyframes storefront-navigation-progress {
    from { transform: translateX(0); }
    to { transform: translateX(164%); }
}

:dir(rtl) #storefront-navigation-progress::before {
    animation-direction: alternate-reverse;
    margin-inline-start: auto;
}

@media (prefers-reduced-motion: reduce) {
    #storefront-navigation-progress::before { animation: none; inline-size: 100%; }
}

    .pb-reveal-pending {
        opacity: 0;
        transform: translateY(12px);
    }

    .pb-reveal-done {
        opacity: 1;
        transform: none;
        transition: opacity 420ms ease-out, transform 420ms ease-out;
    }

    /* A reader who asked for less motion gets the content and none of the
       movement — the transition is the decoration, not the content. */
    @media (prefers-reduced-motion: reduce) {
        .pb-reveal-pending {
            opacity: 1;
            transform: none;
        }

        .pb-reveal-done {
            transition: none;
        }
    }

    .pb-sticky {
        position: sticky;
        inset-block-start: var(--pb-sticky-offset, 0);
        z-index: 5;
    }

    /* The rocket stage. The host becomes its own stacking context so the
       stage can sit behind the section's text (z-index -1) without dropping
       behind the section's background. The stage spans the whole section and
       takes no room; the pin inside it is what stays in view while the text
       scrolls past. Both classes are added by the script, so a page whose
       script never ran carries none of this. */
    .pb-rocket-host {
        position: relative;
        isolation: isolate;
    }

    .pb-rocket-stage {
        position: absolute;
        inset: 0;
        z-index: -1;
        pointer-events: none;
    }

    .pb-rocket-stage__pin {
        position: sticky;
        inset-block-start: 0;
        block-size: 100vh;
        overflow: hidden;
        opacity: 0;
        transition: opacity 800ms ease;
    }

    .pb-rocket-stage.is-ready .pb-rocket-stage__pin {
        opacity: 1;
    }

    /* A widget whose data the page does not have. Only ever rendered inside
       the builder — a visitor never sees one. */
    .pb-widget-needs-data,
    .pb-unknown-widget,
    .pb-failed-widget {
        padding: var(--spacing-md, 16px);
        border: 1px dashed var(--color-border, #e5e7eb);
        border-radius: var(--radius-md, 8px);
        color: var(--color-text-muted, #6b7280);
        font-size: var(--font-size-small, 13px);
        text-align: center;
    }

    /* An image with no picture chosen yet: a picture-shaped box to click on
       (CMS-L41 task 11). Editor-only, like the rule above. */
    .pb-image-placeholder {
        display: grid;
        place-items: center;
        align-content: center;
        gap: 8px;
        aspect-ratio: 16 / 9;
        /* Big enough to read and to click (I23): the bare 82×54 box with an
           icon told a first-time author nothing. */
        min-height: 120px;
        padding: 16px;
        border: 1px dashed var(--color-border, #cbd5e1);
        border-radius: var(--radius-md, 8px);
        background: var(--color-bg-gray, #f3f4f6);
        color: var(--color-text-muted, #64748b);
    }

    .pb-image-placeholder__label {
        font-size: var(--font-size-small, 13px);
        text-align: center;
    }
}

/* Still in @layer haya-defaults: an unlayered rule here beats every page
   style no matter its specificity (CMS-L11), and a page could not undo
   `.pb-generic { display: block }` for a block that must lay out as its
   section's flex or grid child. */
@layer haya-defaults {
    /* ── The embed frame ────────────────────────────────────────────────────────
       The ratio is a custom property so the widget can carry it per node, and the
       frame fills the box absolutely — an iframe without this collapses to its
       default 150px whatever the box around it says. */
    .pb-embed {
        position: relative;
        width: 100%;
        /* Padding an author adds must not widen the box past its column: with
           content-box, width:100% plus padding pushed a form out of its section,
           where overflow:hidden cut it off. */
        box-sizing: border-box;
        aspect-ratio: var(--pb-embed-ratio, 16 / 9);
        overflow: hidden;
    }

    .pb-embed > iframe {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        border: 0;
    }

    /* The generic box owns no look of its own: everything it is comes from the
       inspector. Only `display` is set, so an empty one is still a drop target
       with a height the author can see in the builder. */
    .pb-generic {
        display: block;
    }

    /* CMS-L89: a converted widget or an inserted store design is one element
       whose wrapper takes no box, so that element is the section's flex or
       grid item the way the old widget's root was. */
    .pb-generic.pb-generic--transparent {
        display: contents;
    }

    /* CMS-L89: behaviours do not run on the editing canvas, so a closed
       dialog would be invisible there and its content unreachable; the
       canvas draws it in place instead. */
    #pb-canvas-root dialog:not([open]) {
        display: block;
        position: static;
        inset: auto;
        margin: 0;
        max-width: none;
    }

    /* The editor-only stand-in for a generic block with nothing in it yet: the
       same dashed "needs something" look the other widgets use, so an empty block
       is something an author can see and click rather than a zero-height line. */
    .pb-generic-empty {
        display: grid;
        place-items: center;
        min-height: 6rem;
        padding: var(--spacing-4, 1rem);
        border: 1px dashed currentColor;
        border-radius: var(--radius-md, 0.5rem);
        opacity: 0.6;
        font-size: 0.875rem;
    }
}

/* CMS-L89 — element behaviours (ElementBehaviors). Before the script runs, a
   tabs block shows its first panel only, so the page does not flash every
   panel; on the editing canvas the behaviour attribute is never written, so
   every panel stays visible there and the author can reach each one. */
@layer haya-defaults {
    [data-pb-behavior="tabs"]:not([data-pb-ready]) [role="tabpanel"]:not(:nth-child(1 of [role="tabpanel"])) {
        display: none;
    }

    [data-pb-behavior="tabs"] [role="tabpanel"][hidden] {
        display: none;
    }

    .pb-lightbox {
        max-width: min(92vw, 1400px);
        max-height: 92vh;
        padding: 0;
        border: 0;
        background: transparent;
        overflow: visible;
    }

    .pb-lightbox::backdrop {
        background: rgb(0 0 0 / 0.82);
    }

    .pb-lightbox img {
        display: block;
        max-width: min(92vw, 1400px);
        max-height: 92vh;
        object-fit: contain;
        border-radius: 6px;
    }

    .pb-lightbox__close {
        position: absolute;
        inset-block-start: -2.75rem;
        inset-inline-end: 0;
        width: 2.25rem;
        height: 2.25rem;
        border: 0;
        border-radius: 999px;
        background: rgb(255 255 255 / 0.14);
        color: #fff;
        font-size: 1.5rem;
        line-height: 1;
        cursor: pointer;
    }

    .pb-lightbox__close:focus-visible {
        outline: 2px solid #fff;
        outline-offset: 2px;
    }
}
