/* ==========================================================================
   COCO CANDLES — LUXURY CRAFT DESIGN SYSTEM & ARCHITECTURE
   Optimized for Instagram In-App Browser (iOS WKWebView & Android Chrome)
   WCAG 2.2 AA Accessible • Modern CSS Architecture (oklch, nesting, container queries)
   ========================================================================== */

:root {
    /* --- COLOR PALETTE (OKLCH Color Space) --- */
    --clr-bg: oklch(0.985 0.006 85);            /* Soft natural soy wax / linen */
    --clr-surface: oklch(1 0 0);                /* Pure white surface */
    --clr-surface-glass: oklch(1 0 0 / 0.86);
    --clr-text-main: oklch(0.24 0.018 45);       /* Deep roasted cocoa / obsidian warm */
    --clr-text-muted: oklch(0.50 0.015 50);      /* Warm slate taupe */
    --clr-primary: oklch(0.76 0.12 85);          /* Soft amber gold */
    --clr-primary-dark: oklch(0.62 0.13 78);     /* Antique burnished gold */
    --clr-accent: oklch(0.56 0.035 55);         /* Terracotta / artisanal taupe */
    --clr-border: oklch(0.24 0.018 45 / 0.08);   /* Subtle structural border */
    --clr-card-bg: oklch(0.99 0.003 85);

    /* --- FLUID TYPOGRAPHY (Scalable clamp() without rigid breakpoints) --- */
    --font-family: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-h1: clamp(2rem, 1.4rem + 2.5vw, 3.2rem);
    --font-h2: clamp(1.5rem, 1.2rem + 1.5vw, 2.2rem);
    --font-body: clamp(0.95rem, 0.9rem + 0.25vw, 1.1rem);
    --font-xs: clamp(0.78rem, 0.74rem + 0.15vw, 0.88rem);
    --font-sm: clamp(0.88rem, 0.84rem + 0.2vw, 0.98rem);
    --font-md: clamp(1rem, 0.96rem + 0.25vw, 1.15rem);
    --font-lg: clamp(1.25rem, 1.15rem + 0.4vw, 1.45rem);

    /* --- SPACING TOKENS --- */
    --space-xs: 0.35rem;
    --space-sm: 0.65rem;
    --space-md: 1.1rem;
    --space-lg: 1.6rem;
    --space-xl: 2.2rem;
    --space-2xl: 3.2rem;

    /* --- SHADOWS & GEOMETRY --- */
    --shadow-soft: 0 4px 20px oklch(0.24 0.018 45 / 0.06);
    --shadow-medium: 0 8px 30px oklch(0.24 0.018 45 / 0.10);
    --shadow-heavy: 0 16px 45px oklch(0.24 0.018 45 / 0.18);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-xl: 28px;
    --radius-full: 9999px;
    --transition-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- RESET & ACCESSIBILITY DEFAULTS --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

html::-webkit-scrollbar {
    display: none;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-body);
    line-height: 1.6;
    background-color: var(--clr-bg);
    color: var(--clr-text-main);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    min-height: 100svh;
    padding-top: calc(122px + env(safe-area-inset-top));
    overflow-x: hidden;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

body::-webkit-scrollbar {
    display: none;
}

/* Anti-Zoom on iOS WebViews + Touch Optimization */
input,
select,
textarea,
button {
    font-family: inherit;
    font-size: 1rem; /* >= 16px to prevent automatic iOS zoom */
    touch-action: manipulation; /* Eliminate 300ms tap latency */
    border: none;
    background: none;
}

button,
a {
    cursor: pointer;
    touch-action: manipulation;
}

img,
picture {
    max-width: 100%;
    display: block;
    object-fit: cover;
}

ul {
    list-style: none;
}

/* Glassmorphism Utility */
.glass-effect {
    background: var(--clr-surface-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid oklch(1 0 0 / 0.4);
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

/* --- APP HEADER & ANNOUNCEMENT BAR --- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);

    & .announcement-bar {
        width: 100%;
        background-color: var(--clr-text-main);
        color: var(--clr-surface);
        overflow: hidden;
        padding: 6px 0;
        white-space: nowrap;

        & .marquee-content {
            display: inline-block;
            white-space: nowrap;
            animation: marqueeScroll 22s linear infinite;

            & span {
                font-size: 12px;
                font-weight: 600;
                margin-right: 48px;
                display: inline-block;
            }
        }
    }

    & .header-inner {
        height: 70px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        padding: 6px 16px;
    }

    & .logo {
        margin: 0;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;

        & .logo-link {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
            outline: none;
            border-radius: var(--radius-sm);
            transition: transform var(--transition-fast), opacity var(--transition-fast);

            &:hover {
                transform: scale(1.04);
            }

            &:active {
                transform: scale(0.98);
            }

            &:focus-visible {
                outline: 2px solid var(--clr-primary-dark);
                outline-offset: 4px;
            }
        }

        & .header-logo-img {
            height: 48px;
            width: auto;
            max-height: 48px;
            max-width: 220px;
            object-fit: contain;
            display: block;
            filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.04));
            user-select: none;
            -webkit-user-drag: none;
        }
    }
}

@keyframes marqueeScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- HERO SECTION --- */
.hero {
    position: relative;
    width: 100%;
    min-height: clamp(340px, 50vh, 520px);
    min-height: clamp(340px, 50svh, 520px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: var(--space-lg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-medium);

    & .hero-image-wrapper {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        z-index: 0;

        & picture,
        & .hero-picture {
            display: block;
            width: 100%;
            height: 100%;
        }

        & .hero-image {
            width: 100%;
            height: 100%;
            object-fit: cover;
            object-position: center 62%;
            display: block;
            animation: heroZoom 18s ease-in-out infinite alternate;

            @media (min-width: 768px) {
                object-position: center 56%;
            }
        }
    }

    & .hero-overlay {
        position: absolute;
        inset: 0;
        background: oklch(0.12 0.02 45 / 0.58);
        z-index: 1;
    }

    & .hero-content {
        position: relative;
        z-index: 2;
        width: 100%;
        max-width: 680px;
        text-align: center;
        padding: var(--space-xl) var(--space-md);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: var(--space-sm);
    }

    & .hero-eyebrow {
        display: inline-block;
        font-size: clamp(0.72rem, 0.68rem + 0.2vw, 0.82rem);
        font-weight: 600;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: #FFFFFF;
        background: oklch(0 0 0 / 0.28);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid oklch(1 0 0 / 0.22);
        padding: 6px 18px;
        border-radius: var(--radius-full);
        text-shadow: 0 1px 4px oklch(0 0 0 / 0.4);
        opacity: 0;
        transform: translateY(12px);
        animation: heroFadeUp 0.7s 0.2s var(--transition-smooth) forwards;
    }

    & .hero-heading {
        font-size: clamp(1.8rem, 1.3rem + 2.5vw, 3rem);
        font-weight: 700;
        color: #FFFFFF;
        line-height: 1.15;
        letter-spacing: -0.02em;
        text-shadow: 0 2px 20px oklch(0 0 0 / 0.3);
        max-width: 560px;
        opacity: 0;
        transform: translateY(16px);
        animation: heroFadeUp 0.8s 0.4s var(--transition-smooth) forwards;
    }

    & .hero-subtitle {
        font-size: var(--font-sm);
        color: oklch(0.85 0.005 85);
        line-height: 1.55;
        max-width: 440px;
        text-shadow: 0 1px 8px oklch(0 0 0 / 0.2);
        opacity: 0;
        transform: translateY(14px);
        animation: heroFadeUp 0.8s 0.6s var(--transition-smooth) forwards;
    }

    & .hero-cta {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 52px;
        padding: 0 32px;
        margin-top: var(--space-sm);
        background: oklch(1 0 0 / 0.95);
        color: var(--clr-text-main);
        font-size: var(--font-sm);
        font-weight: 700;
        border-radius: var(--radius-full);
        text-decoration: none;
        box-shadow: 0 8px 30px oklch(0 0 0 / 0.25);
        transition: transform 0.3s var(--transition-smooth),
                    box-shadow 0.3s ease,
                    background-color 0.3s ease;
        opacity: 0;
        transform: translateY(14px);
        animation: heroFadeUp 0.8s 0.8s var(--transition-smooth) forwards;

        & svg {
            transition: transform 0.3s var(--transition-smooth);
        }

        &:hover {
            transform: translateY(-3px) scale(1.03);
            box-shadow: 0 14px 40px oklch(0 0 0 / 0.3);

            & svg {
                transform: translateX(4px);
            }
        }

        &:active {
            transform: translateY(1px) scale(0.98);
        }
    }
}

@keyframes heroFadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes heroZoom {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); }
}

@media (min-width: 768px) {
    .hero {
        min-height: clamp(380px, 50vh, 540px);
    }
}

/* --- SITE NOTICE (news card under the cover, dismissible) --- */
.site-notice {
    margin-top: var(--space-sm);
    margin-bottom: var(--space-xl);
    padding: var(--space-md);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 22px;
    box-shadow: var(--shadow-soft);
    text-align: left;

    & .site-notice-head {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
    }

    & .site-notice-icon {
        flex-shrink: 0;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #FFFFFF;
        background: linear-gradient(135deg, #F58529 0%, #DD2A7B 55%, #8134AF 100%);
    }

    & .site-notice-label {
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--clr-primary-dark);
    }

    & .site-notice-title {
        margin: 2px 0 0;
        font-size: var(--font-md);
        font-weight: 700;
        line-height: 1.25;
        color: var(--clr-text-main);
    }

    & .site-notice-text {
        margin: var(--space-sm) 0 var(--space-md);
        font-size: var(--font-sm);
        line-height: 1.45;
        color: var(--clr-text-muted);
    }

    & .site-notice-btn {
        width: 100%;
        min-height: 48px;
        border-radius: var(--radius-full);
        background: var(--clr-text-main);
        color: var(--clr-surface);
        font-size: var(--font-sm);
        font-weight: 700;
        transition: transform 0.2s ease;

        &:active {
            transform: scale(0.97);
        }
    }

    /* Closing: fade and fold away instead of vanishing */
    &.is-hiding {
        opacity: 0 !important;
        transform: translateY(-8px) !important;
        max-height: 0 !important;
        margin-top: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-width: 0;
        overflow: hidden;
        transition: opacity 0.25s ease, transform 0.3s ease, max-height 0.35s var(--transition-smooth),
                    margin 0.35s var(--transition-smooth), padding 0.35s var(--transition-smooth);
    }
}

/* --- SECTION: PRODUCTS & CONTAINER QUERIES --- */
.products {
    margin-bottom: var(--space-2xl);

    & .products-header {
        margin-bottom: var(--space-md);
        text-align: center;

        & h2 {
            font-size: var(--font-h2);
            font-weight: 700;
            color: var(--clr-text-main);
        }
    }
}

/* Category Filter Chips */
.category-filters {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 1.8vw, 10px);
    padding: 4px var(--space-xs) var(--space-md);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;

    &::-webkit-scrollbar {
        display: none;
    }
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 clamp(10px, 2.2vw, 18px);
    border-radius: var(--radius-full);
    background-color: var(--clr-card-bg);
    color: var(--clr-text-muted);
    font-size: clamp(0.78rem, 0.74rem + 0.2vw, 0.88rem);
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid var(--clr-border);
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.15s ease, border-color 0.25s ease;
    flex-shrink: 0;

    &:active {
        transform: scale(0.96);
    }

    &.active {
        background-color: var(--clr-text-main);
        color: var(--clr-surface);
        border-color: var(--clr-text-main);
        box-shadow: 0 3px 12px oklch(0.24 0.018 45 / 0.18);
    }
}

/* Product Grid & Container Queries */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.product-card-container {
    container-type: inline-size;
}

.product-card {
    background-color: var(--clr-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--clr-border);
    transition: box-shadow 0.3s var(--transition-smooth), transform 0.3s var(--transition-smooth);

    &:hover {
        box-shadow: var(--shadow-medium);
        transform: translateY(-2px);
    }

    & .product-image {
        position: relative;
        aspect-ratio: 1 / 1;
        overflow: hidden;
        background-color: oklch(0.96 0.005 85);
        cursor: pointer;

        & img {
            width: 100%;
            height: 100%;
            aspect-ratio: 1 / 1;
            transition: transform 0.5s var(--transition-smooth);
        }
    }

    &:active .product-image img {
        transform: scale(1.04);
    }

    & .new-badge {
        position: absolute;
        left: 8px;
        top: 8px;
        z-index: 1;
        padding: 3px 10px;
        border-radius: var(--radius-full);
        background: var(--clr-surface);
        color: var(--clr-primary-dark);
        border: 1px solid var(--clr-primary-dark);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        line-height: 1.4;
        pointer-events: none;
    }

    & .photo-count-badge {
        position: absolute;
        right: 8px;
        bottom: 8px;
        z-index: 1;
        padding: 3px 9px;
        border-radius: var(--radius-full);
        background: oklch(0.2 0.02 45 / 0.62);
        color: #FFFFFF;
        font-size: 11px;
        font-weight: 600;
        line-height: 1.4;
        pointer-events: none;
    }

    & .product-info {
        padding: var(--space-md);
        display: flex;
        flex-direction: column;
        flex-grow: 1;
    }

    & .product-title {
        font-size: var(--font-sm);
        font-weight: 600;
        margin-bottom: var(--space-xs);
        text-align: center;
        color: var(--clr-text-main);
    }

    & .add-btn {
        min-height: 48px; /* 48px Touch Target */
        background-color: var(--clr-text-main);
        color: var(--clr-surface);
        padding: 0 var(--space-md);
        border-radius: var(--radius-md);
        font-size: var(--font-sm);
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        transition: background-color 0.25s ease, transform 0.2s ease;
        width: 100%;
        margin-top: auto;

        /* Never let the "+" shrink when the label needs the room */
        & svg {
            flex-shrink: 0;
        }

        & span {
            white-space: nowrap;
        }

        &:active {
            transform: scale(0.97);
            background-color: var(--clr-accent);
        }
    }
}

/* @container Adaptations */
@container (min-width: 280px) {
    .product-card .product-title {
        font-size: var(--font-md);
    }
}

/* Narrow cards (2-column grid on most phones): tighter padding so icon + "Personalizza" both fit */
@container (max-width: 200px) {
    .product-card .product-info {
        padding: var(--space-sm);
    }

    .product-card .add-btn {
        padding: 0 8px;
        gap: 5px;
        font-size: 0.85rem;
    }
}

@container (max-width: 145px) {
    .product-card .add-btn {
        padding: 0 4px;
        gap: 4px;
        font-size: 0.8rem;
    }
}

/* --- SECTION: FAQ & WICK CARE (<details> & <summary>) --- */
.candle-guide {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-2xl);

    & .section-title-wrap {
        text-align: center;
        margin-bottom: var(--space-lg);

        & .section-title {
            font-size: var(--font-h2);
            font-weight: 700;
            color: var(--clr-text-main);
        }

        & .section-subtitle {
            font-size: var(--font-sm);
            color: var(--clr-text-muted);
            margin-top: 4px;
        }
    }

    & .faq-accordion {
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
        max-width: 760px;
        margin: 0 auto;
    }

    & .faq-item {
        background-color: var(--clr-surface);
        border: 1px solid var(--clr-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-soft);
        overflow: hidden;
        transition: border-color 0.3s ease, box-shadow 0.3s ease;

        /* :not(.is-closing) so the gold state fades out as the close animation starts (see initFaqAccordion) */
        &[open]:not(.is-closing) {
            border-color: var(--clr-primary-dark);
            box-shadow: var(--shadow-medium);

            & .faq-icon {
                transform: rotate(180deg);
                color: var(--clr-primary-dark);
            }
        }
    }

    & .faq-question {
        list-style: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--space-md);
        min-height: 48px; /* 48px Touch Target */
        font-size: var(--font-sm);
        font-weight: 600;
        color: var(--clr-text-main);
        cursor: pointer;
        user-select: none;
        touch-action: manipulation;

        &::-webkit-details-marker {
            display: none;
        }

        & .faq-icon {
            flex-shrink: 0;
            color: var(--clr-text-muted);
            transition: transform 0.3s var(--transition-smooth), color 0.3s ease;
        }
    }

    & .faq-answer {
        padding: 0 var(--space-md) var(--space-md);
        font-size: var(--font-sm);
        color: var(--clr-text-muted);
        line-height: 1.6;

        & strong {
            color: var(--clr-text-main);
        }
    }
}

