/* ==========================================================================
   Ambient Field, Halftone Dither Matrices, Paper Grain & Radar Geometry
   ========================================================================== */

/* Fixed SVG Paper Grain Overlay across the entire viewport */
.paper-grain-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-repeat: repeat;
  background-size: 240px 240px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* Ambient Field Layer — Parallax container */
.ambient-field {
  position: fixed;
  inset: -6%;
  z-index: var(--z-ambient);
  pointer-events: none;
  overflow: hidden;
  --px: 0px;
  --py: 0px;
  --glow-boost: 0;
  --blob-shift-x: 0px;
  --blob-shift-y: 0px;
}

:root {
  --decor-offset-x: 20.2vw;
  --decor-offset-y: -45px;
}

/* Organic heavily-blurred ambient mesh blobs */
.ambient-mesh {
  position: absolute;
  inset: 0;
  transform: translate3d(calc(var(--px) * 1 + var(--blob-shift-x)), calc(var(--py) * 1 + var(--blob-shift-y)), 0);
  transition: filter 0.7s var(--ease-mechanical);
  will-change: transform;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(74px);
  transition:
    transform 1.1s var(--ease-mechanical),
    opacity 0.9s var(--ease-mechanical),
    background 1.1s var(--ease-mechanical);
  will-change: transform, opacity;
}

/* Upper-left muted sage-teal cloud (matches Echo Habitat upper-left mass) */
.blob--sage {
  width: clamp(320px, 34vw, 560px);
  height: clamp(320px, 38vh, 520px);
  top: 10%;
  left: 14%;
  background: radial-gradient(
    circle at 46% 52%,
    rgba(47, 81, 84, 0.84) 0%,
    rgba(111, 145, 144, 0.62) 44%,
    rgba(111, 145, 144, 0.0) 76%
  );
  opacity: calc(0.8 + var(--glow-boost) * 0.15);
}

/* Lower-right deep Prussian blue cloud (matches Echo Habitat lower-right mass) */
.blob--prussian {
  width: clamp(380px, 44vw, 720px);
  height: clamp(420px, 58vh, 760px);
  bottom: 2%;
  right: 10%;
  background: radial-gradient(
    ellipse at 52% 58%,
    rgba(11, 47, 78, 0.94) 0%,
    rgba(20, 74, 118, 0.72) 40%,
    rgba(111, 145, 144, 0.30) 66%,
    rgba(15, 56, 90, 0.0) 78%
  );
  opacity: calc(0.88 + var(--glow-boost) * 0.12);
}

/* Lower-left warm peach/coral ambient cloud */
.blob--peach {
  width: clamp(280px, 32vw, 520px);
  height: clamp(280px, 38vh, 520px);
  top: 46%;
  left: 22%;
  background: radial-gradient(
    circle at 50% 48%,
    rgba(244, 162, 140, 0.68) 0%,
    rgba(247, 195, 177, 0.40) 45%,
    rgba(244, 162, 140, 0.0) 75%
  );
  opacity: calc(0.78 + var(--glow-boost) * 0.18);
}

/* Subtle active card proximity glow behind right stack */
.blob--card-halo {
  width: clamp(360px, 36vw, 580px);
  height: clamp(360px, 44vh, 580px);
  top: 26%;
  right: 14%;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(244, 162, 140, 0.36) 0%,
    rgba(111, 145, 144, 0.22) 48%,
    rgba(15, 56, 90, 0) 74%
  );
  filter: blur(68px);
  opacity: calc(0.28 + var(--glow-boost) * 0.55);
  transition: opacity 0.5s var(--ease-mechanical), transform 0.65s var(--ease-mechanical);
}

