/* =============================================================
   PRISM — 3D glass prism splitting a light beam, cursor-reactive
   ============================================================= */

.act--prism {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 50% at 50% 60%, #1a1430 0%, #0a0812 70%),
    #05030a;
  overflow: hidden;
  display: grid;
  place-items: center;
  isolation: isolate;
  --px: 0;
  --py: 0;
}

.act--prism::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px;
  mask-image: radial-gradient(ellipse at 50% 50%, black 30%, transparent 80%);
  pointer-events: none;
  z-index: 0;
}

.prism-stage {
  position: relative;
  width: min(1100px, 92vw);
  height: 560px;
  perspective: 1100px;
  transform-style: preserve-3d;
  z-index: 1;
  transform: rotateY(calc(var(--px) * 28deg)) rotateX(calc(var(--py) * -20deg));
  transition: transform 140ms ease-out;
}

/* Incoming white beam */
.prism-beam-in {
  position: absolute;
  top: 50%;
  left: 0;
  width: 42%;
  height: 8px;
  margin-top: -4px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 20%, #fff 100%);
  box-shadow: 0 0 18px #fff, 0 0 40px rgba(255,255,255,0.6);
  border-radius: 2px;
  animation: beam-pulse 3s ease-in-out infinite;
  transform: translateZ(20px);
}
@keyframes beam-pulse {
  0%,100% { opacity: 0.9; }
  50%     { opacity: 1; box-shadow: 0 0 26px #fff, 0 0 60px rgba(255,255,255,0.75); }
}

/* 3D prism — extruded triangular glass (front + back faces + 3 side strips) */
.prism-glass {
  position: absolute;
  top: 50%;
  left: 42%;
  width: 220px;
  height: 220px;
  margin: -110px 0 0 -110px;
  transform-style: preserve-3d;
  animation: prism-rotate 14s ease-in-out infinite;
}
@keyframes prism-rotate {
  0%,100% { transform: rotateY(-6deg) rotateX(2deg) rotateZ(0); }
  50%     { transform: rotateY(6deg)  rotateX(-2deg) rotateZ(1deg); }
}

/* Front + back triangular caps */
.prism-face {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 4%, 96% 92%, 4% 92%);
  background:
    linear-gradient(110deg,
      rgba(255,255,255,0.04) 0%,
      rgba(216,153,69,0.12) 20%,
      rgba(123,160,91,0.12) 40%,
      rgba(58,90,120,0.16) 60%,
      rgba(74,45,90,0.12) 80%,
      rgba(255,255,255,0.06) 100%),
    linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.04) 50%, rgba(255,255,255,0.16) 100%);
  box-shadow:
    inset 0 0 40px rgba(255,255,255,0.2),
    inset 0 0 4px rgba(255,255,255,0.5);
}
.prism-face.front { transform: translateZ(110px); }
.prism-face.back  { transform: translateZ(-110px); opacity: 0.8; }

/* Three side quads forming the extrusion walls */
.prism-side {
  position: absolute;
  background: linear-gradient(180deg,
    rgba(255,255,255,0.18) 0%,
    rgba(200,200,220,0.08) 50%,
    rgba(255,255,255,0.14) 100%);
  box-shadow: inset 0 0 20px rgba(255,255,255,0.15);
  transform-origin: 50% 50%;
  backface-visibility: hidden;
}
/* bottom strip: from (4%,92%) to (96%,92%), width ~92%, depth 80px */
.prism-side.bottom {
  width: 92%; height: 220px;
  left: 4%; top: 92%;
  margin-top: -110px;
  transform: rotateX(90deg);
}
/* left slope: from (50%,4%) to (4%,92%) */
.prism-side.left {
  width: 220px; height: 240px;
  left: 0; top: 0;
  transform-origin: 100% 50%;
  transform: translateX(50%) rotateY(-60deg);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}
/* right slope */
.prism-side.right {
  width: 220px; height: 240px;
  right: 0; top: 0;
  transform-origin: 0 50%;
  transform: translateX(-50%) rotateY(60deg);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

/* Glowing edge outline on front face */
.prism-face.front::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(
    50% 4%, 96% 92%, 4% 92%,
    4% 92%, 6% 91%, 50% 7%, 94% 91%, 96% 92%
  );
  background: linear-gradient(180deg,
    rgba(255,255,255,0.95) 0%,
    rgba(216,153,69,0.7) 40%,
    rgba(58,90,120,0.7) 100%);
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.9));
}
/* Specular streak */
.prism-face.front::after {
  content: "";
  position: absolute;
  top: 10%; left: 40%;
  width: 15%; height: 80%;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), transparent);
  transform: rotate(5deg);
  filter: blur(2px);
  pointer-events: none;
}

