/* =======================================================
   BASE — Reset, layout mobile-first, tipografía
   Tema 2 "Soft Relief" — fondo plano neomorfo sin olas.
   ======================================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out);
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* ===== App shell — mobile 360×800 base, escala fluida ===== */
.app-shell {
  position: relative;
  width: 100%;
  max-width: var(--app-max-width);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--grad-bg);
  overflow: hidden;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  display: flex;
  flex-direction: column;
  transition: background var(--dur-base) var(--ease-out);
}

/* Neomorfismo no lleva olas — matamos cualquier wave-layer heredada */
.app-shell > .wave-layer,
.app-shell::before,
.app-shell::after {
  display: none !important;
  content: none !important;
}

.page {
  position: relative;
  z-index: 1;
  padding: var(--space-6) var(--space-5);
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

/* ===== Utilities ===== */
.hidden { display: none !important; }

.text-center { text-align: center; }
.text-muted  { color: var(--color-text-muted); }
.text-dim    { color: var(--color-text-dim); }
.text-accent { color: var(--color-accent); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-auto { margin-top: auto; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.full-w { width: 100%; }

/* Fluid scaling para pantallas grandes */
@media (min-width: 481px) {
  body {
    background:
      radial-gradient(ellipse at center, var(--color-bg) 0%, var(--color-bg-sink) 85%);
  }
  .app-shell {
    box-shadow:
      25px 25px 60px var(--shadow-dark),
      -25px -25px 60px var(--shadow-light);
    border-radius: 32px;
    min-height: calc(100vh - 24px);
    margin: 12px auto;
  }
}

/* Reducir motion para usuarios que lo prefieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Scrollbar discreta */
::-webkit-scrollbar { width: 0; height: 0; }

/* Selección */
::selection {
  background: var(--color-accent-glow);
  color: var(--color-text-strong);
}


/* ============================================================
   Velo de arranque — bm-booting (velo anti-FOUC)
   Mientras la app hidrata los datos REALES del servidor, oculta
   todo el contenido (que de otro modo mostraria saludo/nombre de
   relleno hasta cambiar) y muestra un velo con la marca + spinner.
   <html class="bm-booting"> lo activa desde el primer paint;
   api.js lo retira al terminar el boot (o tras un failsafe).
   ============================================================ */
html.bm-booting, html.bm-booting body { overflow: hidden !important; }
html.bm-booting .app-shell, html.bm-booting .face-cam, html.bm-booting .nchat-btn { visibility: hidden !important; }
html.bm-booting::before {
  content: ""; position: fixed; inset: 0; z-index: 99998;
  background: var(--color-bg, #0a1020);
}
html.bm-booting::after {
  content: ""; position: fixed; z-index: 99999;
  top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border: 3px solid rgba(127,127,127,0.22);
  border-top-color: var(--color-accent, #4FC3F7);
  border-radius: 50%;
  animation: bm-boot-spin 0.8s linear infinite;
}
@keyframes bm-boot-spin { to { transform: rotate(360deg); } }
