/* =========================================================
   Capa común: transiciones, microinteracciones, cookies,
   volver arriba, mapa con consentimiento y páginas legales.
   La cargan todas las páginas (incluida la landing de verano).
   ========================================================= */

/* ---------- Transición entre páginas (progressive enhancement) ---------- */
@view-transition { navigation: auto; }

/* ---------- Entrada suave de la página ---------- */
@keyframes tbcPageIn { from { opacity: 0; } to { opacity: 1; } }
body { animation: tbcPageIn .45s ease-out both; }

/* ---------- Hero: entrada escalonada ---------- */
.js-reveal .hero-text > .reveal:nth-child(2) { transition-delay: .12s; }
.js-reveal .hero-text > .reveal:nth-child(3) { transition-delay: .24s; }
.js-reveal .hero-text > .reveal:nth-child(4) { transition-delay: .36s; }
.js-reveal .hero-media.reveal { transition-delay: .3s; }

/* ---------- Microinteracciones en botones ---------- */
.btn-grad:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -12px rgba(25,44,255,.55); }
.btn-grad:active,
a.rounded-full:active,
button.rounded-full:active { transform: scale(.97); }
a.rounded-full:not(.btn-grad), button.rounded-full:not(.btn-grad) { transition-property: color, background-color, border-color, box-shadow, transform, background-position; transition-duration: .2s; }

