/* ==========================================================
   Email Showcase - Structure
   1) Local Tokens
   2) Preview Frame
   3) Switchers (Locale + Version)
   4) Embedded Iframe States
   5) Hint
   6) Desktop Enhancements
   7) Responsive
   ========================================================== */

/* ==========================================================
   Local Tokens
   ========================================================== */
.email-showcase {
    --email-showcase-frame-width: 750px;
    --email-showcase-frame-height: 1100px;
    --email-showcase-frame-height-mobile: 650px;
    --email-showcase-gap: clamp(28px, 4vw, 64px);
    --email-showcase-copy-width: 500px;
    --email-showcase-locale-font-size: 1.5rem;
    --email-showcase-mobile-preview-width: 390px;
    --email-showcase-version-icon-height: 1.2em;
    --email-showcase-version-desktop-scale: 0.82;
    --email-showcase-version-mobile-scale: 0.86;
    --email-showcase-switch-height: 50px;
    --email-showcase-text-to-first-switch-gap: 50px;
    --email-showcase-hint-scroll-distance: 260px;
    --email-showcase-hint-scroll-duration: 700ms;
    --email-showcase-hint-hover-delay: 300ms;
    --email-showcase-mobile-shell-padding: 12px;
    --email-showcase-mobile-shell-radius: 44px;
    --email-showcase-mobile-screen-radius: 32px;

    /* Mobile phone-shell alignment (DIM/Disney parity) */
    --email-showcase-mobile-side-extra-gap: 20px;
    --email-showcase-mobile-shell-padding-compact: 8px;
    --email-showcase-mobile-shell-radius-compact: 34px;
    --email-showcase-mobile-screen-radius-compact: 26px;
    --email-showcase-mobile-ratio: 9 / 16;
}

/* ==========================================================
   Preview Frame
   ========================================================== */
.email-showcase-preview {
    min-width: 0;
    position: relative;
    width: var(--email-showcase-frame-width);
    height: var(--email-showcase-frame-height);
    border-radius: 0;
    background: var(--bg-light);
    overflow: hidden;
    margin-left: auto;
    margin-right: auto;
    transition: width 260ms ease, height 260ms ease, border-radius 260ms ease, box-shadow 260ms ease;
}

.email-showcase-preview.is-frame-ready {
    background: #25262C;
}

.email-showcase-preview.is-mobile {
    width: min(100%, var(--email-showcase-mobile-preview-width));
}

/* ==========================================================
   Switchers (Locale + Version)
   ========================================================== */
.email-showcase-locale-switch {
    margin: var(--title-text-space) 0 0;
    height: var(--email-showcase-switch-height);
    box-sizing: border-box;
    width: fit-content;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    border-radius: 999px;
    background: var(--bg-dark);
}

.email-showcase-locale-label {
    color: var(--text-on-dark);
    font-size: var(--email-showcase-locale-font-size);
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

.email-showcase-locale-label::after {
    content: ':';
    margin-left: 2px;
}

.email-showcase-locale-option {
    border: 0;
    background: transparent;
    color: var(--text-grey);
    font: inherit;
    font-size: var(--email-showcase-locale-font-size);
    line-height: 1;
    text-transform: uppercase;
    opacity: 1;
    cursor: pointer;
    padding: 0;
    transition: color 160ms ease-out;
}

.email-showcase-locale-option.is-active {
    color: var(--text-on-dark);
    cursor: default;
}

.email-showcase-locale-option:hover {
    color: var(--text-on-dark);
    opacity: 1;
}

.email-showcase-locale-option.is-active:hover {
    color: var(--text-on-dark);
    opacity: 1;
}

.email-showcase-locale-option:focus-visible {
    outline: 2px solid var(--text-on-dark);
    outline-offset: 4px;
    border-radius: 4px;
}

.email-showcase-version-switch {
    margin-top: var(--title-text-space);
}

.email-showcase-version-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    color: var(--text-grey);
    transition: color 160ms ease-out;
}

.email-showcase-version-option.is-active,
.email-showcase-version-option:hover {
    color: var(--text-on-dark);
}

.email-showcase-version-icon {
    width: auto;
    height: var(--email-showcase-version-icon-height);
    display: block;
    filter: brightness(0) saturate(100%) invert(68%) sepia(0%) saturate(0%) hue-rotate(164deg) brightness(95%) contrast(88%);
    transition: filter 220ms ease-out;
}

.email-showcase-version-option.is-active .email-showcase-version-icon,
.email-showcase-version-option:hover .email-showcase-version-icon {
    filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(110%) contrast(100%);
}

.email-showcase-version-option[data-preview-mode="mobile"] .email-showcase-version-icon {
    transform: scale(var(--email-showcase-version-mobile-scale));
    transform-origin: center;
}

.email-showcase-version-option[data-preview-mode="desktop"] .email-showcase-version-icon {
    transform: scale(var(--email-showcase-version-desktop-scale));
    transform-origin: center;
}

/* ==========================================================
   Embedded Iframe States
   ========================================================== */
.email-showcase-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    border: 0;
    border-radius: 0;
    background: #25262C;
    overflow: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease-out;
    z-index: 0;
}

.email-showcase-frame::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.email-showcase-frame.is-ready {
    visibility: visible;
}

.email-showcase-frame.is-active {
    opacity: 1;
    pointer-events: auto;
    z-index: 1;
}

@media (hover: hover) and (pointer: fine) {
    body[data-project-slug="dxo-email"] .email-showcase-frame.is-active {
        cursor: pointer;
    }
}

