/* ============================================================================
   Insert Coin — brand.css
   Sistema de diseño CRT reutilizable (Fase 4). Fuente de verdad del CSS propio.
   Los tokens de color se definen aquí como CSS custom properties Y en el
   tailwind.config inline de cada página (para las utilidades bg-phosphor, etc.).
   Si cambias un hex, cámbialo en AMBOS lugares. Ver docs/UI.md.
   ============================================================================ */

/* --- Tokens --- */
:root {
  --crt:        #050505;  /* fondo principal (negro CRT) */
  --crt-dim:    #0A0A0A;  /* superficies secundarias */
  --phosphor:   #39FF7A;  /* verde fósforo — texto/acento primario */
  --phosphor-dim:#1F8E40; /* bordes, estados apagados */
  --magenta:    #FF2E9A;  /* acento secundario, hover, alertas */
  --cyan:       #00E5FF;  /* acento terciario, aberración de glitch */
}

/* --- Base --- */
html { scroll-behavior: smooth; }
html, body {
  background: var(--crt);
  color: var(--phosphor);
  font-family: 'JetBrains Mono', monospace;
}
body { -webkit-font-smoothing: antialiased; }
.display { font-family: 'VT323', monospace; }
.tracking-widest2 { letter-spacing: 0.24em; }
section { scroll-margin-top: 84px; }

/* --- Scanlines + vignette (overlay CRT sobre toda la pantalla) --- */
.scanlines::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background-image: linear-gradient(
    to bottom,
    rgba(255,255,255,0.04) 0px,
    rgba(255,255,255,0.04) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}
.scanlines::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 49;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}

/* --- Sweep (barrido de línea cada 8s) --- */
.sweep {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 48;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(57,255,122,0.05) 50%,
    transparent 100%
  );
  height: 30vh;
  animation: sweep 8s linear infinite;
}
@keyframes sweep {
  from { transform: translateY(-30vh); }
  to   { transform: translateY(120vh); }
}

/* --- Glitch (jitter ocasional con aberración cromática) --- */
.glitch { position: relative; animation: jitter 4s steps(1) infinite; }
@keyframes jitter {
  0%, 96%, 100% { transform: translate(0, 0); text-shadow: 0 0 18px rgba(57,255,122,0.4); }
  97% { transform: translate(-2px, 1px); text-shadow: 2px 0 0 #FF2E9A, -2px 0 0 #00E5FF, 0 0 18px rgba(57,255,122,0.4); }
  98% { transform: translate(2px, -1px); text-shadow: -2px 0 0 #FF2E9A, 2px 0 0 #00E5FF, 0 0 18px rgba(57,255,122,0.4); }
  99% { transform: translate(0, 2px); text-shadow: 0 0 18px rgba(57,255,122,0.6); }
}

/* --- Blink (indicadores tipo ▶) --- */
.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* --- Pulse (dot latido del header) --- */
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(57,255,122,0.6); transform: scale(1); }
  50%      { box-shadow: 0 0 0 12px rgba(57,255,122,0); transform: scale(1.15); }
}

/* --- Boot reveal (revelado escalonado al cargar) --- */
.boot { opacity: 0; animation: boot 0.6s ease-out forwards; }
.boot-1 { animation-delay: 0.0s; }
.boot-2 { animation-delay: 0.4s; }
.boot-3 { animation-delay: 0.9s; }
.boot-4 { animation-delay: 1.5s; }
.boot-5 { animation-delay: 2.2s; }
.boot-6 { animation-delay: 2.8s; }
@keyframes boot { to { opacity: 1; } }

/* --- Phosphor glow --- */
.glow-phosphor { text-shadow: 0 0 14px rgba(57,255,122,0.55), 0 0 30px rgba(57,255,122,0.25); }

/* --- HUD bracket (esquinas de interfaz) --- */
.bracket { position: relative; }
.bracket::before, .bracket::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: var(--phosphor);
  border-style: solid;
  opacity: 0.7;
}
.bracket::before { top: -8px; left: -8px; border-width: 1px 0 0 1px; }
.bracket::after  { bottom: -8px; right: -8px; border-width: 0 1px 1px 0; }

/* --- Nav link (subrayado animado) --- */
.navlink { position: relative; transition: color .2s ease; }
.navlink:hover { color: var(--phosphor); }
.navlink::after {
  content: '';
  position: absolute;
  left: 0; bottom: -6px;
  height: 1px; width: 0;
  background: var(--phosphor);
  transition: width .2s ease;
}
.navlink:hover::after { width: 100%; }
.navlink.active { color: var(--phosphor); }
.navlink.active::after { width: 100%; }