/* Glowing white-peach center star flare right at the radar origin behind the card stack */
.center-flare {
  position: absolute;
  top: calc(50% + var(--decor-offset-y));
  left: calc(50% + var(--decor-offset-x));
  width: 260px;
  height: 260px;
  transform: translate(-50%, -50%) translate3d(calc(var(--px) * 0.55), calc(var(--py) * 0.55), 0);
  background: radial-gradient(
    circle at center,
    rgba(255, 253, 249, 0.98) 0%,
    rgba(255, 241, 232, 0.85) 8%,
    rgba(244, 162, 140, 0.52) 22%,
    rgba(244, 162, 140, 0.14) 44%,
    rgba(244, 162, 140, 0) 70%
  );
  mix-blend-mode: screen;
  filter: blur(2px);
  transition: opacity 0.6s var(--ease-mechanical);
  opacity: calc(0.92 + var(--glow-boost) * 0.08);
}

/* ==========================================================================
   Halftone Dither Texture Overlays (Masked over the blurred color blobs)
   ========================================================================== */

.halftone-layer {
  position: absolute;
  inset: 0;
  transform: translate3d(calc(var(--px) * 0.88 + var(--blob-shift-x) * 0.7), calc(var(--py) * 0.88 + var(--blob-shift-y) * 0.7), 0);
  will-change: transform;
}

/* Dark micro-dot matrix over the sage-teal upper-left mass */
.halftone--sage-dark {
  position: absolute;
  top: 8%;
  left: 10%;
  width: clamp(340px, 38vw, 600px);
  height: clamp(320px, 42vh, 520px);
  background-image: radial-gradient(circle, rgba(26, 26, 26, 0.42) 1.35px, transparent 1.55px);
  background-size: 9px 9px;
  -webkit-mask-image: radial-gradient(ellipse 62% 58% at 52% 48%, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.5) 45%, transparent 78%);
  mask-image: radial-gradient(ellipse 62% 58% at 52% 48%, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.5) 45%, transparent 78%);
  opacity: calc(0.55 + var(--glow-boost) * 0.18);
  transition: opacity 0.5s var(--ease-mechanical);
}

/* Light paper-knockout halftone dots inside the deeper sage-teal & Prussian cores */
.halftone--sage-light {
  position: absolute;
  top: 15%;
  left: 19%;
  width: clamp(220px, 24vw, 390px);
  height: clamp(200px, 28vh, 340px);
  background-image: radial-gradient(circle, rgba(234, 230, 223, 0.82) 1.45px, transparent 1.65px);
  background-size: 9px 9px;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.45) 48%, transparent 76%);
  mask-image: radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.45) 48%, transparent 76%);
  opacity: 0.72;
}

/* Prussian blue halftone matrix — light knockout dots in deep ocean core + dark rim dots */
.halftone--prussian-light {
  position: absolute;
  bottom: 4%;
  right: 12%;
  width: clamp(340px, 40vw, 640px);
  height: clamp(380px, 52vh, 660px);
  background-image: radial-gradient(circle, rgba(234, 230, 223, 0.84) 1.5px, transparent 1.7px);
  background-size: 10px 10px;
  -webkit-mask-image: radial-gradient(ellipse 56% 58% at 52% 56%, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.55) 46%, transparent 78%);
  mask-image: radial-gradient(ellipse 56% 58% at 52% 56%, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.55) 46%, transparent 78%);
  opacity: calc(0.68 + var(--glow-boost) * 0.24);
  transition: opacity 0.5s var(--ease-mechanical);
}

.halftone--prussian-dark {
  position: absolute;
  bottom: 14%;
  right: 20%;
  width: clamp(300px, 36vw, 560px);
  height: clamp(340px, 48vh, 600px);
  background-image: radial-gradient(circle, rgba(15, 34, 52, 0.52) 1.35px, transparent 1.6px);
  background-size: 8.5px 8.5px;
  -webkit-mask-image: radial-gradient(ellipse 58% 60% at 45% 42%, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.35) 52%, transparent 80%);
  mask-image: radial-gradient(ellipse 58% 60% at 45% 42%, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.35) 52%, transparent 80%);
  opacity: calc(0.45 + var(--glow-boost) * 0.2);
  transition: opacity 0.5s var(--ease-mechanical);
}

