/* ==========================================================================
   Shared Animated Background Component
   - .bg-gradients: full-document height (scrolls naturally with the page)
   - .bg-bubbles: full-document height (more circles & massive arcs as you scroll)
   - .bg-noise: fixed to viewport (never scrolls, color-burn blends over gradient)
   - Exact Figma Noise: Mono | Size 0.5 | Density 100% | #A6A6A6 @ 100% | Color burn
   ========================================================================== */

:root {
  /* Default / fallback palette (matches clean Resource/GRADIENT_HOME.png) */
  --bg-top-left: #dad2c2;
  --bg-top-right: #d5d9d1;
  --bg-base: #e2cfb6;
  --bg-warm-mid: #fca97c;
  --bg-primary: #e62611;
  --bg-primary-mid: rgba(254, 118, 72, 0.82);
  --bg-deep: #7b1414;
  --bg-bottom-right: #a5644a;
  --bg-accent: #f8a274;
  --bg-bottom-band: rgba(116, 26, 24, 0.72);

  --bg-noise-color: #a6a6a6;
  --bg-noise-opacity: 1;

  /* Bubble controls */
  --bg-bubble-color: rgba(255, 255, 255, 0.26);
  --bg-bubble-blur: 0px;

  /* Exact Figma Noise parameters (Mono, 0.5, 100%, #A6A6A6 @ 100%, Color Burn) */
  --bg-noise-size: 0.5;
  --bg-noise-density: 1;
  --bg-noise-color: #a6a6a6;
  --bg-noise-opacity: 1;
  --bg-noise-blend: color-burn;

  /* Default 5-circle full-page composition (matches Home) */
  --b1-x: 74vw;
  --b1-y: 18%;
  --b1-size: clamp(400px, 64vw, 940px);
  --b1-opacity: 0.65;

  --b2-x: 10vw;
  --b2-y: 9%;
  --b2-size: clamp(180px, 24vw, 360px);
  --b2-opacity: 0.22;

  --b3-x: 78vw;
  --b3-y: 44%;
  --b3-size: clamp(420px, 68vw, 1020px);
  --b3-opacity: 0.68;

  /* Massive sweeping architectural arc circle */
  --b4-x: -4vw;
  --b4-y: 96%;
  --b4-size: clamp(900px, 175vw, 2400px);
  --b4-opacity: 0.42;

  --b5-x: 86vw;
  --b5-y: 84%;
  --b5-size: clamp(320px, 46vw, 680px);
  --b5-opacity: 0.34;
}

/* --------------------------------------------------------------------------
   Page Themes (clean pre-burn palettes + unique 5-circle compositions)
   -------------------------------------------------------------------------- */

/* 1. Home — matched to clean Resource/GRADIENT_HOME.png & Figma circle scale */
[data-theme="home"] {
  --bg-top-left: #dad2c2;
  --bg-top-right: #c5d3cf;
  --bg-base: #e0d0b8;
  --bg-warm-mid: #fca97c;
  --bg-primary: #e62611;
  --bg-primary-mid: rgba(254, 118, 72, 0.82);
  --bg-deep: #7b1414;
  --bg-bottom-right: #a5644a;
  --bg-accent: #f8a274;
  --bg-bottom-band: rgba(116, 26, 24, 0.72);

  --bg-noise-color: #a6a6a6;
  --bg-noise-opacity: 1;

  --b1-x: 74vw;
  --b1-y: 18%;
  --b1-size: clamp(400px, 64vw, 940px);
  --b1-opacity: 0.65;

  --b2-x: 10vw;
  --b2-y: 9%;
  --b2-size: clamp(180px, 24vw, 360px);
  --b2-opacity: 0.22;

  --b3-x: 78vw;
  --b3-y: 44%;
  --b3-size: clamp(420px, 68vw, 1020px);
  --b3-opacity: 0.68;

  --b4-x: -4vw;
  --b4-y: 96%;
  --b4-size: clamp(900px, 175vw, 2400px);
  --b4-opacity: 0.42;

  --b5-x: 86vw;
  --b5-y: 84%;
  --b5-size: clamp(320px, 46vw, 680px);
  --b5-opacity: 0.34;
}

