/* ==========================================================================
   VIDRIO — superficies, botones y piezas reutilizables
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html { font-family: var(--fuente); font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--texto);
  background: var(--fondo-base);
  font-size: var(--t-md);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--t-2xl); font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: var(--t-lg); font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: var(--t-md); font-weight: 600; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.tenue { color: var(--texto-3); }
.oculto-visual {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

:focus-visible {
  outline: 2.5px solid var(--acento);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ----- Fondo vivo: malla de degradados que se mueve muy despacio ----- */
.fondo {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: var(--fondo-base);
}
.fondo i {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  filter: blur(90px); opacity: 0.75; will-change: transform;
  animation: deriva 60s var(--suave) infinite alternate;
}
.fondo i:nth-child(1) { background: var(--malla-1); top: -25vmax; left: -15vmax; }
.fondo i:nth-child(2) { background: var(--malla-2); top: -20vmax; right: -25vmax; animation-duration: 75s; animation-delay: -20s; }
.fondo i:nth-child(3) { background: var(--malla-3); bottom: -35vmax; left: 10vmax; animation-duration: 90s; animation-delay: -40s; }
.fondo i:nth-child(4) { background: var(--malla-4); bottom: -30vmax; right: -10vmax; animation-duration: 70s; animation-delay: -10s; }
@keyframes deriva {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(8vmax, 6vmax, 0) scale(1.15); }
}
@media (prefers-reduced-motion: reduce) { .fondo i { animation: none; } }

/* ----- Superficie de vidrio ----- */
.vidrio {
  position: relative;
  background: var(--vidrio);
  -webkit-backdrop-filter: blur(var(--blur-vidrio)) saturate(var(--saturacion));
  backdrop-filter: blur(var(--blur-vidrio)) saturate(var(--saturacion));
  border: 1px solid var(--borde-sutil);
  border-radius: var(--r-md);
  /* Brillo especular arriba y a la izquierda */
  box-shadow:
    inset 1px 1px 0 var(--brillo),
    inset 0 0 0 1px var(--borde),
    var(--sombra-1);
}
.vidrio.fuerte { background: var(--vidrio-fuerte); }

/* Reflejo que sigue al cursor (las coordenadas las pone marco.js) */
.vidrio.reflejo::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 0%), var(--brillo), transparent 65%);
  opacity: 0; transition: opacity var(--d-media) var(--suave);
  mix-blend-mode: soft-light;
}
.vidrio.reflejo:hover::after { opacity: 0.9; }

/* ----- Tarjetas ----- */
.tarjeta { padding: var(--e-5); border-radius: var(--r-lg); }
.tarjeta.pulsable {
  display: block; text-decoration: none; cursor: pointer; text-align: left; width: 100%;
  transition: transform var(--d-media) var(--resorte), background-color var(--d-rapida);
}
.tarjeta.pulsable:hover { background: var(--vidrio-hover); transform: translateY(-2px); }
.tarjeta.pulsable:active { transform: scale(0.985); }

/* ----- Botones ----- */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e-2);
  min-height: 40px; padding: 0 var(--e-4);
  border: 1px solid var(--borde-sutil); border-radius: var(--r-pildora);
  background: var(--vidrio-fuerte); color: var(--texto);
  font-size: var(--t-sm); font-weight: 600; text-decoration: none; cursor: pointer;
  box-shadow: inset 1px 1px 0 var(--brillo);
  transition: transform var(--d-media) var(--resorte), background-color var(--d-rapida);
}
.boton:hover { background: var(--vidrio-hover); }
.boton:active { transform: scale(0.95); }
.boton.primario { background: var(--acento); color: var(--acento-texto); border-color: transparent; box-shadow: none; }
.boton.primario:hover { filter: brightness(1.07); }
.boton.icono { width: 40px; padding: 0; }
.boton svg, .icono-svg { width: 20px; height: 20px; flex: none; }

/* ----- Etiquetas de estado ----- */
.etiqueta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-pildora);
  font-size: var(--t-xs); font-weight: 600; white-space: nowrap;
  background: var(--borde-sutil); color: var(--texto-2);
}
.etiqueta::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.etiqueta.activo { color: var(--verde-texto); }
.etiqueta.construccion { color: var(--naranja-texto); }
.etiqueta.proximamente { color: var(--gris-texto); }
.etiqueta.rojo { color: var(--rojo-texto); }
.etiqueta.naranja { color: var(--naranja-texto); }
.etiqueta.amarillo { color: var(--amarillo-texto); }
.etiqueta.verde { color: var(--verde-texto); }
.etiqueta.gris { color: var(--gris-texto); }

.contador {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pildora); background: var(--rojo); color: #fff;
  font-size: 0.6875rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.contador[hidden] { display: none; }

/* ----- Control segmentado ----- */
.segmentado {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pildora);
  background: var(--borde-sutil);
}
.segmentado button {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 14px; border-radius: var(--r-pildora);
  font-size: var(--t-sm); font-weight: 600; color: var(--texto-2);
  transition: background-color var(--d-rapida), color var(--d-rapida);
}
.segmentado button[aria-pressed="true"] {
  background: var(--vidrio-fuerte); color: var(--texto);
  box-shadow: inset 1px 1px 0 var(--brillo), var(--sombra-1);
}

/* ----- Campos ----- */
.campo {
  width: 100%; min-height: 42px; padding: 0 var(--e-4);
  border: 1px solid var(--borde-sutil); border-radius: var(--r-sm);
  background: var(--vidrio-fuerte);
}
.campo::placeholder { color: var(--texto-3); }

/* ----- Estado vacío ----- */
.vacio {
  display: grid; justify-items: center; gap: var(--e-3);
  padding: var(--e-7) var(--e-5); text-align: center; color: var(--texto-2);
}
.vacio svg { width: 44px; height: 44px; color: var(--texto-3); }
.vacio p { max-width: 42ch; }

/* ----- Modales y hojas ----- */
.velo {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: start center;
  padding: 12vh var(--e-4) var(--e-4);
  background: var(--velo);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: aparecer var(--d-media) var(--suave);
}
.velo[hidden] { display: none; }
.modal {
  width: min(640px, 100%); max-height: 76vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--vidrio-modal);
  -webkit-backdrop-filter: blur(var(--blur-modal)) saturate(var(--saturacion));
  backdrop-filter: blur(var(--blur-modal)) saturate(var(--saturacion));
  border-radius: var(--r-lg);
  box-shadow: inset 1px 1px 0 var(--brillo), inset 0 0 0 1px var(--borde), var(--sombra-3);
  animation: subir var(--d-lenta) var(--resorte);
}
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { opacity: 0; transform: translateY(18px) scale(0.97); } }

/* En celular los modales son hojas que suben desde abajo */
@media (max-width: 720px) {
  .velo { place-items: end center; padding: 0; }
  .modal { width: 100%; max-height: 86dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; animation-name: hoja; }
  @keyframes hoja { from { transform: translateY(100%); } }
}

/* ----- Rejillas ----- */
.rejilla { display: grid; gap: var(--e-4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.rejilla.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.pila { display: grid; gap: var(--e-4); }
.fila { display: flex; align-items: center; gap: var(--e-3); flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }

/* Lo oculto siempre se oculta, aunque su clase diga otra cosa. */
[hidden] { display: none !important; }
