/* =====================================================
   theme-toggle.css — Botón animado Sol/Luna
   VORTEX Agency — vortex_pagina_web
   ===================================================== */

/* ---- CONTENEDOR FLOTANTE ---- */
#theme-toggle-btn {
    position: fixed;
    bottom: 106px;
    /* Se pone a la izquierda, el de cotización está a la derecha */
    left: 28px;
    z-index: 999;
    width: 54px;
    height: 54px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- CÁPSULA DE CRISTAL ---- */
.toggle-glass {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(14, 30, 60, 0.45);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reflejo cristal */
.toggle-glass::before {
    content: '';
    position: absolute;
    top: 4px; left: 8px; right: 8px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    pointer-events: none;
    border-radius: 50%;
}

#theme-toggle-btn:hover .toggle-glass {
    transform: scale(1.12);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Tema claro: ajustar colores del botón */
body.light-theme #theme-toggle-btn .toggle-glass {
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(0, 120, 200, 0.25);
    box-shadow:
        0 8px 32px rgba(0, 80, 160, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* ---- FACE WRAPPER (contiene sol y luna) ---- */
.toggle-face-wrap {
    position: relative;
    width: 30px;
    height: 30px;
}

/* ---- SOL ---- */
.toggle-sun {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.toggle-sun svg {
    width: 26px;
    height: 26px;
    overflow: visible;
}

/* Cara del sol */
.sun-face {
    fill: #f5c842;
    filter: drop-shadow(0 0 6px rgba(245, 200, 66, 0.7));
}
.sun-ray {
    stroke: #f5c842;
    stroke-width: 2;
    stroke-linecap: round;
    filter: drop-shadow(0 0 4px rgba(245, 200, 66, 0.6));
}
.sun-eye  { fill: #c87a00; }
.sun-smile { stroke: #c87a00; stroke-width: 1.5; stroke-linecap: round; fill: none; }
.sun-cheek { fill: rgba(255, 140, 80, 0.5); }

/* ---- LUNA ---- */
.toggle-moon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.toggle-moon svg {
    width: 22px;
    height: 22px;
    overflow: visible;
}

.moon-face { fill: #c8d8f0; filter: drop-shadow(0 0 6px rgba(180, 210, 255, 0.6)); }
.moon-eye  { fill: #6888aa; }
.moon-smile { stroke: #6888aa; stroke-width: 1.5; stroke-linecap: round; fill: none; }
.moon-cheek { fill: rgba(120, 160, 220, 0.4); }
.moon-star  { fill: #a0c0e8; }

/* ---- ESTRELLAS de fondo (modo oscuro) ---- */
.toggle-stars {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
    pointer-events: none;
}
.toggle-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.4s;
}
.toggle-star:nth-child(1) { top: 22%; left: 15%; width: 1.5px; height: 1.5px; }
.toggle-star:nth-child(2) { top: 14%; right: 22%; }
.toggle-star:nth-child(3) { bottom: 24%; left: 20%; }
.toggle-star:nth-child(4) { bottom: 18%; right: 16%; width: 1.5px; height: 1.5px; }
.toggle-star:nth-child(5) { top: 40%; right: 12%; }

/* ---- NUBECITA de fondo (modo claro) ---- */
.toggle-cloud {
    position: absolute;
    bottom: 6px; right: 5px;
    font-size: 0.55rem;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(100,160,220,0.4));
}

/* ---- ESTADO: MODO OSCURO (por defecto) ---- */
/* Sol visible, luna oculta */
body:not(.light-theme) .toggle-sun {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}
body:not(.light-theme) .toggle-moon {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}
body:not(.light-theme) .toggle-star { opacity: 0; }
body:not(.light-theme) .toggle-cloud { opacity: 0; }

/* ---- ESTADO: MODO CLARO ---- */
/* Luna visible, sol oculto */
body.light-theme .toggle-sun {
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}
body.light-theme .toggle-moon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}
body.light-theme .toggle-star { opacity: 1; }
body.light-theme .toggle-cloud { opacity: 1; }

/* ---- ANIMACIÓN DE ROTACIÓN AL HACER CLICK ---- */
.toggle-face-wrap.animating .toggle-sun {
    animation: sunSpin 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toggle-face-wrap.animating .toggle-moon {
    animation: moonSpin 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes sunSpin {
    0%   { transform: scale(1) rotate(0deg); }
    40%  { transform: scale(1.2) rotate(20deg); }
    100% { transform: scale(0.5) rotate(-90deg); opacity: 0; }
}

@keyframes moonSpin {
    0%   { transform: scale(0.5) rotate(90deg); opacity: 0; }
    60%  { transform: scale(1.15) rotate(-10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); }
}

/* ---- RAY PULSE en modo oscuro (hover) ---- */
#theme-toggle-btn:hover .sun-ray {
    animation: rayPulse 0.8s ease infinite alternate;
}
@keyframes rayPulse {
    from { stroke-width: 2; filter: drop-shadow(0 0 4px rgba(245,200,66,0.5)); }
    to   { stroke-width: 2.5; filter: drop-shadow(0 0 8px rgba(245,200,66,0.9)); }
}

/* ---- TOOLTIP ---- */
#theme-toggle-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(10, 22, 40, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(200, 214, 229, 0.9);
    font-family: var(--font-body);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 5px 10px;
    border-radius: 8px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
#theme-toggle-btn:hover::after { opacity: 1; }

body.light-theme #theme-toggle-btn::after {
    background: rgba(220, 240, 255, 0.9);
    border-color: rgba(0, 120, 200, 0.2);
    color: #2a4a6a;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
    #theme-toggle-btn {
        bottom: 84px;
        left: 16px;
        width: 48px;
        height: 48px;
    }
    .toggle-glass { width: 48px; height: 48px; }
}