/* 2. Who We Are (about) — dusty mauve, heather lilac, apricot amber & plum */
[data-theme="about"] {
  --bg-top-left: #baa8ab;
  --bg-top-right: #d2c0b4;
  --bg-base: #cbb2a6;
  --bg-warm-mid: #e8a27b;
  --bg-primary: #ea7f53;
  --bg-primary-mid: rgba(238, 142, 94, 0.78);
  --bg-deep: #74515e;
  --bg-bottom-right: #b26c60;
  --bg-accent: #f2aa6a;
  --bg-bottom-band: rgba(116, 70, 82, 0.65);

  --bg-noise-color: #a6a6a6;
  --bg-noise-opacity: 1;

  --b1-x: 18vw;
  --b1-y: 18%;
  --b1-size: clamp(380px, 58vw, 840px);
  --b1-opacity: 0.52;

  --b2-x: 74vw;
  --b2-y: 14%;
  --b2-size: clamp(280px, 42vw, 620px);
  --b2-opacity: 0.38;

  --b3-x: 82vw;
  --b3-y: 52%;
  --b3-size: clamp(420px, 64vw, 920px);
  --b3-opacity: 0.58;

  --b4-x: 4vw;
  --b4-y: 92%;
  --b4-size: clamp(860px, 160vw, 2200px);
  --b4-opacity: 0.38;

  --b5-x: 84vw;
  --b5-y: 82%;
  --b5-size: clamp(300px, 44vw, 640px);
  --b5-opacity: 0.36;
}

/* 3. What We Do (what) — cool mineral, warm champagne, amber & burnt sienna */
[data-theme="what"] {
  --bg-top-left: #ded7c4;
  --bg-top-right: #d1dadc;
  --bg-base: #e9dac0;
  --bg-warm-mid: #f8ca7e;
  --bg-primary: #e87726;
  --bg-primary-mid: rgba(246, 152, 66, 0.8);
  --bg-deep: #9c3b16;
  --bg-bottom-right: #b4784a;
  --bg-accent: #f4be74;
  --bg-bottom-band: rgba(132, 54, 24, 0.64);

  --bg-noise-color: #a6a6a6;
  --bg-noise-opacity: 1;

  --b1-x: 72vw;
  --b1-y: 14%;
  --b1-size: clamp(320px, 46vw, 680px);
  --b1-opacity: 0.68;

  --b2-x: 16vw;
  --b2-y: 44%;
  --b2-size: clamp(190px, 26vw, 390px);
  --b2-opacity: 0.36;

  --b3-x: 48vw;
  --b3-y: 28%;
  --b3-size: clamp(240px, 34vw, 500px);
  --b3-opacity: 0.46;

  --b4-x: 6vw;
  --b4-y: 95%;
  --b4-size: clamp(820px, 150vw, 2100px);
  --b4-opacity: 0.38;

  --b5-x: 84vw;
  --b5-y: 76%;
  --b5-size: clamp(280px, 40vw, 580px);
  --b5-opacity: 0.44;
}

/* 4. How We Do It (how) — eucalyptus, linen stone, slate-teal & spruce */
[data-theme="how"] {
  --bg-top-left: #dcdbce;
  --bg-top-right: #cedbd5;
  --bg-base: #dfe0d4;
  --bg-warm-mid: #a4c9be;
  --bg-primary: #3b8d88;
  --bg-primary-mid: rgba(94, 162, 154, 0.76);
  --bg-deep: #225458;
  --bg-bottom-right: #567d79;
  --bg-accent: #94bfb4;
  --bg-bottom-band: rgba(32, 76, 80, 0.62);

  --bg-noise-color: #a6a6a6;
  --bg-noise-opacity: 1;

  --b1-x: 14vw;
  --b1-y: 52%;
  --b1-size: clamp(260px, 36vw, 520px);
  --b1-opacity: 0.6;

  --b2-x: 56vw;
  --b2-y: 16%;
  --b2-size: clamp(320px, 46vw, 680px);
  --b2-opacity: 0.3;

  --b3-x: 82vw;
  --b3-y: 62%;
  --b3-size: clamp(200px, 28vw, 420px);
  --b3-opacity: 0.68;

  --b4-x: 92vw;
  --b4-y: 100%;
  --b4-size: clamp(760px, 140vw, 1950px);
  --b4-opacity: 0.34;

  --b5-x: 28vw;
  --b5-y: 86%;
  --b5-size: clamp(260px, 38vw, 540px);
  --b5-opacity: 0.4;
}

/* 5. Talk To Us (contact) — rotated -90° (counter-clockwise):
   Alabaster-sage, blush sand, crimson-rose & wine */