/* --- SECTION: INSTAGRAM COMMUNITY --- */
.instagram-box {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-xl);

    & .instagram-card {
        background: linear-gradient(135deg, 
            oklch(0.95 0.08 65 / 0.18) 0%, 
            oklch(0.85 0.15 35 / 0.12) 40%, 
            oklch(0.70 0.18 330 / 0.12) 75%, 
            oklch(0.65 0.15 280 / 0.10) 100%), 
            var(--clr-surface);
        border: 1px solid oklch(0.70 0.18 330 / 0.2);
        border-radius: var(--radius-xl);
        padding: var(--space-xl) var(--space-md);
        text-align: center;
        box-shadow: var(--shadow-medium);
        display: flex;
        flex-direction: column;
        align-items: center;
        position: relative;
        overflow: hidden;
    }

    & .instagram-icon-wrapper {
        width: 60px;
        height: 60px;
        border-radius: 18px;
        background: var(--clr-surface);
        color: #D62976;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: var(--space-md);
        box-shadow: 0 6px 18px oklch(0.70 0.18 330 / 0.18);
        border: 1px solid oklch(0.70 0.18 330 / 0.15);
    }

    & .instagram-title {
        font-size: var(--font-lg);
        font-weight: 700;
        color: var(--clr-text-main);
        margin-bottom: var(--space-xs);
    }

    & .instagram-text {
        font-size: var(--font-sm);
        color: var(--clr-text-muted);
        line-height: 1.5;
        max-width: 400px;
        margin: 0 auto var(--space-lg);
    }

    & .instagram-btn {
        min-height: 48px; /* 48px Touch Target */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        background-color: var(--clr-text-main);
        color: var(--clr-surface);
        padding: 0 24px;
        border-radius: var(--radius-full);
        font-size: var(--font-sm);
        font-weight: 600;
        text-decoration: none;
        box-shadow: 0 4px 16px oklch(0.24 0.018 45 / 0.18);
        transition: transform 0.25s ease, background-color 0.25s ease;

        &:hover {
            background-color: oklch(0.18 0.018 45);
            transform: translateY(-2px);
        }

        &:active {
            transform: scale(0.98);
        }
    }
}

