/* ==========================================================================
   CENTRO DE AYUDA — Fuera del Guión  (js/ayuda.js)
   Estética Dark Luxury + glass. Usa los tokens del tema activo (--t-*) con
   valores dorados por defecto, así que se adapta a los 7 temas de lectura.
   ========================================================================== */

html.ay-sin-scroll { overflow: hidden; }

.ayuda-overlay {
    --ay-surface: var(--t-surface, #14110e);
    --ay-ink: var(--t-ink, #f5f2ec);
    --ay-muted: var(--t-muted, #b9b1a3);
    --ay-accent: var(--t-accent, #d4af37);
    --ay-accent-soft: var(--t-accent-soft, rgba(212, 175, 55, 0.14));
    --ay-border: var(--t-border, rgba(255, 255, 255, 0.09));
    position: fixed;
    inset: 0;
    z-index: 3500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    background: radial-gradient(ellipse at top, rgba(212, 175, 55, 0.08), transparent 60%), rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    animation: ayFondo 0.22s ease both;
    font-family: 'Inter', system-ui, sans-serif;
}
.ayuda-overlay[hidden] { display: none !important; }
.ayuda-overlay.ay-saliendo { animation: ayFondoSalir 0.16s ease both; }
.ayuda-overlay.ay-saliendo .ayuda-card { animation: aySalida 0.16s ease both; }

.ayuda-card {
    position: relative;
    width: 1040px;
    max-width: 100%;
    height: min(780px, calc(100vh - 2.4rem));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
    color: var(--ay-ink);
    background:
        linear-gradient(160deg, rgba(212, 175, 55, 0.07), transparent 38%),
        var(--ay-surface);
    border: 1px solid var(--ay-border);
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    outline: none;
    animation: ayEntrada 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}
.ayuda-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--ay-accent), transparent);
    opacity: 0.8;
}

/* ── Cabecera ─────────────────────────────────────────────────────────── */
.ay-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.3rem 1.5rem 1rem;
}
.ay-head-marca { display: flex; align-items: center; gap: 0.85rem; min-width: 0; flex-shrink: 0; }
.ay-head-icono {
    width: 46px; height: 46px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 14px;
    color: #1a1408;
    background: linear-gradient(135deg, #f0d48a, var(--ay-accent) 55%, #8a6c27);
    box-shadow: 0 8px 24px rgba(212, 175, 55, 0.28);
}
.ay-head-icono svg { width: 24px; height: 24px; }
.ay-head h2 {
    margin: 0;
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--ay-ink);
    text-align: left;
    border: none;
    padding: 0;
    background: none;
}
.ay-head h2::after, .ay-head h2::before { display: none !important; }
.ay-head p { margin: 0.1rem 0 0; font-size: 0.82rem; color: var(--ay-muted); text-align: left; }
.ay-head p b { color: var(--ay-accent); font-weight: 600; }

.ay-buscar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    margin-left: auto;
    max-width: 420px;
    padding: 0 0.9rem;
    height: 44px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--ay-border);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    cursor: text;
}
.ay-buscar:focus-within {
    border-color: var(--ay-accent);
    background: rgba(212, 175, 55, 0.05);
    box-shadow: 0 0 0 4px var(--ay-accent-soft);
}
.ay-buscar svg { width: 17px; height: 17px; color: var(--ay-muted); flex-shrink: 0; }
.ay-buscar input {
    flex: 1; min-width: 0;
    border: none; outline: none; background: transparent;
    color: var(--ay-ink);
    font: inherit; font-size: 0.9rem;
}
.ay-buscar input::placeholder { color: var(--ay-muted); opacity: 0.75; }

