/* ============================================================
   MODAL · DIAGNÓSTICO (Cyberpunk / Verde Neón)
   ------------------------------------------------------------
   Visibilidad controlada por #diagnostico-toggle (checkbox
   pattern). Visibilidad 100% CSS vía :has() — mismo patrón que
   el toggle de tema. Permite abrir/cerrar el modal sin JS,
   alineado con la regla eco-eficiente del sitio.

   Estética intencionalmente distinta al resto de la página
   (modo técnico / operativo). Usa los tokens con sufijo
   '-cyber' definidos en tokens.css para mantener la
   trazabilidad sin acoplarse al sistema principal.
   ============================================================ */

/* El modal existe siempre en el DOM, oculto por default.
   Se muestra cuando el checkbox está :checked. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.18s linear, visibility 0s linear 0.18s;
}

html:has(#diagnostico-toggle:checked) .modal {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.18s linear, visibility 0s linear 0s;
}

/* Backdrop oscuro semitransparente. Es un <label> que cierra
   el modal al hacer clic. Cubre toda la pantalla y queda
   DETRÁS del panel (z-index menor). */
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 15, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
  z-index: 0;
}

/* Panel principal · centrado, fondo cyberpunk, scroll interno. */
.modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--color-bg-cyber);
  color: var(--color-text-cyber);
  font-family: var(--font-mono-cyber);
  border: 1px solid var(--color-accent-cyber);
  border-radius: var(--radius-md);
  padding: 2rem 1.75rem 1.75rem;
  box-shadow:
    0 0 0 1px var(--color-glow-cyber),
    0 12px 48px rgba(0, 0, 0, 0.55),
    0 0 32px var(--color-glow-cyber);
}

/* Botón X · esquina superior derecha del panel */
.modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.85rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--color-text-cyber-mut);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.12s ease, background-color 0.12s ease;
}

.modal__close:hover {
  color: var(--color-accent-cyber);
  background-color: var(--color-glow-cyber);
}

/* Cabecera del modal */
.modal__header {
  margin-bottom: 1.5rem;
  padding-right: 1.5rem;
}

.modal__eyebrow {
  color: var(--color-accent-cyber);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  opacity: 0.85;
}

.modal__title {
  color: var(--color-text-cyber);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.5rem;
}

.modal__sub {
  color: var(--color-text-cyber-mut);
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 0;
}

/* ---------- Formulario ---------- */
.modal__form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal__field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
}

.modal__field label {
  color: var(--color-text-cyber);
  font-size: 0.82rem;
  line-height: 1.4;
  font-weight: 600;
}

/* Inputs, textarea, select · bordes con línea inferior verde
   neón al estilo cyberpunk + glow al focus. */