/* --- FOOTER --- */
.app-footer {
    background-color: var(--clr-text-main);
    color: var(--clr-surface);
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
    padding-bottom: calc(110px + env(safe-area-inset-bottom));
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);

    & .footer-links {
        text-align: center;
        margin-bottom: var(--space-md);
    }

    & .footer-link-btn {
        min-height: 48px; /* 48px Touch Target */
        padding: 0 16px;
        color: var(--clr-surface);
        text-decoration: underline;
        font-size: var(--font-sm);
        font-weight: 600;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    & .copyright {
        text-align: center;
        font-size: 12px;
        color: oklch(1 0 0 / 0.55);
        margin-top: var(--space-md);
        border-top: 1px solid oklch(1 0 0 / 0.12);
        padding-top: var(--space-md);
    }
}

/* --- FLOATING BOTTOM DOCK --- */
.bottom-dock {
    position: fixed;
    bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2 * var(--space-md));
    max-width: 400px;
    height: 68px;
    background: oklch(1 0 0 / 0.92);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: var(--shadow-heavy);
    border: 1px solid oklch(1 0 0 / 0.6);
    z-index: 90;
    padding: 0 var(--space-sm);
}

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    min-height: 48px; /* 48px Touch Target */
    color: var(--clr-text-muted);
    transition: color 0.25s ease;
    gap: 3px;
    position: relative;

    &.active {
        color: var(--clr-text-main);
    }

    & span {
        font-size: 11px;
        font-weight: 600;
    }

    &:active svg {
        transform: scale(0.92);
    }
}

