/* =========================================================================
   Base: reset, marco de teléfono, carcasa de la app y transiciones
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(16px * var(--text-scale)); -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: var(--font-body); font-size: var(--fs-md); line-height: 1.45;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; line-height: 1.15; }
ul, ol { margin: 0; padding: 0; list-style: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
svg { flex-shrink: 0; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Foco visible y consistente en toda la app */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 10px;
}
html[data-contrast="alto"] :focus-visible { outline-width: 4px; outline-offset: 3px; }

/* ---------- Página contenedora (escritorio) ---------- */
.stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

.device { position: relative; width: 100%; height: 100%; }

.app {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg); overflow: hidden; isolation: isolate;
}

/* Barra de estado simulada: solo en el marco de escritorio y en capturas */
.statusbar { display: none; }

@media (min-width: 640px) and (min-height: 620px) {
  body {
    background:
      radial-gradient(900px 600px at 15% 10%, rgba(124, 58, 237, .35), transparent 60%),
      radial-gradient(800px 600px at 90% 90%, rgba(219, 39, 119, .28), transparent 60%),
      #0B0620;
  }
  .device {
    width: 390px; height: 844px; flex: none;
    border-radius: 58px; padding: 12px;
    background: linear-gradient(160deg, #2a2245, #0d0a19 40%, #1b1530);
    box-shadow:
      0 0 0 1.5px rgba(255, 255, 255, .12) inset,
      0 0 0 2px #05030c,
      0 40px 100px rgba(0, 0, 0, .6),
      0 0 120px rgba(192, 38, 211, .18);
    transform: scale(var(--device-scale, 1));
    transform-origin: center;
  }
  .device .app { border-radius: 46px; }
  .device::after { /* isla dinámica */
    content: ""; position: absolute; top: 23px; left: 50%; transform: translateX(-50%);
    width: 118px; height: 34px; border-radius: 20px; background: #000; z-index: 50;
  }
  .app { --statusbar-h: 50px; }
  .statusbar { display: flex; height: var(--statusbar-h); padding: 4px 30px 0 36px; }
  .desk-note { display: flex !important; }
}

html.captura .app { --statusbar-h: 46px; }
html.captura .statusbar { display: flex; height: var(--statusbar-h); padding: 2px 24px 0 30px; }

.statusbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 40;
  align-items: center; justify-content: space-between;
  font-family: var(--font-body); font-weight: 700; font-size: 15px; letter-spacing: .01em;
  pointer-events: none; color: #fff;
}
.statusbar .sb-icons { display: flex; gap: 6px; align-items: center; }
.app.on-light .statusbar { color: #fff; }

/* Nota de escritorio bajo el teléfono */
.desk-note {
  display: none; position: fixed; left: 24px; bottom: 22px; z-index: 5;
  align-items: center; gap: 12px; color: #CFC6EE; font-size: 13px;
}
.desk-note a {
  color: #fff; text-decoration: none; font-weight: 700;
  padding: 8px 14px; border-radius: 999px; background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
}
.desk-note a:hover { background: rgba(255, 255, 255, .14); }

/* ---------- Pantallas ---------- */
.screens { position: relative; flex: 1; min-height: 0; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  will-change: transform, opacity;
}
.screen-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.screen-scroll::-webkit-scrollbar { display: none; }

/* Espacio superior: barra de estado simulada o safe area real */
.top-safe { padding-top: max(var(--statusbar-h), var(--safe-top)); }

/* Transiciones entre pantallas */
.screen.in-forward  { animation: inForward  var(--dur-slow) var(--ease-out) both; z-index: 2; }
.screen.out-forward { animation: outForward var(--dur-slow) var(--ease-out) both; z-index: 1; }
.screen.in-back     { animation: inBack     var(--dur-slow) var(--ease-out) both; z-index: 1; }
.screen.out-back    { animation: outBack    var(--dur-slow) var(--ease-out) both; z-index: 2; }
.screen.in-fade     { animation: inFade     var(--dur) var(--ease-out) both; z-index: 2; }
.screen.out-fade    { animation: outFade    var(--dur) ease both; z-index: 1; }
.screen.in-rise     { animation: inRise     var(--dur-slow) var(--ease-out) both; z-index: 2; }
.screen.leaving     { pointer-events: none; }

@keyframes inForward  { from { transform: translateX(100%); } to { transform: none; } }
@keyframes outForward { to { transform: translateX(-28%); opacity: .4; } }
@keyframes inBack     { from { transform: translateX(-28%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes outBack    { to { transform: translateX(100%); } }
@keyframes inFade     { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
@keyframes outFade    { to { opacity: 0; } }
@keyframes inRise     { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }

/* Movimiento reducido (preferencia del sistema, ajuste de la app o modo captura) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after,
html.captura *, html.captura *::before, html.captura *::after {
  animation-duration: .01ms !important; animation-delay: 0ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important; transition-delay: 0ms !important;
}
/* Animaciones decorativas infinitas: en captura se congelan en un fotograma bonito */
html.captura .no-capture { display: none !important; }

/* Utilidades */
.row { display: flex; align-items: center; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.center { text-align: center; }
.grad-text {
  background: var(--grad-text); -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.pad { padding-left: var(--gutter); padding-right: var(--gutter); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
