/* ==========================================================================
   TodoRuta — capa de diseño compartida (UI/UX + accesibilidad)
   Se carga después del CSS propio de cada página. No sustituye estilos base:
   los mejora y añade componentes reutilizables con prefijo .tr- / --tr-.
   ========================================================================== */

:root {
  --tr-bg: #0f0c29;
  --tr-bg-2: #1b1740;
  --tr-surface: rgba(30, 27, 60, 0.72);
  --tr-surface-2: rgba(255, 255, 255, 0.045);
  --tr-line: rgba(255, 255, 255, 0.12);
  --tr-line-strong: rgba(255, 255, 255, 0.22);
  --tr-ink: #f7f8fc;
  --tr-muted: rgba(247, 248, 252, 0.72);
  --tr-accent: #20c997;
  --tr-accent-2: #4ddfb5;
  --tr-blue: #3a7de0;
  --tr-wa: #25d366;
  --tr-radius: 18px;
  --tr-radius-sm: 12px;
  --tr-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --tr-shadow-sm: 0 8px 22px rgba(0, 0, 0, 0.22);
  --tr-maxw: 1180px;
  --tr-header-h: 76px;
  --tr-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- Reset mínimo y base tipográfica ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--tr-header-h) + 16px);
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  background-color: var(--tr-bg);
  background-image:
    radial-gradient(1100px 600px at 12% -10%, rgba(10, 88, 202, 0.35), transparent 60%),
    radial-gradient(900px 520px at 88% 0%, rgba(32, 201, 151, 0.18), transparent 62%),
    radial-gradient(1000px 700px at 50% 120%, rgba(48, 43, 99, 0.65), transparent 70%),
    linear-gradient(160deg, #0f0c29 0%, #1c1746 48%, #24243e 100%);
  background-attachment: fixed;
  color: var(--tr-ink);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

p,
li {
  text-wrap: pretty;
}

h1,
h2,
h3,
h4 {
  text-wrap: balance;
  letter-spacing: -0.015em;
}

img,
video,
svg,
canvas {
  max-width: 100%;
}

img {
  height: auto;
}

::selection {
  background: rgba(32, 201, 151, 0.32);
  color: #fff;
}

/* ---------- Accesibilidad ---------- */
:focus-visible {
  outline: 3px solid var(--tr-accent);
  outline-offset: 3px;
  border-radius: 6px;
}

a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

.tr-skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 100000;
  padding: 0.85rem 1.35rem;
  border-radius: 0 0 12px 12px;
  background: var(--tr-accent);
  color: #06251c;
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--tr-shadow);
  transition: top 0.2s var(--tr-ease);
}

.tr-skip-link:focus {
  top: 0;
  outline: none;
}

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

/* ---------- Barra de progreso de lectura ---------- */
.tr-progress {
  position: fixed;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  z-index: 100001;
  pointer-events: none;
  background: transparent;
}

.tr-progress__bar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--tr-blue), var(--tr-accent));
  box-shadow: 0 0 12px rgba(32, 201, 151, 0.6);
  transform-origin: 0 50%;
  transition: width 0.12s linear;
}

/* ---------- Header ---------- */
header,
.tr-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 3vw, 1.75rem);
  min-height: var(--tr-header-h);
  background: rgba(20, 17, 45, 0.86);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--tr-line);
  transition: box-shadow 0.3s var(--tr-ease), background-color 0.3s var(--tr-ease);
}

header.is-scrolled {
  background: rgba(17, 14, 42, 0.97);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  border-bottom-color: var(--tr-line);
}

header .logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

header .logo-img {
  height: clamp(34px, 4vw, 44px);
  width: auto;
  max-height: 44px;
  display: block;
}

header h1 {
  margin: 0;
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  line-height: 1.15;
}

.tr-brand {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: inherit;
}

.tr-brand__name {
  font-size: clamp(1.1rem, 1.8vw, 1.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #7ab0ff, var(--tr-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.tr-brand__tag {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tr-muted);
  font-weight: 700;
}

header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-width: 0;
}

header nav a {
  position: relative;
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  transition: color 0.2s, background-color 0.2s;
}

header nav a::after {
  content: "";
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--tr-accent), var(--tr-accent-2));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--tr-ease);
}

header nav a:hover,
header nav a:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

header nav a:hover::after,
header nav a:focus-visible::after,
header nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

header nav a[aria-current="page"] {
  color: #fff;
  background: rgba(32, 201, 151, 0.12);
}

