/* =========================================================
   CyberShield · components.css
   Piezas reutilizables: cristal, botones, chips, campos,
   cursor, arranque, paleta y avisos.
   ========================================================= */

/* ---------- Panel de cristal con borde vivo y esquinas HUD ---------- */

.glass {
  --mx: -400px; --my: -400px;
  position: relative;
  isolation: isolate;
  border: 1px solid transparent;
  border-radius: var(--r);
  background:
    radial-gradient(460px circle at var(--mx) var(--my), color-mix(in srgb, var(--a) 8%, transparent), transparent 60%) padding-box,
    linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 38%) padding-box,
    linear-gradient(var(--panel), var(--panel)) padding-box,
    radial-gradient(260px circle at var(--mx) var(--my), color-mix(in srgb, var(--a) 75%, transparent), transparent 70%) border-box,
    linear-gradient(155deg, var(--line-3), var(--line) 35%, var(--line) 70%, color-mix(in srgb, var(--b) 30%, transparent)) border-box;
  -webkit-backdrop-filter: blur(16px) saturate(140%);
          backdrop-filter: blur(16px) saturate(140%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .05),
    0 24px 60px -24px rgba(0, 0, 0, .8);
}
/* Textura de grano dentro del cristal */
.glass::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; pointer-events: none;
  background: url(../img/noise.svg);
  opacity: .045; mix-blend-mode: overlay;
}
/* Esquinas tipo HUD que aparecen al pasar el ratón */
.glass::after {
  --c: color-mix(in srgb, var(--a) 80%, transparent);
  content: ""; position: absolute; inset: 7px; pointer-events: none;
  background:
    linear-gradient(var(--c), var(--c)) top left / 14px 1.5px,
    linear-gradient(var(--c), var(--c)) top left / 1.5px 14px,
    linear-gradient(var(--c), var(--c)) top right / 14px 1.5px,
    linear-gradient(var(--c), var(--c)) top right / 1.5px 14px,
    linear-gradient(var(--c), var(--c)) bottom left / 14px 1.5px,
    linear-gradient(var(--c), var(--c)) bottom left / 1.5px 14px,
    linear-gradient(var(--c), var(--c)) bottom right / 14px 1.5px,
    linear-gradient(var(--c), var(--c)) bottom right / 1.5px 14px;
  background-repeat: no-repeat;
  opacity: 0; transform: scale(1.02);
  transition: opacity .35s, transform .5s var(--ease);
}
.glass:hover::after { opacity: 1; transform: none; }

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

.btn {
  --mx: 50%; --my: 50%;
  position: relative; overflow: hidden; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 26px;
  border-radius: 14px; border: 1px solid transparent;
  font: 600 .95rem/1 var(--body); letter-spacing: .01em;
  transition: transform .25s var(--ease), box-shadow .3s, filter .3s;
  will-change: transform;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s var(--ease); }
.btn:hover svg { transform: translateX(4px); }
/* Brillo que recorre el botón */
.btn::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .5) 48%, transparent 66%);
  transform: translateX(-130%);
  transition: transform .8s var(--ease);
}
.btn:hover::after { transform: translateX(130%); }
/* Luz que sigue al cursor */
.btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(120px circle at var(--mx) var(--my), rgba(255, 255, 255, .28), transparent 70%);
  opacity: 0; transition: opacity .3s;
}
.btn:hover::before { opacity: 1; }

.btn-primary {
  color: #02131a;
  background: linear-gradient(120deg, var(--a), color-mix(in srgb, var(--a) 55%, var(--b)));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--a) 60%, transparent), 0 10px 30px -8px color-mix(in srgb, var(--a) 60%, transparent);
}
.btn-primary:hover { box-shadow: 0 0 0 1px var(--a), 0 0 40px -4px color-mix(in srgb, var(--a) 75%, transparent); }

.btn-ghost {
  color: var(--text);
  background:
    linear-gradient(var(--bg-2), var(--bg-2)) padding-box,
    linear-gradient(120deg, var(--line-3), var(--line), color-mix(in srgb, var(--a) 45%, transparent)) border-box;
}
.btn-ghost:hover { box-shadow: 0 0 30px -8px color-mix(in srgb, var(--a) 55%, transparent); }