.ay-cerrar {
    width: 40px; height: 40px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 12px;
    border: 1px solid var(--ay-border);
    background: transparent;
    color: var(--ay-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.ay-cerrar:hover { color: var(--ay-ink); border-color: var(--ay-accent); transform: rotate(90deg); }
.ay-cerrar svg { width: 18px; height: 18px; }

/* ── Cifras ───────────────────────────────────────────────────────────── */
.ay-cifras {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    padding: 0 1.5rem 1rem;
}
.ay-cifras > div {
    display: flex; align-items: baseline; gap: 0.45rem;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--ay-border);
}
.ay-cifras strong {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 1.25rem; font-weight: 800;
    background: linear-gradient(135deg, #f0d48a, var(--ay-accent));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.ay-cifras span { font-size: 0.76rem; color: var(--ay-muted); }

/* ── Cuerpo: navegación + contenido ───────────────────────────────────── */
.ay-cuerpo {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 252px 1fr;
    border-top: 1px solid var(--ay-border);
}
.ay-nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.9rem 0.7rem;
    overflow-y: auto;
    border-right: 1px solid var(--ay-border);
    background: rgba(0, 0, 0, 0.12);
}
.ay-nav-item {
    position: relative;
    display: flex; align-items: center; gap: 0.7rem;
    width: 100%;
    padding: 0.62rem 0.75rem;
    border: none; border-radius: 10px;
    background: transparent;
    color: var(--ay-muted);
    font: inherit; font-size: 0.86rem; font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, transform 0.18s;
}
.ay-nav-item svg { width: 17px; height: 17px; flex-shrink: 0; transition: color 0.18s; }
.ay-nav-item span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ay-nav-item em {
    font-style: normal; font-size: 0.7rem; font-weight: 700;
    padding: 0.08rem 0.45rem; border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ay-muted);
}
.ay-nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--ay-ink); transform: translateX(2px); }
.ay-nav-item:focus-visible { outline: 2px solid var(--ay-accent); outline-offset: 1px; }
.ay-nav-item.activa {
    color: var(--ay-ink);
    background: linear-gradient(90deg, var(--ay-accent-soft), transparent);
}
.ay-nav-item.activa::before {
    content: '';
    position: absolute; left: 0; top: 22%; bottom: 22%;
    width: 3px; border-radius: 3px;
    background: var(--ay-accent);
    box-shadow: 0 0 10px var(--ay-accent);
}
.ay-nav-item.activa svg { color: var(--ay-accent); }
.ay-nav-item.activa em { background: var(--ay-accent); color: #1a1408; }
.ayuda-overlay.ay-buscando .ay-nav-item.ay-sin-resultados { opacity: 0.35; }

.ay-contenido {
    overflow-y: auto;
    padding: 1.3rem 1.5rem 1.6rem;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.35) transparent;
}
.ay-seccion[hidden] { display: none; }
.ay-seccion + .ay-seccion { margin-top: 1.8rem; }
.ay-seccion-head { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 1.1rem; animation: aySube 0.3s ease both; }
.ay-seccion-icono {
    width: 40px; height: 40px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 12px;
    background: var(--ay-accent-soft);
    color: var(--ay-accent);
    border: 1px solid rgba(212, 175, 55, 0.25);
}
.ay-seccion-icono svg { width: 20px; height: 20px; }
.ay-seccion-head h3 {
    margin: 0;
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 1.15rem; font-weight: 700;
    color: var(--ay-ink); text-align: left;
}
.ay-seccion-head p { margin: 0.15rem 0 0; font-size: 0.84rem; color: var(--ay-muted); text-align: left; }

.ay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 0.85rem;
}

/* ── Tarjetas ─────────────────────────────────────────────────────────── */
.ay-tarjeta {
    display: flex;
    gap: 0.85rem;
    padding: 1rem 1.05rem;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
    border: 1px solid var(--ay-border);
    transition: border-color 0.22s, transform 0.22s, box-shadow 0.22s;
    animation: aySube 0.34s ease both;
    animation-delay: calc(var(--i, 0) * 40ms);
}
.ay-tarjeta[hidden] { display: none; }
.ay-tarjeta:hover {
    border-color: rgba(212, 175, 55, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
}
.ay-tarjeta-icono {
    width: 36px; height: 36px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--ay-accent);
    transition: background 0.22s, transform 0.22s;
}
.ay-tarjeta:hover .ay-tarjeta-icono { background: var(--ay-accent-soft); transform: scale(1.06); }
.ay-tarjeta-icono svg { width: 18px; height: 18px; }
.ay-tarjeta-cuerpo { flex: 1; min-width: 0; }
.ay-tarjeta h4 {
    margin: 0.1rem 0 0.35rem;
    font-size: 0.95rem; font-weight: 700;
    color: var(--ay-ink); text-align: left;
}
.ay-tarjeta p {
    margin: 0;
    font-size: 0.85rem; line-height: 1.6;
    color: var(--ay-muted); text-align: left;
}
.ay-tarjeta p b, .ay-pasos b { color: var(--ay-ink); font-weight: 600; }