/* Outgoing spectrum — a single tight wedge of refracted light.
   Rays fan only a few degrees apart so their glows fuse into one continuous
   dispersion cone. Everything additively blended for true-light realism. */
.prism-spectrum {
  position: absolute;
  top: 50%;
  left: calc(42% + 20px);
  width: 58%;
  height: 500px;
  margin-top: 0;
  transform-origin: 0 0;
  pointer-events: none;
  transform-style: preserve-3d;
  transform: translateZ(80px) rotateY(calc(var(--px) * -6deg));
  mix-blend-mode: screen;
  --fan: 1;
  filter: saturate(1.2) contrast(1.05);
}
/* Continuous rainbow wedge behind the rays — gives the fan a solid 3D body */
.prism-spectrum::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 100%;
  height: 120px;
  margin-top: -60px;
  transform-origin: 0 50%;
  transform: rotate(calc(3deg * var(--fan))) translateZ(-10px);
  background: conic-gradient(
    from 86deg at 0% 50%,
    transparent 0deg,
    transparent 3deg,
    rgba(255,40,40,0.0)   3.0deg,
    rgba(255,40,40,0.85)  4.0deg,
    rgba(255,130,30,0.85) 5.0deg,
    rgba(255,230,40,0.85) 6.0deg,
    rgba(40,230,90,0.85)  7.0deg,
    rgba(40,200,255,0.85) 8.0deg,
    rgba(60,80,255,0.85)  9.0deg,
    rgba(170,50,255,0.85) 10.0deg,
    rgba(170,50,255,0.0)  11.0deg,
    transparent 12deg,
    transparent 360deg);
  mask-image: linear-gradient(90deg, transparent 0%, #000 18%, #000 95%, transparent 100%);
  filter: blur(4px);
  opacity: 0.9;
}
/* Bright exit hotspot where the refracted beam leaves the glass */
.prism-spectrum::after {
  content: "";
  position: absolute;
  left: -14px; top: -20px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(255,255,255,0.7) 25%, rgba(255,255,255,0) 70%);
  filter: blur(1.5px);
  animation: beam-pulse 3s ease-in-out infinite;
}
.ray {
  position: absolute;
  top: 0;
  left: 0;
  height: 1.5px;
  width: 100%;
  border-radius: 2px;
  transform-origin: 0 50%;
  animation: ray-fade 3s ease-in-out infinite;
  transition: transform 180ms ease-out;
  mix-blend-mode: screen;
}
/* Soft wide glow halo around each thin core ray — overlaps with neighbors to form the wedge body */
.ray::before {
  content: "";
  position: absolute;
  inset: -6px 0;
  background: inherit;
  filter: blur(8px);
  opacity: 0.9;
  border-radius: 12px;
}

/* True spectrum hues. Rays fan tightly (only ~9° total) so they form a single
   unified pyramid of light. Dispersion monotonic — red bends least, violet most. */