.dock-icon-wrapper {
    position: relative;
    display: flex;
}

.badge {
    position: absolute;
    top: -6px;
    right: -10px;
    background-color: var(--clr-text-main);
    color: var(--clr-surface);
    font-size: 11px;
    font-weight: 700;
    height: 19px;
    min-width: 19px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #FFFFFF;
    box-shadow: 0 2px 6px oklch(0.24 0.018 45 / 0.25);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s var(--transition-smooth), transform 0.3s var(--transition-smooth);

    &.visible {
        opacity: 1;
        transform: scale(1);
    }

    &.pop {
        animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
}

@keyframes badgePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* ==========================================================================
   NATIVE <dialog> BOTTOM SHEETS WITH @starting-style & DISCRETE TRANSITIONS
   ========================================================================== */

dialog.bottom-sheet-dialog {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
    min-height: 380px;
    max-height: 90vh;
    max-height: 90dvh; /* Instagram Viewport Safe */
    background: var(--clr-surface);
    border: none;
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    padding: var(--space-lg) var(--space-md) calc(var(--space-md) + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-heavy);
    display: none;
    pointer-events: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;

    /* Entry & Exit discrete transitions */
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.35s var(--transition-smooth),
                opacity 0.35s var(--transition-smooth),
                display 0.35s allow-discrete,
                overlay 0.35s allow-discrete;

    &[open] {
        display: flex;
        pointer-events: auto;
        transform: translateY(0);
        opacity: 1;
    }
}

@starting-style {
    dialog.bottom-sheet-dialog[open] {
        transform: translateY(100%);
        opacity: 0;
    }
}

dialog.bottom-sheet-dialog::backdrop {
    background-color: oklch(0 0 0 / 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    /* backdrop-filter is intentionally NOT transitioned: animating blur radius forces a
       full-viewport repaint every frame, which is a common source of jank/scatti in
       Instagram's in-app WKWebView. It snaps to blurred instantly instead; the dimming
       (background-color) and the sheet itself still animate smoothly. */
    transition: background-color 0.35s ease,
                display 0.35s allow-discrete,
                overlay 0.35s allow-discrete;
}

dialog.bottom-sheet-dialog[open]::backdrop {
    background-color: oklch(0 0 0 / 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

@starting-style {
    dialog.bottom-sheet-dialog[open]::backdrop {
        background-color: oklch(0 0 0 / 0);
        backdrop-filter: blur(0px);
    }
}

/* Tablet & Desktop Dialog Placement */
@media (min-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    dialog.bottom-sheet-dialog {
        inset: auto 24px 24px auto;
        width: 430px;
        border-radius: var(--radius-xl);
        max-height: 80vh;
        max-height: 80dvh;
        transform: translateY(20px) scale(0.96);
    }

    dialog.bottom-sheet-dialog[open] {
        transform: translateY(0) scale(1);
    }

    @starting-style {
        dialog.bottom-sheet-dialog[open] {
            transform: translateY(20px) scale(0.96);
        }
    }
}

@media (min-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Dialog Header */
.sheet-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    margin-bottom: var(--space-md);
    padding: 0 48px 18px 48px;
    border-bottom: 1px solid var(--clr-border);
    flex-shrink: 0;

    & h3 {
        font-size: var(--font-lg);
        font-weight: 700;
        color: var(--clr-text-main);
        text-align: center;
        margin: 0;
        line-height: 1.3;
    }
}

/* Share button: mirrors the close button, on the left of the sheet header */
.share-btn {
    position: absolute;
    left: 0;
    top: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: var(--clr-bg);
    color: var(--clr-text-muted);
    border: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;

    & .share-done-icon {
        display: none;
    }

    &:hover {
        color: var(--clr-text-main);
        background-color: oklch(0 0 0 / 0.08);
    }

    &:active {
        transform: scale(0.92);
    }

    &.is-done {
        color: #FFFFFF;
        background-color: oklch(0.60 0.16 155);
        border-color: transparent;

        & .share-icon {
            display: none;
        }

        & .share-done-icon {
            display: block;
        }
    }
}

.close-btn {
    position: absolute;
    right: 0;
    top: 0;
    width: 42px;  /* 42px Touch Target */
    height: 42px; /* 42px Touch Target */
    border-radius: 50%;
    background-color: var(--clr-bg);
    color: var(--clr-text-muted);
    border: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;

    &:hover {
        color: var(--clr-text-main);
        background-color: oklch(0 0 0 / 0.08);
    }

    &:active {
        transform: scale(0.92);
    }
}

.sheet-content {
    padding: var(--space-xs) 0 var(--space-md);
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;

    &::-webkit-scrollbar {
        display: none;
    }

    /* Fade content itself (photos included) into the header/footer edges as it
       scrolls, instead of a hard clip. Masking the container (rather than
       overlaying a translucent block on top) avoids washing images out with a
       white smear. Only applied once there's actually hidden content on that
       side (.is-scrolled / .has-more-below, toggled in app.js) so it doesn't
       fade content that's still fully at rest. */
    &.is-scrolled {
        -webkit-mask-image: linear-gradient(to bottom, transparent, black 20px);
        mask-image: linear-gradient(to bottom, transparent, black 20px);
    }

    &.has-more-below {
        -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent);
        mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent);
    }

    &.is-scrolled.has-more-below {
        -webkit-mask-image: linear-gradient(to bottom, transparent, black 20px, black calc(100% - 20px), transparent);
        mask-image: linear-gradient(to bottom, transparent, black 20px, black calc(100% - 20px), transparent);
    }
}

/* List Items in Cart / Wishlist */
.wishlist-items {
    display: flex;
    flex-direction: column;
    gap: 0;
    list-style: none;
    padding: 0;
    margin: 0;
}

.list-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--clr-border);
    max-height: 320px;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s var(--transition-smooth), max-height 0.35s ease, padding 0.3s ease;

    &:first-child {
        padding-top: var(--space-xs);
    }

    &:last-child {
        border-bottom: none;
        padding-bottom: var(--space-xs);
    }

    &.removing {
        opacity: 0;
        transform: translateX(40px);
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-bottom-color: transparent;
    }

    &.entering {
        animation: listItemIn 0.35s var(--transition-smooth);
    }
}

