/* ══════════════════════════════════════════════════════════
   🤲 QUIROMANCIA SUPREMA — MOBILE EXCELLENCE v6.0
   Bottom Nav estilo app · Safe Areas · Touch 44px ·
   Rendimiento móvil · Gestos · Micro-interacciones
   ══════════════════════════════════════════════════════════ */

/* ═══════════ SAFE AREAS (notch / dynamic island / home bar) ═══════════ */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --bottomnav-height: 64px;
}

/* ═══════════ BOTTOM NAVIGATION — ESTILO APP NATIVA ═══════════ */
.bottom-nav {
    display: none; /* solo visible en móvil */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 9500;
    height: calc(var(--bottomnav-height) + var(--safe-bottom));
    padding: 6px max(10px, var(--safe-left)) calc(6px + var(--safe-bottom)) max(10px, var(--safe-right));
    background: var(--glass);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}
.bottom-nav-inner {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: 100%;
    max-width: 520px;
    margin: 0 auto;
    gap: 2px;
}
.bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    border-radius: 14px;
    position: relative;
    transition: color 0.25s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    text-decoration: none;
    padding: 4px 0;
}
.bnav-item i {
    font-size: 1.15rem;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bnav-item.active { color: var(--primary-light); }
.bnav-item.active i { transform: translateY(-2px) scale(1.12); }
.bnav-item:active i { transform: scale(0.88); }
/* Píldora indicadora superior */
.bnav-item::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 26px; height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary-light), var(--accent));
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bnav-item.active::before { transform: translateX(-50%) scaleX(1); }
/* Botón central destacado — Lectura */
.bnav-item.bnav-cta {
    color: #fff;
}
.bnav-item.bnav-cta .bnav-cta-circle {
    width: 46px; height: 46px;
    margin-top: -22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--cosmic-purple));
    box-shadow: 0 6px 22px rgba(124, 106, 239, 0.55), 0 0 0 4px var(--dark);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}
.bnav-item.bnav-cta .bnav-cta-circle i {
    font-size: 1.25rem;
    color: #fff;
}
.bnav-item.bnav-cta.active .bnav-cta-circle {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    box-shadow: 0 6px 26px rgba(240, 180, 41, 0.55), 0 0 0 4px var(--dark);
    transform: translateY(-3px) scale(1.06);
}
.bnav-item.bnav-cta:active .bnav-cta-circle { transform: scale(0.92); }
.bnav-item.bnav-cta::before { display: none; }
.bnav-item .bnav-badge {
    position: absolute;
    top: 0px; right: calc(50% - 20px);
    min-width: 15px; height: 15px;
    padding: 0 3px;
    border-radius: 8px;
    background: var(--accent);
    color: #1a1200;
    font-size: 0.56rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bnav-item .bnav-badge:empty { display: none; }
[data-theme="light"] .bnav-item.bnav-cta .bnav-cta-circle { box-shadow: 0 6px 22px rgba(124,106,239,0.4), 0 0 0 4px #faf8ff; }
[data-theme="light"] .bottom-nav { box-shadow: 0 -8px 32px rgba(124,106,239,0.12); }

/* ═══════════ SWIPE HINT EN GUÍA (móvil) ═══════════ */
.swipe-hint {
    display: none;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin: 6px 0 2px;
    animation: swipePulse 2.4s ease-in-out infinite;
}
@keyframes swipePulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 0.95; }
}