/* --- Card (producto / bloque) --- */
.card {
  border: 1px solid rgba(57,255,122,0.22);
  background: var(--crt-dim);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.card:hover {
  border-color: rgba(57,255,122,0.7);
  box-shadow: 0 0 30px rgba(57,255,122,0.12);
  transform: translateY(-3px);
}

/* --- Mockup placeholder (declarado, no foto real) --- */
.mockup {
  aspect-ratio: 4 / 5;
  background-color: var(--crt);
  background-image:
    linear-gradient(rgba(57,255,122,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57,255,122,0.10) 1px, transparent 1px);
  background-size: 22px 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Galería de producto (visualización conceptual) --- */
.product-gallery { overflow: hidden; }
.product-stage {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #020202;
  border-bottom: 1px solid rgba(57,255,122,0.18);
}
.product-main {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-main.is-updating { animation: productSignal .24s steps(2, jump-none); }
@keyframes productSignal {
  0% { opacity: .25; filter: contrast(1.25) saturate(1.3); transform: scale(1.01); }
  100% { opacity: 1; filter: none; transform: scale(1); }
}
.product-concept {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  background: rgba(5,5,5,0.82);
  backdrop-filter: blur(4px);
}
.product-thumbs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: var(--crt);
  border-bottom: 1px solid rgba(57,255,122,0.18);
}
.product-thumb {
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(57,255,122,0.18);
  background: #020202;
  opacity: .5;
  cursor: pointer;
  transition: opacity .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.product-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-thumb:hover,
.product-thumb.is-active {
  opacity: 1;
  border-color: rgba(57,255,122,0.78);
  box-shadow: inset 0 0 0 1px rgba(57,255,122,0.18), 0 0 14px rgba(57,255,122,0.1);
}
.product-thumb:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* --- Chips de estado --- */
.chip {
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  border: 1px solid rgba(57,255,122,0.4);
  padding: 3px 8px;
  color: rgba(57,255,122,0.85);
}
.chip-sold { border-color: rgba(255,46,154,0.5); color: var(--magenta); }

/* --- Campo de formulario --- */
.field {
  background: transparent;
  border: 1px solid rgba(57,255,122,0.3);
  padding: 14px 18px;
  color: var(--phosphor);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  width: 100%;
  outline: none;
  transition: all 0.2s ease;
}
.field::placeholder { color: rgba(57,255,122,0.35); text-transform: lowercase; }
.field:focus { border-color: var(--phosphor); box-shadow: 0 0 0 1px var(--phosphor), 0 0 24px rgba(57,255,122,0.25); }
textarea.field { resize: vertical; min-height: 130px; }

/* --- Botón arcade --- */
.btn-submit {
  background: var(--phosphor);
  color: var(--crt);
  padding: 14px 28px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
}
.btn-submit:hover { background: var(--magenta); color: var(--crt); box-shadow: 0 0 24px rgba(255,46,154,0.5); }

/* --- Neon Invaders (arcade jugable de index.html) --- */
.arcade-machine {
  border: 1px solid rgba(57,255,122,0.35);
  background: rgba(5,5,5,0.92);
  box-shadow: 0 0 45px rgba(57,255,122,0.08), inset 0 0 40px rgba(57,255,122,0.025);
  padding: clamp(10px, 2vw, 20px);
}
.arcade-hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 2px 12px;
  color: rgba(57,255,122,0.62);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.arcade-hud span { min-width: 0; }
.arcade-hud span:nth-child(n+3) { text-align: right; }
.arcade-hud strong { color: var(--phosphor); font-weight: 600; }
.arcade-screen {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(57,255,122,0.4);
  background: #020202;
  box-shadow: inset 0 0 36px rgba(57,255,122,0.08);
}
.arcade-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(57,255,122,0.035) 3px 4px);
  mix-blend-mode: screen;
}
.arcade-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 64 / 45;
  outline: none;
  image-rendering: pixelated;
  touch-action: none;
}
.arcade-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--cyan); }
.arcade-panel { padding-top: 16px; }
.arcade-actions,
.arcade-controls {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
}
.arcade-actions { flex-wrap: wrap; margin-bottom: 14px; }
.arcade-secondary,
.arcade-controls button {
  border: 1px solid rgba(57,255,122,0.45);
  background: transparent;
  color: var(--phosphor);
  font: 600 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .18s ease, color .18s ease, background .18s ease, box-shadow .18s ease;
}
.arcade-secondary { padding: 13px 20px; }
.arcade-controls button {
  min-width: 72px;
  min-height: 54px;
  padding: 12px 18px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.arcade-controls .arcade-fire {
  min-width: 112px;
  border-color: rgba(255,46,154,0.7);
  color: var(--magenta);
}
.arcade-secondary:hover,
.arcade-controls button:hover,
.arcade-controls button.is-pressed {
  border-color: var(--phosphor);
  background: rgba(57,255,122,0.1);
  box-shadow: 0 0 18px rgba(57,255,122,0.14);
}
.arcade-controls .arcade-fire:hover,
.arcade-controls .arcade-fire.is-pressed {
  border-color: var(--magenta);
  background: rgba(255,46,154,0.1);
  box-shadow: 0 0 18px rgba(255,46,154,0.18);
}
.arcade-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.35;
  box-shadow: none;
}
.arcade-sound[aria-pressed="false"] {
  border-color: rgba(255,46,154,0.55);
  color: var(--magenta);
}
.arcade-help,
.arcade-noscript {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  margin-top: 14px;
  color: rgba(57,255,122,0.5);
  font-size: 9px;
  line-height: 1.6;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.arcade-noscript { justify-content: center; color: var(--magenta); }

@media (max-width: 640px) {
  .arcade-hud { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 6px; }
  .arcade-hud span:nth-child(even) { text-align: right; }
  .arcade-hud span:nth-child(3) { text-align: left; }
  .arcade-controls button { min-width: 64px; padding-inline: 14px; }
  .arcade-controls .arcade-fire { min-width: 96px; }
  .arcade-help { justify-content: center; text-align: center; }
}

/* --- Legales --- */
.legal h2 { font-family: 'VT323', monospace; }
.placeholder { color: var(--magenta); border-bottom: 1px dotted rgba(255,46,154,0.5); }

/* ============================================================================
   FX arcade (vanilla JS · js/brand.js). Las capas de canvas se inyectan solas;
   aquí van el layering y los efectos puramente CSS (glitch de card, flicker,
   caret de typewriter).
   ============================================================================ */

/* Capas inyectadas por js/brand.js */
.ic-starfield { position: fixed; inset: 0; z-index: 0;  pointer-events: none; }   /* detrás del contenido (main z-10) */
.ic-fx        { position: fixed; inset: 0; z-index: 47; pointer-events: none; }   /* chispas/estela sobre el contenido, bajo el sweep/scanlines */
.ic-flicker   { position: fixed; inset: 0; z-index: 51; pointer-events: none;
                background: rgba(57,255,122,0.03); mix-blend-mode: overlay; opacity: 0;
                animation: icFlicker 9s steps(1) infinite; }
@keyframes icFlicker {
  0%, 96%, 100% { opacity: 0; }
  96.5% { opacity: 0.6; }
  97%   { opacity: 0; }
  97.6% { opacity: 0.45; }
  98%   { opacity: 0; }
}

/* Typewriter (boot de consola) */
.tw-caret::after { content: '▋'; margin-left: 2px; color: var(--phosphor); animation: blink 1.1s steps(1) infinite; }

/* Card hover: glitch RGB en el texto display (nombre de la pieza / número) */
.card:hover .display { animation: cardGlitch .38s steps(2, jump-none) 1; }
@keyframes cardGlitch {
  0%   { text-shadow: none; transform: translate(0, 0); }
  30%  { text-shadow: 2px 0 0 var(--magenta), -2px 0 0 var(--cyan); transform: translate(-1px, 0); }
  60%  { text-shadow: -2px 0 0 var(--magenta), 2px 0 0 var(--cyan); transform: translate(1px, 0); }
  100% { text-shadow: none; transform: translate(0, 0); }
}

/* --- Accesibilidad: respetar reduce-motion --- */
@media (prefers-reduced-motion: reduce) {
  .boot, .glitch, .sweep, .blink, .pulse { animation: none !important; opacity: 1 !important; }
  .ic-flicker { animation: none !important; opacity: 0 !important; }
  .card:hover .display { animation: none !important; }
  .product-main.is-updating { animation: none !important; }
  .product-thumb { transition: none !important; }
  html { scroll-behavior: auto; }
}