@keyframes listItemIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.list-item-main {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    width: 100%;
}

.list-item .item-img {
    width: 68px;
    height: 68px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
    background-color: var(--clr-bg);
    border: 1px solid var(--clr-border);
}

.list-item-info {
    flex: 1;
    min-width: 0; /* Prevents text squishing/truncation */
    display: flex;
    flex-direction: column;
    gap: 3px;

    & .item-title, & h4 {
        font-size: var(--font-sm);
        font-weight: 600;
        color: var(--clr-text-main);
        line-height: 1.35;
        margin: 0;
        word-break: break-word;
    }

    & .item-details {
        display: flex;
        flex-direction: column;
        gap: 3px;
        margin-top: 2px;
    }

    & .item-detail-badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: var(--font-xs);
        color: var(--clr-text-muted);
        line-height: 1.3;

        & strong {
            color: var(--clr-text-main);
            font-weight: 600;
        }

        & svg {
            color: var(--clr-primary-dark);
            flex-shrink: 0;
        }
    }

}

.item-delete-btn {
    width: 44px;  /* Touch friendly 44px */
    height: 44px; /* Touch friendly 44px */
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-text-muted);
    border-radius: 50%;
    flex-shrink: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    margin-top: -6px;
    margin-right: -4px;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;

    &:hover {
        color: #C0392B;
        background-color: oklch(0.6 0.2 25 / 0.1);
    }

    &:active {
        transform: scale(0.9);
    }
}

.list-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: oklch(0.965 0.006 85 / 0.7);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 6px 10px 6px 14px;
}

.item-qty-caption {
    font-size: var(--font-xs);
    font-weight: 600;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.item-qty-controls {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-full);
    padding: 3px;
    box-shadow: 0 1px 3px oklch(0 0 0 / 0.04);
}

.qty-btn {
    width: 38px;  /* 38px in compact list */
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-text-main);
    border-radius: 50%;
    background-color: var(--clr-bg);
    border: 1px solid var(--clr-border);
    touch-action: manipulation;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;

    &:hover {
        background-color: var(--clr-surface);
        border-color: var(--clr-primary-dark);
    }

    &:active {
        background: oklch(0 0 0 / 0.08);
        transform: scale(0.92);
    }
}

.item-qty {
    display: inline-block;
    font-size: var(--font-sm);
    font-weight: 700;
    min-width: 2.2ch;
    text-align: center;
    color: var(--clr-text-main);

    &.pop {
        animation: qtyPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
}

@keyframes qtyPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-xl) var(--space-sm);
    color: var(--clr-text-muted);
    display: none;
    margin: auto 0;

    &.visible {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex-grow: 1;
        gap: var(--space-xs);
        animation: fadeIn 0.4s ease both;
    }

    & .empty-state-icon {
        width: 64px;
        height: 64px;
        border-radius: var(--radius-full);
        background: oklch(0.76 0.12 85 / 0.15);
        color: var(--clr-primary-dark);
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: var(--space-xs);
    }

    & h4 {
        font-size: var(--font-md);
        font-weight: 600;
        color: var(--clr-text-main);
    }

    & p {
        font-size: var(--font-sm);
        color: var(--clr-text-muted);
        max-width: 260px;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sheet Footer & Actions */
.sheet-footer {
    position: relative;
    margin-top: auto;
    padding: var(--space-md) 0 var(--space-xs);
    flex-shrink: 0;

    & .disclaimer {
        text-align: center;
        font-size: var(--font-xs);
        color: var(--clr-text-muted);
        margin-top: var(--space-sm);
    }
}

.primary-btn {
    min-height: 48px; /* 48px Touch Target */
    width: 100%;
    padding: 14px var(--space-md);
    background-color: var(--clr-text-main);
    color: var(--clr-surface);
    border-radius: var(--radius-full);
    font-size: var(--font-md);
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
    box-shadow: 0 8px 24px oklch(0.24 0.018 45 / 0.22);
    transition: transform 0.25s ease, box-shadow 0.3s ease, background-color 0.4s ease, opacity 0.18s ease;

    &.btn-swapping {
        opacity: 0;
    }

    @media (hover: hover) and (pointer: fine) {
        &:hover {
            background-color: oklch(0.18 0.018 45);
            box-shadow: 0 12px 28px oklch(0.24 0.018 45 / 0.28);
            transform: translateY(-2px);
        }
    }

    &:active {
        transform: translateY(1px) scale(0.98);
    }

    &.btn-added {
        background-color: oklch(0.55 0.18 150);
        color: #FFFFFF;
        box-shadow: 0 8px 24px oklch(0.55 0.18 150 / 0.38);
        animation: btnSuccessPulse 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
}

@keyframes btnSuccessPulse {
    0% { transform: scale(1); }
    45% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

/* --- PRODUCT DETAIL MODAL --- */
.detail-sheet {
    /* Full-bleed photo at the top: no inner padding, the sections add their own */
    padding: 0 !important;
    height: 92vh;
    height: 92dvh;
    overflow: hidden;

    & .sheet-content {
        padding: 0 0 var(--space-md);
        /* The top fade would cut the photo under the bar: keep only the bottom one */
        &.is-scrolled {
            -webkit-mask-image: none;
            mask-image: none;
        }

        &.has-more-below,
        &.is-scrolled.has-more-below {
            -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent);
            mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent);
        }
    }

    & .sheet-footer {
        padding: var(--space-sm) var(--space-md) calc(var(--space-sm) + env(safe-area-inset-bottom));
        border-top: 1px solid var(--clr-border);
        background: var(--clr-surface);
    }
}

/* The sheet itself takes the initial focus (so no button shows a focus ring on open) */
#detail-scroll:focus {
    outline: none;
}