/* ==========================================================
   Hint
   ========================================================== */
.email-showcase-hint {
    display: inline-block;
    width: fit-content;
    margin: var(--title-text-space) 0 0;
    color: var(--text-grey);
    font-size: var(--text-hint-size);
    font-weight: var(--canvas-showcase-hint-weight, 400);
    line-height: var(--body-leading);
}

/* ==========================================================
   Desktop Enhancements
   ========================================================== */
@media (min-width: 769px) {
    .email-showcase-hint {
        cursor: pointer;
        transition: color 180ms ease-out;
    }

    .email-showcase-hint:hover {
        color: var(--text-on-light);
    }

    .email-showcase-preview.is-mobile {
        padding: var(--email-showcase-mobile-shell-padding);
        border-radius: var(--email-showcase-mobile-shell-radius);
        background: var(--bg-dark);
        box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-on-dark) 24%, transparent);
    }

    .email-showcase-preview.is-mobile .email-showcase-frame {
        inset: var(--email-showcase-mobile-shell-padding);
        width: calc(100% - (var(--email-showcase-mobile-shell-padding) * 2));
        height: calc(100% - (var(--email-showcase-mobile-shell-padding) * 2));
        border-radius: var(--email-showcase-mobile-screen-radius);
        overflow: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .email-showcase-preview.is-mobile .email-showcase-frame::-webkit-scrollbar {
        width: 0;
        height: 0;
        display: none;
    }

    .email-showcase-preview.is-mobile::after {
        content: "";
        position: absolute;
        right: -2px;
        top: 28%;
        width: 3px;
        height: 72px;
        border-radius: 999px;
        background: color-mix(in srgb, var(--bg-dark) 82%, var(--text-on-dark));
        pointer-events: none;
    }
}

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 1024px) {
    .email-showcase-preview.is-mobile {
        width: min(100%, var(--email-showcase-mobile-preview-width));
    }

    .email-showcase-frame {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .email-showcase-preview {
        height: var(--email-showcase-frame-height-mobile);
    }

    .email-showcase-preview.is-mobile {
        width: min(100%, var(--email-showcase-mobile-preview-width));
        padding: var(--email-showcase-mobile-shell-padding);
        border-radius: var(--email-showcase-mobile-shell-radius);
        background: var(--bg-dark);
        box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-on-dark) 24%, transparent);
    }

    .email-showcase-preview.is-mobile .email-showcase-frame {
        inset: var(--email-showcase-mobile-shell-padding);
        width: calc(100% - (var(--email-showcase-mobile-shell-padding) * 2));
        height: calc(100% - (var(--email-showcase-mobile-shell-padding) * 2));
        border-radius: var(--email-showcase-mobile-screen-radius);
        overflow: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .email-showcase-preview.is-mobile .email-showcase-frame::-webkit-scrollbar {
        width: 0;
        height: 0;
        display: none;
    }

    .email-showcase-preview.is-mobile::after {
        content: "";
        position: absolute;
        right: -2px;
        top: 28%;
        width: 3px;
        height: 72px;
        border-radius: 999px;
        background: color-mix(in srgb, var(--bg-dark) 82%, var(--text-on-dark));
        pointer-events: none;
    }

    .email-showcase-locale-switch {
        width: 100%;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
        justify-content: center;
        gap: clamp(6px, 2.2vw, 10px);
        padding: 12px clamp(12px, 4vw, 18px);
    }

    .email-showcase-locale-label,
    .email-showcase-locale-option {
        font-size: clamp(1rem, 4.3vw, 1.2rem);
    }

    .email-showcase-hint {
        display: block;
        width: fit-content;
        margin-left: auto;
        margin-right: auto;
        text-align: center;
    }

    .email-showcase-version-switch {
        display: none !important;
    }

    /* iOS: keep all iframes loadable; only active one should handle touch scrolling. */
    .email-showcase-frame.is-active {
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 640px) {
    body[data-project-slug="dxo-email"] .email-showcase {
        --email-showcase-mobile-preview-width: calc(100dvw - (2 * (var(--page-gutter) + var(--email-showcase-mobile-side-extra-gap))));
        --email-showcase-mobile-shell-padding: var(--email-showcase-mobile-shell-padding-compact);
        --email-showcase-mobile-shell-radius: var(--email-showcase-mobile-shell-radius-compact);
        --email-showcase-mobile-screen-radius: var(--email-showcase-mobile-screen-radius-compact);
    }

    body[data-project-slug="dxo-email"] .email-showcase-preview {
        width: min(100%, var(--email-showcase-mobile-preview-width));
        height: auto;
        aspect-ratio: var(--email-showcase-mobile-ratio);
    }

    body[data-project-slug="dxo-email"] .email-showcase-preview.is-mobile {
        width: min(100%, var(--email-showcase-mobile-preview-width));
        padding: var(--email-showcase-mobile-shell-padding);
        border-radius: var(--email-showcase-mobile-shell-radius);
    }

    body[data-project-slug="dxo-email"] .email-showcase-preview.is-mobile .email-showcase-frame {
        inset: var(--email-showcase-mobile-shell-padding);
        width: calc(100% - (var(--email-showcase-mobile-shell-padding) * 2));
        height: calc(100% - (var(--email-showcase-mobile-shell-padding) * 2));
        border-radius: var(--email-showcase-mobile-screen-radius);
        aspect-ratio: auto;
    }
}
