/* ==========================================================================
   Escuela Cristiana Camireña — hoja de estilos principal
   Temas claro y oscuro · sin dependencias externas
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens · tema claro (valores por defecto)
   -------------------------------------------------------------------------- */
:root {
    color-scheme: light;

    --bg: #f7f4ec;
    --bg-a: #fbf9f3;
    --bg-b: #eef2e5;
    --bg-c: #fbf9f3;

    --text: #14231a;
    --text-muted: #4f5e53;
    --tagline: #2f5d38;

    --surface: #fffdf7;
    --border: rgba(20, 60, 30, 0.16);

    --accent: #146320;
    --accent-hover: #0f4f19;
    --accent-contrast: #ffffff;

    --footer-bg: #ece7d9;
    --footer-text: #56635a;

    --focus: #0b7a2b;
    --shadow-color: rgba(16, 48, 24, 0.20);
    --logo-shadow: rgba(16, 48, 24, 0.22);

    --glow-1: rgba(25, 124, 40, 0.10);
    --glow-2: rgba(30, 115, 45, 0.08);
}

/* --------------------------------------------------------------------------
   Tokens · tema oscuro automático (preferencia del sistema)
   Mantener sincronizado con el bloque [data-theme="dark"]
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #0f0f0f;
        --bg-a: #0f0f0f;
        --bg-b: #16281a;
        --bg-c: #0f0f0f;

        --text: #f6f8f6;
        --text-muted: #c3cdc4;
        --tagline: #a9d6b2;

        --surface: rgba(255, 255, 255, 0.05);
        --border: rgba(255, 255, 255, 0.18);

        --accent: #197C28;
        --accent-hover: #167526;
        --accent-contrast: #ffffff;

        --footer-bg: #0a0a0a;
        --footer-text: #a3aea5;

        --focus: #7ee787;
        --shadow-color: rgba(0, 0, 0, 0.55);
        --logo-shadow: rgba(0, 0, 0, 0.55);

        --glow-1: rgba(25, 124, 40, 0.18);
        --glow-2: rgba(30, 115, 45, 0.12);
    }
}

/* --------------------------------------------------------------------------
   Tokens · tema oscuro elegido con el botón
   Mantener sincronizado con el bloque @media de arriba
   -------------------------------------------------------------------------- */
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0f0f0f;
    --bg-a: #0f0f0f;
    --bg-b: #13200f;
    --bg-c: #0f0f0f;

    --text: #f6f8f6;
    --text-muted: #c3cdc4;
    --tagline: #a9d6b2;

    --surface: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.18);

    --accent: #197C28;
    --accent-hover: #167526;
    --accent-contrast: #ffffff;

    --footer-bg: #0a0a0a;
    --footer-text: #a3aea5;

    --focus: #7ee787;
    --shadow-color: rgba(0, 0, 0, 0.55);
    --logo-shadow: rgba(0, 0, 0, 0.55);

    --glow-1: rgba(25, 124, 40, 0.18);
    --glow-2: rgba(30, 115, 45, 0.12);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body,
h1,
p {
    margin: 0;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--accent);
    color: var(--accent-contrast);
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Portada
   -------------------------------------------------------------------------- */
#intro {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(4.5rem, 11vh, 6rem) clamp(1.25rem, 5vw, 2.5rem) clamp(3rem, 8vh, 4.5rem);
    overflow: hidden;
    background:
        radial-gradient(ellipse 70% 60% at 28% 18%, var(--glow-1), transparent 70%),
        radial-gradient(ellipse 65% 60% at 74% 82%, var(--glow-2), transparent 70%),
        linear-gradient(150deg, var(--bg-a) 0%, var(--bg-b) 52%, var(--bg-c) 100%);
}

.container {
    width: min(100%, 680px);
    text-align: center;
}

.logo {
    display: block;
    width: auto;
    height: clamp(118px, 18vh, 150px);
    margin: 0 auto;
    filter: drop-shadow(0 16px 28px var(--logo-shadow));
}

/* Aviso de estado */
h1 {
    margin-top: 1.5rem;
    font-size: clamp(2rem, 6.2vw, 3.05rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

/* Lema */
.tagline {
    max-width: 30ch;
    margin: 1.05rem auto 0;
    font-family: Georgia, "Times New Roman", serif;
    font-style: italic;
    font-size: clamp(1.05rem, 2.8vw, 1.3rem);
    color: var(--tagline);
    text-wrap: balance;
}

.lead {
    max-width: 46ch;
    margin: 1.3rem auto 0;
    color: var(--text-muted);
    font-size: clamp(0.95rem, 2.3vw, 1.02rem);
    text-wrap: pretty;
}

/* --------------------------------------------------------------------------
   Acciones
   -------------------------------------------------------------------------- */
.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.7rem;
    margin-top: 2.1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 48px;
    padding: 0.72rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-contrast);
}

.icon {
    width: 1.15em;
    height: 1.15em;
    flex: none;
}

.icon-end {
    width: 0.95em;
    height: 0.95em;
    opacity: 0.85;
}

@media (hover: hover) {
    .btn:hover {
        border-color: var(--accent);
        color: var(--accent);
        transform: translateY(-2px);
        box-shadow: 0 12px 22px -12px var(--shadow-color);
    }

    .btn-primary:hover {
        border-color: var(--accent-hover);
        background: var(--accent-hover);
        color: var(--accent-contrast);
    }
}

/* --------------------------------------------------------------------------
   Conmutador de tema
   -------------------------------------------------------------------------- */
.theme-toggle {
    position: absolute;
    top: clamp(0.9rem, 3vw, 1.5rem);
    right: clamp(0.9rem, 3vw, 1.5rem);
    z-index: 3;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease;
}

/* Solo se muestra si hay JavaScript (evita un botón inútil sin JS) */
.js .theme-toggle {
    display: inline-flex;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.theme-toggle .icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

@media (hover: hover) {
    .theme-toggle:hover {
        border-color: var(--accent);
        color: var(--accent);
    }
}

/* --------------------------------------------------------------------------
   Pie de página
   -------------------------------------------------------------------------- */
footer {
    padding: 1.35rem clamp(1rem, 4vw, 2rem);
    border-top: 1px solid var(--border);
    background: var(--footer-bg);
}

.copyright {
    color: var(--footer-text);
    font-size: 0.875rem;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Página 404
   -------------------------------------------------------------------------- */
.error-code {
    color: var(--accent);
    font-size: clamp(3.5rem, 14vw, 5.5rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
}

.error-code + h1 {
    margin-top: 0.75rem;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    #intro {
        padding-top: clamp(4.75rem, 14vh, 6rem);
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        width: 100%;
    }
}

/* --------------------------------------------------------------------------
   Accesibilidad: movimiento reducido
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .btn:hover {
        transform: none;
    }
}
