/* ── Variables ───────────────────────────────────────────── */
:root {
    --esc-red:        #e10423;
    --esc-dark:       #2a2a2a;
    --esc-light:      #f5f5f5;
    --esc-white:      #ffffff;
    --esc-border:     #e0e0e0;
    --esc-shadow:     0 2px 10px rgba(0,0,0,.10);
    --esc-shadow-lg:  0 16px 48px rgba(0,0,0,.22);
    --esc-radius:     10px;
    --esc-transition: .22s ease;
}

/* ── Scope reset ─────────────────────────────────────────── */
.esc-ad-formats-wrapper *,
.esc-ad-formats-wrapper *::before,
.esc-ad-formats-wrapper *::after { box-sizing: border-box; }

/* ── Wrapper ─────────────────────────────────────────────── */
.esc-ad-formats-wrapper { width: 100%; position: relative; }

.esc-ad-formats-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--esc-dark);
    margin: 0 0 18px;
    line-height: 1.2;
}

/* ── Outer row: [arrow] [viewport] [arrow] ───────────────── */
.esc-ad-formats-outer {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Viewport ────────────────────────────────────────────── */
.esc-ad-formats-viewport {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

/* ── Track ───────────────────────────────────────────────── */
.esc-ad-formats-track {
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    padding: 0 2px 0;
    transition: transform .35s cubic-bezier(.4,0,.2,1);
    will-change: transform;
    /* desktop: grab cursor */
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y; /* allow vertical page scroll, JS handles horizontal */
}
.esc-ad-formats-track.esc-ad-formats-dragging {
    transition: none;
    cursor: grabbing;
}

/* ── Card – width set by JS, height fixed ────────────────── */
.esc-ad-formats-card {
    flex-shrink: 0;
    /* width + flex set inline by JS, height is determined by image aspect-ratio */
    background: var(--esc-white);
    border: 1.5px solid var(--esc-border);
    border-radius: var(--esc-radius);
    overflow: hidden;
    box-shadow: var(--esc-shadow);
    transition: transform var(--esc-transition), box-shadow var(--esc-transition),
                border-color var(--esc-transition);
}
.esc-ad-formats-card--link { cursor: pointer; }
.esc-ad-formats-card--link:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,.13);
    border-color: var(--esc-red);
}
.esc-ad-formats-card--link:focus-visible {
    outline: 3px solid var(--esc-red);
    outline-offset: 2px;
}

/* ── Card image – fills all space above label ────────────── */
.esc-ad-formats-card-img {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--esc-light);
}
.esc-ad-formats-card-img img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
    transition: transform .35s ease;
}
.esc-ad-formats-card--link:hover .esc-ad-formats-card-img img { transform: scale(1.05); }

.esc-ad-formats-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: #aaa;
}

/* ── Overlay ─────────────────────────────────────────────── */
.esc-ad-formats-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(42,42,42,.5);
    opacity: 0;
    transition: opacity var(--esc-transition);
    backdrop-filter: blur(2px);
}
.esc-ad-formats-card--link:hover .esc-ad-formats-overlay { opacity: 1; }

/* ── Card label ──────────────────────────────────────────── */
.esc-ad-formats-card-label {
    flex-shrink: 0;
    padding: 9px 12px 11px;
    font-size: 13px; font-weight: 600;
    color: var(--esc-dark);
    line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: var(--esc-white);
}

/* ── Arrow buttons ───────────────────────────────────────── */
.esc-ad-formats-btn {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--esc-white);
    border: 1.5px solid var(--esc-border);
    box-shadow: var(--esc-shadow);
    color: var(--esc-dark);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--esc-transition), border-color var(--esc-transition),
                color var(--esc-transition), transform var(--esc-transition);
    padding: 0;
}
.esc-ad-formats-btn:hover {
    background: var(--esc-red);
    border-color: var(--esc-red);
    color: var(--esc-white);
    transform: scale(1.08);
}
.esc-ad-formats-btn:disabled { opacity: .3; pointer-events: none; }

