/* =====================================================
   TRANSESTRELLA — CAPA UX GLOBAL
   CTA de cabecera, barra CTA móvil, progreso de scroll,
   animaciones de entrada, microinteracciones, volver arriba,
   banner de cookies, modo oscuro y animación de carga.
   JS: assets/js/ux.js — Markup: functions.php (ts_ux_*)
   ===================================================== */

:root {
  --ts-ease: cubic-bezier(.22, .61, .36, 1);
  --ts-mbar-h: 64px;
}

/* ══════════════════════════════════════════
   1. CTA EN CABECERA (visible antes del scroll)
══════════════════════════════════════════ */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 22px;
  flex-shrink: 0;
}

.nav-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--ts-gold);
  color: #fff;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 9px 18px;
  border-radius: 4px;
  white-space: nowrap;
  transition: background .2s, transform .2s var(--ts-ease), box-shadow .2s;
}

.nav-cta-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  transition: transform .2s var(--ts-ease);
}

.nav-cta-btn:hover {
  background: var(--ts-gold-hov);
  box-shadow: 0 6px 18px rgba(245, 166, 35, .35);
  transform: translateY(-1px);
}

.nav-cta-btn:hover svg { transform: translateX(3px); }

/* Interruptor de modo oscuro */
.ts-theme-toggle {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .18);
  background: transparent;
  color: rgba(255, 255, 255, .85);
  cursor: pointer;
  transition: background .2s, color .2s, transform .3s var(--ts-ease);
}

.ts-theme-toggle:hover {
  background: rgba(255, 255, 255, .1);
  color: var(--ts-gold);
}

.ts-theme-toggle:active { transform: scale(.9) rotate(-20deg); }

.ts-theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ts-theme-toggle .ts-ico-sun { display: none; }
html[data-theme="dark"] .ts-theme-toggle .ts-ico-sun { display: block; }
html[data-theme="dark"] .ts-theme-toggle .ts-ico-moon { display: none; }

@media (min-width: 769px) {
  .nav-inner > .nav-links { margin-left: auto; }
}

@media (min-width: 769px) and (max-width: 1140px) {
  .nav-links { gap: 16px; }
  .nav-links a { font-size: 12px; }
  .nav-actions { margin-left: 14px; }
}

@media (max-width: 768px) {
  .nav-inner { gap: 8px; }
  .nav-actions { margin-left: auto; gap: 6px; order: 2; }
  .nav-toggle { order: 3; }
  .nav-cta-btn { padding: 8px 12px; font-size: 13px; }
  .nav-cta-btn svg { display: none; }
  .ts-theme-toggle { width: 34px; height: 34px; }
}

@media (max-width: 380px) {
  .nav-logo img { height: 38px !important; }
}

/* ══════════════════════════════════════════
   2. BARRA CTA MÓVIL (siempre visible)
══════════════════════════════════════════ */
.ts-mbar { display: none; }

@media (max-width: 768px) {
  .ts-mbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 998;
    display: grid;
    grid-template-columns: 1fr 1fr 1.3fr;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(8, 50, 102, .97);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, .18);
  }

  .ts-mbar a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 46px;
    border-radius: 6px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    text-decoration: none;
    color: #fff;
    transition: transform .15s var(--ts-ease), filter .15s;
  }

  .ts-mbar a:active { transform: scale(.96); filter: brightness(.92); }

  .ts-mbar svg { width: 18px; height: 18px; flex-shrink: 0; }

  .ts-mbar-call { background: rgba(255, 255, 255, .1); }
  .ts-mbar-call svg { stroke: currentColor; fill: none; stroke-width: 2; }
  .ts-mbar-wa { background: #25D366; }
  .ts-mbar-wa svg { fill: #fff; }
  .ts-mbar-quote { background: var(--ts-gold); }

  body { padding-bottom: calc(var(--ts-mbar-h) + env(safe-area-inset-bottom)); }

  /* El flotante de WhatsApp queda integrado en la barra */
  .wa-float { display: none !important; }
}

/* ══════════════════════════════════════════
   3. BARRA DE PROGRESO DE SCROLL
══════════════════════════════════════════ */
.ts-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 1002;
  pointer-events: none;
}

.ts-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ts-gold), #FFC65C);
  transform-origin: 0 50%;
  transform: scaleX(var(--ts-progress, 0));
  box-shadow: 0 0 8px rgba(245, 166, 35, .55);
}

.admin-bar .ts-progress { top: 32px; }
@media (max-width: 782px) { .admin-bar .ts-progress { top: 46px; } }

