/* app.css — frame de teléfono, router, tab bar, panel de estados y modo presentación. Solo tokens. */
:root { --tabbar-h: calc(var(--touch) + var(--sp-5)); } /* 64 px */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface-0); color: var(--text-primary);
  font-family: var(--font-body); font-size: var(--fs-body-m); line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
input, select, textarea { font: inherit; }
[hidden] { display: none !important; }

/* ---------- escenario + teléfono ---------- */
.stage { display: flex; align-items: center; justify-content: center; gap: var(--sp-6); width: 100%; height: 100vh; height: 100dvh; padding: var(--sp-4); }
.phone {
  position: relative; flex: none; width: var(--phone-w); height: var(--phone-h); max-height: 100%;
  background: var(--surface-0); overflow: hidden;
  border-radius: calc(var(--r-sheet) + var(--sp-3)); border: 1px solid var(--border-strong);
  box-shadow: var(--elev-1), var(--shadow-sheet);
}
@media (max-width: 430px) {
  .stage { padding: 0; gap: 0; }
  .phone { width: 100vw; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; border: 0; box-shadow: none; }
}

/* ---------- pantallas + transición 220 ms ---------- */
#screen { position: absolute; inset: 0; overflow: hidden; }
.screen { position: absolute; inset: 0; background: var(--surface-0); overflow: hidden; display: flex; flex-direction: column; }
.screen.with-tabbar { padding-bottom: var(--tabbar-h); }
.screen--enter-forward { animation: slideInR var(--dur-base) var(--ease) both; }
.screen--enter-back    { animation: slideInL var(--dur-base) var(--ease) both; }
.screen--exit-forward  { animation: slideOutL var(--dur-base) var(--ease) both; pointer-events: none; }
.screen--exit-back     { animation: slideOutR var(--dur-base) var(--ease) both; pointer-events: none; }
.screen--enter-fade    { animation: fadeIn var(--dur-base) var(--ease) both; }
@keyframes slideInR  { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideInL  { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOutL { to { transform: translateX(-24px); opacity: 0; } }
@keyframes slideOutR { to { transform: translateX(24px); opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.screen__scroll { flex: 1; overflow-y: auto; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
.topbar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-3); min-height: 56px; }
.topbar__title { flex: 1; font-family: var(--font-display); font-size: var(--fs-body-l); font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- tab bar (glass) ---------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--tabbar-h); z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-subtle);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--touch); color: var(--text-secondary); font-size: var(--fs-overline); font-weight: 600; text-decoration: none;
  -webkit-tap-highlight-color: transparent; transition: color var(--dur-fast) var(--ease);
}
.tab { position: relative; }
.tab::before { content: ''; position: absolute; top: 0; left: 50%; width: 20px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); transform: translateX(-50%) scaleX(0); transition: transform var(--dur-base) var(--ease); }
.tab[aria-current="page"] { color: var(--text-primary); }
.tab[aria-current="page"] .icon { color: var(--brand); }
.tab[aria-current="page"]::before { transform: translateX(-50%) scaleX(1); }
.tab:active .icon { transform: scale(.9); }
.tab .icon { transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.tab--fab { justify-content: flex-start; }
.fab {
  width: var(--fab); height: var(--fab); margin-top: calc(-1 * var(--sp-5)); border-radius: var(--r-pin);
  background: var(--brand); color: var(--text-primary); display: grid; place-items: center;
  box-shadow: var(--glow-brand-soft); border: 2px solid var(--surface-0);
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.fab:hover { background: var(--brand-hover); box-shadow: var(--glow-brand); }
.fab:active { transform: scale(.94); }
.tab__badge { position: absolute; margin-left: 18px; margin-top: -22px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-chip); background: var(--brand); color: var(--text-primary); font-size: 10px; display: grid; place-items: center; }

/* ---------- panel de estados ---------- */
.state-fab {
  position: fixed; right: var(--sp-4); top: var(--sp-4); z-index: 100;
  width: var(--touch); height: var(--touch); border-radius: var(--r-pin);
  background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border-strong);
  display: grid; place-items: center; transition: color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.state-fab:hover { color: var(--text-primary); }
@media (max-width: 430px) {
  /* en pantallas chicas es una pestañita en el borde: no tapa la tab bar ni el perfil */
  .state-fab { top: 40%; right: 0; width: 28px; height: 52px; border-radius: 12px 0 0 12px; border-right: 0; opacity: .75; }
  .state-fab .icon { width: 16px; height: 16px; }
}
.state-panel {
  position: fixed; right: var(--sp-4); top: calc(var(--sp-4) + var(--touch) + var(--sp-2)); z-index: 100; width: 260px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-card);
  padding: var(--sp-4); display: grid; gap: var(--sp-3); box-shadow: var(--shadow-sheet);
}
.state-panel h2 { font-family: var(--font-display); font-size: var(--fs-body-m); margin: 0; display: flex; justify-content: space-between; align-items: center; }
.state-panel label { display: grid; gap: var(--sp-1); font-size: var(--fs-body-s); color: var(--text-secondary); }
.state-panel select, .state-panel input {
  min-height: 40px; padding: 0 var(--sp-3); border-radius: var(--r-input); background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border-strong);
}
.state-panel .btn { min-height: 40px; }
@media (max-width: 430px) { .state-panel { right: var(--sp-2); top: 40%; } }
.state-panel kbd { font-family: var(--font-mono); font-size: var(--fs-overline); padding: 2px 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--border-strong); }
.state-panel__meta { font-size: var(--fs-overline); color: var(--text-tertiary); font-family: var(--font-mono); }

