/* base.css — reglas compartidas por todas las páginas.
   Se carga ANTES del CSS específico de cada página.
   Objetivo: eliminar el scroll horizontal fantasma y dar un
   pulido estático de época (2000s) consistente. Sin animaciones. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Mata el scroll horizontal: el viewport nunca debe desbordar.
   ponytail: la causa raíz eran los `width: 100vw` (incluyen el ancho
   de la barra de scroll); esto es el cinturón de seguridad global. */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Cursor de cámara/puntería (estética REC / Manhunt). Los interactivos conservan
   el suyo; los hotspots del paseo heredan el del fondo para NO delatarse. */
body { cursor: crosshair; }
a[href]:not(.paseo-spot), button, [role="button"], select, summary { cursor: pointer; }
input, textarea { cursor: text; }

/* Foco de teclado visible y acorde a la estética: rojo lúgubre, dashed retro */
a:focus-visible,
button:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px dashed #7a1a1a;
    outline-offset: 2px;
}

/* Leve resplandor rojo en títulos — toque lúgubre, estático (sin movimiento) */
h1,
h2 {
    text-shadow: 0 0 3px rgba(122, 26, 26, 0.45);
}

/* ===== Capa snuff / VHS global (estética tipo Manhunt / Postal): grano de película
   + scanlines + viñeta sobre toda la página. No captura clics; la conversación del
   ojo (z-index 2000) y los modales (9999) quedan por encima. */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
    background:
        radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.62) 100%),
        repeating-linear-gradient(0deg, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,0.15) 3px, rgba(0,0,0,0) 4px),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: cover, 100% 100%, 170px 170px;
    /* La cinta se gasta: el grano/scanlines se intensifican con --decay (estado.js). */
    opacity: calc(0.27 + var(--decay, 0) * 0.33);
    animation: snuffGrain 0.45s steps(3) infinite;
}
@keyframes snuffGrain {
    0%, 100% { background-position: center, 0 0, 0 0; }
    33% { background-position: center, 0 0, 7px -5px; }
    66% { background-position: center, 0 0, -6px 7px; }
}

/* ===== Desgaste de la cinta (capa que crea estado.js). Invisible al inicio
   (--decay 0); a medida que vuelves/te quedas, asoma una barra de tracking
   que rueda, como una cinta vieja. No captura clics. */
.vhs-decay {
    position: fixed;
    inset: 0;
    z-index: 61;
    pointer-events: none;
    opacity: var(--decay, 0);
}
.vhs-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 16px;
    background: linear-gradient(rgba(255,255,255,0.06), rgba(0,0,0,0.22), rgba(255,255,255,0.05));
    filter: blur(0.6px);
    mix-blend-mode: overlay;
    animation: vhsRoll 6.5s linear infinite;
}
@keyframes vhsRoll {
    0%   { top: -6%; }
    100% { top: 106%; }
}

/* ===== Encendido tipo VHS/CRT (sólo la 1ra visita; lo crea estado.js).
   Línea brillante que se abre desde el centro y revela la página. */
.poweron {
    position: fixed;
    inset: 0;
    z-index: 100001;
    background: #000;
    pointer-events: none;
    animation: poweronOut 0.35s ease 1.05s forwards;
}
.poweron::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 84vw;
    height: 3px;
    background: #fff;
    box-shadow: 0 0 24px 6px rgba(255, 255, 255, 0.9), 0 0 60px 12px rgba(122, 26, 26, 0.5);
    transform: translate(-50%, -50%) scaleX(0) scaleY(1);
    animation: poweronLine 1.05s ease forwards;
}
@keyframes poweronLine {
    0%   { transform: translate(-50%, -50%) scaleX(0) scaleY(1); opacity: 0; }
    18%  { transform: translate(-50%, -50%) scaleX(1) scaleY(1); opacity: 1; }
    55%  { transform: translate(-50%, -50%) scaleX(1) scaleY(60); opacity: 0.9; }
    100% { transform: translate(-50%, -50%) scaleX(1) scaleY(220); opacity: 0; }
}
@keyframes poweronOut { to { opacity: 0; } }

/* Respeta a quien pide menos movimiento */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Fase 3 — Transición de página estilo grindhouse (Postal loading screen).
   La controla js/transition.js: cubre con la pantalla de carga + parpadeo de
   proyector y rayones de película al navegar entre páginas internas. */
.reel {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.reel--on {
    opacity: 1;
    pointer-events: auto;
}

.reel-img {
    position: absolute;
    inset: 0;
    background: url('../img/sources/postal-loadingScreen.jpg') no-repeat center center / cover;
    filter: contrast(1.15) saturate(0.85) brightness(0.9);
    animation: reelFlicker 0.12s steps(2) infinite;
}
@keyframes reelFlicker {
    0%   { opacity: 0.92; }
    50%  { opacity: 1; }
    100% { opacity: 0.86; }
}

/* Rayones de película que saltan lateralmente */
.reel-scratch {
    position: absolute;
    inset: 0;
    pointer-events: none;
    mix-blend-mode: screen;
    background:
        linear-gradient(90deg, transparent 18%, rgba(255,255,255,0.18) 18.4%, transparent 18.8%),
        linear-gradient(90deg, transparent 61%, rgba(0,0,0,0.5) 61.3%, transparent 61.7%),
        linear-gradient(90deg, transparent 77%, rgba(255,255,255,0.12) 77.2%, transparent 77.5%);
    animation: reelScratch 0.2s steps(3) infinite;
}
@keyframes reelScratch {
    0%   { transform: translateX(0); }
    33%  { transform: translateX(-8px); }
    66%  { transform: translateX(11px); }
    100% { transform: translateX(-4px); }
}

/* Marca de cambio de rollo (cigarette burn) arriba a la derecha */
.reel-cue {
    position: absolute;
    top: 6%;
    right: 7%;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.7);
    box-shadow: inset 0 0 0 8px rgba(0,0,0,0.55);
    opacity: 0;
    animation: reelCue 1.1s steps(1) infinite;
}
@keyframes reelCue {
    0%, 88%  { opacity: 0; }
    90%, 96% { opacity: 0.85; }
}

.reel-cap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8%;
    text-align: center;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 3px;
    font-size: 1.1rem;
    color: #c0140e;
    text-shadow: 0 0 6px rgba(122, 26, 26, 0.8), 0 0 2px #000;
    animation: reelBlink 0.9s steps(2) infinite;
}
@keyframes reelBlink {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}

/* Sin movimiento => sin transición (el JS además ni la crea) */
@media (prefers-reduced-motion: reduce) {
    .reel { display: none !important; }
}

/* ===== Fase 4 — "El paseo": hotspots disfrazados hacia la página secreta.
   Se ven como parte de la página; sólo un parpadeo rojo los delata al hover/focus.
   La navegación (con reel) la hereda de js/transition.js: son <a> .html internos. */
.paseo-spot {
    color: inherit;
    text-decoration: inherit;
    cursor: inherit;
    outline: none;
}
.paseo-spot:hover,
.paseo-spot:focus-visible {
    color: #c0140e;
    text-shadow: 0 0 6px rgba(122, 26, 26, 0.85), 0 0 2px #000;
    cursor: pointer;
    animation: paseoFlicker 0.16s steps(2) 4;
}
.paseo-spot--block {
    display: inline-block;
}
.paseo-spot--block:hover,
.paseo-spot--block:focus-visible {
    filter: contrast(1.2) saturate(1.3) hue-rotate(-12deg);
    animation: paseoFlicker 0.16s steps(2) 4;
}
@keyframes paseoFlicker {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}
