/* ==========================================================================
   PSQ AL DÍA · Estilos comunes
   Se carga DESPUÉS del <style> de cada página, así que manda sobre él.
   - Colores de marca y modo oscuro en un solo sitio.
   - .psq-light-island: zona que se mantiene SIEMPRE clara (paneles de las
     herramientas), porque sus scripts usan colores fijos pensados para fondo claro.
   - Para una página sin modo oscuro: <html class="psq-light-only">
   ========================================================================== */

/* ---------- Colores (modo claro) ---------- */
:root,
.psq-light-island {
    --brand: #256095;           /* azul del logo */
    --brand-strong: #1b4a76;
    --brand-soft: #eaf2fa;
    --brand-grad: linear-gradient(135deg, #256095 0%, #3a86c8 100%);
    --btn-bg: #256095;
    --btn-text: #ffffff;

    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #f0f3f7;
    --text-main: #0f1b2d;
    --text-muted: #52627a;
    --border: #e3e8ef;

    --shadow-sm: 0 1px 2px rgba(15, 27, 45, .04), 0 4px 14px rgba(15, 27, 45, .05);
    --shadow-md: 0 18px 40px -18px rgba(15, 27, 45, .25);

    /* Nombres antiguos que usan las páginas y los scripts de las herramientas */
    --primary: var(--brand);
    --primary-light: var(--brand-soft);
    --card: var(--surface);
    --card-bg: var(--surface);
    --bg-alt: var(--surface-2);
    --bg-main: var(--bg);
    --text: var(--text-main);
    --white: var(--surface);
    --primary-color: var(--text-main);
    --accent-color: var(--brand);
    --bg-light: var(--bg);
    --radius: 1.25rem;
}

:root { color-scheme: light dark; }
:root[data-theme="light"], :root.psq-light-only { color-scheme: light; }
:root[data-theme="dark"]:not(.psq-light-only) { color-scheme: dark; }

/* ---------- Colores (modo oscuro) ---------- */
/* Oscuro: automático (según el móvil) salvo que se haya elegido "claro" en Ajustes */
@media (prefers-color-scheme: dark) {
    :root:not(.psq-light-only):not([data-theme="light"]) {
        --brand: #7db3e8;
        --brand-strong: #a9cdf1;
        --brand-soft: rgba(125, 179, 232, .12);
        --brand-grad: linear-gradient(135deg, #2b6aa6 0%, #4b8fd0 100%);
        --btn-bg: #2b6aa6;
        --btn-text: #ffffff;

        --bg: #0b1220;
        --surface: #121b2b;
        --surface-2: #18233a;
        --text-main: #e7edf5;
        --text-muted: #9aa9be;
        --border: #22304a;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-md: 0 18px 40px -18px rgba(0, 0, 0, .6);

        --primary: var(--brand);
        --primary-light: var(--brand-soft);
        --card: var(--surface);
        --card-bg: var(--surface);
        --bg-alt: var(--surface-2);
        --bg-main: var(--bg);
        --text: var(--text-main);
        --white: var(--surface);
        --primary-color: var(--text-main);
        --accent-color: var(--brand);
        --bg-light: var(--bg);
    }
}
/* Oscuro elegido a mano en Ajustes (mismos valores) */
:root[data-theme="dark"]:not(.psq-light-only) {
    --brand: #7db3e8;
    --brand-strong: #a9cdf1;
    --brand-soft: rgba(125, 179, 232, .12);
    --brand-grad: linear-gradient(135deg, #2b6aa6 0%, #4b8fd0 100%);
    --btn-bg: #2b6aa6;
    --btn-text: #ffffff;

    --bg: #0b1220;
    --surface: #121b2b;
    --surface-2: #18233a;
    --text-main: #e7edf5;
    --text-muted: #9aa9be;
    --border: #22304a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 18px 40px -18px rgba(0, 0, 0, .6);

    --primary: var(--brand);
    --primary-light: var(--brand-soft);
    --card: var(--surface);
    --card-bg: var(--surface);
    --bg-alt: var(--surface-2);
    --bg-main: var(--bg);
    --text: var(--text-main);
    --white: var(--surface);
    --primary-color: var(--text-main);
    --accent-color: var(--brand);
    --bg-light: var(--bg);
}

/* Paneles de herramienta: siempre claros y legibles */
.psq-light-island {
    color-scheme: light;
    background: var(--surface) !important;
    color: var(--text-main);
}

/* ---------- Toques de color (títulos y brillo de fondo) ---------- */
:root {
    --title-grad: linear-gradient(120deg, #1f5486 0%, #2a74b8 55%, #1a7fa3 100%);
    --glow-a: rgba(58, 134, 200, .20);
    --glow-b: rgba(26, 160, 190, .14);
    --icon-grad: linear-gradient(135deg, #256095 0%, #2f86c4 60%, #1f9bbd 100%);
}
/* Oscuro: automático (según el móvil) salvo que se haya elegido "claro" en Ajustes */
@media (prefers-color-scheme: dark) {
    :root:not(.psq-light-only):not([data-theme="light"]) {
        --title-grad: linear-gradient(120deg, #b9d8f6 0%, #8cc0ef 50%, #6fd3e8 100%);
        --glow-a: rgba(58, 134, 200, .28);
        --glow-b: rgba(34, 190, 220, .16);
        --icon-grad: linear-gradient(135deg, #2b6aa6 0%, #3a8fd0 60%, #23a6c6 100%);
    }
}
/* Oscuro elegido a mano en Ajustes (mismos valores) */
:root[data-theme="dark"]:not(.psq-light-only) {
    --title-grad: linear-gradient(120deg, #b9d8f6 0%, #8cc0ef 50%, #6fd3e8 100%);
    --glow-a: rgba(58, 134, 200, .28);
    --glow-b: rgba(34, 190, 220, .16);
    --icon-grad: linear-gradient(135deg, #2b6aa6 0%, #3a8fd0 60%, #23a6c6 100%);
}

/* Título grande con degradado (texto grande: contraste ≥ 3,9:1 en todo el degradado) */
.psq-grad-text,
.psq-hero h1,
body.psq-tool .hero h1 {
    background: var(--title-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--brand);
}

/* Títulos repartidos en líneas equilibradas (sin palabras sueltas al final) */
h1, h2, .psq-hero h1 { text-wrap: balance; }

/* Brillo difuminado detrás de la cabecera de cada página */
.psq-glow { position: relative; isolation: isolate; }
.psq-glow::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -40px 0 auto 0;
    height: 420px;
    pointer-events: none;
    background:
        radial-gradient(38% 60% at 30% 35%, var(--glow-a) 0%, transparent 70%),
        radial-gradient(34% 55% at 72% 30%, var(--glow-b) 0%, transparent 70%);
    filter: blur(10px);
}

/* Aparición suave solo en la primera carga (clase .psq-first-load en <body>) */
@keyframes psqFadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}
.psq-first-load .psq-stagger > * { animation: psqFadeUp .55s cubic-bezier(.2, .7, .2, 1) both; }
.psq-first-load .psq-stagger > *:nth-child(2) { animation-delay: .05s; }
.psq-first-load .psq-stagger > *:nth-child(3) { animation-delay: .10s; }
.psq-first-load .psq-stagger > *:nth-child(4) { animation-delay: .15s; }
.psq-first-load .psq-stagger > *:nth-child(5) { animation-delay: .20s; }
.psq-first-load .psq-stagger > *:nth-child(6) { animation-delay: .25s; }
.psq-first-load .psq-stagger > *:nth-child(n+7) { animation-delay: .30s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Base ---------- */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Barra superior común ---------- */
.psq-topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: none;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    padding: .7rem max(1rem, calc((100% - 1100px) / 2));
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}

.psq-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 800;
    font-size: 1.18rem;
    letter-spacing: -.03em;
}
.psq-brand img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: block;
    box-shadow: var(--shadow-sm);
}
.psq-brand span b { color: var(--brand); font-weight: 800; }

.psq-nav-link {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem .9rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 700;
    font-size: .85rem;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: color .2s, border-color .2s;
}
.psq-nav-link:hover { color: var(--brand); border-color: var(--brand); }

/* ---------- Hero común ---------- */
.psq-hero {
    text-align: center;
    padding: 3.75rem 1.25rem 2.75rem;
    background: transparent;
    color: var(--text-main);
}
.psq-hero h1 {
    margin: 0 0 .7rem;
    font-size: clamp(2.1rem, 6vw, 3.25rem);
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1.05;
}
.psq-hero p {
    margin: 0 auto;
    max-width: 620px;
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.55;
}

/* ---------- Botón principal ---------- */
.psq-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    padding: .9rem 1.6rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-weight: 800;
    font-size: 1rem;
    color: var(--btn-text);
    background: var(--icon-grad);
    box-shadow: 0 12px 30px -10px rgba(47, 134, 196, .75), inset 0 1px 0 rgba(255, 255, 255, .18);
    transition: transform .2s, box-shadow .2s;
}
.psq-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px -12px rgba(37, 96, 149, .8); }

/* ---------- Pie común ---------- */
.psq-footer {
    text-align: center;
    padding: 2rem 1rem 2.5rem;
    border-top: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: .85rem;
}
.psq-footer a { color: var(--brand); font-weight: 700; text-decoration: none; }
.psq-footer img {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 8px;
    opacity: .7;
    filter: none;
}

/* ==========================================================================
   Páginas de herramienta con la plantilla común (body.psq-tool)
   ========================================================================== */
body.psq-tool .hero {
    padding: 3.5rem 1.25rem 2.75rem;
    background: transparent;
}
body.psq-tool .hero h1 {
    font-size: clamp(2.1rem, 6vw, 3.25rem);
    letter-spacing: -.04em;
    line-height: 1.05;
}
body.psq-tool .hero p { color: var(--text-muted); }

body.psq-tool .feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
}
body.psq-tool .feature-card h3 { color: var(--text-main); }
body.psq-tool .feature-card p { color: var(--text-muted); }
body.psq-tool .feature-icon { color: var(--brand); background: var(--brand-soft); }

body.psq-tool #modalData {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

body.psq-tool .info-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-main);
}
body.psq-tool .info-panel h2 { color: var(--text-main); }
body.psq-tool .info-panel i { color: var(--brand); }

