/* =========================================
   MEDIA.CSS — fondos que cambian + sonido
   (compartido por las 4 páginas)
   ========================================= */

/* ---------- Fondo con imágenes / videos ---------- */

.bg-media {
    position: fixed;
    inset: 0;
    z-index: 0;                /* detrás del contenido, encima de los fondos sólidos */
    overflow: hidden;
    pointer-events: none;
    opacity: var(--bg-opacity, 0.6);   /* deja ver los efectos de abajo */
}

.bg-media .bg-item {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;          /* llena cualquier pantalla sin deformar */
    object-position: center;
    opacity: 0;
    transform: scale(1.04);
    transition: opacity 1.6s ease, transform 8s ease-out;
}

.bg-media .bg-item.is-active {
    opacity: 1;
    transform: scale(1);        /* zoom suave (efecto Ken Burns) */
}

/* Capa de color para que el texto se lea bien */
.bg-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--bg-tint, rgba(0, 0, 0, 0.35));
}

/* ---------- Mosaico de recuerdos ---------- */

.bg-media.is-collage {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    grid-auto-rows: minmax(220px, 1fr);
    grid-auto-flow: dense;
    gap: 7px;
    padding: 7px;
    opacity: 1;
    background: #09070a;
}

.bg-media.is-collage .bg-item,
.bg-media.is-collage .bg-item.is-active {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    opacity: 0.92;
    transform: none;
    filter: saturate(0.82) brightness(0.92);
    transition: filter 0.5s ease, opacity 0.5s ease;
}

.bg-media.is-collage .bg-item:nth-child(3n + 1) {
    grid-row: span 2;
}

.bg-media.is-collage .bg-item:nth-child(5n + 2) {
    grid-column: span 2;
}

.bg-media.is-collage::after {
    z-index: 1;
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.06), var(--bg-tint, rgba(0, 0, 0, 0.32))),
        radial-gradient(circle at center, transparent 35%, rgba(0, 0, 0, 0.10) 100%);
}

@media (max-width: 600px) {
    .bg-media.is-collage {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: minmax(180px, 1fr);
        gap: 4px;
        padding: 4px;
    }
}

/* ---------- Pantalla de entrada (solo Inicio) ---------- */

.gate {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 35%, #2a1220, #12090e 70%);
    color: #fff;
    text-align: center;
    transition: opacity 0.7s ease, visibility 0.7s ease;
}

.gate.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.gate-card {
    max-width: 340px;
}

.gate-emoji {
    font-size: clamp(3rem, 16vw, 4.5rem);
    margin-bottom: 12px;
    animation: gate-bounce 1.8s ease-in-out infinite;
}

.gate h2 {
    margin: 0 0 10px;
    font-size: clamp(1.3rem, 6vw, 1.8rem);
    line-height: 1.25;
}

.gate p {
    margin: 0 0 24px;
    font-size: 0.95rem;
    opacity: 0.8;
}

.gate-btn {
    min-height: 52px;
    padding: 0 30px;
    border: 0;
    border-radius: 999px;
    background: #f3b6c9;
    color: #2a1220;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.gate-btn:active {
    transform: scale(0.97);
}

@keyframes gate-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

/* ---------- Botón de sonido ---------- */

.sound-btn {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 900;
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

.sound-hint {
    position: fixed;
    left: 50%;
    bottom: max(72px, calc(env(safe-area-inset-bottom) + 60px));
    z-index: 900;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
    padding: 12px 20px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    color: #222;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    animation: hint-pulse 1.6s ease-in-out infinite;
}

.sound-hint[hidden] {
    display: none;
}

@keyframes hint-pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50%      { transform: translateX(-50%) scale(1.05); }
}

/* ---------- Ajustes extra para pantallas pequeñas ---------- */

@media (max-width: 380px) {
    .gate h2 { font-size: 1.2rem; }
    .sound-btn { width: 44px; height: 44px; }
}

/* Celular en horizontal: menos altura disponible */
@media (max-height: 480px) and (orientation: landscape) {
    .gate-emoji { font-size: 2.4rem; margin-bottom: 4px; }
    .gate p { margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .bg-media .bg-item { transition: opacity 0.4s ease; transform: none; }
    .gate-emoji, .sound-hint { animation: none; }
}
