/* =============================================================
   AQUA AMAZÓNICA — BASE / UTILIDADES
   Complementa tokens.css. Reset extendido + utilities mobile-first.
   ============================================================= */

html, body {
  width: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text-body);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  text-rendering: optimizeLegibility;
  /* NO usar overflow-x:hidden aquí — bloquea swipe horizontal de hijos en iOS */
}

#app {
  position: relative;
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  box-shadow: 0 0 0 1px var(--color-border-soft);
  overflow-x: hidden; /* recorta el shell — solo el #app, no body */
}

@media (max-width: 480px) {
  #app { box-shadow: none; }
}

#view-container {
  position: relative;
  width: 100%;
  padding-bottom: 0;
  transition: opacity var(--transition-fast);
}

body.has-bottom-nav #view-container {
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + var(--space-5));
}

body.has-header #view-container {
  padding-top: 0;
}

#view-container.transitioning { opacity: 0; }

/* ============== Scrollbar móvil ============== */
::-webkit-scrollbar { width: 0; height: 0; }
.h-scroll {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch; /* momentum iOS */
  touch-action: pan-x pan-y;         /* permite swipe en ambos ejes */
  scroll-snap-type: x proximity;     /* proximity en lugar de mandatory: más permisivo en iOS */
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: var(--space-2) var(--screen-padding-x);
  margin: 0 calc(var(--screen-padding-x) * -1);
  -webkit-user-select: none;
  user-select: none;
  /* iOS: asegurar que el contenedor tenga su propio stacking context */
  position: relative;
  will-change: scroll-position;
}
.h-scroll::-webkit-scrollbar { display: none; }
.h-scroll > * {
  scroll-snap-align: start;
  flex-shrink: 0;
  -webkit-touch-callout: none; /* evita el popup de "guardar imagen" al mantener pulsado */
}

/* ============== Tipografía utilitaria ============== */
.text-display    { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-5xl); line-height: var(--lh-tight); color: var(--color-text-primary); letter-spacing: var(--ls-tight); }
.text-h1         { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-4xl); line-height: var(--lh-tight); color: var(--color-text-primary); letter-spacing: var(--ls-tight); }
.text-h2         { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-3xl); line-height: var(--lh-tight); color: var(--color-text-primary); }
.text-h3         { font-family: var(--font-display); font-weight: var(--fw-bold);      font-size: var(--fs-2xl); line-height: var(--lh-tight); color: var(--color-text-primary); }
.text-h4         { font-family: var(--font-display); font-weight: var(--fw-bold);      font-size: var(--fs-xl);  line-height: var(--lh-snug);  color: var(--color-text-primary); }
.text-body       { font-family: var(--font-body); font-weight: var(--fw-regular); font-size: var(--fs-md); line-height: var(--lh-relaxed); color: var(--color-text-body); }
.text-body-sm    { font-family: var(--font-body); font-weight: var(--fw-regular); font-size: var(--fs-sm); line-height: var(--lh-normal); color: var(--color-text-body); }
.text-muted      { color: var(--color-text-muted); }
.text-overline   { font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-xs); letter-spacing: var(--ls-wider); text-transform: uppercase; color: var(--color-eco-deep); }
.text-overline-sm{ font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-2xs); letter-spacing: var(--ls-wider); text-transform: uppercase; color: var(--color-text-muted); }
.text-on-image   { color: var(--color-text-on-image); text-shadow: 0 1px 3px rgba(0,0,0,0.35); }

.uppercase  { text-transform: uppercase; }
.center     { text-align: center; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2    { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3    { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ============== Layout utilitarias ============== */
.flex      { display: flex; }
.flex-col  { display: flex; flex-direction: column; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.flex-1    { flex: 1 1 0%; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: 1fr 1fr; }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

.hidden { display: none !important; }
.relative { position: relative; }
.absolute { position: absolute; }
.sticky   { position: sticky; }
.full     { width: 100%; }
.w-full   { width: 100%; }

/* ============== Padding / Margin ============== */
.screen-pad     { padding-left: var(--screen-padding-x); padding-right: var(--screen-padding-x); }
.section-pad-y  { padding-top: var(--space-6); padding-bottom: var(--space-6); }
.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); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

/* ============== Iconografía ============== */
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-16 { width: 16px; height: 16px; }
.icon-20 { width: 20px; height: 20px; }
.icon-24 { width: 24px; height: 24px; }
.icon-28 { width: 28px; height: 28px; }
.icon-32 { width: 32px; height: 32px; }
.icon-40 { width: 40px; height: 40px; }
.icon-48 { width: 48px; height: 48px; }

/* ============== Accesibilidad ============== */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
  white-space: nowrap;
}

*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============== Imágenes ============== */
img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: cover;
}

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

/* ============== Animaciones globales ============== */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in 250ms ease both; }

@keyframes ondas {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}
