/* ================================================================
   MADMED — Proceso Section Redesign
   "Pipeline Flow" — Serpentine path with animated particles
   ================================================================ */

/* ── Theme Variables ─────────────────────────────────────────── */
.proceso-section {
  --pr-bg: #f8fafc;
  --pr-text: #0f172a;
  --pr-muted: #64748b;
  --pr-accent: #0891b2;
  --pr-accent-bright: #0ea5e9;
  --pr-accent-bg: #ecfeff;
  --pr-accent-glow: rgba(8, 145, 178, 0.25);
  --pr-card-bg: #ffffff;
  --pr-card-border: #e2e8f0;
  --pr-card-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --pr-card-hover-shadow: 0 8px 32px rgba(8, 145, 178, 0.15);
  --pr-path-color: #0891b2;
  --pr-dot-color: rgba(226, 232, 240, 0.7);
  --pr-gradient: linear-gradient(135deg, #0ea5e9, #0891b2, #0d9488);
}

[data-theme="dark"] .proceso-section,
html.dark .proceso-section {
  --pr-bg: #0a0f1a;
  --pr-text: #e2e8f0;
  --pr-muted: #94a3b8;
  --pr-accent: #22d3ee;
  --pr-accent-bright: #67e8f9;
  --pr-accent-bg: rgba(34, 211, 238, 0.08);
  --pr-accent-glow: rgba(34, 211, 238, 0.3);
  --pr-card-bg: #0f1d2e;
  --pr-card-border: #1e3a5f;
  --pr-card-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  --pr-card-hover-shadow: 0 8px 32px rgba(34, 211, 238, 0.12);
  --pr-path-color: #22d3ee;
  --pr-dot-color: rgba(30, 58, 95, 0.5);
  --pr-gradient: linear-gradient(135deg, #22d3ee, #06b6d4, #14b8a6);
}

/* ── Section Base ────────────────────────────────────────────── */
.proceso-section {
  position: relative;
  padding: 3rem 0;
  overflow: hidden;
  background: var(--pr-bg);
  transition: background-color 0.3s ease;
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

@media (min-width: 768px) {
  .proceso-section {
    padding: 4rem 0;
  }
}

/* Dot-grid background */
.proceso-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--pr-dot-color) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.5;
  pointer-events: none;
}

/* Ambient glow blobs */
.pr-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(80px);
  opacity: 0.15;
  background: var(--pr-accent);
}
.pr-glow--1 { width: 400px; height: 400px; top: -10%; left: 10%; }
.pr-glow--2 { width: 300px; height: 300px; bottom: -5%; right: 15%; }

/* Container */
.pr-container {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  z-index: 1;
}

@media (min-width: 640px) {
  .pr-container { padding: 0 1.5rem; }
}