/* ══════════════════════════════════════════
   4. ANIMACIONES DE ENTRADA AL HACER SCROLL
   Solo se ocultan elementos cuando el JS está activo (.ts-js)
══════════════════════════════════════════ */
.ts-js .ts-reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity .7s var(--ts-ease), transform .7s var(--ts-ease);
  transition-delay: var(--ts-delay, 0s);
}

.ts-js .ts-reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ══════════════════════════════════════════
   5. MICROINTERACCIONES
══════════════════════════════════════════ */
.btn-primary,
.btn-outline-white,
.btn-outline-blue,
.nav-cta-btn,
.ts-mbar a,
.ts-cookie-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/* Brillo que sigue al cursor */
.btn-primary::after,
.btn-outline-white::after,
.btn-outline-blue::after,
.nav-cta-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .28), transparent 60%);
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}

.btn-primary:hover::after,
.btn-outline-white:hover::after,
.btn-outline-blue:hover::after,
.nav-cta-btn:hover::after { opacity: 1; }

.btn-primary,
.btn-outline-white,
.btn-outline-blue {
  transition: background .2s, border-color .2s, color .2s, transform .2s var(--ts-ease), box-shadow .2s;
}

.btn-primary:hover,
.btn-outline-white:hover,
.btn-outline-blue:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(8, 50, 102, .18);
}

.btn-primary:active,
.btn-outline-white:active,
.btn-outline-blue:active,
.nav-cta-btn:active { transform: translateY(0) scale(.97); }

/* Onda al hacer clic */
.ts-ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(255, 255, 255, .45);
  animation: tsRipple .6s var(--ts-ease) forwards;
  pointer-events: none;
  z-index: 0;
}

@keyframes tsRipple {
  to { transform: scale(2.6); opacity: 0; }
}

/* Subrayado animado en enlaces de navegación y pie de página */
.nav-links > li > a,
.footer-links a {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: color .18s, background-size .3s var(--ts-ease);
}

.nav-links > li > a:hover,
.footer-links a:hover { background-size: 100% 1px; }

/* Tarjetas: elevación suave */
.svc-card,
.channel-card,
.branch-card,
.ob-card,
.post-card {
  transition: transform .3s var(--ts-ease), box-shadow .3s var(--ts-ease);
}

.svc-card:hover,
.channel-card:hover,
.branch-card:hover,
.ob-card:hover,
.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 34px rgba(8, 50, 102, .14);
}

/* Foco visible y consistente para teclado */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--ts-gold);
  outline-offset: 3px;
}

/* ══════════════════════════════════════════
   6. BOTÓN VOLVER ARRIBA (con anillo de progreso)
══════════════════════════════════════════ */
.ts-totop {
  position: fixed;
  right: 32px;
  bottom: 32px;
  z-index: 997;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--ts-blue-deep);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(8, 50, 102, .3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(.9);
  transition: opacity .3s, visibility .3s, transform .3s var(--ts-ease), background .2s;
}

.ts-totop.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.ts-totop:hover { background: var(--ts-blue); }
.ts-totop:hover .ts-totop-arrow { transform: translateY(-2px); }

.ts-totop-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.ts-totop-ring circle {
  fill: none;
  stroke: var(--ts-gold);
  stroke-width: 2.5;
  stroke-dasharray: 138.2;
  stroke-dashoffset: calc(138.2 - 138.2 * var(--ts-progress, 0));
}

.ts-totop-arrow {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .2s var(--ts-ease);
}

@media (max-width: 768px) {
  .ts-totop {
    right: 14px;
    bottom: calc(var(--ts-mbar-h) + 14px + env(safe-area-inset-bottom));
    width: 42px;
    height: 42px;
  }
}

/* ══════════════════════════════════════════
   7. BANNER DE COOKIES (discreto)
══════════════════════════════════════════ */
.ts-cookie {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 9999;
  width: min(380px, calc(100vw - 28px));
  background: #fff;
  color: var(--ts-gray-dark);
  border: 1px solid var(--ts-gray-line);
  border-left: 3px solid var(--ts-gold);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(8, 50, 102, .18);
  padding: 16px 18px;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  animation: tsCookieIn .45s var(--ts-ease) both;
}

.ts-cookie[hidden] { display: none; }

.ts-cookie.is-leaving {
  animation: tsCookieOut .3s var(--ts-ease) forwards;
}

.ts-cookie-title {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ts-blue-deep);
  margin-bottom: 4px;
}

.ts-cookie p { margin: 0 0 12px; }

.ts-cookie p a {
  color: var(--ts-blue);
  font-weight: 600;
}