/* ---------- modo presentación ---------- */
body.present .state-fab, body.present .state-panel { display: none; }
body.present .stage { flex-direction: row; align-items: center; padding-top: calc(var(--touch) + var(--sp-8)); }
.present-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90; min-height: calc(var(--touch) + var(--sp-4));
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4);
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border-bottom: 1px solid var(--border-subtle);
}
.present-bar__brand { font-family: var(--font-display); font-weight: 700; color: var(--brand); margin-right: var(--sp-2); }
.present-bar select { flex: 1; max-width: 420px; min-height: 40px; padding: 0 var(--sp-3); border-radius: var(--r-input); background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border-strong); }
.present-bar__count { font-family: var(--font-mono); font-size: var(--fs-body-s); color: var(--text-secondary); min-width: 84px; text-align: center; }
.present-bar__nav { display: flex; gap: var(--sp-1); }
.present-bar a { color: var(--text-secondary); font-size: var(--fs-body-s); text-decoration: none; margin-left: auto; }
.present-note {
  width: 320px; max-width: 100%; align-self: center;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-card); padding: var(--sp-5);
  display: grid; gap: var(--sp-3); box-shadow: var(--elev-1);
}
.present-note__step { font-family: var(--font-mono); color: var(--text-tertiary); font-size: var(--fs-overline); letter-spacing: .08em; }
.present-note__route { font-family: var(--font-mono); color: var(--info); font-size: var(--fs-body-s); }
.present-note__text { margin: 0; font-size: var(--fs-body-l); line-height: var(--lh-normal); }
.present-note__state { display: inline-flex; gap: var(--sp-2); align-items: center; font-size: var(--fs-body-s); color: var(--text-secondary); }
.present-note__state .badge { text-transform: none; letter-spacing: 0; }
.present-note__hint { color: var(--text-tertiary); font-size: var(--fs-body-s); }
@media (max-width: 900px) {
  body.present .stage { flex-direction: column; height: auto; min-height: 100vh; overflow-y: auto; }
  .present-note { width: var(--phone-w); }
}
@media (max-width: 430px) {
  body.present .stage { padding-top: calc(var(--touch) + var(--sp-4)); }
  body.present .phone { height: calc(100vh - var(--touch) - var(--sp-4) - 180px); }
}