/* ── Header ──────────────────────────────────────────────────── */
.pr-header {
  text-align: center;
  margin-bottom: 2.5rem;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

@media (min-width: 768px) {
  .pr-header { margin-bottom: 3.5rem; }
}

.pr-header.--visible {
  opacity: 1;
  transform: translateY(0);
}

.pr-badge {
  display: inline-block;
  padding: 0.4rem 1.1rem;
  border-radius: 9999px;
  background: var(--pr-accent-bg);
  color: var(--pr-accent);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0.875rem;
  border: 1px solid rgba(8, 145, 178, 0.15);
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.pr-title {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--pr-text);
  margin: 0 0 0.75rem;
  line-height: 1.15;
  transition: color 0.3s ease;
}
@media (min-width: 640px) { .pr-title { font-size: 2.25rem; } }
@media (min-width: 1024px) { .pr-title { font-size: 2.75rem; } }

.pr-title-accent {
  background: var(--pr-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.pr-subtitle {
  font-size: 1rem;
  color: var(--pr-muted);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.65;
  transition: color 0.3s ease;
}

/* ── Desktop Flow (≥768px) ──────────────────────────────────── */
.pr-flow {
  position: relative;
  display: none;
}

@media (min-width: 768px) {
  .pr-flow { display: block; }
}

/* SVG overlay */
.pr-svg-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.pr-svg-wrap svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Path layers */
.pr-path-bg {
  fill: none;
  stroke: var(--pr-card-border);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke 0.3s;
}

.pr-path-main {
  fill: none;
  stroke: url(#prGrad);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: var(--pr-len);
  stroke-dashoffset: var(--pr-len);
}

.pr-flow.--visible .pr-path-main {
  animation: prDrawPath 1.8s cubic-bezier(0.4, 0, 0.2, 1) 0.3s forwards;
}

@keyframes prDrawPath {
  to { stroke-dashoffset: 0; }
}

/* Flowing dashes (particles) */
.pr-path-flow {
  fill: none;
  stroke: url(#prGrad);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 4 20;
  opacity: 0;
}

.pr-flow.--visible .pr-path-flow {
  animation: prFlowIn 0.4s ease 2.1s forwards, prFlowMove 2.5s linear 2.1s infinite;
}

@keyframes prFlowIn { to { opacity: 0.7; } }
@keyframes prFlowMove { to { stroke-dashoffset: -24; } }

/* Glow behind path */
.pr-path-glow {
  fill: none;
  stroke: var(--pr-path-color);
  stroke-width: 12;
  stroke-linecap: round;
  opacity: 0;
  filter: blur(10px);
}

.pr-flow.--visible .pr-path-glow {
  animation: prGlowPulse 3s ease-in-out 2s infinite;
}

@keyframes prGlowPulse {
  0%, 100% { opacity: 0.06; }
  50% { opacity: 0.14; }
}

/* Traveling particle (dot) — opacity controlled by JS after positioning */
.pr-particle {
  fill: var(--pr-accent-bright);
  opacity: 0;
  filter: url(#prParticleGlow);
  transition: opacity 0.4s ease;
}

/* Step junction dots */
.pr-junction {
  fill: var(--pr-card-bg);
  stroke: var(--pr-path-color);
  stroke-width: 2;
  opacity: 0;
  transition: fill 0.3s, stroke 0.3s;
}

.pr-flow.--visible .pr-junction {
  animation: prDotPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.pr-flow.--visible .pr-junction:nth-of-type(1) { animation-delay: 0.5s; }
.pr-flow.--visible .pr-junction:nth-of-type(2) { animation-delay: 0.8s; }
.pr-flow.--visible .pr-junction:nth-of-type(3) { animation-delay: 1.0s; }
.pr-flow.--visible .pr-junction:nth-of-type(4) { animation-delay: 1.3s; }
.pr-flow.--visible .pr-junction:nth-of-type(5) { animation-delay: 1.5s; }
.pr-flow.--visible .pr-junction:nth-of-type(6) { animation-delay: 1.7s; }

@keyframes prDotPop {
  0%   { opacity: 0; r: 0; }
  70%  { r: 8; }
  100% { opacity: 1; r: 6; }
}

/* ── Grid ────────────────────────────────────────────────────── */
.pr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  row-gap: 4.5rem;
  column-gap: 1.5rem;
  position: relative;
  z-index: 2;
}

@media (min-width: 1024px) {
  .pr-grid { column-gap: 2.5rem; }
}

/* Serpentine bottom row reorder */
.pr-step[data-step="4"] { grid-column: 3; grid-row: 2; }
.pr-step[data-step="5"] { grid-column: 2; grid-row: 2; }
.pr-step[data-step="6"] { grid-column: 1; grid-row: 2; }

/* ── Step Node ───────────────────────────────────────────────── */
.pr-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
}

.pr-flow.--visible .pr-step {
  animation: prStepIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.pr-flow.--visible .pr-step[data-step="1"] { animation-delay: 0.45s; }
.pr-flow.--visible .pr-step[data-step="2"] { animation-delay: 0.7s; }
.pr-flow.--visible .pr-step[data-step="3"] { animation-delay: 0.95s; }
.pr-flow.--visible .pr-step[data-step="4"] { animation-delay: 1.25s; }
.pr-flow.--visible .pr-step[data-step="5"] { animation-delay: 1.5s; }
.pr-flow.--visible .pr-step[data-step="6"] { animation-delay: 1.75s; }

@keyframes prStepIn {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Number circle */
.pr-num {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--pr-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 0.875rem;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 4px 16px var(--pr-accent-glow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  z-index: 3;
}

.pr-step:hover .pr-num {
  transform: scale(1.12);
  box-shadow: 0 6px 28px var(--pr-accent-glow);
}

/* Pulse ring */
.pr-num::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--pr-accent);
  opacity: 0;
}

.pr-flow.--visible .pr-num::after {
  animation: prPulse 2.8s ease-out infinite;
}

.pr-step[data-step="1"] .pr-num::after { animation-delay: 0s; }
.pr-step[data-step="2"] .pr-num::after { animation-delay: 0.5s; }
.pr-step[data-step="3"] .pr-num::after { animation-delay: 1.0s; }
.pr-step[data-step="4"] .pr-num::after { animation-delay: 1.5s; }
.pr-step[data-step="5"] .pr-num::after { animation-delay: 2.0s; }
.pr-step[data-step="6"] .pr-num::after { animation-delay: 2.5s; }

@keyframes prPulse {
  0%   { opacity: 0.5; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.7); }
}

/* Step card */
.pr-card {
  background: var(--pr-card-bg);
  border: 1px solid var(--pr-card-border);
  border-radius: 1rem;
  padding: 1.125rem 1rem;
  width: 100%;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease,
              background-color 0.3s ease, border-color 0.3s ease;
  box-shadow: var(--pr-card-shadow);
}

.pr-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--pr-gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s ease;
}

.pr-step:hover .pr-card {
  transform: translateY(-4px);
  box-shadow: var(--pr-card-hover-shadow);
}

.pr-step:hover .pr-card::before {
  transform: scaleX(1);
}

/* Watermark */
.pr-watermark {
  position: absolute;
  top: -4px;
  right: 6px;
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--pr-accent);
  opacity: 0.04;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

/* Icon */
.pr-icon {
  width: 28px;
  height: 28px;
  color: var(--pr-accent);
  margin: 0 auto 0.5rem;
  transition: color 0.3s;
}
.pr-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Title & desc */
.pr-step-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--pr-text);
  margin: 0 0 0.25rem;
  transition: color 0.3s ease;
}

.pr-step-desc {
  font-size: 0.8125rem;
  color: var(--pr-muted);
  line-height: 1.5;
  margin: 0;
  transition: color 0.3s ease;
}

/* ── Mobile Timeline (<768px) ────────────────────────────────── */
.pr-mobile {
  display: block;
  position: relative;
}

@media (min-width: 768px) {
  .pr-mobile { display: none; }
}

/* Vertical line — positioned dynamically by JS to align with node centers */
.pr-mobile-line {
  position: absolute;
  left: 23px;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--pr-card-border);
  transition: background-color 0.3s;
  z-index: 0;
}

/* Animated progress fill — positioned dynamically by JS */
.pr-mobile-progress {
  position: absolute;
  left: 23px;
  top: 0;
  width: 2px;
  height: 0;
  background: var(--pr-gradient);
  transition: height 0.6s ease;
  z-index: 1;
}

/* Mobile step */
.pr-m-step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 2rem;
  position: relative;
  z-index: 2;
  opacity: 0;
}