.ts-cookie-actions {
  display: flex;
  gap: 8px;
}

.ts-cookie-btn {
  flex: 1;
  border-radius: 4px;
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}

.ts-cookie-accept {
  background: var(--ts-blue);
  border: 1px solid var(--ts-blue);
  color: #fff;
}

.ts-cookie-accept:hover { background: var(--ts-blue-dark); }

.ts-cookie-reject {
  background: transparent;
  border: 1px solid var(--ts-gray-line);
  color: var(--ts-gray-dark);
}

.ts-cookie-reject:hover { border-color: var(--ts-blue); color: var(--ts-blue); }

@keyframes tsCookieIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}

@keyframes tsCookieOut {
  to { opacity: 0; transform: translateY(20px); }
}

@media (max-width: 768px) {
  .ts-cookie {
    left: 14px;
    bottom: calc(var(--ts-mbar-h) + 12px + env(safe-area-inset-bottom));
  }
}

/* ══════════════════════════════════════════
   8. ANIMACIÓN DE CARGA
   Barra superior + velo breve. Se oculta sola aunque falle el JS.
══════════════════════════════════════════ */
.ts-loader {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ts-blue-deep);
  pointer-events: none;
  animation: tsLoaderOut .35s ease 2.5s forwards;
}

.ts-loader.is-done {
  animation: tsLoaderOut .35s ease forwards;
}

/* Solo en la primera vista de la sesión (o mientras se aplica el modo oscuro) */
html.ts-no-loader .ts-loader { display: none; }

.ts-loader-star {
  width: 46px;
  height: 46px;
  background: var(--ts-gold);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: tsStarPulse 1s ease-in-out infinite;
}

@keyframes tsStarPulse {
  0%, 100% { transform: scale(.85) rotate(0deg); opacity: .75; }
  50% { transform: scale(1.05) rotate(36deg); opacity: 1; }
}

@keyframes tsLoaderOut {
  to { opacity: 0; visibility: hidden; }
}

/* Barra de navegación entre páginas */
.ts-navbar-load {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  z-index: 100001;
  background: var(--ts-gold);
  box-shadow: 0 0 10px rgba(245, 166, 35, .7);
  opacity: 0;
  pointer-events: none;
}

.ts-navbar-load.is-active {
  opacity: 1;
  animation: tsNavLoad 6s cubic-bezier(.1, .7, .2, 1) forwards;
}

@keyframes tsNavLoad {
  0% { width: 0; }
  20% { width: 45%; }
  100% { width: 92%; }
}

/* Imágenes: aparición suave al terminar de cargar */
.ts-js img.ts-img-fade {
  opacity: 0;
  transition: opacity .5s ease;
}

.ts-js img.ts-img-fade.is-loaded { opacity: 1; }

/* ══════════════════════════════════════════
   9. MODO OSCURO
   El JS oscurece las superficies claras en tiempo de ejecución;
   aquí van los elementos globales y la base.
══════════════════════════════════════════ */
html[data-theme="dark"] {
  color-scheme: dark;
  --ts-gray-bg: #131d2b;
  --ts-gray-line: rgba(255, 255, 255, .12);
  --ts-gray-dark: #d9e1ea;
  --ts-white: #0f1722;
}

html[data-theme="dark"] body {
  background: #0b121c;
  color: #d9e1ea;
}

/* Evita el destello claro mientras se aplica el tema */
html.ts-dark-pending body {
  visibility: hidden;
  animation: tsReveal 0s linear 1.5s forwards;
}

@keyframes tsReveal {
  to { visibility: visible; }
}

html[data-theme="dark"] img:not([src*="logo"]) { filter: brightness(.9); }

html[data-theme="dark"] .ts-cookie {
  background: #172232;
  color: #d9e1ea;
  border-color: rgba(255, 255, 255, .12);
  border-left-color: var(--ts-gold);
}

