/* ═══════════════════════════════════════════════════════════
   AG Transitions — Cinematic page transitions
   Editorial + warm gold + museum-branded
   ═══════════════════════════════════════════════════════════ */

/* ── View Transitions API (Safari 18+, Chrome 127+) ────────── */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 360ms;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}
::view-transition-old(root) { animation-name: ag-vt-out; }
::view-transition-new(root) { animation-name: ag-vt-in; }
@keyframes ag-vt-out {
    to { opacity: 0; transform: scale(0.97) translateY(4px); filter: blur(4px); }
}
@keyframes ag-vt-in {
    from { opacity: 0; transform: scale(1.02) translateY(-4px); }
}

.artwork-hero { view-transition-name: artwork-hero; }

/* ── Overlay con glass effect ─────────────────────────────── */
.ag-curtain {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 16, 28, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 420ms cubic-bezier(0.22, 1, 0.36, 1),
                background 420ms cubic-bezier(0.22, 1, 0.36, 1),
                backdrop-filter 420ms cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}

/* Gradient de fondo sutil */
.ag-curtain::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse 70% 50% at 50% 35%, rgba(201, 168, 76, 0.08), transparent 60%),
        radial-gradient(ellipse 50% 70% at 50% 100%, rgba(27, 79, 138, 0.14), transparent 70%);
    opacity: 0;
    transition: opacity 600ms cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}
.ag-curtain--active::before { opacity: 1; }

.ag-curtain--active {
    pointer-events: all;
    opacity: 1;
    background: rgba(8, 16, 28, 0.92);
    backdrop-filter: blur(28px) saturate(1.4);
    -webkit-backdrop-filter: blur(28px) saturate(1.4);
}

/* ── Logo del museo (sin fondo, solo el logo pulsa) ────────── */
.ag-logo {
    width: 118px;
    height: 118px;
    margin: 0 auto 1.5rem;
    position: relative;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 540ms cubic-bezier(0.22, 1, 0.36, 1),
                transform 540ms cubic-bezier(0.22, 1, 0.36, 1);
}
.ag-curtain--active .ag-logo {
    opacity: 1;
    transform: scale(1);
    animation: ag-logo-pulse 2.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    animation-delay: 540ms;
}
.ag-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.55));
}
.ag-logo__fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%; height: 100%;
    font-size: 4rem;
    color: #C9A84C;
    filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.55));
}

/* Pulso con el logo mismo: scale + glow dorado rítmico */
@keyframes ag-logo-pulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.55))
                drop-shadow(0 0 0px rgba(201, 168, 76, 0));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.55))
                drop-shadow(0 0 32px rgba(201, 168, 76, 0.45));
    }
}
/* Versión pausa (logo más quieto, glow suave constante) */
.ag-curtain--paused .ag-logo {
    animation: ag-logo-idle 3.8s ease-in-out infinite;
}
@keyframes ag-logo-idle {
    0%, 100% { filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.55))
                      drop-shadow(0 0 14px rgba(201, 168, 76, 0.15)); }
    50%      { filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.55))
                      drop-shadow(0 0 20px rgba(201, 168, 76, 0.28)); }
}

/* ── Card container ────────────────────────────────────────── */
.ag-card {
    max-width: min(90vw, 520px);
    text-align: center;
    transform: translateY(18px) scale(0.96);
    opacity: 0;
    transition: transform 560ms cubic-bezier(0.22, 1, 0.36, 1),
                opacity 560ms cubic-bezier(0.22, 1, 0.36, 1);
    padding: 1.75rem 1.5rem;
    position: relative;
    z-index: 1;
}
.ag-curtain--active .ag-card {
    transform: translateY(0) scale(1);
    opacity: 1;
    transition-delay: 160ms;
}

/* Museo nombre (siempre sobre el logo, pequeñito) */
.ag-card__museum {
    font-size: 0.62rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 600;
    margin-bottom: 1.2rem;
}

.ag-card__eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: #C9A84C;
    font-weight: 600;
    margin-bottom: 0.85rem;
    opacity: 0.9;
}

.ag-card__divider {
    width: 48px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #C9A84C, transparent);
    margin: 0 auto 1.1rem;
    opacity: 0.6;
}

.ag-card__title {
    font-family: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
    font-size: clamp(2rem, 7vw, 3rem);
    font-weight: 500;
    color: #F4EBD0;
    line-height: 1.15;
    margin: 0 0 0.7rem;
    letter-spacing: -0.005em;
    font-style: italic;
}

.ag-card__subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.68);
    font-weight: 400;
    letter-spacing: 0.02em;
    margin: 0 0 1.4rem;
}

/* ── Countdown ─────────────────────────────────────────────── */
.ag-card__countdown {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.72rem;
    color: rgba(201, 168, 76, 0.9);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 0.3rem;
}
.ag-card__countdown-ring {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(201, 168, 76, 0.22);
    border-top-color: #C9A84C;
    animation: ag-spin 1s linear infinite;
}

/* ── Dots de "cargando" elegantes (para flash entre obras) ── */
.ag-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
}
.ag-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #C9A84C;
    opacity: 0.3;
    animation: ag-dots-bounce 1.2s ease-in-out infinite;
}
.ag-dots span:nth-child(1) { animation-delay: 0s; }
.ag-dots span:nth-child(2) { animation-delay: 0.15s; }
.ag-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ag-dots-bounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-6px); }
}

/* ── Botones de acción ─────────────────────────────────────── */
.ag-card__actions {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}
.ag-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.7rem 1.25rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 30px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.ag-btn:hover,
.ag-btn:active {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
    transform: scale(0.98);
}
.ag-btn--primary {
    background: #C9A84C;
    border-color: #C9A84C;
    color: #0D1B2A;
    font-weight: 700;
}
.ag-btn--primary:hover,
.ag-btn--primary:active {
    background: #d4b35a;
    border-color: #d4b35a;
    color: #0D1B2A;
}
.ag-btn--secondary { color: rgba(255,255,255,0.55); }
.ag-btn__icon {
    width: 14px; height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Mantener la API antigua .ag-card__cancel como alias */
.ag-card__cancel {
    display: inline-block;
    margin-top: 1.5rem;
    padding: 0.55rem 1.2rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 30px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.78rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.ag-card__cancel:hover,
.ag-card__cancel:active {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
    transform: scale(0.98);
}

/* ── Variantes ─────────────────────────────────────────────── */
.ag-curtain--complete .ag-card__title { color: #C9A84C; }
.ag-curtain--complete .ag-card__eyebrow { color: #4ade80; }
.ag-curtain--complete::before {
    background:
        radial-gradient(ellipse 80% 60% at 50% 40%, rgba(74, 222, 128, 0.15), transparent 60%),
        radial-gradient(ellipse 60% 70% at 50% 100%, rgba(201, 168, 76, 0.2), transparent 70%);
}

.ag-curtain--flash {
    background: rgba(8, 16, 28, 0.9);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
}
.ag-curtain--flash .ag-logo { width: 72px; height: 72px; }

/* ── Reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ag-curtain,
    .ag-curtain--active,
    .ag-card,
    .ag-logo,
    .ag-curtain--active .ag-card,
    .ag-curtain--active .ag-logo {
        transition-duration: 120ms !important;
        transition-delay: 0 !important;
    }
    .ag-curtain--active .ag-logo,
    .ag-card__countdown-ring,
    .ag-dots span {
        animation: none !important;
    }
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 120ms !important;
    }
}

@keyframes ag-spin { to { transform: rotate(360deg); } }