/* Top bar: transparent buttons over the photo; solid with the name once scrolled */
.detail-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    height: 60px;
    padding: 9px var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    background: transparent;
    border-bottom: 1px solid transparent;
    transition: background-color 0.25s ease, border-color 0.25s ease;

    & .share-btn,
    & .close-btn {
        position: static;
        flex-shrink: 0;
        background-color: oklch(1 0 0 / 0.86);
        -webkit-backdrop-filter: blur(6px);
        backdrop-filter: blur(6px);
        box-shadow: 0 2px 10px oklch(0.2 0.02 45 / 0.16);
    }

    & .detail-topbar-title {
        flex: 1;
        min-width: 0;
        margin: 0;
        font-size: var(--font-md);
        font-weight: 700;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: var(--clr-text-main);
        opacity: 0;
        transform: translateY(6px);
        transition: opacity 0.2s ease, transform 0.25s var(--transition-smooth);
    }

    &.is-solid {
        background: var(--clr-surface);
        border-bottom-color: var(--clr-border);

        & .share-btn,
        & .close-btn {
            background-color: var(--clr-bg);
            box-shadow: none;
        }
    }

    &.show-title .detail-topbar-title {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Big swipeable photo(s) */
.detail-gallery {
    position: relative;
    flex-shrink: 0;
    background-color: oklch(0.96 0.005 85);

    & .detail-gallery-track {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;

        &::-webkit-scrollbar {
            display: none;
        }

        & img {
            flex: 0 0 100%;
            width: 100%;
            height: auto;
            aspect-ratio: 4 / 3;
            max-height: 34dvh;
            object-fit: cover;
            object-position: center 45%;
            scroll-snap-align: start;
            scroll-snap-stop: always;
            cursor: zoom-in;
            -webkit-user-drag: none;
        }
    }

    & .detail-gallery-dots {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 12px;
        display: flex;
        justify-content: center;
        gap: 6px;
        pointer-events: none;

        &[hidden] {
            display: none;
        }

        & .detail-dot {
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background: oklch(1 0 0 / 0.55);
            box-shadow: 0 1px 3px oklch(0.2 0.02 45 / 0.3);
            transition: background-color 0.2s ease, transform 0.2s ease;

            &.is-active {
                background: #FFFFFF;
                transform: scale(1.3);
            }
        }
    }

    /* Tiny hint that the photo opens full-size */
    & .detail-zoom-badge {
        position: absolute;
        right: 12px;
        bottom: 12px;
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background-color: oklch(1 0 0 / 0.88);
        color: var(--clr-text-main);
        box-shadow: 0 1px 4px oklch(0.24 0.018 45 / 0.18);
        pointer-events: none;
    }
}

.detail-body {
    padding: 0 var(--space-md);
}

.detail-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-md) 0 var(--space-xs);
    text-align: left;

    & .detail-category {
        margin-bottom: 2px;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--clr-primary-dark);
    }

    & h4 {
        font-size: clamp(1.5rem, 1.35rem + 0.6vw, 1.75rem);
        font-weight: 700;
        line-height: 1.2;
        color: var(--clr-text-main);
    }

    /* Measures block: pill + a small "Larghezza × altezza" legend under it */
    & .detail-dims-block {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        margin-top: var(--space-sm);

        &[hidden] {
            display: none;
        }
    }

    & .detail-dims-hint {
        padding-left: 4px;
        font-size: 0.72rem;
        line-height: 1.2;
        color: var(--clr-text-muted);
    }

    /* Measures pill (ruler icon + "Circa L × A cm") */
    & .detail-dims {
        display: inline-flex;
        align-items: flex-start;
        gap: 6px;
        margin: 0;
        padding: 4px 10px 4px 8px;
        border-radius: var(--radius-md);
        background-color: oklch(0.76 0.12 85 / 0.14);
        border: 1px solid oklch(0.62 0.13 78 / 0.28);
        font-size: var(--font-xs);
        font-weight: 600;
        line-height: 1.35;
        color: var(--clr-text-main);

        & svg {
            flex-shrink: 0;
            margin-top: 1px;
            color: var(--clr-primary-dark);
        }

        & .dims-sep {
            margin: 0 1px;
            font-weight: 400;
            color: var(--clr-primary-dark);
        }
    }

}

.option-group {
    padding: var(--space-md) 0;
    text-align: center;

    /* Divider between Colore / Fragranza / Quantità */
    & + .option-group {
        border-top: 1px solid var(--clr-border);
    }

    &:last-child {
        padding-bottom: 0;
    }

    & .option-label {
        display: block;
        font-size: var(--font-sm);
        font-weight: 600;
        margin-bottom: var(--space-sm);
        color: var(--clr-text-main);

        & strong {
            color: var(--clr-accent);
        }
    }
}

.color-note {
    margin: 0 0 var(--space-md);
    padding: var(--space-sm) var(--space-md);
    text-align: center;
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--clr-text-main);
    background: var(--clr-card-bg);
    border: 1px dashed var(--clr-border);
    border-radius: var(--radius-lg);
}

.fragrance-preview {
    margin: 0;
    font-size: var(--font-sm);
    font-style: italic;
    color: var(--clr-primary-dark);
    min-height: 1.3em;
}

.detail-body .option-group {
    text-align: left;

    & .option-label {
        margin-bottom: 2px;
        font-size: var(--font-xs);
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--clr-text-muted);
    }
}

.detail-body .size-options {
    justify-content: flex-start;
}