.pr-m-step:last-child {
  padding-bottom: 0;
}

/* Alternate entrance directions using data-step */
.pr-m-step[data-step="1"],
.pr-m-step[data-step="3"],
.pr-m-step[data-step="5"] { transform: translateX(-16px); }

.pr-m-step[data-step="2"],
.pr-m-step[data-step="4"],
.pr-m-step[data-step="6"] { transform: translateX(16px); }

.pr-m-step.--visible {
  animation: prMobileIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.pr-m-step[data-step="1"].--visible { animation-delay: 0.05s; }
.pr-m-step[data-step="2"].--visible { animation-delay: 0.12s; }
.pr-m-step[data-step="3"].--visible { animation-delay: 0.19s; }
.pr-m-step[data-step="4"].--visible { animation-delay: 0.26s; }
.pr-m-step[data-step="5"].--visible { animation-delay: 0.33s; }
.pr-m-step[data-step="6"].--visible { animation-delay: 0.40s; }

@keyframes prMobileIn {
  to { opacity: 1; transform: translateX(0); }
}

/* Mobile node circle */
.pr-m-node {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--pr-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  position: relative;
  z-index: 2;
  box-shadow: 0 3px 12px var(--pr-accent-glow);
}

/* Mobile card */
.pr-m-card {
  flex: 1;
  min-width: 0;
  background: var(--pr-card-bg);
  border: 1px solid var(--pr-card-border);
  border-radius: 0.875rem;
  padding: 1rem 1rem 1rem 1.125rem;
  position: relative;
  overflow: hidden;
  transition: background-color 0.3s, border-color 0.3s;
  box-shadow: var(--pr-card-shadow);
}

/* Left accent stripe */
.pr-m-card::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--pr-gradient);
  border-radius: 3px 0 0 3px;
}

/* Arrow from card to node */
.pr-m-card::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 14px;
  width: 12px;
  height: 12px;
  background: var(--pr-card-bg);
  border-left: 1px solid var(--pr-card-border);
  border-bottom: 1px solid var(--pr-card-border);
  transform: rotate(45deg);
  transition: background-color 0.3s, border-color 0.3s;
  z-index: -1;
}

.pr-m-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.pr-m-icon {
  width: 22px;
  height: 22px;
  color: var(--pr-accent);
  flex-shrink: 0;
  transition: color 0.3s;
}
.pr-m-icon svg { width: 100%; height: 100%; display: block; }

.pr-m-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--pr-text);
  margin: 0;
  transition: color 0.3s;
}

.pr-m-desc {
  font-size: 0.8125rem;
  color: var(--pr-muted);
  line-height: 1.55;
  margin: 0;
  transition: color 0.3s;
}

/* ── Small tablet tweaks (768-1023) ──────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  .pr-grid {
    column-gap: 1rem;
  }
  .pr-card {
    padding: 0.875rem 0.75rem;
  }
  .pr-step-title { font-size: 0.875rem; }
  .pr-step-desc  { font-size: 0.75rem; }
  .pr-num { width: 44px; height: 44px; font-size: 1rem; }
}

/* ── Accessibility: prefers-reduced-motion ───────────────────── */
@media (prefers-reduced-motion: reduce) {
  .pr-header,
  .pr-step,
  .pr-m-step {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s !important;
  }

  .pr-path-main {
    stroke-dashoffset: 0 !important;
    animation: none !important;
  }

  .pr-path-flow,
  .pr-path-glow {
    animation: none !important;
    opacity: 0 !important;
  }

  .pr-junction {
    animation: none !important;
    opacity: 1 !important;
    r: 6 !important;
  }

  .pr-particle { opacity: 0 !important; }

  .pr-num::after { animation: none !important; }

  .pr-card::before { transition: transform 0.2s !important; }
}