html[data-theme="dark"] .ts-cookie-title { color: #fff; }
html[data-theme="dark"] .ts-cookie p a { color: #7fb6ee; }
html[data-theme="dark"] .ts-cookie-reject { color: #d9e1ea; }

html[data-theme="dark"] .ts-totop { background: #1c2a3d; }
html[data-theme="dark"] .wa-bubble::after { border-top-color: #0f1722; }

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background-color: #0f1722 !important;
  color: #e6edf5 !important;
  border-color: rgba(255, 255, 255, .18) !important;
}

html[data-theme="dark"] ::placeholder { color: rgba(230, 237, 245, .45) !important; }

/* Transición suave al cambiar de tema */
html.ts-theme-anim,
html.ts-theme-anim * {
  transition: background-color .35s ease, color .35s ease, border-color .35s ease !important;
}

/* ══════════════════════════════════════════
   10. PÁGINA 404
══════════════════════════════════════════ */
.ts-404 {
  position: relative;
  overflow: hidden;
  background: var(--ts-blue-deep);
  color: #fff;
  padding: 90px 24px 110px;
  text-align: center;
}

.ts-404::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px circle at 15% 20%, rgba(15, 91, 167, .55), transparent 60%),
    radial-gradient(500px circle at 90% 85%, rgba(245, 166, 35, .16), transparent 60%);
  pointer-events: none;
}

.ts-404-inner {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
}

.ts-404-code {
  font-family: var(--font-display);
  font-size: clamp(110px, 22vw, 200px);
  font-weight: 800;
  line-height: .9;
  letter-spacing: -.02em;
  color: transparent;
  -webkit-text-stroke: 2px rgba(255, 255, 255, .22);
  display: inline-flex;
  align-items: center;
  gap: .08em;
}

.ts-404-code .ts-404-star {
  width: .62em;
  height: .62em;
  background: var(--ts-gold);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: tsStarPulse 2.4s ease-in-out infinite;
}

.ts-404-road {
  position: relative;
  height: 4px;
  max-width: 420px;
  margin: 26px auto 30px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .35) 0 26px, transparent 26px 44px);
  background-size: 44px 4px;
  animation: tsRoad 1s linear infinite;
  border-radius: 2px;
}

@keyframes tsRoad {
  to { background-position: -44px 0; }
}

.ts-404-truck {
  position: absolute;
  bottom: 6px;
  left: 0;
  width: 54px;
  height: 30px;
  fill: var(--ts-gold);
  animation: tsTruck 7s ease-in-out infinite;
}

@keyframes tsTruck {
  0% { left: -10%; }
  50% { left: 55%; }
  100% { left: 110%; }
}

.ts-404 h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 46px);
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 14px;
  color: #fff;
}

.ts-404 h1 em {
  font-style: normal;
  color: var(--ts-gold);
}

.ts-404-lead {
  font-size: 17px;
  color: rgba(255, 255, 255, .78);
  max-width: 560px;
  margin: 0 auto 30px;
}

.ts-404-search {
  display: flex;
  max-width: 480px;
  margin: 0 auto 30px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.ts-404 .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.ts-404-search input {
  flex: 1;
  min-width: 0;
  border: none;
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ts-gray-dark);
  outline: none;
}

.ts-404-search button {
  border: none;
  background: var(--ts-gold);
  color: #fff;
  padding: 0 20px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: background .2s;
}

.ts-404-search button:hover { background: var(--ts-gold-hov); }

.ts-404-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.ts-404 .btn-outline-white { color: #fff; }

.ts-404-links {
  background: var(--ts-gray-bg);
  padding: 64px 24px 80px;
}

.ts-404-links-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.ts-404-links h2 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  color: var(--ts-blue-deep);
  text-align: center;
  margin: 0 0 30px;
}

.ts-404-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.ts-404-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--ts-gray-line);
  border-top: 3px solid var(--ts-blue);
  border-radius: 6px;
  padding: 20px;
  text-decoration: none;
  color: var(--ts-gray-dark);
  transition: transform .3s var(--ts-ease), box-shadow .3s var(--ts-ease), border-color .2s;
}

.ts-404-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 34px rgba(8, 50, 102, .14);
  border-top-color: var(--ts-gold);
}

.ts-404-card strong {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--ts-blue-deep);
}

.ts-404-card span { font-size: 14px; color: #666; }

.ts-404-card em {
  font-style: normal;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ts-blue);
  margin-top: auto;
  padding-top: 6px;
}

@media (max-width: 900px) {
  .ts-404-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .ts-404 { padding: 64px 18px 80px; }
  .ts-404-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════
   11. MOVIMIENTO REDUCIDO
══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .ts-js .ts-reveal { opacity: 1; transform: none; transition: none; }
  .ts-loader { display: none; }
  .ts-ripple, .ts-404-road, .ts-404-truck, .ts-404-star, .ts-loader-star { animation: none !important; }
  .btn-primary:hover, .btn-outline-white:hover, .btn-outline-blue:hover,
  .svc-card:hover, .channel-card:hover, .branch-card:hover, .ob-card:hover, .post-card:hover,
  .ts-404-card:hover { transform: none; }
  html.ts-theme-anim, html.ts-theme-anim * { transition: none !important; }
}
