/**
 * AstraSolara Chart Preview — product-page live preview.
 *
 * Every selector is namespaced under .astrasolara-chart-preview so nothing here can reach
 * the add-to-cart form or the surrounding Basel/WooCommerce markup.
 */

.astrasolara-chart-preview {
    margin: 24px 0 0;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.astrasolara-chart-preview[hidden] {
    display: none !important;
}

.astrasolara-chart-preview__heading {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
}

.astrasolara-chart-preview__note {
    margin: 0 0 12px;
    font-size: 13px;
    opacity: 0.75;
}

.astrasolara-chart-preview__trigger {
    margin: 0;
}

.astrasolara-chart-preview__trigger[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Stage ------------------------------------------------------------------ */

/*
 * The box reserves its space before the image arrives, so a render never shoves the
 * Add to Cart button down the page mid-interaction.
 */
.astrasolara-chart-preview__stage {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1 / 1;
    margin: 14px 0 0;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
}

.astrasolara-chart-preview__stage[hidden] {
    display: none !important;
}

.astrasolara-chart-preview__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 180ms ease;
}

.astrasolara-chart-preview__image[hidden] {
    display: none !important;
}

.astrasolara-chart-preview--stale .astrasolara-chart-preview__image {
    opacity: 0.4;
}

/* Skeleton --------------------------------------------------------------- */

.astrasolara-chart-preview__skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        100deg,
        rgba(255, 255, 255, 0.05) 30%,
        rgba(255, 255, 255, 0.14) 50%,
        rgba(255, 255, 255, 0.05) 70%
    );
    background-size: 300% 100%;
    animation: astrasolara-chart-preview-shimmer 1.4s ease-in-out infinite;
}

.astrasolara-chart-preview__skeleton[hidden] {
    display: none !important;
}

@keyframes astrasolara-chart-preview-shimmer {
    0%   { background-position: 150% 0; }
    100% { background-position: -50% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .astrasolara-chart-preview__skeleton {
        animation: none;
    }
}

/* Status / messages ------------------------------------------------------ */

.astrasolara-chart-preview__status {
    margin: 10px 0 0;
    font-size: 13px;
    line-height: 1.45;
}

.astrasolara-chart-preview__status[hidden] {
    display: none !important;
}

.astrasolara-chart-preview__status--error {
    color: #ffb4a8;
}

.astrasolara-chart-preview__retry {
    margin-left: 8px;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.astrasolara-chart-preview__chip {
    display: inline-block;
    margin: 10px 0 0;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.12);
}

.astrasolara-chart-preview__chip[hidden] {
    display: none !important;
}

.astrasolara-chart-preview__disclaimer {
    margin: 10px 0 0;
    font-size: 12px;
    opacity: 0.65;
}

/*
 * Gallery mode owns the image, so the fallback stage must not reserve its square. The
 * script never unhides the stage in this mode; this is the belt to that braces, and keeps
 * the "See your chart" block down to heading, note, button, status and captions.
 */
.astrasolara-chart-preview--gallery .astrasolara-chart-preview__stage {
    display: none !important;
}

/* Gallery slide ---------------------------------------------------------- */

/*
 * When the preview renders into the product gallery's main image, the loading and stale
 * treatments have to live on that slide instead of on the form's stage box.
 *
 * These are the only rules in this file that reach outside the .astrasolara-chart-preview
 * namespace, and every one of them is gated on .astrasolara-preview-slide — a class this
 * script adds to exactly one <figure> and only after a render. Nothing here applies to a
 * gallery we have not written into.
 */

.astrasolara-preview-slide {
    position: relative;
}

.astrasolara-preview-slide .astrasolara-preview-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    /* Above jQuery.zoom's .zoomImg, which is absolutely positioned in the same figure. */
    z-index: 3;
}

.astrasolara-preview-slide .astrasolara-preview-overlay__shimmer,
.astrasolara-preview-slide .astrasolara-preview-overlay__chip {
    opacity: 0;
    transition: opacity 180ms ease;
}

/* Loading: a shimmer over the image the shopper already has, not a blanked box. */
.astrasolara-preview-slide .astrasolara-preview-overlay__shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        100deg,
        rgba(255, 255, 255, 0) 30%,
        rgba(255, 255, 255, 0.22) 50%,
        rgba(255, 255, 255, 0) 70%
    );
    background-size: 300% 100%;
}

.astrasolara-preview-slide--loading .astrasolara-preview-overlay__shimmer {
    opacity: 1;
    animation: astrasolara-chart-preview-shimmer 1.4s ease-in-out infinite;
}

.astrasolara-preview-slide--loading img {
    opacity: 0.75;
}

/* Stale: same dim + chip language as the stage box, anchored on the slide. */
.astrasolara-preview-slide--stale img {
    opacity: 0.4;
}

.astrasolara-preview-slide .astrasolara-preview-overlay__chip {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.4;
    color: #fff;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(2px);
}

.astrasolara-preview-slide--stale .astrasolara-preview-overlay__chip {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .astrasolara-preview-slide--loading .astrasolara-preview-overlay__shimmer {
        animation: none;
    }
}

/* Light-theme fallback: the dark cosmic palette is the norm, but the shop templates can
   render on a light background, where translucent white loses all contrast. */
@media (prefers-color-scheme: light) {
    body:not(.astrasolara-dark) .astrasolara-chart-preview__stage {
        background: rgba(0, 0, 0, 0.06);
    }

    body:not(.astrasolara-dark) .astrasolara-chart-preview__chip {
        background: rgba(0, 0, 0, 0.08);
    }

    body:not(.astrasolara-dark) .astrasolara-chart-preview {
        border-top-color: rgba(0, 0, 0, 0.12);
    }

    /* The shimmer reads as a white wash on a light image; darken it instead. */
    body:not(.astrasolara-dark) .astrasolara-preview-slide .astrasolara-preview-overlay__shimmer {
        background-image: linear-gradient(
            100deg,
            rgba(0, 0, 0, 0) 30%,
            rgba(0, 0, 0, 0.10) 50%,
            rgba(0, 0, 0, 0) 70%
        );
    }
}