/* Mobile: arrows move below the slider, centered */
@media (max-width: 599px) {
    .esc-ad-formats-outer {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px 10px;
    }
    .esc-ad-formats-viewport {
        order: -1;
        flex: 0 0 100%;
    }
    .esc-ad-formats-btn {
        display: flex !important;
        order: 1;
    }
    .esc-ad-formats-track {
        cursor: default;
    }
}

.esc-ad-formats-empty { color: #999; font-style: italic; padding: 20px 0; }

/* ── Card height breakpoints ─────────────────────────────── */

/* ═══════════════════════════════════════════════════════════
   MODAL – responsive, max 1920×1080, z-index above Avada
═══════════════════════════════════════════════════════════ */
#esc-ad-formats-modal {
    display: none;
    position: fixed; inset: 0;
    z-index: 999999 !important;
    background: rgba(42,42,42,.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center; justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity .25s ease;
}
#esc-ad-formats-modal.esc-ad-formats-open {
    display: flex;
    opacity: 1;
}

/* ── Modal box ───────────────────────────────────────────── */
#esc-ad-formats-modal-box {
    background: var(--esc-white);
    border-radius: 12px;
    box-shadow: var(--esc-shadow-lg);
    display: flex;
    flex-direction: column;
    width:      min(calc(100vw - 40px), 1920px);
    height:     min(calc(100vh - 40px), 1080px);
    max-width:  1920px;
    max-height: 1080px;
    position: relative;
    overflow: hidden;
    transform: scale(.96) translateY(12px);
    transition: transform .28s cubic-bezier(.34,1.4,.64,1);
}

/* ── Close ───────────────────────────────────────────────── */
#esc-ad-formats-modal-close {
    position: absolute; top: 10px; right: 10px; z-index: 10;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--esc-light); border: 1px solid var(--esc-border);
    color: var(--esc-dark); cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--esc-transition), color var(--esc-transition),
                transform var(--esc-transition);
}
#esc-ad-formats-modal-close:hover {
    background: var(--esc-red); border-color: var(--esc-red);
    color: var(--esc-white); transform: rotate(90deg);
}

/* ── Header ──────────────────────────────────────────────── */
#esc-ad-formats-modal-header {
    flex-shrink: 0;
    padding: 14px 52px 12px 18px;
    font-weight: 700; font-size: .95rem;
    color: var(--esc-dark); line-height: 1.2;
    border-bottom: 1px solid var(--esc-border);
    background: transparent;
}

/* ── Body – iframe fills via absolute ────────────────────── */
#esc-ad-formats-modal-body {
    flex: 1;
    position: relative;
    background: var(--esc-white);
    overflow: hidden;
    min-height: 0;
}
#esc-ad-formats-modal-body iframe {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    border: none; display: block;
    background: var(--esc-white);
}

/* ── Loader ──────────────────────────────────────────────── */
#esc-ad-formats-modal-loader {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--esc-white); z-index: 5; pointer-events: none;
}
.esc-ad-formats-spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(42,42,42,.1);
    border-top-color: var(--esc-red);
    border-radius: 50%;
    animation: esc-ad-formats-spin .7s linear infinite;
}
@keyframes esc-ad-formats-spin { to { transform: rotate(360deg); } }

/* ── Footer ──────────────────────────────────────────────── */
#esc-ad-formats-modal-footer {
    flex-shrink: 0;
    padding: 9px 16px; border-top: 1px solid var(--esc-border);
    background: var(--esc-light); display: flex; justify-content: flex-end;
}
#esc-ad-formats-modal-extlink {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 500;
    color: var(--esc-red); text-decoration: none;
}
#esc-ad-formats-modal-extlink:hover { text-decoration: underline; }

/* ── Avada ───────────────────────────────────────────────── */
.fusion-builder-column .esc-ad-formats-wrapper,
.fusion-column-wrapper  .esc-ad-formats-wrapper { overflow: visible; }
