/* ============================================================
   APREU_Art-Linea — la línea que "explota" en naranja (mobile-first)
   Variables inline desde campos:
     --from / --to   color de fondo inicial / final
     --line          color del trazo
     --start / --end tramo del scroll (%) donde ocurre la explosión
     --story-h       largo total del scroll de la sección
   El texto es SIEMPRE blanco y solo aparece cuando el fondo ya es naranja.
   IMPORTANTE: ningún ancestro puede tener overflow:hidden o el sticky deja de funcionar.
   ============================================================ */
.art-line {
  /* Grosor inicial y final del trazo (unidades del viewBox 2400×1600).
     Móvil: inicio grueso porque en vertical el lienzo se recorta. Subir --w-to = se llena antes. */
  --w-from: 300px;
  --w-to: 2500px;
  /* Valores que mueve el fallback JS (0 → 1). Sin JS: estado final visible */
  --draw: 1;
  --grow: 1;
  --show: 1;

  position: relative;
  /* Más alto = la animación se reparte en más scroll (más lenta) */
  height: var(--story-h, 240vh);
  color: var(--arq-white);
  text-align: center;
}

.art-line__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  /* overflow en el propio escenario sí está bien (no es ancestro del sticky) */
  overflow: hidden;
  background-color: var(--to);
}

/* Marcador del ancla #descubre: va a --anchor-p del recorrido sticky (0.16 = 16%),
   donde la línea ya está dibujada. Cambia "Punto de llegada del botón" en los campos. */
.art-line__anchor {
  position: absolute;
  left: 0;
  top: calc((var(--story-h, 240vh) - 100vh) * var(--anchor-p, .16));
  width: 1px; height: 1px;
  pointer-events: none;
}

.art-line__svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.art-line__path {
  fill: none;
  stroke: var(--line);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: calc(var(--w-from) + (var(--w-to) - var(--w-from)) * var(--grow));
  stroke-dashoffset: calc((1 - var(--draw)) * 1px);
}

/* ---------- Círculos blancos (aparecen con el naranja) ----------
   Sin soporte de scroll-driven: escala/opacidad siguen a --show (fallback JS).
   Cambia top/left/width de cada nth-child para recolocarlos (siempre en los bordes,
   lejos del texto central). Rellenos = .5 de opacidad; contorno = borde blanco. */
.art-line__dots { position: absolute; inset: 0; pointer-events: none; }
.art-line__dot {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .5);
  transform: scale(var(--show));
  opacity: var(--show);
}
.art-line__dot:nth-child(even) { background: none; border: 3px solid var(--arq-white); }
.art-line__dot:nth-child(1) { top: 7%;  left: 8%;   width: 54px;  height: 54px; }
.art-line__dot:nth-child(2) { top: 12%; right: 10%; width: 86px;  height: 86px; }
.art-line__dot:nth-child(3) { top: 24%; right: 26%; width: 18px;  height: 18px; }
.art-line__dot:nth-child(4) { top: 22%; left: 20%;  width: 30px;  height: 30px; }
.art-line__dot:nth-child(5) { bottom: 14%; left: 12%; width: 70px; height: 70px; }
.art-line__dot:nth-child(6) { bottom: 9%; right: 14%; width: 44px; height: 44px; }
.art-line__dot:nth-child(7) { bottom: 26%; right: 6%; width: 22px; height: 22px; }
.art-line__dot:nth-child(8) { bottom: 22%; left: 30%; width: 14px; height: 14px; }

/* ---------- Contenido (blanco, centrado) ---------- */
.art-line__content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 980px;
  padding: 0 var(--arq-gutter);
  opacity: var(--show);
}
.art-line__content:focus-within { opacity: 1 !important; }
.art-line__title {
  font-family: var(--arq-font-display);
  font-weight: 700;
  font-size: clamp(2.7rem, 11vw, 6.6rem);
  line-height: .98;
  letter-spacing: -.02em;
  text-wrap: balance;
}
/* 1.25rem+ regular sobre naranja: cumple como texto grande a partir de 24px → mínimo 1.5rem */
.art-line__text {
  max-width: 34ch;
  margin: 20px auto 0;
  font-size: 1.5rem;
  line-height: 1.35;
  text-wrap: balance;
}
/* ---------- Flecha "Empieza aquí" ----------
   Círculo blanco con flecha naranja (ícono, no texto) + texto blanco 1.2rem bold (texto grande). */