.btn-sm { min-height: 38px; padding: 0 16px; font-size: .85rem; border-radius: 11px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn:active { transform: scale(.97); }

/* ---------- Chips y teclas ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  background: rgba(255, 255, 255, .02);
  border: 1px solid var(--line-2); border-radius: 10px;
  color: var(--muted);
  font: 500 .78rem/1 var(--mono);
  transition: color .2s, border-color .2s, background .2s, box-shadow .2s;
}
.chip:hover { color: var(--a); border-color: var(--a-mid); background: var(--a-soft); box-shadow: 0 0 18px -6px var(--a); }

.kbd {
  display: inline-block; padding: 2px 6px;
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px;
  font: 600 .7rem/1.2 var(--mono); color: var(--muted);
}

.swatch {
  width: 12px; height: 12px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--a), var(--b), var(--a));
  box-shadow: 0 0 8px var(--a);
}

.tag {
  font: 700 .66rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 99px;
  border: 1px solid currentColor; white-space: nowrap;
  background: color-mix(in srgb, currentColor 10%, transparent);
}
.crit { color: var(--bad); }
.alto { color: var(--warn); }
.medio { color: var(--info); }

.dot-ok {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 10px var(--ok);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
  100% { box-shadow: 0 0 0 12px transparent; }
}

/* ---------- Campos ---------- */

.field {
  width: 100%;
  padding: 14px 16px;
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  outline: 0;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.field::placeholder { color: var(--dim); }
.field:focus {
  border-color: var(--a);
  background: rgba(0, 0, 0, .5);
  box-shadow: 0 0 0 4px var(--a-soft), 0 0 24px -8px var(--a);
}

.meter { display: flex; gap: 6px; margin: 16px 0 8px; }
.meter i {
  position: relative; flex: 1; height: 8px; border-radius: 6px;
  background: var(--line); overflow: hidden;
  transition: background .35s, box-shadow .35s;
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; margin-top: 12px; }

.readout { font: .8rem/1.5 var(--mono); color: var(--muted); min-height: 2.6em; margin-top: 10px; }

/* ---------- Revelado al hacer scroll ---------- */

.reveal {
  opacity: 0; translate: 0 50px; filter: blur(6px);
  transition: opacity .9s var(--ease), translate .9s var(--ease), filter .9s var(--ease);
  transition-delay: var(--d, 0ms);
}
.reveal.in { opacity: 1; translate: 0 0; filter: none; }

/* ---------- Efecto glitch para títulos ---------- */

.glitch { position: relative; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  -webkit-background-clip: text; background-clip: text;
  opacity: 0; pointer-events: none;
}
.glitch::before { color: var(--a); background: none; -webkit-text-fill-color: var(--a); }
.glitch::after { color: var(--bad); background: none; -webkit-text-fill-color: var(--bad); }
.glitch:hover::before { opacity: .7; animation: glitch-a .45s steps(2) infinite; }
.glitch:hover::after { opacity: .7; animation: glitch-b .45s steps(2) infinite; }
@keyframes glitch-a {
  0% { clip-path: inset(10% 0 60% 0); transform: translate(-3px, -1px); }
  50% { clip-path: inset(55% 0 15% 0); transform: translate(3px, 1px); }
  100% { clip-path: inset(30% 0 40% 0); transform: translate(-2px, 0); }
}
@keyframes glitch-b {
  0% { clip-path: inset(65% 0 5% 0); transform: translate(3px, 1px); }
  50% { clip-path: inset(5% 0 70% 0); transform: translate(-3px, -1px); }
  100% { clip-path: inset(40% 0 30% 0); transform: translate(2px, 0); }
}

/* ---------- Barra de progreso de lectura ---------- */

#progress {
  position: fixed; top: 0; left: 0; z-index: 130;
  width: 100%; height: 2px;
  transform-origin: 0 0; transform: scaleX(0);
  background: linear-gradient(90deg, var(--a), var(--b), var(--ok));
  box-shadow: 0 0 12px var(--a);
}

/* ---------- Cursor personalizado ---------- */

#cursor, #cursor-dot {
  position: fixed; top: 0; left: 0; z-index: 300;
  pointer-events: none; border-radius: 50%;
  opacity: 0; transition: opacity .3s;
}
#cursor.on, #cursor-dot.on { opacity: 1; }
#cursor {
  width: 36px; height: 36px; margin: -18px 0 0 -18px;
  border: 1px solid color-mix(in srgb, var(--a) 70%, transparent);
  box-shadow: 0 0 14px -4px var(--a), inset 0 0 10px -6px var(--a);
  transition: opacity .3s, width .3s var(--ease), height .3s var(--ease), margin .3s var(--ease), background .3s, border-radius .3s;
}
#cursor::before, #cursor::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  background: color-mix(in srgb, var(--a) 70%, transparent);
}
#cursor::before { width: 1px; height: 6px; margin: -24px 0 0 -.5px; box-shadow: 0 42px 0 0 color-mix(in srgb, var(--a) 70%, transparent); }
#cursor::after { height: 1px; width: 6px; margin: -.5px 0 0 -24px; box-shadow: 42px 0 0 0 color-mix(in srgb, var(--a) 70%, transparent); }
#cursor.big { width: 60px; height: 60px; margin: -30px 0 0 -30px; background: color-mix(in srgb, var(--a) 8%, transparent); }
#cursor.text { width: 4px; height: 26px; margin: -13px 0 0 -2px; border-radius: 2px; background: var(--a); }
#cursor.text::before, #cursor.text::after { display: none; }
#cursor.press { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
#cursor-dot { width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; background: var(--a); box-shadow: 0 0 10px var(--a); }