header nav a.tr-nav-cta {
  margin-left: 0.4rem;
  padding-inline: 1rem;
  background: linear-gradient(135deg, var(--tr-accent), #12a97c);
  color: #04251c;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(32, 201, 151, 0.28);
}

header nav a.tr-nav-cta::after {
  display: none;
}

header nav a.tr-nav-cta:hover,
header nav a.tr-nav-cta:focus-visible {
  color: #04251c;
  background: linear-gradient(135deg, var(--tr-accent-2), var(--tr-accent));
  transform: translateY(-1px);
}

/* Botón hamburguesa inyectado por JS cuando la página no lo trae */
.tr-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--tr-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.tr-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 900px) {
  header {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
  }

  .tr-brand__tag {
    display: none;
  }

  .tr-menu-toggle {
    display: inline-flex;
    margin-left: auto;
    order: 3;
  }

  header nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 1rem;
    background: rgba(16, 13, 40, 0.99);
    border-bottom: 1px solid var(--tr-line);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    max-height: min(75vh, 620px);
    overflow-y: auto;
  }

  header nav.is-open {
    display: flex !important;
    animation: tr-drop 0.22s var(--tr-ease);
  }

  header nav a {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 0.98rem;
    background: rgba(255, 255, 255, 0.04);
  }

  header nav a.tr-nav-cta {
    margin-left: 0;
    text-align: center;
  }
}

@keyframes tr-drop {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Migas de pan ---------- */
.tr-breadcrumbs {
  max-width: var(--tr-maxw);
  margin: 0 auto;
  padding: 1rem 1.5rem 0;
  font-size: 0.82rem;
  color: var(--tr-muted);
}

.tr-breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tr-breadcrumbs a {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.tr-breadcrumbs a:hover {
  color: var(--tr-accent);
  border-bottom-color: currentColor;
}

.tr-breadcrumbs li + li::before {
  content: "›";
  margin-right: 0.45rem;
  opacity: 0.45;
}

.tr-breadcrumbs [aria-current="page"] {
  color: var(--tr-accent);
  font-weight: 600;
}

/* ---------- Botones ---------- */
.tr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 48px;
  padding: 0.8rem 1.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s var(--tr-ease), box-shadow 0.2s var(--tr-ease),
    background-color 0.2s var(--tr-ease), border-color 0.2s var(--tr-ease);
}

.tr-btn:hover {
  transform: translateY(-2px);
}

.tr-btn:active {
  transform: translateY(0);
}

.tr-btn--primary {
  background: linear-gradient(135deg, var(--tr-blue), #0a58ca);
  box-shadow: 0 10px 26px rgba(10, 88, 202, 0.35);
}

.tr-btn--primary:hover {
  box-shadow: 0 14px 32px rgba(10, 88, 202, 0.45);
}

.tr-btn--accent {
  background: linear-gradient(135deg, var(--tr-accent), #10a87b);
  color: #04251c;
  box-shadow: 0 10px 26px rgba(32, 201, 151, 0.3);
}

.tr-btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--tr-line-strong);
  color: #fff;
}

.tr-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.tr-btn--wa {
  background: var(--tr-wa);
  color: #04251c;
  box-shadow: 0 10px 26px rgba(37, 211, 102, 0.28);
}

.tr-btn--block {
  width: 100%;
}

/* ---------- Etiquetas y encabezados de sección ---------- */
.hero h1,
.hero h2 {
  font-size: clamp(2rem, 4.8vw, 3.15rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin: 0 0 1.35rem;
}

.hero p {
  font-size: clamp(1rem, 1.5vw, 1.1rem);
  line-height: 1.75;
}

.tr-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid rgba(32, 201, 151, 0.35);
  border-radius: 999px;
  background: rgba(32, 201, 151, 0.1);
  color: var(--tr-accent-2);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tr-lead {
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  line-height: 1.75;
  color: var(--tr-muted);
}

.tr-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--tr-surface-2);
  border: 1px solid var(--tr-line);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tr-muted);
}

/* ---------- Sección de enlaces relacionados ---------- */
.tr-related {
  max-width: var(--tr-maxw);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4.5rem) 1.5rem;
}

.tr-related h2 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  text-align: center;
}

.tr-related > p {
  margin: 0 auto 2rem;
  max-width: 640px;
  text-align: center;
  color: var(--tr-muted);
}

.tr-related__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.tr-related__card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--tr-line);
  border-radius: var(--tr-radius-sm);
  background: var(--tr-surface);
  color: inherit;
  text-decoration: none;
  transition: transform 0.25s var(--tr-ease), border-color 0.25s var(--tr-ease),
    background-color 0.25s var(--tr-ease);
}