.art-line__go {
  display: inline-flex; flex-direction: column; align-items: center; gap: 12px;
  margin-top: 28px;
  color: var(--arq-white);
  text-decoration: none;
}
.art-line__go-text { font-size: 1.2rem; font-weight: 700; }
.art-line__go-icon {
  display: grid; place-items: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--arq-white);
  color: var(--arq-accent);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, .22);
  transition: background-color .25s ease, color .25s ease;
}
.art-line__go-icon svg { width: 30px; height: 30px; }
/* Hover: solo color */
.art-line__go:hover .art-line__go-icon { background: var(--arq-dark); color: var(--arq-white); }
.art-line__go:focus-visible { border-radius: 16px; }

/* ---------- CSS scroll-driven animations (Chrome/Edge/Safari 26+) ----------
   "contain" = el tramo en que la sección cubre toda la pantalla (cuando el escenario está pegado). */
@supports (animation-timeline: view()) {
  .art-line { view-timeline: --art-line block; }
  .art-line__stage {
    animation: art-line-bg linear both;
    animation-timeline: --art-line;
    animation-range: contain var(--start) contain var(--end);
  }
  .art-line__path {
    animation: art-line-draw linear both, art-line-grow linear both;
    animation-timeline: --art-line, --art-line;
    /* El dibujo arranca en cuanto la sección ASOMA por abajo (entry 0%), no cuando ya cubre la
       pantalla: así nunca se ve un tramo crema vacío entre el hero y la línea. */
    animation-range: entry 0% contain var(--start), contain var(--start) contain var(--end);
  }
  .art-line__content {
    /* Aparece en el último 10% de la explosión. Cambia el 10% para que aparezca antes/después */
    animation: art-line-show linear both;
    animation-timeline: --art-line;
    animation-range: contain calc(var(--end) - 10%) contain var(--end);
  }
  .art-line__go-icon {
    /* La flecha cae y rebota DURANTE el scroll restante (ligada al scroll, no en bucle → sin
       movimiento automático infinito; WCAG 2.2.2). */
    animation: art-line-bob linear both;
    animation-timeline: --art-line;
    animation-range: contain calc(var(--end) - 6%) contain 100%;
  }
  .art-line__dot {
    /* Cada círculo "brota" en el tramo final, desfasado --k. Rebote con overshoot en el keyframe. */
    animation: art-line-dot linear both;
    animation-timeline: --art-line;
    animation-range: contain calc(var(--end) - 14% + var(--k)) contain calc(var(--end) - 4% + var(--k));
  }
}
@keyframes art-line-bob {
  0%   { transform: translateY(-36px); }
  18%  { transform: translateY(10px); }
  30%  { transform: translateY(0); }
  48%  { transform: translateY(12px); }
  62%  { transform: translateY(0); }
  80%  { transform: translateY(12px); }
  100% { transform: translateY(0); }
}
@keyframes art-line-dot {
  0%   { opacity: 0; transform: scale(0); }
  70%  { opacity: 1; transform: scale(1.18); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes art-line-bg   { from { background-color: var(--from); } to { background-color: var(--to); } }
/* Empieza con 20% ya trazado (.8): desde el primer pixel visible hay línea */
@keyframes art-line-draw { from { stroke-dashoffset: .8px; } to { stroke-dashoffset: 0px; } }
@keyframes art-line-grow { from { stroke-width: var(--w-from); } to { stroke-width: var(--w-to); } }
@keyframes art-line-show { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* ---------- Tablet ---------- */
@media (min-width: 768px) { .art-line { --w-from: 240px; } }

/* ---------- Desktop ---------- */
@media (min-width: 1024px) {
  .art-line { --w-from: 200px; }
  .art-line__text { font-size: 1.65rem; }
}

/* ---------- Movimiento reducido: estado final estático, sin sección alta ---------- */
@media (prefers-reduced-motion: reduce) {
  .art-line { height: auto; }
  .art-line__stage {
    position: relative;
    min-height: 70svh;
    padding: var(--arq-section-y) 0;
    animation: none;
    background-color: var(--to);
  }
  .art-line__path { animation: none; stroke-dashoffset: 0; stroke-width: var(--w-to); }
  .art-line__content { animation: none; opacity: 1; }
  .art-line__dot { animation: none; opacity: 1; transform: none; }
  .art-line__go-icon { animation: none; }
  .art-line__anchor { top: 0; }
}

/* ---------- Desktop: círculos más grandes ---------- */
@media (min-width: 1024px) {
  .art-line__dot:nth-child(1) { width: 90px; height: 90px; }
  .art-line__dot:nth-child(2) { width: 150px; height: 150px; }
  .art-line__dot:nth-child(5) { width: 120px; height: 120px; }
  .art-line__dot:nth-child(6) { width: 70px; height: 70px; }
}