.ay-pasos {
    margin: 0.65rem 0 0;
    padding: 0;
    list-style: none;
    counter-reset: paso;
    display: flex; flex-direction: column; gap: 0.4rem;
}
.ay-pasos li {
    counter-increment: paso;
    position: relative;
    padding-left: 1.75rem;
    font-size: 0.82rem; line-height: 1.5;
    color: var(--ay-muted);
}
.ay-pasos li::before {
    content: counter(paso);
    position: absolute; left: 0; top: 0.05rem;
    width: 1.2rem; height: 1.2rem;
    display: grid; place-items: center;
    border-radius: 50%;
    font-size: 0.68rem; font-weight: 800;
    background: var(--ay-accent-soft);
    color: var(--ay-accent);
}

.ay-tip {
    display: flex !important; gap: 0.5rem; align-items: flex-start;
    margin-top: 0.65rem !important;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    font-size: 0.79rem !important;
    background: rgba(212, 175, 55, 0.07);
    border-left: 2px solid var(--ay-accent);
}
.ay-tip svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 0.15rem; color: var(--ay-accent); }

.ay-colores { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.ay-color {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.22rem 0.6rem 0.22rem 0.3rem;
    border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--ay-border);
    color: var(--ay-ink);
}
.ay-color i { width: 14px; height: 14px; border-radius: 50%; display: block; }
.ay-color-amarillo i { background: #f5d742; }
.ay-color-verde i { background: #4ade80; }
.ay-color-rojo i { background: #f87171; }
.ay-color-azul i { background: #60a5fa; }

.ay-temas { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.6rem; }
.ay-tema {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 9px;
    font-family: 'Playfair Display', serif; font-size: 0.8rem; font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    transition: transform 0.18s;
}
.ay-tema:hover { transform: translateY(-2px) scale(1.06); }

.ay-acciones { margin-top: 0.75rem; display: flex; align-items: center; gap: 0.6rem; }
.ay-btn-probar {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.42rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(212, 175, 55, 0.45);
    background: transparent;
    color: var(--ay-accent);
    font: inherit; font-size: 0.78rem; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.ay-btn-probar[hidden] { display: none; }
.ay-btn-probar svg { width: 14px; height: 14px; transition: transform 0.2s; }
.ay-btn-probar:hover { background: var(--ay-accent); color: #1a1408; border-color: var(--ay-accent); box-shadow: 0 6px 18px rgba(212, 175, 55, 0.3); }
.ay-btn-probar:hover svg { transform: translateX(3px); }
.ay-btn-probar:focus-visible { outline: 2px solid var(--ay-accent); outline-offset: 2px; }
.ay-instalada { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 600; color: #4ade80; }
.ay-instalada[hidden] { display: none; }
.ay-instalada svg { width: 16px; height: 16px; }

/* Sin resultados */
.ay-vacio { text-align: center; padding: 3rem 1rem; color: var(--ay-muted); }
.ay-vacio[hidden] { display: none; }
.ay-vacio > svg { width: 42px; height: 42px; color: var(--ay-accent); opacity: 0.7; }
.ay-vacio h4 { margin: 0.8rem 0 0.3rem; color: var(--ay-ink); font-size: 1rem; }
.ay-vacio p { margin: 0 0 1rem; font-size: 0.86rem; }

/* ── Pie ──────────────────────────────────────────────────────────────── */
.ay-pie {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--ay-border);
    background: rgba(0, 0, 0, 0.12);
}
.ay-pie-tip { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.76rem; color: var(--ay-muted); }
.ay-pie-tip svg { width: 15px; height: 15px; }
.ayuda-overlay kbd {
    display: inline-block;
    min-width: 1.4em;
    padding: 0.05rem 0.38rem;
    border-radius: 6px;
    font-family: 'DM Mono', ui-monospace, monospace; font-size: 0.72rem;
    text-align: center;
    color: var(--ay-ink);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--ay-border);
    border-bottom-width: 2px;
}
.ay-btn-entendido {
    padding: 0.6rem 1.6rem;
    border-radius: 999px;
    border: none;
    font: inherit; font-size: 0.88rem; font-weight: 700;
    color: #1a1408;
    background: linear-gradient(135deg, #f0d48a, var(--ay-accent) 60%, #a8842f);
    box-shadow: 0 8px 22px rgba(212, 175, 55, 0.3);
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s;
}
.ay-btn-entendido:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(212, 175, 55, 0.4); }

/* ── Temas claros: superficie translúcida clara y contraste ───────────── */
:is(body.white-theme, body.clinico-theme, body.sepia-theme, body.sunset-theme) .ayuda-card {
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.28);
}
:is(body.white-theme, body.clinico-theme, body.sepia-theme, body.sunset-theme) :is(.ay-tarjeta, .ay-cifras > div) {
    background: rgba(0, 0, 0, 0.025);
}
:is(body.white-theme, body.clinico-theme, body.sepia-theme, body.sunset-theme) :is(.ay-nav, .ay-pie) {
    background: rgba(0, 0, 0, 0.03);
}
:is(body.white-theme, body.clinico-theme, body.sepia-theme, body.sunset-theme) .ay-cifras strong {
    background: none; -webkit-text-fill-color: var(--ay-accent); color: var(--ay-accent);
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 860px) {
    .ayuda-overlay { padding: 0; align-items: flex-end; }
    .ayuda-card {
        height: 94vh; height: 94dvh;
        border-radius: 22px 22px 0 0;
        animation-name: ayHojaSube;
    }
    .ay-head { flex-wrap: wrap; padding: 1rem 1rem 0.8rem; gap: 0.7rem; }
    .ay-head-marca { flex: 1; }
    .ay-buscar { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; height: 42px; }
    .ay-cifras { grid-template-columns: repeat(2, 1fr); padding: 0 1rem 0.8rem; gap: 0.45rem; }
    .ay-cifras > div { padding: 0.45rem 0.7rem; }
    .ay-cifras strong { font-size: 1.05rem; }
    .ay-cuerpo { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .ay-nav {
        flex-direction: row;
        gap: 0.35rem;
        padding: 0.6rem 1rem;
        overflow-x: auto; overflow-y: hidden;
        border-right: none;
        border-bottom: 1px solid var(--ay-border);
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .ay-nav::-webkit-scrollbar { display: none; }
    .ay-nav-item {
        width: auto; flex-shrink: 0;
        padding: 0.45rem 0.8rem;
        border-radius: 999px;
        border: 1px solid var(--ay-border);
        font-size: 0.8rem;
    }
    .ay-nav-item em { display: none; }
    .ay-nav-item:hover { transform: none; }
    .ay-nav-item.activa { background: var(--ay-accent-soft); border-color: var(--ay-accent); }
    .ay-nav-item.activa::before { display: none; }
    .ay-contenido { padding: 1rem; }
    .ay-grid { grid-template-columns: 1fr; gap: 0.7rem; }
    .ay-pie { padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom)); }
    .ay-pie-tip { display: none; }
    .ay-btn-entendido { width: 100%; }
}

/* ── Animaciones ──────────────────────────────────────────────────────── */
@keyframes ayFondo { from { opacity: 0; } to { opacity: 1; } }
@keyframes ayFondoSalir { from { opacity: 1; } to { opacity: 0; } }
@keyframes ayEntrada { from { opacity: 0; transform: translateY(14px) scale(0.975); } to { opacity: 1; transform: none; } }
@keyframes aySalida { to { opacity: 0; transform: translateY(8px) scale(0.985); } }
@keyframes ayHojaSube { from { transform: translateY(100%); } to { transform: none; } }
@keyframes aySube { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .ayuda-overlay, .ayuda-card, .ay-tarjeta, .ay-seccion-head { animation: none !important; }
    .ay-tarjeta:hover, .ay-nav-item:hover, .ay-cerrar:hover { transform: none; }
}
