/* ===================================================================
   LabCode by Labsys — fósforo ámbar y verde sobre CRT
   Fase 1: boot · Fase 2: login · Fase 3: escritorio con terminales
   =================================================================== */

:root {
  --negro: #050803;
  --negro-panel: rgba(5, 12, 5, 0.92);
  --verde: #39FF6E;
  --verde-dim: #1E8C42;
  --verde-linea: rgba(57, 255, 110, 0.18);
  --ambar: #FFB000;
  --ambar-dim: #8C6200;
  --ambar-linea: rgba(255, 176, 0, 0.20);
  --texto: #B8E6C0;
  --texto-dim: #5E8A66;

  --f-crt: "VT323", monospace;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--negro);
  color: var(--texto);
  font-family: var(--f-mono);
  min-height: 100vh;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: var(--verde); }
:focus-visible { outline: 2px solid var(--ambar); outline-offset: 2px; }
.ventana:focus { outline: none; }

.oculto { display: none !important; }

/* brillo fósforo */
.glow-v { text-shadow: 0 0 6px rgba(57, 255, 110, 0.55); }
.ambar { color: var(--ambar); text-shadow: 0 0 6px rgba(255, 176, 0, 0.45); }
.ok { color: var(--verde); text-shadow: 0 0 6px rgba(57, 255, 110, 0.55); }
.dim { color: var(--texto-dim); }
.prompt { color: var(--ambar); }

/* ---------- capa scanlines CRT (global) ---------- */

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background:
    repeating-linear-gradient(0deg,
      rgba(0, 0, 0, 0.22) 0 1px,
      transparent 1px 3px);
}
.scanlines::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ---------- fases boot / login ---------- */

.fase { min-height: 100vh; }

#boot, #login {
  padding: 2rem clamp(1rem, 4vw, 3rem);
  font-family: var(--f-crt);
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.35;
}

#boot-log, #login-log {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--texto);
}

#boot-log .ok-tag { color: var(--verde); }
#boot-log .warn-tag { color: var(--ambar); }

/* cursor de bloque parpadeante */
.cursor::after {
  content: "█";
  color: var(--verde);
  animation: parpadeo 0.9s steps(1) infinite;
}
@keyframes parpadeo { 50% { opacity: 0; } }

.saltar {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  font-family: var(--f-mono);
  font-size: 0.75rem;
  color: var(--texto-dim);
  border: 1px solid var(--texto-dim);
  padding: 0.4rem 0.9rem;
  border-radius: 3px;
  z-index: 60;
}
.saltar:hover { color: var(--ambar); border-color: var(--ambar); }

/* ---------- escritorio ---------- */

#escritorio {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* lluvia matrix (canvas de fondo) */
#lluvia {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.35;
}

/* rejilla luminosa con horizonte en perspectiva */
.rejilla {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(transparent 60%, rgba(5, 8, 3, 0.6)),
    repeating-linear-gradient(0deg, transparent 0 47px, var(--verde-linea) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, var(--ambar-linea) 47px 48px);
  mask-image: radial-gradient(ellipse at 50% 40%, rgba(0,0,0,0.9), transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, rgba(0,0,0,0.9), transparent 75%);
}

/* ---------- barra superior ---------- */

.barra {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.55rem clamp(0.8rem, 3vw, 2rem);
  border-bottom: 1px solid var(--verde-dim);
  background: var(--negro-panel);
  box-shadow: 0 0 18px rgba(57, 255, 110, 0.12);
  font-size: 0.85rem;
}

