/* Section bridges — smooth shape transitions between tones */

:root {
  --bridge-h: clamp(3.25rem, 8vw, 5.75rem);
  --tone-base: var(--color-bg-deep);
  --tone-alt: var(--color-bg-secondary);
  --tone-footer: var(--color-bg-primary);
  --bridge-blend-intensity: 0.6;
  --bridge-animation-speed: 20s;
}

.section--base {
  background: linear-gradient(
    180deg,
    var(--tone-base) 0%,
    var(--tone-base) 85%,
    var(--tone-alt) 100%
  );
  background-size: 100% 100%;
  background-attachment: fixed;
}

.section--alt {
  background: linear-gradient(
    180deg,
    var(--tone-alt) 0%,
    var(--tone-alt) 85%,
    var(--tone-base) 100%
  );
  background-size: 100% 100%;
  background-attachment: fixed;
}

.section-bridge {
  position: relative;
  height: var(--bridge-h);
  margin-top: calc(var(--bridge-h) * -0.52);
  margin-bottom: calc(var(--bridge-h) * -0.48);
  z-index: 2;
  pointer-events: none;
  line-height: 0;
  overflow: hidden;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.section-bridge::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(99, 102, 241, 0.05) 25%,
    rgba(56, 189, 248, 0.08) 50%,
    rgba(99, 102, 241, 0.05) 75%,
    transparent 100%
  );
  opacity: 0;
  animation: bridge-pulse var(--bridge-animation-speed) ease-in-out infinite;
}

.section-bridge svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.15));
  animation: bridge-subtle-move 8s ease-in-out infinite;
}

.section-bridge .bridge-fill {
  fill: var(--bridge-to);
  opacity: 0.95;
  animation: bridge-fill-opacity 6s ease-in-out infinite;
}

.section-bridge .bridge-rim {
  fill: none;
  stroke: url(#bridge-stroke-global);
  stroke-width: 1.5;
  opacity: 0.85;
  stroke-dasharray: 2000;
  stroke-dashoffset: 0;
  animation: bridge-rim-flow 12s linear infinite;
}

.section-bridge .bridge-accent {
  fill: none;
  stroke: rgba(56, 189, 248, 0.2);
  stroke-width: 1;
  stroke-dasharray: 8 12;
  stroke-dashoffset: 0;
  animation: bridge-accent-flow 4s linear infinite;
}

/* Bridge glow effect */
.section-bridge::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(
    to top,
    rgba(99, 102, 241, 0.1) 0%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.6s ease;
}

.section-bridge:hover::after {
  opacity: 1;
}

@keyframes bridge-pulse {
  0%, 100% { opacity: 0; }
  50% { opacity: 0.6; }
}

@keyframes bridge-subtle-move {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes bridge-fill-opacity {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 0.88; }
}

@keyframes bridge-rim-flow {
  0% { stroke-dashoffset: 0; opacity: 0.85; }
  50% { opacity: 0.92; }
  100% { stroke-dashoffset: -2000; opacity: 0.85; }
}

@keyframes bridge-accent-flow {
  0% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -20; }
}

/* Pull sections together at bridges */
.section--merge-top {
  padding-top: calc(var(--space-2xl) + var(--bridge-h) * 0.28);
}
.section--merge-bottom {
  padding-bottom: calc(var(--space-2xl) + var(--bridge-h) * 0.2);
}

.stats-bar--merged {
  margin-bottom: calc(var(--bridge-h) * -0.35);
}

/* Flip bridge when transition goes alt → base vs base → alt */
.section-bridge--flip-y svg {
  transform: scaleY(-1);
}

.light .section-bridge .bridge-accent {
  stroke: rgba(99, 102, 241, 0.22);
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.section-bridge--soft {
  --bridge-h: clamp(2rem, 5vw, 3.25rem);
  margin-top: calc(var(--bridge-h) * -0.45);
  margin-bottom: calc(var(--bridge-h) * -0.4);
}

.section-bridge--footer {
  --bridge-h: clamp(2.5rem, 6vw, 4rem);
  margin-bottom: 0;
}

.section--compact {
  padding-top: calc(var(--space-lg) + var(--bridge-h) * 0.22);
  padding-bottom: var(--space-lg);
}

.site-footer--merged {
  position: relative;
  z-index: 1;
  margin-top: calc(var(--bridge-h) * -0.42);
  padding-top: calc(var(--space-xl) + var(--bridge-h) * 0.3);
}
