/* Página 404 compartida (landing, marketplaces y tiendas). La usan la app (F3) y Apache (ErrorDocument).
   Concepto: cuarto oscuro con un foco colgando; el apagador lo prende y la luz llena la pantalla. */

:root {
    --bg: #0a0918;
    --text: #f4f4ff;
    --muted: #b8b9d9;
    --primary: #4f46e5;
    --primary-hover: #6366f1;
    --on-primary: #ffffff;
    --ghost-bg: rgba(255, 255, 255, 0.06);
    --ghost-border: rgba(165, 180, 252, 0.3);
    --ghost-hover: rgba(165, 180, 252, 0.14);
    --warm: #ffd66b;
    --focus: #a5b4fc;
    --cord: 70vh;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Fondo ---------- */

.aurora {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.45;
    transition: opacity 0.8s ease;
}

.blob {
    position: absolute;
    width: 42vmax;
    height: 42vmax;
    border-radius: 50%;
    filter: blur(90px);
    will-change: transform;
}

.blob-1 { background: #3730a3; top: -14vmax; left: -10vmax; animation: drift1 22s ease-in-out infinite alternate; }
.blob-2 { background: #1d4ed8; bottom: -18vmax; right: -12vmax; animation: drift2 26s ease-in-out infinite alternate; }
.blob-3 { background: #6d28d9; top: 35%; left: 60%; width: 26vmax; height: 26vmax; opacity: 0.7; animation: drift3 30s ease-in-out infinite alternate; }

@keyframes drift1 { to { transform: translate(18vw, 14vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vw, -12vh) scale(1.1); } }
@keyframes drift3 { to { transform: translate(-30vw, 10vh) scale(0.85); } }

.grid-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.5;
    background-image:
        linear-gradient(rgba(165, 180, 252, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(165, 180, 252, 0.07) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
    transition: opacity 0.8s ease;
}

/* Luz cálida que sale del foco; el JS la centra en el foco (--lx / --ly) */
.room-light {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background:
        radial-gradient(circle at var(--lx, 50%) var(--ly, 32%), rgba(255, 214, 107, 0.34) 0, rgba(255, 190, 90, 0.14) 22vmax, rgba(255, 170, 80, 0) 55vmax);
    transition: opacity 0.5s ease;
}

.lights-on .room-light { opacity: 1; }
.lights-on .aurora { opacity: 0.8; }
.lights-on .grid-bg { opacity: 1; }

/* ---------- Contenido ---------- */

.wrap {
    position: relative;
    z-index: 1;
    flex: 1;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 48px 16px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.code {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(6px, 1.5vw, 14px);
    margin-bottom: 20px;
}

.digit {
    font-family: "Space Grotesk", system-ui, sans-serif;
    font-weight: 700;
    font-size: clamp(96px, 22vw, 180px);
    line-height: 0.8;
    letter-spacing: -0.04em;
    background: linear-gradient(160deg, #ffffff 20%, #a5b4fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transition: filter 0.5s ease;
}

.lights-on .digit {
    filter: drop-shadow(0 0 22px rgba(255, 214, 107, 0.35));
}

/* ---------- El foco ---------- */

.bulb-slot {
    position: relative;
    width: clamp(78px, 17vw, 138px);
    height: calc(clamp(78px, 17vw, 138px) * 1.433);
    margin-bottom: calc(clamp(96px, 22vw, 180px) * -0.06);
}

.bulb {
    position: absolute;
    inset: 0;
    display: block;
    cursor: pointer;
    transform-origin: 50% calc(-1 * var(--cord));
    animation: sway 5s ease-in-out infinite alternate;
    -webkit-tap-highlight-color: transparent;
}

/* Cable que sube hasta arriba de la pantalla */
.bulb::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 100%;
    width: 2px;
    height: var(--cord);
    margin-left: -1px;
    background: linear-gradient(to top, #3b3e5e, #24263d);
}

/* Empujón al usar el apagador (lo activa el JS) */
.bulb.swing {
    animation: swing 1.6s var(--ease-out), sway 5s ease-in-out 1.6s infinite alternate;
}

@keyframes sway {
    from { transform: rotate(-0.6deg); }
    to { transform: rotate(0.6deg); }
}

@keyframes swing {
    0% { transform: rotate(0); }
    15% { transform: rotate(2.4deg); }
    35% { transform: rotate(-1.8deg); }
    55% { transform: rotate(1.1deg); }
    75% { transform: rotate(-0.6deg); }
    100% { transform: rotate(-0.6deg); }
}

.bulb-svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.glass-off {
    fill: rgba(165, 180, 252, 0.1);
    stroke: rgba(165, 180, 252, 0.55);
    stroke-width: 2.5;
}

.glass-on {
    opacity: 0;
    transition: opacity 0.35s ease;
}

.neck,
.filament {
    stroke: #7d82ad;
    transition: stroke 0.3s ease, filter 0.3s ease;
}

.shine {
    fill: rgba(255, 255, 255, 0.22);
}

.lights-on .glass-on,
.bulb.flicker .glass-on {
    opacity: 1;
}

.lights-on .filament,
.bulb.flicker .filament {
    stroke: #fff4c2;
    filter: drop-shadow(0 0 4px #fff);
}

.lights-on .neck { stroke: #c9a24a; }

.lights-on .bulb-svg {
    filter: drop-shadow(0 0 28px rgba(255, 214, 107, 0.85)) drop-shadow(0 0 70px rgba(255, 190, 90, 0.45));
}

/* Parpadeo de "invitación" al cargar */
.bulb.flicker .glass-on {
    animation: flicker 1.1s steps(1) forwards;
}

@keyframes flicker {
    0% { opacity: 0.9; }
    10% { opacity: 0; }
    22% { opacity: 0.7; }
    30% { opacity: 0; }
    38% { opacity: 1; }
    52% { opacity: 0; }
    100% { opacity: 0; }
}

/* ---------- Apagador ---------- */

.switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 6px 18px 6px 8px;
    border: 1px solid var(--ghost-border);
    border-radius: 999px;
    background: var(--ghost-bg);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background-color 0.2s ease, border-color 0.3s ease, transform 0.2s var(--ease-out);
}

.switch:hover { background: var(--ghost-hover); }
.switch:active { transform: scale(0.97); }

.switch-track {
    position: relative;
    width: 56px;
    height: 32px;
    border-radius: 999px;
    background: #23233d;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
    transition: background-color 0.3s ease;
}

.switch-thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #9ea3c9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.35s var(--ease-out), background-color 0.3s ease, box-shadow 0.3s ease;
}

.switch[aria-checked="true"] { border-color: rgba(255, 214, 107, 0.55); }
.switch[aria-checked="true"] .switch-track { background: #d99a1e; }
.switch[aria-checked="true"] .switch-thumb {
    transform: translateX(24px);
    background: #fff8dc;
    box-shadow: 0 0 12px 2px rgba(255, 214, 107, 0.8);
}

/* Pulso para invitar a usar el apagador (se quita al primer uso).
   Va en un pseudo-elemento para no pisar la animación de entrada (.reveal) del botón. */
.switch { position: relative; }

.switch.hint::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    pointer-events: none;
    animation: hint 1.6s ease-in-out 2;
}

@keyframes hint {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 214, 107, 0); }
    50% { box-shadow: 0 0 0 8px rgba(255, 214, 107, 0.2); }
}

.status {
    min-height: 1.5em;
    margin: 10px 0 28px;
    font-size: 15px;
    color: var(--muted);
}

/* ---------- Textos ---------- */

.eyebrow {
    margin: 0 0 8px;
    font-family: "Space Grotesk", system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

h1 {
    margin: 0 0 12px;
    font-family: "Space Grotesk", system-ui, sans-serif;
    font-size: clamp(26px, 5vw, 40px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.lead {
    margin: 0 0 32px;
    max-width: 52ch;
    font-size: clamp(16px, 2.2vw, 18px);
    color: var(--muted);
    text-wrap: pretty;
}

.path-wrap {
    display: block;
    margin-top: 8px;
    font-size: 14px;
}

.path-wrap code {
    display: inline-block;
    max-width: 100%;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--ghost-bg);
    border: 1px solid var(--ghost-border);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
    overflow-wrap: anywhere;
}

/* ---------- Botones ---------- */

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 22px;
    border-radius: 999px;
    border: 0;
    font: inherit;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s var(--ease-out), box-shadow 0.2s ease;
}

.btn[hidden] { display: none; }

.btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 8px 24px -8px rgba(79, 70, 229, 0.7);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-ghost {
    background: var(--ghost-bg);
    color: var(--text);
    border: 1px solid var(--ghost-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.btn-ghost:hover {
    background: var(--ghost-hover);
    transform: translateY(-2px);
}

.btn:active { transform: translateY(0) scale(0.98); }

.btn:focus-visible,
.switch:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

.foot {
    position: relative;
    z-index: 1;
    min-height: 52px;
    padding: 16px;
    text-align: center;
    font-family: "Space Grotesk", system-ui, sans-serif;
    font-size: 13px;
    letter-spacing: 0.08em;
    color: var(--muted);
}

/* ---------- Entrada escalonada ---------- */

.reveal {
    opacity: 0;
    translate: 0 16px;
    animation: reveal 0.6s var(--ease-out) forwards;
    animation-delay: calc(var(--d, 0) * 70ms + 80ms);
}

@keyframes reveal { to { opacity: 1; translate: 0 0; } }

/* ---------- Pantallas chicas ---------- */

@media (max-width: 480px) {
    .wrap { padding-top: 40px; }
    .actions { flex-direction: column; width: 100%; }
    .btn { width: 100%; }
}

/* ---------- Movimiento reducido: sin balanceo ni parpadeos; el apagador sigue funcionando ---------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
    .reveal { opacity: 1; translate: none; }
}