.btn-menu {
  color: var(--ambar);
  border: 1px solid var(--ambar-dim);
  padding: 0.3rem 0.9rem;
  border-radius: 3px;
  letter-spacing: 0.12em;
  font-weight: 600;
  text-shadow: 0 0 6px rgba(255, 176, 0, 0.45);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.btn-menu:hover, .btn-menu[aria-expanded="true"] {
  background: rgba(255, 176, 0, 0.12);
  box-shadow: 0 0 14px rgba(255, 176, 0, 0.35);
}

.barra-marca {
  font-family: var(--f-crt);
  font-size: 1.3rem;
  color: var(--verde);
  text-shadow: 0 0 8px rgba(57, 255, 110, 0.6);
  letter-spacing: 0.08em;
}

.barra-derecha {
  margin-left: auto;
  display: flex;
  gap: 1.2rem;
  align-items: center;
  font-size: 0.78rem;
}

/* ---------- menú matrix ---------- */

.menu {
  position: absolute;
  top: 3.2rem;
  left: clamp(0.8rem, 3vw, 2rem);
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  background: var(--negro-panel);
  border: 1px solid var(--verde-dim);
  box-shadow: 0 0 25px rgba(57, 255, 110, 0.25), inset 0 0 40px rgba(57, 255, 110, 0.05);
}

.menu-item {
  text-align: left;
  font-family: var(--f-crt);
  font-size: 1.25rem;
  padding: 0.55rem 1.1rem;
  color: var(--verde);
  border-bottom: 1px dashed rgba(57, 255, 110, 0.2);
  letter-spacing: 0.05em;
  transition: background 0.12s ease;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover, .menu-item:focus-visible {
  background: rgba(57, 255, 110, 0.14);
  color: #CFFFDD;
  text-shadow: 0 0 8px rgba(57, 255, 110, 0.8);
}
.menu-item::before { content: "▸ "; color: var(--ambar); }

/* ---------- mesa de trabajo y ventanas-terminal ---------- */

.mesa {
  position: relative;
  z-index: 10;
  flex: 1;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.ventana {
  position: absolute;
  width: min(680px, calc(100vw - 2rem));
  background: var(--negro-panel);
  border: 1px solid var(--verde-dim);
  box-shadow: 0 0 30px rgba(57, 255, 110, 0.18), 0 18px 50px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(2px);
}
.ventana-ambar {
  border-color: var(--ambar-dim);
  box-shadow: 0 0 30px rgba(255, 176, 0, 0.16), 0 18px 50px rgba(0, 0, 0, 0.8);
}

/* animación de apertura tipo CRT: se enciende desde una línea */
@keyframes abrir-crt {
  0%   { transform: scaleY(0.02) scaleX(0.6); opacity: 0; }
  40%  { transform: scaleY(0.02) scaleX(1); opacity: 1; }
  100% { transform: scaleY(1) scaleX(1); opacity: 1; }
}
.ventana.abriendo { animation: abrir-crt 0.32s ease-out; transform-origin: center; }

@keyframes cerrar-crt {
  0%   { transform: scaleY(1); opacity: 1; }
  60%  { transform: scaleY(0.02); opacity: 1; }
  100% { transform: scaleY(0.02) scaleX(0); opacity: 0; }
}
.ventana.cerrando { animation: cerrar-crt 0.25s ease-in forwards; transform-origin: center; }

.ventana-barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid var(--verde-dim);
  background: rgba(57, 255, 110, 0.07);
  cursor: grab;
  user-select: none;
}
.ventana-ambar .ventana-barra {
  border-bottom-color: var(--ambar-dim);
  background: rgba(255, 176, 0, 0.07);
}
.ventana-barra:active { cursor: grabbing; }

.v-titulo {
  font-family: var(--f-crt);
  font-size: 1.15rem;
  color: var(--verde);
  text-shadow: 0 0 6px rgba(57, 255, 110, 0.5);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ventana-ambar .v-titulo { color: var(--ambar); text-shadow: 0 0 6px rgba(255, 176, 0, 0.5); }

.v-cerrar {
  color: var(--texto-dim);
  font-size: 0.9rem;
  padding: 0 0.3rem;
}
.v-cerrar:hover { color: var(--ambar); text-shadow: 0 0 8px rgba(255, 176, 0, 0.7); }

.ventana-cuerpo {
  padding: 1.1rem 1.2rem 1.4rem;
  font-size: 0.88rem;
  line-height: 1.65;
  display: grid;
  gap: 0.8rem;
  max-height: min(60vh, 520px);
  overflow-y: auto;
}

/* scrollbar fósforo */
.ventana-cuerpo::-webkit-scrollbar { width: 8px; }
.ventana-cuerpo::-webkit-scrollbar-track { background: rgba(57, 255, 110, 0.05); }
.ventana-cuerpo::-webkit-scrollbar-thumb { background: var(--verde-dim); }

.logo-ascii {
  font-family: monospace;
  font-size: clamp(0.4rem, 1.5vw, 0.72rem);
  line-height: 1.15;
  color: var(--verde);
  text-shadow: 0 0 8px rgba(57, 255, 110, 0.5);
  overflow-x: auto;
}

.marca-sub {
  font-family: var(--f-crt);
  font-size: 1.15rem;
  color: var(--verde);
  letter-spacing: 0.18em;
  text-shadow: 0 0 8px rgba(57, 255, 110, 0.45);
  margin: 0.15rem 0 0.35rem;
}

.tagline { font-family: var(--f-crt); font-size: 1.35rem; color: var(--texto); }

.enlace {
  color: var(--ambar);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.enlace:hover { text-shadow: 0 0 8px rgba(255, 176, 0, 0.7); }

/* listado de productos (cada ítem abre su ficha) */
.listado { list-style: none; display: grid; gap: 0.15rem; }
.listado-item {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: start;
  gap: 0.9rem;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.listado-item:hover, .listado-item:focus-visible {
  background: rgba(255, 176, 0, 0.07);
  border-left-color: var(--ambar);
}
.listado-item .abrir {
  color: var(--texto-dim);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.listado-item:hover .abrir, .listado-item:focus-visible .abrir {
  opacity: 1;
  color: var(--ambar);
}
.cod {
  font-weight: 600;
  color: var(--ambar);
  text-shadow: 0 0 5px rgba(255, 176, 0, 0.4);
  white-space: nowrap;
}
.listado .desc strong { color: var(--texto); display: block; }
.listado .desc span { color: var(--texto-dim); font-size: 0.82rem; }

/* fichas de producto */
.ventana-ficha { width: min(560px, calc(100vw - 2rem)); }

.ficha-cabecera {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.ficha-cabecera strong {
  font-family: var(--f-crt);
  font-size: 1.5rem;
  color: var(--verde);
  text-shadow: 0 0 8px rgba(57, 255, 110, 0.5);
}

.ficha-sub {
  font-weight: 600;
  margin-top: 0.3rem;
}

.ficha-modulos {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.ficha-modulos li {
  font-size: 0.78rem;
  color: var(--texto);
  border: 1px solid var(--verde-dim);
  padding: 0.15rem 0.6rem;
  background: rgba(57, 255, 110, 0.06);
  white-space: nowrap;
}

/* servicios */
.servicios dt {
  font-family: var(--f-crt);
  font-size: 1.25rem;
  color: var(--verde);
  margin-top: 0.4rem;
}
.servicios dd { color: var(--texto-dim); margin-left: 2.6rem; }

.contacto-linea {
  display: flex;
  gap: 1rem;
  align-items: baseline;
}
.contacto-linea .ambar { min-width: 3.2rem; font-weight: 600; }

.btn-demo {
  display: inline-block;
  font-family: var(--f-crt);
  font-size: 1.3rem;
  color: var(--negro);
  background: var(--verde);
  text-decoration: none;
  padding: 0.2rem 0.9rem;
  box-shadow: 0 0 18px rgba(57, 255, 110, 0.5);
}
.btn-demo:hover { background: var(--ambar); box-shadow: 0 0 18px rgba(255, 176, 0, 0.6); }

/* ---------- pie de estado ---------- */

.pie-status {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.5rem clamp(0.8rem, 3vw, 2rem);
  border-top: 1px solid var(--verde-dim);
  background: var(--negro-panel);
  font-size: 0.72rem;
  color: var(--texto-dim);
}

/* ---------- responsive / accesibilidad ---------- */

@media (max-width: 700px) {
  .ventana {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 100%;
    margin-bottom: 1rem;
  }
  .barra { gap: 0.8rem; }
  .barra-marca { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #lluvia { display: none; }
}