/* Fragrances: one tidy row, swipe sideways, soft fade on the side(s) with more chips */
.fragrance-options {
    display: flex;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    /* top room for the "Consigliata" tag, side/bottom room for the pop ring */
    padding: 16px 14px 12px;
    margin: 0 -14px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    --fade-l: 0px;
    --fade-r: 0px;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);

    &::-webkit-scrollbar {
        display: none;
    }

    & .fragrance-chip {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

.size-options {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.fragrance-chip,
.size-chip {
    position: relative;
    min-height: 48px; /* 48px Touch Target */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--clr-border);
    background-color: var(--clr-surface);
    color: var(--clr-text-main);
    font-size: var(--font-sm);
    font-weight: 500;
    cursor: pointer;
    /* No color transition on purpose: fading text and background together makes
       the label vanish mid-way (both hit the same grey) and reads as a flicker. */

    &.selected {
        background-color: var(--clr-text-main);
        color: var(--clr-surface);
        border-color: var(--clr-text-main);
    }

    /* Recommended pick: gold outline + small tag sitting on the top border */
    &.recommended {
        border-color: var(--clr-primary-dark);
    }
}

/* Fragrance change: the chip pops with a soft ring and the description fades in.
   Colours still switch instantly on purpose (see note above), so nothing flickers. */
@media (prefers-reduced-motion: no-preference) {
    .fragrance-chip.just-selected,
    .size-chip.just-selected {
        animation: chipPop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .fragrance-preview.is-swapping {
        animation: previewIn 0.34s var(--transition-smooth);
    }
}

@keyframes chipPop {
    0% {
        transform: scale(0.93);
        box-shadow: 0 0 0 0 oklch(0.76 0.12 85 / 0.55);
    }
    55% {
        transform: scale(1.07);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 12px oklch(0.76 0.12 85 / 0);
    }
}

@keyframes previewIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.size-chip {
    min-width: 48px; /* keeps "S" / "M" / "L" as comfortable tap targets */
}

.recommended-tag {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1px 7px;
    border-radius: var(--radius-full);
    background-color: var(--clr-surface);
    border: 1px solid var(--clr-primary-dark);
    color: var(--clr-primary-dark);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
}

.detail-qty-controls {
    margin: 0;
    border: 1px solid var(--clr-border);
    padding: 3px;
    flex-shrink: 0;

    & .qty-btn {
        width: 44px;
        height: 44px;
    }
}

.detail-qty-value {
    min-width: 28px;
    padding: 0 6px;
    text-align: center;
    font-size: var(--font-lg);
}

/* Fixed bottom bar of the candle sheet: quantity + "Aggiungi" side by side */
/* Candle switch from "Scopri anche": fade out, then rise back in */
#detail-dialog .sheet-content {
    transition: opacity 0.36s var(--transition-smooth), transform 0.36s var(--transition-smooth);

    &.is-switching {
        opacity: 0;
        transform: translateY(14px);
        transition-duration: 0.2s;
        transition-timing-function: ease-in;
    }
}

.sheet-footer.detail-footer {
    display: flex;
    align-items: center;
    gap: var(--space-sm);

    & .checkout-btn {
        flex: 1;
        width: auto;
        min-width: 0;
    }
}

/* Strengths row in the candle sheet (moved here from the home page) */
.detail-features {
    list-style: none;
    margin: var(--space-md) 0 0;
    padding: var(--space-sm) 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xs);
    border-top: 1px solid var(--clr-border);
    border-bottom: 1px solid var(--clr-border);

    & .detail-feature {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        text-align: center;
    }

    & .detail-feature-icon {
        color: var(--clr-primary-dark);
        display: flex;
    }

    & .detail-feature-label {
        font-size: var(--font-xs);
        font-weight: 600;
        color: var(--clr-text-main);
        line-height: 1.25;
    }
}

/* "Scopri anche" strip */
.related {
    margin-top: var(--space-lg);

    &[hidden] {
        display: none;
    }

    & .related-title {
        font-size: var(--font-sm);
        font-weight: 700;
        text-align: center;
        margin-bottom: var(--space-sm);
        color: var(--clr-text-main);
    }

    & .related-list {
        display: flex;
        gap: var(--space-sm);
        overflow-x: auto;
        padding: 2px var(--space-xs) var(--space-sm);
        scroll-snap-type: x proximity;
        scroll-padding-inline: var(--space-xs);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        touch-action: pan-x pan-y;
        /* Soft fade on the side(s) where more cards are hidden; widths set from JS */
        --fade-l: 0px;
        --fade-r: 0px;
        -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
        mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);

        &::-webkit-scrollbar {
            display: none;
        }
    }

    & .related-card {
        flex: 0 0 96px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        scroll-snap-align: start;
        touch-action: manipulation;

        & img {
            width: 96px;
            height: 96px;
            object-fit: cover;
            border-radius: var(--radius-md);
            border: 1px solid var(--clr-border);
        }

        & span {
            max-width: 96px;
            font-size: var(--font-xs);
            font-weight: 600;
            color: var(--clr-text-main);
            text-align: center;
            line-height: 1.25;
        }

        &:active img {
            transform: scale(0.97);
        }
    }
}

/* --- CONTACT & PRIVACY DIALOGS --- */
.wa-sheet-body {
    text-align: center;
    padding: var(--space-lg) var(--space-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.wa-icon-large {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: oklch(0.65 0.22 145 / 0.15);
    color: #25D366;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
}

.wa-contact-title {
    font-size: var(--font-lg);
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.wa-contact-text {
    font-size: var(--font-sm);
    color: var(--clr-text-muted);
    max-width: 300px;
    margin: 0 auto;
}

.wa-cta-btn {
    background-color: #25D366;
    color: #FFFFFF;
    text-decoration: none;

    &:hover {
        background-color: #1ebe5b;
    }
}

/* --- NEWS POPUP --- */
.news-body {
    text-align: center;
    align-items: center;

    & .news-image {
        width: min(100%, 260px);
        height: auto;
        aspect-ratio: 1 / 1;
        object-fit: cover;
        object-position: center 55%;
        border-radius: var(--radius-xl);
        box-shadow: var(--shadow-medium);
        margin: 0 auto var(--space-md);
    }

    & .news-title {
        font-size: var(--font-lg);
        font-weight: 700;
        margin-bottom: var(--space-xs);
        text-wrap: balance;
    }

    & .news-text {
        font-size: var(--font-sm);
        color: var(--clr-text-muted);
        margin: 0 auto var(--space-md);
    }

    & .news-fragrances-label {
        font-size: var(--font-xs);
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--clr-primary-dark);
        margin-bottom: var(--space-xs);
    }

    & .news-chips {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    & .news-chip {
        padding: 8px 16px;
        border-radius: var(--radius-full);
        border: 1px solid var(--clr-border);
        background: var(--clr-card-bg);
        font-size: var(--font-sm);
        font-weight: 500;
        color: var(--clr-text-main);
    }
}

.news-later-btn {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: var(--space-xs);
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--clr-text-muted);
}

.legal-text {
    & .legal-updated {
        font-size: var(--font-xs);
        font-style: italic;
        color: var(--clr-text-muted);
        margin-bottom: var(--space-md);
        padding-bottom: var(--space-sm);
        border-bottom: 1px solid var(--clr-border);
    }

    & h4 {
        font-size: var(--font-sm);
        margin-top: var(--space-md);
        margin-bottom: 4px;
        color: var(--clr-text-main);
    }

    & p {
        font-size: var(--font-xs);
        color: var(--clr-text-muted);
        margin-bottom: var(--space-sm);
        line-height: 1.6;
    }
}

/* --- NATIVE DIALOG: IMAGE VIEWER LIGHTBOX --- */
dialog.viewer-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    background: oklch(0 0 0 / 0.92);
    border: none;
    padding: var(--space-md);
    display: none;
    pointer-events: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.35s ease, display 0.35s allow-discrete, overlay 0.35s allow-discrete;

    &[open] {
        display: flex;
        pointer-events: auto;
        opacity: 1;
    }
}

@starting-style {
    dialog.viewer-dialog[open] {
        opacity: 0;
    }
}

.viewer-close-btn {
    position: absolute;
    top: calc(20px + env(safe-area-inset-top));
    right: 20px;
    width: 48px;  /* 48px Touch Target */
    height: 48px; /* 48px Touch Target */
    border-radius: 50%;
    background: oklch(1 0 0 / 0.2);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2001;

    &:hover {
        background: oklch(1 0 0 / 0.35);
    }
}

.viewer-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;

    /* Every photo gets the same rounded square frame, whatever its original ratio.
       The photo zooms inside the frame (pinch / double tap / wheel), see initViewerZoom() */
    & .viewer-frame {
        width: min(100%, 85dvh, 560px);
        aspect-ratio: 1 / 1;
        border-radius: var(--radius-xl);
        overflow: hidden;
        touch-action: none; /* pinch & pan are handled in JS, only inside the open viewer */
        cursor: zoom-in;
        user-select: none;
        -webkit-user-select: none;

        &.is-zoomed {
            cursor: grab;
        }
    }

    & img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center 45%;
        transform-origin: center center;
        will-change: transform;
        pointer-events: none;
        -webkit-user-drag: none;
    }
}

