/* ===== PRODUCT LOADING STATE =====
   Built to shorten how long the wait feels:
   - a progress bar that moves fast early, then eases (front-loaded progress feels quicker)
   - a slow left-to-right shimmer that flows down the layout (motion reads as work happening)
   - messages that change every few seconds (occupied time feels shorter than empty time)
   - nothing but the skeleton for the first 0.4s, so quick loads never flash "loading" */
#loadingState {
    --loading-gold: var(--shop-accent-color, #d4af37);
    --loading-base: color-mix(in srgb, var(--loading-gold) 14%, var(--bg-secondary));
    --loading-glint: #fffdf6;
    padding: 1.5rem 0 4rem;
}

[data-theme="dark"] #loadingState {
    --loading-base: color-mix(in srgb, var(--loading-gold) 8%, rgba(255, 255, 255, 0.07));
    --loading-glint: color-mix(in srgb, var(--loading-gold) 35%, rgba(255, 255, 255, 0.25));
}

/* ----- Status: progress bar + rotating message ----- */
.product-loading-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    margin: 0 auto 1.4rem;
    max-width: 240px;
}

.product-loading-progress {
    width: 100%;
    height: 3px;
    border-radius: 999px;
    overflow: hidden;
    background: color-mix(in srgb, var(--loading-gold) 16%, transparent);
    opacity: 0;
    animation: product-loading-fade-in 0.3s ease 0.4s forwards;
}

.product-loading-progress-fill {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, color-mix(in srgb, var(--loading-gold) 60%, #fff), var(--loading-gold));
    transform-origin: left;
    transform: scaleX(0.04);
    animation: product-loading-progress 9s cubic-bezier(0.1, 0.7, 0.2, 1) 0.4s forwards;
}

.product-loading-messages {
    display: grid;
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    color: color-mix(in srgb, var(--loading-gold) 70%, var(--text-primary, #222));
}

.product-loading-messages > span {
    grid-area: 1 / 1;
    text-align: center;
    opacity: 0;
}

.product-loading-messages > span:nth-child(1) {
    animation: product-loading-msg-in 0.4s ease 0.4s both, product-loading-msg-out 0.35s ease 2.6s forwards;
}

.product-loading-messages > span:nth-child(2) {
    animation: product-loading-msg-in 0.4s ease 2.9s both, product-loading-msg-out 0.35s ease 5.4s forwards;
}

.product-loading-messages > span:nth-child(3) {
    animation: product-loading-msg-in 0.4s ease 5.7s both;
}

/* ----- Skeleton that mirrors the real product layout ----- */
.product-loading-shell {
    display: grid;
    grid-template-columns: minmax(260px, 440px) 1fr;
    gap: 2rem;
    align-items: start;
}

.product-loading-media,
.product-loading-line,
.product-loading-cta {
    position: relative;
    overflow: hidden;
    background: linear-gradient(100deg, var(--loading-base) 35%, var(--loading-glint) 50%, var(--loading-base) 65%);
    background-size: 250% 100%;
    animation: product-loading-sweep 1.6s ease-in-out infinite;
    animation-delay: var(--wave, 0s);
}

.product-loading-media {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

/* Soft monogram gives the eye something to rest on inside the big empty box */
.product-loading-mark {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(2.5rem, 12vw, 4rem);
    font-weight: 700;
    line-height: 1;
    color: var(--loading-gold);
    opacity: 0.3;
    animation: product-loading-breathe 2s ease-in-out infinite;
}

.product-loading-content {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding-top: 0.35rem;
}

.product-loading-line {
    height: 0.95rem;
    border-radius: 999px;
}

.product-loading-line-title { height: 1.5rem; width: min(80%, 480px); --wave: 0.12s; }
.product-loading-line-subtitle { width: min(48%, 280px); --wave: 0.22s; }
.product-loading-line-price { height: 1.25rem; width: min(30%, 170px); margin-top: 0.55rem; --wave: 0.32s; }

.product-loading-cta {
    width: min(45%, 220px);
    height: 2.75rem;
    border-radius: 0.75rem;
    margin-top: 0.8rem;
    --wave: 0.42s;
}

/* ----- Keyframes ----- */
@keyframes product-loading-sweep {
    from { background-position: 100% 0; }
    to { background-position: -50% 0; }
}

@keyframes product-loading-progress {
    0% { transform: scaleX(0.04); }
    25% { transform: scaleX(0.55); }
    60% { transform: scaleX(0.8); }
    100% { transform: scaleX(0.92); }
}

@keyframes product-loading-breathe {
    0%, 100% { opacity: 0.2; transform: scale(0.94); }
    50% { opacity: 0.55; transform: scale(1.06); }
}

@keyframes product-loading-fade-in {
    to { opacity: 1; }
}

@keyframes product-loading-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes product-loading-msg-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-6px); }
}

/* ----- Reduced motion: still layout, one steady message ----- */
@media (prefers-reduced-motion: reduce) {
    .product-loading-media,
    .product-loading-line,
    .product-loading-cta,
    .product-loading-mark,
    .product-loading-progress-fill {
        animation: none;
    }

    .product-loading-progress { animation: none; opacity: 1; }
    .product-loading-progress-fill { transform: scaleX(0.6); }
    .product-loading-messages > span:nth-child(1) { animation: none; opacity: 1; }
    .product-loading-messages > span:nth-child(n + 2) { display: none; }
}

@media (max-width: 991.98px) {
    #loadingState { padding-top: 1rem; }

    .product-loading-shell {
        grid-template-columns: 1fr;
        gap: 1.2rem;
        margin-inline: 1.25rem;
    }

    .product-loading-line-title { width: 85%; }
    .product-loading-line-subtitle { width: 60%; }
    .product-loading-line-price { width: 40%; }
    .product-loading-cta { width: 55%; }
}