/* Central vertical halftone dither spine (aligned with radar vertical axis behind card stack) */
.halftone--axis-spine {
  position: absolute;
  top: 10%;
  bottom: 8%;
  left: calc(50% + var(--decor-offset-x));
  width: 96px;
  transform: translate3d(-50%, var(--decor-offset-y), 0);
  background-image: radial-gradient(circle, rgba(26, 26, 26, 0.44) 1.25px, transparent 1.5px);
  background-size: 8px 8px;
  -webkit-mask-image: radial-gradient(ellipse 46% 48% at 50% 50%, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.32) 55%, transparent 92%);
  mask-image: radial-gradient(ellipse 46% 48% at 50% 50%, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.32) 55%, transparent 92%);
  opacity: 0.52;
}

/* ==========================================================================
   Diagrammatic Radar & Orbital SVG Telemetry Layer
   ========================================================================== */

.radar-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-radar);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  --rx: 0px;
  --ry: 0px;
  --orbit-deg: 0deg;
}

.radar-svg {
  width: min(92vw, 1180px);
  height: min(90vh, 920px);
  overflow: visible;
  transform: translate3d(
    calc(var(--decor-offset-x) + var(--rx)),
    calc(var(--decor-offset-y) + var(--ry)),
    0
  );
  will-change: transform;
}

.radar-orbit-group {
  transform-origin: 500px 420px;
  transform: rotate(var(--orbit-deg));
  transition: transform 0.9s var(--ease-mechanical);
}

.radar-line {
  stroke: rgba(26, 26, 26, 0.24);
  stroke-width: 1;
  fill: none;
  vector-effect: non-scaling-stroke;
}

.radar-line--faint {
  stroke: rgba(26, 26, 26, 0.13);
  stroke-width: 1;
  fill: none;
}

.radar-ring-white {
  stroke: rgba(255, 253, 249, 0.62);
  stroke-width: 1;
  fill: none;
}

.radar-ring-dashed {
  stroke: rgba(255, 253, 249, 0.72);
  stroke-width: 1;
  stroke-dasharray: 2.5 5;
  fill: none;
}

.radar-dot {
  fill: var(--ink-primary);
}

.radar-crosshair {
  stroke: rgba(26, 26, 26, 0.36);
  stroke-width: 1;
}

/* Subtle pulsing specular center flare inside SVG */
.radar-center-node {
  animation: centerPulse 5.2s ease-in-out infinite;
}

@keyframes centerPulse {
  0%, 100% {
    opacity: 0.88;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

/* Per-role subtle ambient field shifts (keeps the exact palette while giving each role breathing space) */
.ambient-field[data-role-tone="ux"] { --blob-shift-x: 0px; --blob-shift-y: 0px; }
.ambient-field[data-role-tone="photo"] { --blob-shift-x: 24px; --blob-shift-y: -14px; }
.ambient-field[data-role-tone="writer"] { --blob-shift-x: -22px; --blob-shift-y: 12px; }
.ambient-field[data-role-tone="florist"] { --blob-shift-x: 16px; --blob-shift-y: 22px; }
.ambient-field[data-role-tone="engineer"] { --blob-shift-x: -18px; --blob-shift-y: -18px; }
.ambient-field[data-role-tone="data"] { --blob-shift-x: 28px; --blob-shift-y: 6px; }
.ambient-field[data-role-tone="painter"] { --blob-shift-x: -26px; --blob-shift-y: -8px; }
.ambient-field[data-role-tone="glass"] { --blob-shift-x: 20px; --blob-shift-y: 16px; }

@media (max-width: 1024px) {
  :root {
    --decor-offset-x: 0px;
    --decor-offset-y: 16vh;
  }
}
