/* ===== Fuente corporativa Cerwall ===== */
@font-face {
  font-family: 'Good Times';
  src: url('../assets/fonts/good_times.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

/* ===== Paleta corporativa Cerwall =====
   Valores observados en cerwall.es:
   - Azul oscuro primario:  #222e5e
   - Azul claro acento:     #699bd5
   - Amarillo acento:       #efac2f
   - Rojo alerta:           #b91c1c
*/
:root {
  --c-bg:          #0b1226;
  --c-bg-2:        #070b18;
  --c-primary:     #222e5e;
  --c-accent-b:    #699bd5;
  --c-accent-y:    #efac2f;
  --c-alert:       #b91c1c;
  --c-text:        #e9eef8;
  --c-text-dim:    #8ea2c6;
  --c-text-mute:   #5b6f96;
}

/* ===== Reset + base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100dvh; min-height: 100%; overflow: hidden; background: var(--c-bg); color: var(--c-text); }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.app {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100svh; /* viewport mínimo estable para que no baile con la barra */
}

.scene {
  position: absolute;
  inset: 0;
  display: none;
  padding:
    max(20px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  overflow: hidden;
}
.scene.is-active {
  display: flex;
  animation: sceneIn 0.5s ease-out;
}
@keyframes sceneIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   ESCENA 0a — VERIFICACIÓN ANTI-BOT (estilo Cloudflare Turnstile)
   ================================================================ */
.scene--prep {
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  gap: 0;
  padding: calc(26vh + env(safe-area-inset-top)) 0 0 0 !important;
  background: #0f141d;
}
.bot-check {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 360px;
  width: calc(100vw - 36px);
  margin: 0 18px;
}

/* Widget tipo Turnstile: caja con check + texto a la derecha */
.bot-check__widget {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #1a2030;
  border: 1px solid #2a3448;
  border-radius: 10px;
  padding: 14px 16px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* Caja cuadrada con spinner dentro */
.bot-check__box {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 2px solid #3d4a65;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f141d;
  position: relative;
}
.bot-check__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: #3a8dff;
  border-right-color: #3a8dff;
  border-radius: 50%;
  animation: prepSpin 0.8s linear infinite;
}
.bot-check__tick {
  position: absolute;
  inset: 4px;
  color: #38c172;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.2s ease, transform 0.3s ease;
}
.bot-check__box.is-done .bot-check__spinner { display: none; }
.bot-check__box.is-done .bot-check__tick { opacity: 1; transform: scale(1); }
.bot-check__box.is-done { border-color: #38c172; background: rgba(56, 193, 114, 0.12); }
@keyframes prepSpin { to { transform: rotate(360deg); } }

.bot-check__text { text-align: left; flex: 1; min-width: 0; }
.bot-check__label {
  margin: 0 0 2px;
  font-size: 14px;
  color: #e6edf5;
  font-weight: 500;
  line-height: 1.25;
}
.bot-check__sub {
  margin: 0;
  font-size: 11.5px;
  color: #8792a8;
  line-height: 1.3;
}

/* Lista de pasos */
.bot-check__steps {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bot-check__step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #6b7892;
  background: transparent;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}
.bot-check__step::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3d4a65;
  flex-shrink: 0;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.bot-check__step.is-active {
  color: #b8c4da;
}
.bot-check__step.is-active::before {
  background: #3a8dff;
  box-shadow: 0 0 0 3px rgba(58, 141, 255, 0.2);
  animation: stepPulse 1.2s ease-in-out infinite;
}
.bot-check__step.is-done { color: #8792a8; }
.bot-check__step.is-done::before { background: #38c172; }
@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(58, 141, 255, 0.2); }
  50%      { box-shadow: 0 0 0 6px rgba(58, 141, 255, 0.08); }
}

/* Footer con branding */
.bot-check__foot {
  position: absolute;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #6b7892;
  font-size: 11px;
}
.bot-check__logo {
  height: 18px;
  max-width: 100px;
  object-fit: contain;
  background: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  box-sizing: content-box;
  opacity: 0.85;
}
.bot-check__brand {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: #8792a8;
}
.bot-check__ref {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px;
  color: #556276;
}

/* ================================================================
   ESCENA 0 — INTRO (ambiente, un mensaje fuerte para enganchar)
   ================================================================ */
.scene--intro {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 20px;
  background:
    radial-gradient(1000px 600px at 50% 30%, rgba(105, 155, 213, 0.18), transparent 60%),
    linear-gradient(180deg, var(--c-primary) 0%, var(--c-bg-2) 100%);
}
.intro__brand {
  height: 38px;
  max-width: 180px;
  object-fit: contain;
  margin-bottom: 12px;
  background: #ffffff;
  padding: 8px 18px;
  border-radius: 8px;
  box-sizing: content-box;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.intro__eyebrow {
  margin: 0;
  font-family: 'Good Times', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--c-accent-b);
  text-transform: uppercase;
}
.intro__head {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 400;
}
.intro__big {
  font-family: 'Good Times', ui-sans-serif, sans-serif;
  font-size: clamp(34px, 10vw, 92px);
  line-height: 1;
  color: #ffffff;
  letter-spacing: 2px;
  text-shadow: 0 0 30px rgba(105, 155, 213, 0.4);
}
.intro__mid {
  font-family: ui-monospace, Menlo, monospace;
  font-size: clamp(13px, 3.4vw, 18px);
  color: var(--c-text);
  letter-spacing: 0.5px;
}
.intro__sub {
  margin: 8px 0 0;
  font-size: clamp(12px, 3vw, 14px);
  color: var(--c-accent-y);
  letter-spacing: 0.5px;
  max-width: 580px;
}

/* ================================================================
   ESCENA 1 — FILTRACIONES (una empresa por pantalla, secuencial)
   ================================================================ */
.scene--breaches {
  flex-direction: column;
  background:
    radial-gradient(1200px 700px at 50% 40%, rgba(105, 155, 213, 0.10), transparent 60%),
    linear-gradient(180deg, var(--c-bg) 0%, var(--c-bg-2) 100%);
  color: var(--c-text);
  padding: 0;
  gap: 0;
  overflow: hidden;
}

/* Brand bar superior: Cerwall + etiqueta de sección */
.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding:
    max(14px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    12px
    max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(105, 155, 213, 0.15);
  flex-shrink: 0;
  z-index: 2;
  background: rgba(7, 11, 24, 0.55);
}
.brand-bar__logo {
  height: 22px;
  max-width: 140px;
  object-fit: contain;
  object-position: left center;
  background: #ffffff;
  padding: 5px 10px;
  border-radius: 5px;
  box-sizing: content-box;
}
.brand-bar__tag {
  font-family: 'Good Times', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 2.5px;
  color: var(--c-accent-b);
  text-transform: uppercase;
  text-align: right;
  line-height: 1.2;
  max-width: 55%;
}
@media (max-width: 430px) {
  .brand-bar { padding: 10px 12px; }
  .brand-bar__logo { height: 22px; max-width: 110px; }
  .brand-bar__tag { font-size: 8px; letter-spacing: 2px; }
}

/* Stage: contenedor donde las cards se superponen */
.breach-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ---- Collage: tile individual que aparece con pop-in ---- */
.breach-tile {
  position: absolute;
  background: #ffffff;
  border-radius: 10px;
  padding: 10px;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(105, 155, 213, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.4) rotate(var(--rot, 0deg));
  transform-origin: center center;
  transition:
    opacity 0.42s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.52s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform, opacity;
  overflow: hidden;
  /* default cuadrado — se sobrescribe por JS al cargar el logo real */
  aspect-ratio: 1 / 1;
}
.breach-tile.is-in {
  opacity: 1;
  transform: scale(1) rotate(var(--rot, 0deg));
}

/* Tamaños: solo ancho (% del stage). Altura la dicta el aspect-ratio del logo,
   inyectado por JS en tiempo real. Cap por max-width absoluto para que en
   desktop no se inflen. Sin tier 'S' — todos los tiles quedan grandes
   y legibles, la variación la aportan XL/L/M. */
.breach-tile--xl { width: 38%; max-width: 240px; }
.breach-tile--l  { width: 30%; max-width: 180px; }
.breach-tile--m  { width: 24%; max-width: 150px; }
.breach-tile--s  { width: 24%; max-width: 150px; }  /* fallback: si queda un 's' suelto cae a tamaño M */

.breach-tile img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Fallback si falla el <img>: texto en Good Times */
.breach-tile--text {
  font-family: 'Good Times', ui-sans-serif, sans-serif;
  font-size: clamp(9px, 1.8vw, 14px);
  letter-spacing: 1px;
  color: var(--c-primary);
  text-align: center;
  line-height: 1.1;
  text-transform: uppercase;
  padding: 6px 8px;
}

/* Brechas españolas: borde amarillo corporativo */
.breach-tile--local {
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.45),
    0 0 0 2px var(--c-accent-y);
}

/* Stage atenuado cuando aparece el total encima */
.breach-stage.is-dimmed .breach-tile {
  opacity: 0.08;
  transition: opacity 0.6s ease;
}

/* ---- Overlay con el total agregado ---- */
.breach-summary {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 30px 24px;
  background: rgba(5, 8, 16, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.45s ease, transform 0.6s ease;
  z-index: 10;
  pointer-events: none;
}
.breach-summary.is-in {
  opacity: 1;
  transform: scale(1);
}
.breach-summary__eyebrow {
  margin: 0 0 4px;
  font-family: 'Good Times', ui-monospace, monospace;
  font-size: clamp(10px, 2.6vw, 13px);
  letter-spacing: 4px;
  color: var(--c-accent-b);
  text-transform: uppercase;
}
.breach-summary__block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.breach-summary__big {
  font-family: 'Good Times', ui-sans-serif, sans-serif;
  font-size: clamp(30px, 10vw, 78px);
  line-height: 1;
  color: #ffffff;
  letter-spacing: 1.5px;
  text-shadow: 0 0 24px rgba(105, 155, 213, 0.35);
}
.breach-summary__big--alt {
  color: var(--c-accent-y);
  text-shadow: 0 0 24px rgba(239, 172, 47, 0.35);
}
.breach-summary__sub {
  font-family: ui-monospace, Menlo, monospace;
  font-size: clamp(12px, 3vw, 16px);
  color: var(--c-text);
  letter-spacing: 0.5px;
}
.breach-summary__sep {
  width: 60%;
  max-width: 280px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(105, 155, 213, 0.4), transparent);
  margin: 2px 0;
}
.breach-summary__foot {
  margin: 8px 0 0;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--c-text-dim);
  text-transform: uppercase;
}

/* ================================================================
   ESCENA 2 — HAS SIDO HACKEADO (impacto, pantalla completa)
   ================================================================ */
.scene--hacked {
  background:
    radial-gradient(800px 500px at 50% 45%, rgba(185, 28, 28, 0.35), transparent 65%),
    linear-gradient(180deg, var(--c-primary) 0%, #0b1226 100%);
  overflow: hidden;
  position: absolute;
  inset: 0;
}
/* Scene--hacked anula el flex del padre y usa posicionamiento explícito
   para que el título quede centrado en el centro visual real del viewport
   aunque iOS Safari muestre sus barras de navegación. */
.scene--hacked.is-active {
  display: block;
}
.hacked__brand {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  height: 28px;
  max-width: 140px;
  object-fit: contain;
  background: #ffffff;
  padding: 6px 14px;
  border-radius: 6px;
  box-sizing: content-box;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.hacked__title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  font-family: 'Good Times', ui-sans-serif, sans-serif;
  font-size: clamp(38px, 12vw, 108px);
  font-weight: 400;
  color: #ffffff;
  letter-spacing: 2px;
  text-align: center;
  width: 92%;
  line-height: 1.05;
  text-shadow: 0 0 28px rgba(0, 0, 0, 0.5);
  animation: hackedIn 0.9s steps(6, end) 1;
}
.hacked__title::before,
.hacked__title::after {
  content: attr(data-text);
  position: absolute; left: 0; right: 0; top: 0;
  pointer-events: none;
  font-family: inherit;
  letter-spacing: inherit;
}
.hacked__title::before {
  color: var(--c-accent-y);
  transform: translate(-3px, 0);
  mix-blend-mode: screen;
  opacity: 0.6;
}
.hacked__title::after {
  color: var(--c-accent-b);
  transform: translate(3px, 0);
  mix-blend-mode: screen;
  opacity: 0.6;
}
/* Glitch sobre el translate(-50%,-50%) base: aplicamos offsets relativos */
@keyframes hackedIn {
  0%   { transform: translate(-50%, -50%) scale(0.94);         opacity: 0; }
  20%  { transform: translate(calc(-50% - 6px), calc(-50% + 2px)); opacity: 0.9; }
  40%  { transform: translate(calc(-50% + 5px), calc(-50% - 3px)); }
  60%  { transform: translate(calc(-50% - 3px), calc(-50% + 1px)); }
  80%  { transform: translate(calc(-50% + 2px), -50%); }
  100% { transform: translate(-50%, -50%) scale(1);            opacity: 1; }
}

/* ================================================================
   ESCENA 3 — EVIDENCIA (estado final persistente)
   Título arriba (mini) · datos en terminal · cerwall abajo
   ================================================================ */
.scene--evidence {
  flex-direction: column;
  background:
    radial-gradient(900px 400px at 50% -20%, rgba(185, 28, 28, 0.18), transparent 60%),
    linear-gradient(180deg, #0b1226 0%, #050810 100%);
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  gap: 8px;
}

.evidence__head {
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(105, 155, 213, 0.18);
  flex-shrink: 0;
}
.evidence__title {
  margin: 0 0 2px;
  font-family: 'Good Times', ui-sans-serif, sans-serif;
  font-weight: 400;
  font-size: clamp(16px, 5.2vw, 26px);
  letter-spacing: 1.5px;
  color: #ffffff;
  position: relative;
  display: inline-block;
}
.evidence__title::before,
.evidence__title::after {
  content: attr(data-text);
  position: absolute; left: 0; right: 0; top: 0;
  pointer-events: none;
  font-family: inherit;
  letter-spacing: inherit;
}
.evidence__title::before {
  color: var(--c-accent-y);
  transform: translate(-1.5px, 0);
  mix-blend-mode: screen;
  opacity: 0.55;
}
.evidence__title::after {
  color: var(--c-accent-b);
  transform: translate(1.5px, 0);
  mix-blend-mode: screen;
  opacity: 0.55;
}
.evidence__sub {
  margin: 0;
  font-size: 10.5px;
  color: var(--c-accent-y);
  letter-spacing: 0.3px;
}

.evidence__terminal {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #030606;
  border: 1px solid #113a1d;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.terminal__head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #0a130d;
  border-bottom: 1px solid #113a1d;
}
.terminal__dot { width: 9px; height: 9px; border-radius: 50%; }
.terminal__dot--r { background: #ff5f56; }
.terminal__dot--y { background: #ffbd2e; }
.terminal__dot--g { background: #27c93f; }
.terminal__title { margin-left: 6px; color: #6ac289; font-size: 10.5px; letter-spacing: 1px; }

.terminal__out {
  flex: 1; margin: 0; padding: 10px 10px 14px;
  color: #c6ffd6;
  font-size: clamp(10.5px, 2.8vw, 12.5px);
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  background:
    linear-gradient(180deg, rgba(62,229,139,0.04), transparent 70%),
    #000;
  white-space: normal;
}
.terminal__out::-webkit-scrollbar { display: none; }

.term-prompt { color: #a8ffbf; font-size: clamp(10.5px, 2.8vw, 12.5px); margin-bottom: 2px; }
.term-prompt__p { color: #3ee58b; font-weight: 700; margin-right: 6px; }
.term-prompt__c { color: #ffffff; }
.term-spacer { height: 6px; }

.term-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 1px;
}
.term-line--warn .term-label,
.term-line--warn .term-val { color: #ffb454; }
.term-tag { color: #3ee58b; font-weight: 700; flex: 0 0 auto; }
.term-tag--warn { color: var(--c-alert); text-shadow: 0 0 6px rgba(185, 28, 28, 0.5); }
.term-label {
  color: #9ad4ae;
  flex: 0 0 auto;
  min-width: 84px;
}
.term-dots { flex: 1 1 0; min-width: 10px; color: #2e5c3a; overflow: hidden; }
.term-dots::before {
  content: '................................................................';
  letter-spacing: 1px;
}
.term-val {
  color: #fff;
  flex: 0 1 auto;
  word-break: break-word;
}

/* En móviles estrechos: etiqueta arriba, valor abajo para que entre todo */
@media (max-width: 430px) {
  .term-line { flex-wrap: wrap; }
  .term-dots { display: none; }
  .term-label { min-width: 0; flex: 1 1 auto; }
  .term-val { flex: 1 1 100%; margin-left: 34px; color: #fff; }
}

/* Scanlines sutiles, estáticas */
.evidence__terminal::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0) 0px,
    rgba(255,255,255,0) 2px,
    rgba(0,0,0,0.22) 3px,
    rgba(0,0,0,0.22) 4px
  );
  opacity: 0.3;
  mix-blend-mode: multiply;
}

.evidence__foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 2px;
  flex-shrink: 0;
}
.evidence__logo {
  height: 22px;
  max-width: 120px;
  object-fit: contain;
  background: #ffffff;
  padding: 4px 10px;
  border-radius: 5px;
  box-sizing: content-box;
}
.evidence__link {
  color: #ffffff;
  font-family: 'Good Times', monospace;
  font-size: 10.5px;
  letter-spacing: 1.5px;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.5);
  padding-bottom: 2px;
}

/* Accesibilidad */
@media (prefers-reduced-motion: reduce) {
  .scene.is-active,
  .hacked__title {
    animation: none !important;
  }
  .breach-tile {
    transition: opacity 0.35s ease;
    transform: rotate(var(--rot, 0deg)) !important;
  }
  .breach-tile.is-in { opacity: 1; transform: rotate(var(--rot, 0deg)) !important; }
  .breach-summary { transition: opacity 0.3s ease; transform: none !important; }
}