/* ═══════════ ACTIVACIÓN MODO MÓVIL ═══════════ */
@media (max-width: 768px) {
    /* Bottom nav visible; ocultar hamburguesa y links top */
    .bottom-nav { display: block; }
    .mobile-menu-btn, .mobile-menu { display: none !important; }
    .swipe-hint { display: block; }

    /* Espacio inferior para no tapar contenido con la bottom nav */
    .section { padding-bottom: calc(var(--bottomnav-height) + var(--safe-bottom) + 28px) !important; }
    .main-footer { padding-bottom: calc(var(--bottomnav-height) + var(--safe-bottom) + 20px); }

    /* Back-to-top y toasts por encima de la bottom nav */
    .back-to-top {
        bottom: calc(var(--bottomnav-height) + var(--safe-bottom) + 16px);
        right: 16px;
        width: 44px; height: 44px;
    }
    .toast-container {
        bottom: calc(var(--bottomnav-height) + var(--safe-bottom) + 14px);
    }

    /* Nav superior compacta con safe area */
    .main-nav {
        padding-top: var(--safe-top);
        height: calc(var(--nav-height) + var(--safe-top));
    }

    /* ═══ TOUCH TARGETS ≥ 44px ═══ */
    .nav-icon-btn, .theme-toggle, .lang-trigger { min-width: 44px; min-height: 44px; }
    .lang-option { min-height: 46px; padding-top: 12px; padding-bottom: 12px; }
    .guide-tab { min-height: 44px; }
    .toggle-btn { min-height: 56px; }
    .history-close, .history-item-delete { min-width: 40px; min-height: 40px; }
    input, select, .form-select {
        min-height: 48px;
        font-size: 16px !important; /* evita zoom automático de iOS */
    }
    .btn-primary, .btn-secondary { min-height: 50px; }

    /* ═══ RENDIMIENTO MÓVIL ═══ */
    .aurora-blob { filter: blur(60px); }         /* blur más barato */
    .aurora-blob-3 { display: none; }            /* menos capas */
    #cosmicCanvas { opacity: 0.7; }
    .analysis-card::before, .about-card::before, .stat-card::before { display: none; } /* sin borde-máscara costoso */
    .portal-glow { animation: none; }

    /* ═══ LAYOUT FLUIDO ═══ */
    .container { padding: 0 16px; }
    .portal-content { padding: 0 12px; }
    .portal-title { font-size: clamp(1.7rem, 8vw, 2.3rem); line-height: 1.15; }
    .portal-subtitle { font-size: clamp(0.85rem, 3.8vw, 1rem); }
    .portal-features { gap: 8px; }
    .feature-badge { font-size: 0.72rem; padding: 7px 12px; }
    .tradition-tag { font-size: 0.68rem; padding: 6px 10px; }
    .section-title { font-size: clamp(1.3rem, 6vw, 1.6rem); }
    .stats-row { gap: 12px; }
    .stat-card { padding: 18px 10px; }
    .stat-number { font-size: 1.9rem; }
    .stat-label { font-size: 0.7rem; }

    /* Resultados en 1 columna en móvil */
    .result-card-content > div[style*="grid-template-columns:1fr 1fr"],
    .result-card-content > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Drawer historial ancho completo con safe areas */
    .history-drawer {
        padding-top: var(--safe-top);
        padding-bottom: var(--safe-bottom);
    }

    /* Guía: pasos y tabs más compactos */
    .guide-tabs {
        position: sticky;
        top: calc(var(--nav-height) + var(--safe-top));
        z-index: 500;
        background: var(--glass);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        padding: 8px 4px;
        border-radius: 0 0 14px 14px;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .guide-tabs::-webkit-scrollbar { display: none; }
    .guide-tab { flex-shrink: 0; white-space: nowrap; }

    /* Upload zones apiladas con buena proporción */
    .upload-area { gap: 14px; }

    /* Cosmic chips en columna si no caben */
    .cosmic-profile { gap: 8px; }
    .cosmic-chip { width: 100%; max-width: 340px; justify-content: flex-start; }

    /* Loading mandala más pequeño */
    .loading-mandala { transform: scale(0.85); }
}

/* ═══════════ MÓVIL PEQUEÑO ═══════════ */
@media (max-width: 380px) {
    .bnav-item { font-size: 0.55rem; }
    .bnav-item i { font-size: 1.05rem; }
    .bnav-item.bnav-cta .bnav-cta-circle { width: 42px; height: 42px; margin-top: -20px; }
    .portal-emoji { font-size: 3rem; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .feature-badge { font-size: 0.66rem; }
}

/* ═══════════ LANDSCAPE MÓVIL ═══════════ */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .bottom-nav { display: none; }
    .section { padding-bottom: 40px !important; }
    .portal-container { min-height: auto; padding: 30px 0; }
    .portal-ring { display: none; }
}

/* ═══════════ TABLETS: mantener top nav, sin bottom nav ═══════════ */
@media (min-width: 769px) {
    .bottom-nav { display: none !important; }
}

/* ═══════════ TAP FEEDBACK GLOBAL EN TÁCTIL ═══════════ */
@media (hover: none) and (pointer: coarse) {
    .analysis-card:active, .about-card:active, .stat-card:active,
    .line-guide-card:active, .mount-guide-card:active,
    .tradition-detail-card:active, .history-item:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    .btn-primary:active:not(:disabled), .btn-secondary:active {
        transform: scale(0.97);
    }
    /* Desactivar hovers persistentes en táctil */
    .analysis-card:hover, .about-card:hover, .stat-card:hover { transform: none; }
}

/* ═══════════ PANTALLA STANDALONE (PWA instalada) ═══════════ */
@media (display-mode: standalone) {
    .main-nav { padding-top: max(var(--safe-top), 8px); }
}