.modal__field input,
.modal__field textarea,
.modal__field select {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  color: var(--color-text-cyber);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(90, 110, 133, 0.4);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.modal__field input::placeholder,
.modal__field textarea::placeholder {
  color: var(--color-text-cyber-mut);
  opacity: 1;
}

/* Estado :focus · borde + glow verde neón, sin animaciones pesadas */
.modal__field input:focus,
.modal__field textarea:focus,
.modal__field select:focus {
  border-color: var(--color-accent-cyber);
  background-color: rgba(0, 255, 102, 0.04);
  box-shadow: 0 0 0 3px var(--color-glow-cyber);
}

/* Textarea · no se redimensiona por el usuario (mantiene layout) */
.modal__field textarea {
  resize: vertical;
  min-height: 90px;
  max-height: 200px;
}

/* Select · flecha nativa del sistema, fondo coherente */
.modal__field select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--color-accent-cyber) 50%),
    linear-gradient(135deg, var(--color-accent-cyber) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

.modal__field select option {
  background: var(--color-bg-cyber);
  color: var(--color-text-cyber);
}

/* Counter de caracteres · actualizado en tiempo real por el
   listener JS inline en index.html. Mantiene sincronizado
   aria-valuenow para lectores de pantalla. */
.modal__counter {
  position: absolute;
  bottom: 0.45rem;
  right: 0.6rem;
  color: var(--color-text-cyber-mut);
  font-size: 0.7rem;
  pointer-events: none;
  font-family: inherit;
}

/* Helper text · guía visible debajo del textarea (d-proceso).
   MEDIUM auditoría UX/UI: mejora la calidad de respuesta del usuario
   listando qué info concreta ayuda al diagnóstico. Color muted para
   no competir con el label, conectado con aria-describedby al input. */
.modal__help {
  margin: 0.35rem 0 0;
  color: var(--color-text-cyber-mut);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ---------- Botón submit ---------- */
.modal__submit {
  margin-top: 0.5rem;
  width: 100%;
  background: var(--color-accent-cyber);
  color: var(--color-bg-cyber);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.95rem 1.25rem;
  border: 1px solid var(--color-accent-cyber);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: box-shadow 0.15s ease, background-color 0.15s ease;
  box-shadow: 0 0 0 0 transparent;
}

.modal__submit:hover {
  background: #1AFF77;
  box-shadow:
    0 0 0 3px var(--color-glow-cyber),
    0 0 24px rgba(0, 255, 102, 0.45);
}

.modal__submit:active {
  background: #00E65A;
  box-shadow: 0 0 0 2px rgba(0, 255, 102, 0.3);
}

.modal__submit:focus-visible {
  outline: 2px solid var(--color-accent-cyber);
  outline-offset: 3px;
}

/* ---------- Overlay de "Generando diagnóstico" ----------
   Se monta encima del .modal__panel con position: absolute,
   tapando el form con un fondo del mismo color del panel
   + un blur sutil para legibilidad.
   El atributo HTML `hidden` lo arranca oculto; el JS lo muestra
   en el submit. Si JS está apagado, el form nativo funciona
   exactamente como antes (mejora progresiva). */
.modal__overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  /* encima del form (z=auto) y del header */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-radius: var(--radius-md);
  /* mismo radius que .modal__panel */
  animation: overlay-fade-in 180ms ease-out;
}

.modal__overlay[hidden] {
  display: none;
  /* por si el UA ignora el atributo hidden */
}

.modal__overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--color-text-cyber);
  /* mismo color de texto que .modal__panel */
}

.modal__overlay-logo {
  width: 96px;
  height: 120px;
  animation: overlay-logo-pulse 1.6s ease-in-out infinite;
}

.modal__overlay-eyebrow {
  margin: 0;
  font-family: var(--font-mono-cyber);
  font-size: 0.75rem;
  color: var(--color-accent-cyber);
  letter-spacing: 0.05em;
  text-transform: lowercase;
}

.modal__overlay-text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text-cyber);
  font-weight: 500;
}

@keyframes overlay-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes overlay-logo-pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.06);
    opacity: 0.8;
  }
}

/* En móvil el panel pasa a height: 100vh → el overlay
   ya cubre todo por el inset:0, no necesita overrides. */

/* Texto de apoyo debajo del CTA del hero — siempre visible,
   persuade a hacer clic antes de abrir el modal.
   Color claro para legibilidad sobre el background del hero. */
.hero-cta__help {
  color: rgba(249, 249, 249, 0.78);
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0.75rem 0 0;
  max-width: 32rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.hero-cta__help strong {
  color: #F9F9F9;
}

/* ---------- Responsive · móvil ---------- */
@media (max-width: 720px) {
  .modal {
    padding: 0;
    align-items: stretch;
  }

  .modal__panel {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 2.5rem 1.25rem 1.5rem;
  }

  .modal__title {
    font-size: 1.15rem;
  }
}

/* ---------- Accesibilidad · focus visible solo con teclado ---------- */
.modal__close:focus-visible {
  outline: 2px solid #00FF66;
  outline-offset: 2px;
}