/* ---------- Botón volver arriba ---------- */
.back-to-top {
  position: fixed; right: 24px; bottom: calc(var(--tbc-banner-h, 0px) + 92px); z-index: 49;
  width: 48px; height: 48px; border-radius: 999px; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: var(--bc-ultramarine, #160B86);
  box-shadow: 0 10px 28px -10px rgba(22,11,134,.45);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .25s ease, transform .25s ease, background-color .2s ease, color .2s ease, bottom .3s ease;
}
.back-to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.back-to-top:hover { background: var(--bc-ultramarine, #160B86); color: #fff; }
.back-to-top svg { width: 20px; height: 20px; }

/* El WhatsApp flotante sube mientras el banner de cookies está visible */
body .wa-ping { transition: bottom .3s ease, background-color .2s ease; }
body.cookie-banner-visible .wa-ping { bottom: calc(var(--tbc-banner-h, 0px) + 20px); }

/* ---------- Banner de cookies ---------- */
.cookie-banner {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 70;
  max-width: 980px; margin: 0 auto;
  background: #0A0840; color: #E1E1E1;
  border: 1px solid rgba(160,153,255,.25); border-radius: 22px;
  box-shadow: 0 24px 48px -16px rgba(10,8,64,.55);
  padding: 18px 22px;
  display: flex; align-items: center; gap: 18px 24px; flex-wrap: wrap;
  font-size: 15px; line-height: 1.5;
  transform: translateY(calc(100% + 24px)); transition: transform .35s cubic-bezier(.2,.7,.2,1);
}
.cookie-banner.is-visible { transform: none; }
.cookie-banner p { flex: 1 1 380px; margin: 0; }
.cookie-banner a { color: #A099FF; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.cookie-banner a:hover { color: #fff; }
.cookie-banner__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cookie-banner button {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  padding: 11px 22px; border-radius: 999px; transition: background-color .2s, color .2s, border-color .2s, transform .15s;
}
.cookie-banner button:active { transform: scale(.97); }
.cookie-banner__accept { background: #192CFF; color: #fff; border: 1px solid #192CFF; }
.cookie-banner__accept:hover { background: #fff; color: #160B86; border-color: #fff; }
.cookie-banner__reject { background: transparent; color: #E1E1E1; border: 1px solid rgba(225,225,225,.5); }
.cookie-banner__reject:hover { border-color: #fff; color: #fff; }
.cookie-banner button:focus-visible, .back-to-top:focus-visible, .map-consent button:focus-visible {
  outline: none; box-shadow: 0 0 0 2px #0A0840, 0 0 0 4px #A099FF;
}
@media (max-width: 640px) {
  .cookie-banner { flex-direction: column; align-items: stretch; text-align: left; padding: 16px 18px; font-size: 14px; }
  .cookie-banner p { flex: none; }
  .cookie-banner__actions button { flex: 1; }
}

/* Enlace "Configurar cookies" del pie, con aspecto de enlace */
.cookie-settings-link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: rgba(225,225,225,.7); transition: color .2s; }
.cookie-settings-link:hover { color: #A099FF; }

/* ---------- Mapa: solo se carga con consentimiento ---------- */
.map-consent {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 24px; text-align: center;
  background: radial-gradient(circle at 30% 30%, rgba(160,153,255,.35), transparent 60%), #e9e6f5;
  color: #0A0840;
}
.map-consent p { margin: 0; max-width: 300px; font-size: 14px; line-height: 1.5; color: rgba(10,8,64,.8); }
.map-consent button {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 12px 22px; border-radius: 999px; border: 0;
  background: #160B86; color: #fff; font: inherit; font-weight: 600;
  transition: background-color .2s, transform .15s;
}
.map-consent button:hover { background: #192CFF; }
.map-consent button:active { transform: scale(.97); }
.contact-map.is-loaded .map-consent { display: none; }
.contact-map .map-chip { z-index: 2; }

/* ---------- Páginas legales ---------- */
.legal { color: rgba(10,8,64,.85); font-size: 17px; line-height: 1.7; }
.legal > p:first-child { font-size: 14px; color: rgba(10,8,64,.7); margin-bottom: 2rem; }
.legal h2 { font-family: 'Clash Grotesk', system-ui, sans-serif; font-weight: 600; font-size: 28px; line-height: 1.15; letter-spacing: -.01em; color: #160B86; margin: 2.6rem 0 1rem; }
.legal h3 { font-family: 'Clash Grotesk', system-ui, sans-serif; font-weight: 500; font-size: 21px; line-height: 1.2; color: #160B86; margin: 1.8rem 0 .7rem; }
.legal p, .legal ul, .legal table { margin-bottom: 1.1rem; }
.legal ul { padding-left: 1.3rem; list-style: disc; }
.legal li { margin-bottom: .45rem; }
.legal li::marker { color: #192CFF; }
.legal strong { color: #0A0840; font-weight: 600; }
.legal a { color: #192CFF; text-decoration: underline; text-underline-offset: 3px; word-break: break-word; }
.legal a:hover { color: #160B86; }
.legal .table-wrap { overflow-x: auto; margin-bottom: 1.1rem; border-radius: 16px; border: 1px solid rgba(22,11,134,.12); background: #fff; }
.legal table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 0; min-width: 620px; }
.legal th, .legal td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid rgba(22,11,134,.08); }
.legal th { background: rgba(160,153,255,.18); color: #160B86; font-weight: 600; }
.legal tr:last-child td { border-bottom: 0; }

/* ---------- Reduced motion: fuera todo el movimiento de esta capa ---------- */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  body { animation: none; }
  .btn-grad:hover, .btn-grad:active, a.rounded-full:active, button.rounded-full:active { transform: none; }
  .back-to-top, .back-to-top.is-visible { transform: none; transition: opacity .01ms; }
  .cookie-banner { transition: none; }
}

/* ---------- Menú móvil cerrado: sin borde fantasma bajo la cabecera ---------- */
.mobile-menu:not(.is-open) { border-width: 0; box-shadow: none; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }

/* Tablas legales en móvil: cada fila como tarjeta */
@media (max-width: 640px) {
  .legal .table-wrap { border: 0; background: transparent; overflow: visible; }
  .legal table { min-width: 0; }
  .legal thead { display: none; }
  .legal table, .legal tbody, .legal tr, .legal td { display: block; width: 100%; }
  .legal tr { background: #fff; border: 1px solid rgba(22,11,134,.12); border-radius: 16px; padding: 6px 0; margin-bottom: 12px; }
  .legal td { border: 0; padding: 6px 16px; }
  .legal td::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #160B86; }
}