.ray.r1 { /* red    ~700nm */
  background: linear-gradient(90deg, rgba(255,40,40,0) 0%, rgba(255,40,40,0.95) 18%, #ff2828 55%, #ff4040 100%);
  transform: rotate(calc(3deg   * var(--fan))) translateZ(6px);  animation-delay: 0.00s;
}
.ray.r2 { /* orange ~620nm */
  background: linear-gradient(90deg, rgba(255,130,30,0) 0%, rgba(255,130,30,0.95) 18%, #ff821e 55%, #ff9628 100%);
  transform: rotate(calc(4.2deg * var(--fan))) translateZ(4px);  animation-delay: 0.04s;
}
.ray.r3 { /* yellow ~580nm */
  background: linear-gradient(90deg, rgba(255,230,40,0) 0%, rgba(255,230,40,0.95) 18%, #ffe628 55%, #fff04c 100%);
  transform: rotate(calc(5.4deg * var(--fan))) translateZ(2px);  animation-delay: 0.08s;
}
.ray.r4 { /* green  ~530nm */
  background: linear-gradient(90deg, rgba(40,230,90,0) 0%, rgba(40,230,90,0.95) 18%, #28e65a 55%, #4ced78 100%);
  transform: rotate(calc(6.6deg * var(--fan))) translateZ(0);    animation-delay: 0.12s;
}
.ray.r5 { /* cyan   ~490nm */
  background: linear-gradient(90deg, rgba(40,200,255,0) 0%, rgba(40,200,255,0.95) 18%, #28c8ff 55%, #4cd4ff 100%);
  transform: rotate(calc(7.8deg * var(--fan))) translateZ(-2px); animation-delay: 0.16s;
}
.ray.r6 { /* blue   ~460nm */
  background: linear-gradient(90deg, rgba(60,80,255,0) 0%, rgba(60,80,255,0.95) 18%, #3c50ff 55%, #5466ff 100%);
  transform: rotate(calc(9deg   * var(--fan))) translateZ(-4px); animation-delay: 0.20s;
}
.ray.r7 { /* violet ~400nm */
  background: linear-gradient(90deg, rgba(170,50,255,0) 0%, rgba(170,50,255,0.95) 18%, #aa32ff 55%, #bc54ff 100%);
  transform: rotate(calc(10.2deg * var(--fan))) translateZ(-6px); animation-delay: 0.24s;
}
@keyframes ray-fade {
  0%,100% { opacity: 0.9; }
  50%     { opacity: 1; }
}

/* Projection wall — narrow, bright rainbow band where the fan lands */
.prism-wall {
  position: absolute;
  top: 50%;
  right: 2%;
  width: 10px;
  height: 200px;
  margin-top: -70px;
  background:
    linear-gradient(180deg,
      rgba(255,40,40,0)    0%,
      rgba(255,40,40,0.95) 10%,
      rgba(255,130,30,1)   25%,
      rgba(255,230,40,1)   40%,
      rgba(40,230,90,1)    55%,
      rgba(40,200,255,1)   70%,
      rgba(60,80,255,1)    85%,
      rgba(170,50,255,0.95) 95%,
      rgba(170,50,255,0)   100%);
  box-shadow:
    0 0 24px rgba(255,255,255,0.35),
    0 0 80px rgba(255,255,255,0.2);
  filter: blur(1.5px);
  mix-blend-mode: screen;
  transform: translateZ(10px) rotateY(calc(var(--px) * 4deg));
  border-radius: 6px;
  animation: wall-bloom 3s ease-in-out 0.6s infinite;
}
@keyframes wall-bloom {
  0%,100% { opacity: 0.75; filter: blur(1.5px); }
  50%     { opacity: 1;    filter: blur(2.5px); }
}

.prism-caption {
  position: absolute;
  left: 50%;
  top: 10%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 3;
  color: #f5efe4;
  letter-spacing: -0.03em;
}
.prism-caption .eyebrow {
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: inline-flex;
  gap: 12px;
}
.prism-caption h2 {
  font-family: var(--lw-font-serif);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(56px, 8vw, 104px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  margin: 0;
}
.prism-caption h2 em {
  font-style: italic;
  background: linear-gradient(90deg, #c65d3a, #d89945, #e8c65a, #7ba05b, #3a5a78, #7a45a5, #c13a88);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.prism-caption p {
  margin-top: 24px;
  color: rgba(255,255,255,0.7);
  font-size: 15px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
  letter-spacing: 0;
}

.prism-stage .particle {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px #fff, 0 0 12px rgba(255,255,255,0.5);
  opacity: 0;
  animation: particle-drift 8s ease-in-out infinite;
}
@keyframes particle-drift {
  0%   { opacity: 0; transform: translate(0,0) scale(0.5); }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(60px, -40px) scale(1.2); }
}
.prism-stage .particle:nth-child(1)  { top: 20%; left: 10%; animation-delay: 0s;   }
.prism-stage .particle:nth-child(2)  { top: 70%; left: 15%; animation-delay: 1.5s; }
.prism-stage .particle:nth-child(3)  { top: 30%; left: 35%; animation-delay: 3s;   }
.prism-stage .particle:nth-child(4)  { top: 80%; left: 60%; animation-delay: 4.5s; }
.prism-stage .particle:nth-child(5)  { top: 25%; left: 75%; animation-delay: 6s;   }
.prism-stage .particle:nth-child(6)  { top: 60%; left: 85%; animation-delay: 2.5s; }

.prism-meta {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 48px;
  font-family: var(--lw-font-mono);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.prism-meta span strong {
  color: #d89945;
  font-weight: 500;
}