/* Photo gallery controls inside the image viewer */
.viewer-content {
    position: relative;
    flex-direction: column;
    gap: var(--space-md);
}

.viewer-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: oklch(1 0 0 / 0.2);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;

    &[hidden] {
        display: none;
    }

    &:hover {
        background: oklch(1 0 0 / 0.35);
    }

    &.viewer-prev-btn {
        left: 4px;
    }

    &.viewer-next-btn {
        right: 4px;
    }
}

.viewer-dots {
    display: flex;
    gap: 8px;

    &[hidden] {
        display: none;
    }

    & .viewer-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: oklch(1 0 0 / 0.4);
        transition: background-color 0.2s ease, transform 0.2s ease;

        &.is-active {
            background: #FFFFFF;
            transform: scale(1.25);
        }
    }
}

/* --- TOAST NOTIFICATION --- */
.toast {
    position: fixed;
    bottom: calc(var(--space-md) + 72px + 14px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(14px) scale(0.92);
    background: linear-gradient(135deg, oklch(0.60 0.16 155) 0%, oklch(0.50 0.16 155) 100%);
    color: #FFFFFF;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: var(--font-sm);
    font-weight: 600;
    box-shadow: 0 8px 24px oklch(0.50 0.16 155 / 0.35);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;

    &.show {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
        pointer-events: auto;
    }
}

/* --- STORAGE NOTICE BANNER --- */
.storage-notice {
    position: fixed;
    bottom: calc(var(--space-md) + 68px + var(--space-sm) + env(safe-area-inset-bottom));
    left: 50%;
    transform: translate(-50%, 150%);
    opacity: 0;
    width: calc(100% - 2 * var(--space-md));
    max-width: 400px;
    background-color: var(--clr-surface);
    padding: 12px 12px 12px 14px;
    border-radius: 22px;
    box-shadow: var(--shadow-heavy);
    z-index: 3000;
    transition: transform 0.45s var(--transition-smooth), opacity 0.4s ease;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    border: 1px solid var(--clr-border);
    pointer-events: none;

    &.show {
        transform: translate(-50%, 0);
        opacity: 1;
        pointer-events: all;
    }

    & .storage-icon {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        background: oklch(0.76 0.12 85 / 0.15);
        color: var(--clr-primary-dark);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    & .storage-body {
        flex-grow: 1;

        & .storage-title {
            font-size: 14px;
            font-weight: 600;
            color: var(--clr-text-main);
            margin-bottom: 2px;
        }

        & .storage-text {
            font-size: 12px;
            color: var(--clr-text-muted);
            line-height: 1.35;
        }
    }

    & .storage-accept-btn {
        min-height: 44px; /* Touch Target */
        min-width: 56px;
        padding: 0 18px;
        font-size: 13px;
        font-weight: 600;
        color: var(--clr-surface);
        background-color: var(--clr-accent);
        border-radius: var(--radius-full);
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s ease, background-color 0.2s ease;

        &:hover {
            background-color: oklch(0.48 0.035 55);
        }

        &:active {
            transform: scale(0.95);
        }
    }
}

/* --- SCROLL REVEAL (IntersectionObserver) --- */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s var(--transition-smooth), transform 0.4s var(--transition-smooth);
    will-change: opacity, transform;

    &.is-revealed {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- VIEW TRANSITIONS API SUPPORT --- */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.28s;
    animation-timing-function: var(--transition-smooth);
}

/* --- SCROLL LOCKING UTILITIES (Instagram In-App WebView Safe) --- */
html.scroll-locked,
body.scroll-locked {
    overflow: hidden !important;
    overscroll-behavior: contain !important;
    touch-action: none;
}

body.scroll-locked {
    position: fixed !important;
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
}

/* Ensure bottom sheet scrollable areas and image viewer remain fully scrollable */
dialog.bottom-sheet-dialog,
dialog.viewer-dialog,
.sheet-content,
.legal-text,
.viewer-content {
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch;
}


/* --- CONTACT (Instagram) --- */
.wa-icon-large {
    background: linear-gradient(135deg, oklch(0.85 0.12 70 / 0.28), oklch(0.68 0.2 350 / 0.22));
    color: #C13584;
}

.wa-cta-btn {
    background: linear-gradient(135deg, #F58529 0%, #DD2A7B 55%, #8134AF 100%);

    &:hover {
        background: linear-gradient(135deg, #e5771b 0%, #cb206d 55%, #732a9e 100%);
    }
}

.contact-hint {
    margin-top: var(--space-md);
    text-align: center;

    &[hidden] {
        display: none;
    }

    & .contact-hint-note {
        margin: 0 0 var(--space-sm);
        font-size: var(--font-xs);
        line-height: 1.4;
        color: var(--clr-text-muted);
    }

    & textarea {
        width: 100%;
        height: 96px;
        margin-bottom: var(--space-sm);
        padding: var(--space-xs) var(--space-sm);
        border: 1px solid var(--clr-border);
        border-radius: var(--radius-md);
        background: var(--clr-surface);
        font: inherit;
        font-size: var(--font-xs);
        resize: none;
    }
}

/* Big call to action that opens the Instagram chat once the list has been copied */
.contact-open-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 60px;
    padding: 14px var(--space-md);
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #F58529 0%, #DD2A7B 55%, #8134AF 100%);
    color: #FFFFFF;
    font-size: var(--font-lg);
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 10px 28px oklch(0.6 0.2 350 / 0.35);
    animation: contactOpenIn 0.4s var(--transition-smooth);
    transition: transform 0.2s ease;

    &:active {
        transform: scale(0.97);
    }

    & svg {
        width: 24px;
        height: 24px;
    }
}

@keyframes contactOpenIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