.tr-related__card:hover {
  transform: translateY(-4px);
  border-color: rgba(32, 201, 151, 0.5);
  background: rgba(32, 201, 151, 0.08);
}

.tr-related__card strong {
  font-size: 1rem;
  color: #fff;
}

.tr-related__card span {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--tr-muted);
}

.tr-related__card em {
  margin-top: 0.35rem;
  font-style: normal;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--tr-accent);
}

/* ---------- Footer ---------- */
.tr-footer {
  margin-top: clamp(3rem, 8vw, 6rem);
  border-top: 1px solid var(--tr-line);
  background: rgba(12, 10, 32, 0.72);
  padding: clamp(2.5rem, 6vw, 4rem) 1.5rem 1.5rem;
  font-size: 0.92rem;
  opacity: 1;
  text-align: left;
}

.tr-footer__inner {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, 1fr));
  gap: 2rem;
  max-width: var(--tr-maxw);
  margin: 0 auto;
}

.tr-footer img {
  height: 44px;
  width: auto;
  margin-bottom: 0.9rem;
}

.tr-footer__brand p {
  margin: 0 0 1rem;
  max-width: 34ch;
  color: var(--tr-muted);
  line-height: 1.65;
}

.tr-footer h2 {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.95);
}

.tr-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.tr-footer a {
  color: var(--tr-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.tr-footer a:hover {
  color: var(--tr-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tr-footer address {
  font-style: normal;
  color: var(--tr-muted);
  line-height: 1.8;
}

.tr-footer address strong {
  color: #fff;
  font-weight: 600;
}

.tr-footer__bottom {
  max-width: var(--tr-maxw);
  margin: 2.5rem auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--tr-line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
}

.tr-footer__bottom nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.tr-footer__bottom a {
  color: rgba(255, 255, 255, 0.7);
}

@media (max-width: 860px) {
  .tr-footer__inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .tr-footer__inner {
    grid-template-columns: 1fr;
  }

  .tr-footer__bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- Volver arriba ---------- */
.tr-to-top {
  position: fixed;
  right: clamp(14px, 2.5vw, 26px);
  bottom: clamp(86px, 12vh, 104px);
  z-index: 9990;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--tr-line-strong);
  border-radius: 50%;
  background: rgba(20, 17, 48, 0.9);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s, background-color 0.2s;
  box-shadow: var(--tr-shadow-sm);
  backdrop-filter: blur(8px);
}

.tr-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.tr-to-top:hover {
  background: var(--tr-accent);
  color: #04251c;
}

/* ---------- Animación de entrada ---------- */
.tr-reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s var(--tr-ease), transform 0.6s var(--tr-ease);
  will-change: opacity, transform;
}

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

.no-js .tr-reveal,
.tr-reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .tr-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .tr-progress,
  .tr-to-top {
    display: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ---------- Ajustes de legibilidad para contenido heredado ---------- */
main section > p,
main section li {
  max-width: 78ch;
}

.content-box,
.card,
.metric {
  border-radius: var(--tr-radius);
}

table {
  border-collapse: collapse;
}

th {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tr-muted);
}

/* Enlaces dentro de párrafos de contenido */
main p a:not([class]) {
  color: var(--tr-accent-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

main p a:not([class]):hover {
  color: #fff;
}

/* ---------- Marco de interfaz (ilustraciones sin imágenes externas) ---------- */
.tr-mock {
  margin: 1.5rem 0 0.5rem;
  border: 1px solid var(--tr-line);
  border-radius: 16px;
  overflow: hidden;
  background: #0c0a22;
  box-shadow: var(--tr-shadow-sm);
}

.tr-mock__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid var(--tr-line);
}

.tr-mock__bar span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

.tr-mock__bar span:nth-child(1) {
  background: #ff6b6b;
}
.tr-mock__bar span:nth-child(2) {
  background: #ffc107;
}
.tr-mock__bar span:nth-child(3) {
  background: #20c997;
}

.tr-mock__bar b {
  margin-left: 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--tr-muted);
}

.tr-mock svg {
  display: block;
  width: 100%;
  height: auto;
}

.tr-mock figcaption {
  padding: 0.65rem 0.9rem;
  border-top: 1px solid var(--tr-line);
  font-size: 0.8rem;
  color: var(--tr-muted);
  text-align: center;
}

/* ---------- Impresión ---------- */
@media print {
  header,
  .tr-to-top,
  .tr-progress,
  .whatsapp-float,
  .whatsapp {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #111 !important;
  }

  a {
    color: #000 !important;
    text-decoration: underline !important;
  }
}
