/* =============================================================================
   Base: reset, tipografía, layout
   ============================================================================= */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img, svg { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
a { color: var(--gold-deep); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 600; }
h1 { font-family: var(--serif); font-size: var(--fs-2xl); }
h2 { font-family: var(--serif); font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p  { margin: 0; }

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

/* --- Layout ---------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  padding: calc(var(--s-3) + env(safe-area-inset-top)) var(--s-4) var(--s-3);
  background: rgba(245, 239, 228, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--s-2); text-decoration: none; color: var(--ink); }
.brand-mark { width: 32px; height: 32px; border-radius: 50%; }
.brand-name { font-weight: 800; font-size: var(--fs-xs); letter-spacing: 0.22em; }
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.topbar-actions .btn { white-space: nowrap; min-width: max-content; flex: none; }
.topbar-actions .btn[href="/perfil"] { min-width: 108px; }
@media (max-width: 420px) { .topbar-actions .btn { padding: 0 var(--s-3); } .brand-name { letter-spacing: 0.16em; } }

.app { outline: none; min-height: 60vh; padding-bottom: var(--s-7); }

.site-footer {
  border-top: 1px solid var(--line);
  padding: var(--s-5) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom));
  text-align: center; font-size: var(--fs-xs); color: var(--ink-mute);
  display: flex; flex-direction: column; gap: 2px;
}
.site-footer strong { letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft); }

.container {
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--s-5) var(--s-4);
}
.container.wide { max-width: var(--wide); }

.stack   { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-6); }
.row     { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.center  { text-align: center; align-items: center; }

.eyebrow {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--gold-deep);
}
.muted { color: var(--ink-mute); }
.small { font-size: var(--fs-sm); }

.loading { display: flex; align-items: center; justify-content: center; gap: var(--s-3); padding: var(--s-8) var(--s-4); color: var(--ink-mute); }
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--gold-deep);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  h1 { font-size: var(--fs-3xl); }
  .container { padding: var(--s-7) var(--s-5); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* --- Modo app: barra de secciones abajo, sin barra de arriba ni pie de página ---------------- */
:root { --tabbar: 64px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(251, 246, 236, 0.96);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px -20px rgba(20, 16, 8, 0.35);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  flex: 1 1 0; min-width: 0; max-width: 140px; min-height: var(--tabbar);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--ink-mute);
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em; line-height: 1.1; text-align: center;
  padding: 6px 2px 4px; -webkit-tap-highlight-color: transparent;
}
.tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar .tab-img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; opacity: 0.75; transition: opacity .2s, transform .2s; }
.tabbar .tab-mascot { background: var(--paper-2); }
.tabbar a.is-active { color: var(--olive-deep); }
.tabbar a.is-active .tab-img { opacity: 1; transform: scale(1.08); box-shadow: 0 0 0 2px var(--olive-light); }
.tabbar a.is-active svg { stroke-width: 2.1; }
body.has-tabbar .topbar,
body.has-tabbar .site-footer { display: none; }
body.has-tabbar .app { padding-top: env(safe-area-inset-top); padding-bottom: calc(var(--tabbar) + var(--s-6) + env(safe-area-inset-bottom)); }
body.has-tabbar .tester { bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom)); }
/* El "← Inicio" de arriba ya no hace falta: Inicio está en la barra */
body.has-tabbar .container > .stack-lg > a.small[href="/"]:first-child { display: none; }