[data-theme="contact"] {
  --bg-top-left: #dfd7ce;
  --bg-top-right: #d6dbd4;
  --bg-base: #ecd5cc;
  --bg-warm-mid: #f3a4a3;
  --bg-primary: #df4261;
  --bg-primary-mid: rgba(236, 102, 122, 0.78);
  --bg-deep: #841e3a;
  --bg-bottom-right: #b06270;
  --bg-accent: #f099a2;
  --bg-bottom-band: rgba(118, 28, 52, 0.66);

  /* Bubble slots rotated -90° counter-clockwise around center (50%, 50%) */
  --b1-x: 44vw;
  --b1-y: 38%;
  --b1-size: clamp(340px, 50vw, 720px);
  --b1-opacity: 0.66;

  --b2-x: 22vw;
  --b2-y: 90%;
  --b2-size: clamp(200px, 28vw, 420px);
  --b2-opacity: 0.38;

  --b3-x: 10vw;
  --b3-y: 62%;
  --b3-size: clamp(160px, 22vw, 320px);
  --b3-opacity: 0.54;

  --b4-x: 92vw;
  --b4-y: 108%;
  --b4-size: clamp(780px, 145vw, 2000px);
  --b4-opacity: 0.36;

  --b5-x: 84vw;
  --b5-y: 18%;
  --b5-size: clamp(240px, 34vw, 500px);
  --b5-opacity: 0.42;
}

/* 6. Policies / T&Cs / Legal (legal) — calm stone, parchment, clay & umber */
[data-theme="legal"] {
  --bg-top-left: #dcd8cd;
  --bg-top-right: #d4dbd4;
  --bg-base: #e3dccd;
  --bg-warm-mid: #e0b38d;
  --bg-primary: #c2734b;
  --bg-primary-mid: rgba(208, 136, 98, 0.74);
  --bg-deep: #783e2c;
  --bg-bottom-right: #9c6c56;
  --bg-accent: #dab090;
  --bg-bottom-band: rgba(108, 56, 40, 0.62);

  --bg-noise-color: #a6a6a6;
  --bg-noise-opacity: 1;

  --b1-x: 12vw;
  --b1-y: 36%;
  --b1-size: clamp(220px, 32vw, 460px);
  --b1-opacity: 0.5;

  --b2-x: 70vw;
  --b2-y: 66%;
  --b2-size: clamp(300px, 42vw, 600px);
  --b2-opacity: 0.32;

  --b3-x: 48vw;
  --b3-y: 12%;
  --b3-size: clamp(240px, 34vw, 500px);
  --b3-opacity: 0.56;

  --b4-x: 10vw;
  --b4-y: 96%;
  --b4-size: clamp(740px, 138vw, 1900px);
  --b4-opacity: 0.32;

  --b5-x: 86vw;
  --b5-y: 34%;
  --b5-size: clamp(190px, 26vw, 380px);
  --b5-opacity: 0.36;
}

/* --------------------------------------------------------------------------
   Background Canvas Layers
   - .bg-gradients: oversized 155vmax viewport-fixed canvas that smoothly orbits
     counter-clockwise as you scroll, keeping fiery warmth on the Splash while
     swinging airy sage/sand behind left-aligned manifesto copy on scroll
   - .bg-bubbles: full-document height (more circles & massive arcs as you scroll)
   - .bg-noise: fixed to viewport (never scrolls or rotates, color-burn blends live)
   -------------------------------------------------------------------------- */

.bg-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  isolation: isolate;
}