.ripple {
  position: fixed; z-index: 180; pointer-events: none;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1.5px solid var(--c); box-shadow: 0 0 20px var(--c), inset 0 0 12px var(--c);
}

/* ---------- Aviso flotante ---------- */

#toast {
  position: fixed; bottom: 22px; left: 50%; z-index: 260;
  max-width: min(92vw, 520px);
  padding: 12px 18px 12px 40px;
  background: color-mix(in srgb, var(--bg-2) 90%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--a-mid); border-radius: 12px;
  box-shadow: 0 0 30px -10px var(--a), 0 20px 40px -20px #000;
  font: .8rem/1.4 var(--mono);
  transform: translate(-50%, 160%); visibility: hidden;
  transition: transform .5s var(--spring), visibility .5s;
}
#toast::before {
  content: ""; position: absolute; left: 16px; top: 50%;
  width: 10px; height: 10px; margin-top: -5px; border-radius: 50%;
  background: var(--a); box-shadow: 0 0 10px var(--a);
}
#toast[data-kind="ok"]::before { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
#toast[data-kind="bad"]::before { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
#toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ---------- Pantalla de arranque ---------- */

#boot {
  position: fixed; inset: 0; z-index: 400;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--a) 10%, transparent), transparent 50%),
    var(--bg);
  cursor: pointer;
  transition: opacity .8s var(--ease), visibility .8s, filter .8s;
}
#boot.done { opacity: 0; visibility: hidden; filter: blur(12px); }
.boot-box { width: min(460px, 86vw); font: .82rem/1.7 var(--mono); color: var(--a); }
.boot-logo { width: 96px; height: 96px; margin: 0 auto 26px; overflow: visible; }
.boot-logo .b-ring { fill: none; stroke: var(--a); stroke-width: 1.2; stroke-dasharray: 6 10; transform-origin: 60px 60px; opacity: .55; }
.boot-logo .r1 { animation: spin 6s linear infinite; }
.boot-logo .r2 { animation: spin 4s linear infinite reverse; stroke-dasharray: 2 6; }
.boot-logo .b-shield { fill: var(--a-soft); stroke: var(--a); stroke-width: 2; stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw-in 1.4s var(--ease) forwards; filter: drop-shadow(0 0 8px var(--a)); }
.boot-logo .b-check { fill: none; stroke: var(--ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw-in .6s 1.1s var(--ease) forwards; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes draw-in { to { stroke-dashoffset: 0; } }
.boot-log { min-height: 140px; white-space: pre-line; text-shadow: 0 0 10px color-mix(in srgb, var(--a) 60%, transparent); }
.boot-bar { position: relative; height: 3px; margin: 16px 0 10px; background: var(--line); overflow: hidden; border-radius: 3px; }
.boot-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--a), var(--ok)); box-shadow: 0 0 16px var(--a); transition: width .25s var(--ease); }
.boot-foot { display: flex; justify-content: space-between; color: var(--muted); }

/* ---------- Paleta de comandos ---------- */

#palette {
  position: fixed; inset: 0; z-index: 250;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 15vh 16px 0;
  background: rgba(2, 3, 8, .65);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
#palette[hidden] { display: none; }
.pal { width: min(560px, 100%); padding: 12px; animation: pop .35s var(--spring); }
.pal-head { display: flex; align-items: center; gap: 10px; }
#pal-list { list-style: none; margin-top: 10px; max-height: 46vh; overflow: auto; }
#pal-list button {
  width: 100%; display: flex; align-items: center; gap: 10px;
  text-align: left; background: none; border: 0; border-radius: 10px;
  padding: 11px 12px; color: var(--muted);
  transition: background .15s, color .15s;
}
#pal-list button::before { content: "›"; color: var(--a); opacity: 0; transition: opacity .15s, transform .15s; transform: translateX(-4px); }
#pal-list button.sel { background: var(--a-soft); color: var(--text); }
#pal-list button.sel::before { opacity: 1; transform: none; }
.pal-foot { display: flex; gap: 16px; padding: 10px 6px 2px; border-top: 1px solid var(--line); margin-top: 8px; font: .72rem var(--mono); color: var(--dim); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(10px); } }