body.psq-tool .nav-footer { border-top: 1px solid var(--border); }
body.psq-tool .link-back { color: var(--brand); }

body.psq-tool .site-bottom-info {
    background: transparent;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}
body.psq-tool .site-bottom-info img {
    border-radius: 5px;
    opacity: .7;
    filter: none;
}

@media (max-width: 600px) {
    .psq-brand { font-size: 1.1rem; }
    .psq-brand img { width: 32px; height: 32px; }
    .psq-nav-link span { display: none; }
    .psq-nav-link { padding: .55rem .7rem; }
    body.psq-tool .hero { padding: 2.25rem 1rem 2rem; }

    /* Tarjetas de presentación en filas compactas: la herramienta queda más arriba */
    body.psq-tool .features-grid { gap: .75rem; margin-top: 0; margin-bottom: 1.75rem; }
    body.psq-tool .features-grid .feature-card {
        display: grid;
        grid-template-columns: 44px 1fr;
        column-gap: .9rem;
        row-gap: .2rem;
        align-items: start;
        text-align: left;
        padding: 1rem 1.1rem;
    }
    body.psq-tool .features-grid .feature-card:hover { transform: none; }
    body.psq-tool .features-grid .feature-icon {
        grid-row: span 2;
        width: 44px;
        height: 44px;
        margin: 0;
        border-radius: 12px;
        font-size: 1.15rem;
    }
    body.psq-tool .features-grid .feature-card h3 { margin: 0; font-size: 1.02rem; }
    body.psq-tool .features-grid .feature-card p { margin: 0; font-size: .9rem; line-height: 1.45; }
}

/* Línea final común de las herramientas («© 2026 PSQ AL DÍA · Herramientas clínicas»).
   :where() no suma especificidad: los estilos propios de cada página siguen mandando. */
:where(.site-bottom-info) { display: block; text-align: center; padding: 2rem 1rem; font-size: .85rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 2rem; }
:where(.site-bottom-info img) { height: 18px; vertical-align: middle; margin-right: 8px; opacity: .5; border-radius: 5px; }
:where(.nav-footer) { display: block; margin-top: 3rem; text-align: center; padding: 2rem; border-top: 1px solid var(--border); }
:where(.link-back) { color: var(--brand); font-weight: 800; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; text-transform: uppercase; letter-spacing: .5px; }