.bg-gradients {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.bg-gradient {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 155vmax;
  height: 155vmax;
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse 46% 36% at 10% 82%, var(--bg-deep) 0%, transparent 72%),
    radial-gradient(ellipse 58% 48% at 16% 74%, var(--bg-primary) 0%, var(--bg-primary-mid) 44%, transparent 78%),
    radial-gradient(ellipse 54% 44% at 74% 78%, var(--bg-accent) 0%, transparent 74%),
    radial-gradient(ellipse 48% 42% at 20% 42%, var(--bg-warm-mid) 0%, transparent 74%),
    radial-gradient(ellipse 74% 64% at 84% 20%, var(--bg-top-right) 0%, transparent 78%),
    radial-gradient(ellipse 52% 44% at 54% 12%, var(--bg-top-right) 0%, transparent 74%),
    linear-gradient(160deg, var(--bg-top-left) 12%, var(--bg-base) 54%, var(--bg-accent) 88%);
  transform: translate3d(-50%, -50%, 0) rotate(calc(-85deg - var(--bg-scroll, 0) * 10deg));
  will-change: transform, opacity;
  opacity: 1;
  transition: opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Page-specific rotation for Talk To Us (Contact)
   Rotated -90° (counter-clockwise) from default (-85deg - 90deg = -175deg) */
.bg-gradient[data-theme="contact"] {
  transform: translate3d(-50%, -50%, 0) rotate(calc(-175deg - var(--bg-scroll, 0) * 10deg));
}

/* Entering layer starts at opacity: 0 and smoothly cross-fades to 1 over 0.85s */
.bg-gradient.is-entering,
.bg-gradient[data-theme].is-entering {
  opacity: 0;
}

/* --------------------------------------------------------------------------
   Full-Page Floating Translucent Circles (Bubbles)
   - Distributed down the full page height so new circles appear as you scroll
   - Includes a massive sweeping architectural arc circle (slot 4)
   -------------------------------------------------------------------------- */

.bg-bubbles {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.bg-bubble-slot {
  position: absolute;
  transform: translate(-50%, -50%);
  transition:
    left 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    top 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    width 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    height 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.9s ease;
}

.bg-bubble-slot--1 {
  left: var(--b1-x);
  top: var(--b1-y);
  width: var(--b1-size);
  height: var(--b1-size);
  opacity: var(--b1-opacity);
}

.bg-bubble-slot--2 {
  left: var(--b2-x);
  top: var(--b2-y);
  width: var(--b2-size);
  height: var(--b2-size);
  opacity: var(--b2-opacity);
}

.bg-bubble-slot--3 {
  left: var(--b3-x);
  top: var(--b3-y);
  width: var(--b3-size);
  height: var(--b3-size);
  opacity: var(--b3-opacity);
}

.bg-bubble-slot--4 {
  left: var(--b4-x);
  top: var(--b4-y);
  width: var(--b4-size);
  height: var(--b4-size);
  opacity: var(--b4-opacity);
}

.bg-bubble-slot--5 {
  left: var(--b5-x);
  top: var(--b5-y);
  width: var(--b5-size);
  height: var(--b5-size);
  opacity: var(--b5-opacity);
}

.bg-bubble {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--bg-bubble-color);
  filter: blur(var(--bg-bubble-blur));
  will-change: transform;
}

.bg-bubble--1 {
  animation: bg-drift-1 34s ease-in-out infinite;
}

.bg-bubble--2 {
  animation: bg-drift-2 40s ease-in-out infinite;
}

.bg-bubble--3 {
  animation: bg-drift-3 44s ease-in-out infinite;
}

.bg-bubble--4 {
  animation: bg-drift-4 54s ease-in-out infinite;
}

.bg-bubble--5 {
  animation: bg-drift-5 38s ease-in-out infinite;
}

@keyframes bg-drift-1 {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  33% {
    transform: translate3d(-10vw, -8vh, 0) scale(0.92);
  }
  66% {
    transform: translate3d(8vw, 6vh, 0) scale(1.08);
  }
}

@keyframes bg-drift-2 {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  35% {
    transform: translate3d(18vw, 12vh, 0) scale(1.18);
  }
  70% {
    transform: translate3d(6vw, 22vh, 0) scale(0.9);
  }
}

@keyframes bg-drift-3 {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  30% {
    transform: translate3d(-14vw, -8vh, 0) scale(0.9);
  }
  65% {
    transform: translate3d(-6vw, 10vh, 0) scale(1.08);
  }
}

@keyframes bg-drift-4 {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(5vw, -5vh, 0) scale(1.04);
  }
}

@keyframes bg-drift-5 {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  40% {
    transform: translate3d(-14vw, -10vh, 0) scale(1.12);
  }
  75% {
    transform: translate3d(6vw, -16vh, 0) scale(0.92);
  }
}

/* --------------------------------------------------------------------------
   Fixed Figma Mono Noise Overlay (Never Scrolls!)
   - position: fixed keeps grain completely stationary on the viewport
   - Blends via color-burn directly against the scrolling gradient & circles
   -------------------------------------------------------------------------- */

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  opacity: var(--bg-noise-opacity);
  mix-blend-mode: var(--bg-noise-blend);
  background-repeat: repeat;
  background-size: 128px 128px;
  transition: opacity 0.85s ease;
}

@media (prefers-reduced-motion: reduce) {
  .bg-bubble {
    animation: none;
  }

  .bg-gradient {
    transform: translate3d(-50%, -50%, 0) rotate(-90deg);
  }

  .bg-gradient[data-theme="contact"] {
    transform: translate3d(-50%, -50%, 0) rotate(-175deg);
  }

  .bg-bubble-slot,
  .bg-gradient {
    transition: none;
  }
}
