/* ==========================================
   RESET & BASE
   ========================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Locks scroll while the gem GLBs are still downloading — see the
   gem-preloader block below and js/gem-viewer.js, which removes this
   class once every gem-canvas has resolved. */
body.is-gem-loading {
  overflow: hidden;
  height: 100vh;
}

:root {
  /* ── Colour tokens ──────────────────────────────────────────
     Adjust these to match the real brand palette.
  ──────────────────────────────────────────────────────────── */
  --clr-bg:            #000000;       /* pure black — used for intro/outro  */
  --clr-pinned-bg:     #050508;       /* very slightly tinted for pin area  */
  --clr-text-primary:  #ffffff;
  --clr-text-muted:    rgba(255,255,255,0.5);
  --clr-accent:        #6c63ff;       /* purple — eyebrow labels, accents   */
  --clr-accent-alt:    #00d4ff;       /* cyan — service number labels       */
  --clr-fuse:          rgba(255,255,255,0.15);
  --clr-glow:          #7b74ff;       /* fuse glow dot colour               */

  /* ── Image container ─────────────────────────────────────
     The graphic images (sphere/diamond/star) sit inside this.
     No border-radius or clipping — they float as objects.
     Adjust --image-size to scale the central graphic up/down.
  ──────────────────────────────────────────────────────────── */
  --image-size:        380px;

  /* ── Layout ─────────────────────────────────────────────── */
  --fuse-x:            50vw;
  --fuse-width:        1px;

  /* ── Service block column width (S1 right rail, S2 corners) */
  --svc-col-width:     300px;

  /* ── How far a service block may drift from the centred gem on
     wide screens. right:6% / left:6% alone scale with viewport width,
     so on ultra-wide monitors the blocks end up hundreds of px from
     the gem — every service-block position rule below clamps against
     this fixed px offset instead of letting the percentage run away. */
  --svc-max-offset:    250px;
}

/* ==========================================
   BACKGROUND CANVAS — Three.js flying card
   Fixed fullscreen, behind all content.
   ========================================== */

#bg-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

html { scroll-behavior: auto; }

body {
  background-color: var(--clr-bg);
  color: var(--clr-text-primary);
  font-family: 'BrandonGrotesque', sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}


/* ==========================================
   TYPOGRAPHY HELPERS
   ========================================== */

/* Small uppercase spaced label — used above headings and for service numbers */
.eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--clr-accent);
}

/* Main section heading — matches the wide-spaced uppercase style in reference */
.section-heading {
  font-size: clamp(0.85rem, 1.2vw, 1.05rem);
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--clr-text-primary);
  white-space: nowrap;  /* prevents wrapping on the fuse line */
}

/* Service label — e.g. "SERVICE 01" */
.svc-label {
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--clr-accent-alt);
  margin-bottom: 0.5rem;
}

/* Service name — medium-weight subheading */
.svc-name {
  font-size: 1.22rem;
  font-weight: 600;
  color: var(--clr-text-primary);
  margin-bottom: 0.55rem;
  letter-spacing: 0.01em;
}

/* Service description body copy */
.svc-desc {
  font-size: 1.02rem;
  color: var(--clr-text-muted);
  line-height: 1.65;
}


/* ==========================================
   FUSE LINE
   Fixed dead-centre of viewport.
   ========================================== */

.fuse-track {
  position: fixed;
  top: 0;
  left: var(--fuse-x);
  transform: translateX(-50%);
  width: var(--fuse-width);
  height: 100vh;
  z-index: 100;
  pointer-events: none;
  /* Hidden by default — JS fades it in when the pin locks.
     Do not set opacity here; JS owns this value. */
  opacity: 0;
}

.fuse-line {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    var(--clr-fuse) 15%,
    var(--clr-fuse) 85%,
    transparent 100%
  );
}

.fuse-glow {
  /* The travelling dot. GSAP moves its `top` value via scroll scrub.
     Adjust width/height to change bloom size.
     Adjust box-shadow spreads to change glow radius.            */
  position: absolute;
  left: 50%;
  top: 0%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--clr-glow);
  box-shadow:
    0 0  6px 2px var(--clr-glow),
    0 0 20px 5px rgba(123,116,255,0.45),
    0 0 50px 10px rgba(123,116,255,0.15);
}

/* Trailing tail behind the glow dot */
.fuse-glow::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  width: 1px;
  height: 60px;           /* ← tail length; adjust freely */
  background: linear-gradient(to top, var(--clr-glow), transparent);
}


/* ==========================================
   DEBUG OVERLAY
   ========================================== */

.debug-overlay {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  background: rgba(0,0,0,0.9);
  border: 1px solid var(--clr-accent);
  border-radius: 6px;
  padding: 0.8rem 1.2rem;
  font-size: 0.72rem;
  font-family: monospace;
  color: var(--clr-accent-alt);
  display: none;
  min-width: 200px;
}

.debug-overlay.is-active { display: block; }

.debug-row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.2rem 0;
}

.debug-row span:first-child { color: var(--clr-text-muted); }


/* ==========================================
   INTRO SECTION
   Pure black. Full viewport. Normal flow.
   ========================================== */

.section-intro {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  background: #000;       /* ← pure black, no gradient */
}

.intro-inner {
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}

.intro-inner h1 {
  font-size: clamp(2.8rem, 6vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: #fff;
}

.intro-sub {
  font-size: 1rem;
  color: rgba(255,255,255,0.45);
  max-width: 44ch;
}

/* Animated scroll indicator */
.scroll-indicator {
  width: 22px;
  height: 38px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 11px;
  display: flex;
  justify-content: center;
  padding-top: 6px;
  margin-top: 1.5rem;
}

.scroll-indicator span {
  display: block;
  width: 2px;
  height: 7px;
  background: rgba(255,255,255,0.5);
  border-radius: 2px;
  animation: scrollBounce 1.7s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); opacity: 1; }
  75%       { transform: translateY(13px); opacity: 0; }
}


/* ==========================================
   PINNED WRAPPER
   Exact 100vh — ScrollTrigger pins it here.
   All story sections position:absolute inside.
   ========================================== */

.pinned-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
  overflow: visible;   /* allows final image to scale beyond bounds */
  background: transparent;   /* background canvas shows through */
}


/* ==========================================
   CENTRE IMAGE CONTAINER
   Absolutely centred. No clipping — the graphic
   images float as objects, not inside a card frame.
   ========================================== */

.image-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--image-size);
  height: var(--image-size);
  z-index: 10;
  opacity: 0;   /* hidden until GSAP entrance runs — avoids FOUC stack-flash of all 3 layers */
  /* No border-radius, no overflow:hidden — graphics float freely */
}

/* Layers 2/3/4 stay hidden until GSAP drives their transitions in —
   prevents them showing through layer 1's transparent PNG areas before JS runs. */
#imgLayer2, #imgLayer3, #imgLayer4 { opacity: 0; }

.img-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Real graphic image — fill the container, preserve aspect ratio */
.img-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;  /* contain = show full image without cropping */
  display: block;
  position: relative;
  z-index: 2;
}

/* 3D gem viewport — same footprint as the old graphic image */
.img-layer canvas.gem-canvas {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 2;
}

/* Placeholder — visible while real image is absent.
   A simple glowing circle that suggests the graphic shape. */
.img-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  z-index: 1;
}

/* Each placeholder has a distinct glow tint to distinguish sections */
.img-placeholder--1::before {
  content: '';
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(108,99,255,0.25) 0%, transparent 70%);
  border: 1px solid rgba(108,99,255,0.3);
}

.img-placeholder--2::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  background: radial-gradient(ellipse, rgba(0,100,200,0.22) 0%, transparent 70%);
  border: 1px solid rgba(0,100,200,0.25);
  transform: rotate(45deg);  /* diamond shape */
}

.img-placeholder--3::before {
  content: '';
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,180,160,0.2) 0%, transparent 70%);
  border: 1px solid rgba(0,180,160,0.25);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* z-index stack: layer 1 on top initially */
#imgLayer1 { z-index: 4; }
#imgLayer2 { z-index: 3; }
#imgLayer3 { z-index: 2; }
#imgLayer4 { z-index: 1; }

/* ── Explosion canvas ─────────────────────────────────────────
   Fixed + centred, covering the full viewport. Fades in showing
   gem4 as an assembled shard cluster once gem4 has grown to full
   size, then the burst + settle-into-carousel is scrubbed by
   scroll — see CONFIG.zoom / buildExplodeTL in js/main.js and
   js/gem-explosion.js. z-index above the fuse track (100) so it
   fully covers the scene; below the debug overlay (9999). */
.explosion-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  opacity: 0;
  pointer-events: none;
  z-index: 150;
}


/* ==========================================
   STORY SECTIONS — shared base
   All position:absolute, filling pinned wrapper.
   opacity:0 by default; GSAP drives visibility.
   ========================================== */

.story-section {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;   /* GSAP controls this per-section */
}

/* ── Section title wrap ──────────────────────
   Centred horizontally, sits on the fuse line
   just below the central image.
   Top offset: 50% (viewport centre) + half image
   height + gap. Adjust --title-gap to move it.  */
.section-title-wrap {
  --title-gap: 24px;   /* gap between bottom of image and title */
  position: absolute;
  left: 50%;
  top: calc(50% + var(--image-size) / 2 + var(--title-gap));
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;          /* animated by GSAP */
}


/* ==========================================
   SECTION 1 — Platform & Systems
   Reference: section1.jpg
   Services stacked in right column: 03 → 02 → 01
   ========================================== */

/* Right-side service rail */
.s1-services {
  position: absolute;
  /* 6% of viewport on narrow/medium screens; on wide screens this
     switches to holding a constant --svc-max-offset gap from the
     centred gem instead of continuing to scale with viewport width. */
  right: max(6%, calc(50% - var(--svc-max-offset) - var(--svc-col-width)));
  top: 50%;
  transform: translateY(-50%);
  width: var(--svc-col-width);
  display: flex;
  flex-direction: column;
  gap: 2.8rem;           /* ← gap between stacked services    */
}

/* Individual service blocks within the right rail */
.s1-services .service-block {
  opacity: 0;            /* GSAP animates each block in        */
}


/* ==========================================
   SECTION 2 — Integration & Automation
   Reference: section2.jpg
   SERVICE 03: top-right | 01: bottom-left | 02: bottom-right
   ========================================== */

/* Shared base for all S2 service blocks */
.s2-svc {
  position: absolute;
  width: var(--svc-col-width);
  opacity: 0;            /* GSAP animates in                   */
}

/* SERVICE 03 — top-right quadrant.
   Adjust `right` and `top` to fine-tune position. Same wide-screen
   clamp as .s1-services — see --svc-max-offset. */
.s2-svc--tr {
  right: max(6%, calc(50% - var(--svc-max-offset) - var(--svc-col-width)));
  top: 14%;
}

/* SERVICE 01 — bottom-left quadrant */
.s2-svc--bl {
  left: max(6%, calc(50% - var(--svc-max-offset) - var(--svc-col-width)));
  bottom: 16%;
}

/* SERVICE 02 — bottom-right quadrant */
.s2-svc--br {
  right: max(6%, calc(50% - var(--svc-max-offset) - var(--svc-col-width)));
  bottom: 16%;
}


/* ==========================================
   SECTION 3 — Creative & Interaction
   Reference: section3.jpg
   Services in a horizontal bottom row: 01 | 02 | 03
   ========================================== */

.s3-services-row {
  position: absolute;
  bottom: 10%;           /* ← distance from bottom of viewport */
  left: 50%;
  transform: translateX(-50%);
  width: 88%;
  /* Caps the row's own width on wide screens instead of letting
     space-around spread the outer two blocks further and further
     from the centred gem as the viewport grows. */
  max-width: calc(2 * (var(--svc-max-offset) + 320px) + var(--image-size));
  display: flex;
  justify-content: space-around;
  gap: 2rem;
  /* Perspective enables the 3D rotateX drop-in on each child.
     Increase this value to reduce the 3D depth effect (flatter).
     Decrease it for a more dramatic tilt. 600–1200px is a good range. */
  perspective: 900px;
  perspective-origin: 50% 0%;  /* vanishing point at the top centre */
}

.s3-svc {
  flex: 1;
  max-width: 320px;
  opacity: 0;            /* GSAP animates in                   */
}

/* Centre column: nudge text to center */
.s3-svc:nth-child(2) {
  text-align: center;
}


/* ==========================================
   OUTRO SECTION
   Dark with subtle radial. Normal flow.
   ========================================== */

.section-outro {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  background: radial-gradient(ellipse 70% 50% at 50% 40%, #0a0a20 0%, #000 100%);
}

.outro-inner {
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}

.outro-inner h2 {
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.cta-btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.9rem 2.4rem;
  background: var(--clr-accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 3px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cta-btn:hover {
  opacity: 0.85;
  transform: translateY(-2px);
}


/* ==========================================
   RESPONSIVE — TABLET / MOBILE
   ========================================== */

@media (max-width: 900px) {
  :root {
    --image-size:     240px;
    --svc-col-width:  180px;
  }

  /* On mobile the right column would collide with the image;
     shift it to be a bottom row instead */
  .s1-services {
    position: absolute;
    right: auto;
    left: 0;
    right: 0;
    top: auto;
    bottom: 8%;
    transform: none;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    padding: 0 4%;
    gap: 1rem;
  }

  .s1-services .service-block {
    flex: 1;
    max-width: 160px;
  }

  /* S2 corners: stack them */
  .s2-svc--tr { right: 4%; top: 8%; }
  .s2-svc--bl { left: 4%; bottom: 10%; }
  .s2-svc--br { right: 4%; bottom: 10%; }

  .s3-services-row { bottom: 6%; padding: 0 3%; gap: 1rem; }

  .section-title-wrap {
    --title-gap: 16px;
  }
}

@media (max-width: 540px) {
  :root { --image-size: 200px; }

  .s2-svc--tr,
  .s2-svc--bl,
  .s2-svc--br { width: 140px; }

  .svc-name { font-size: 0.82rem; }
  .svc-desc { font-size: 0.74rem; }
}


/* ==========================================
   GEM PRELOADER
   Fullscreen blocker shown until every gem GLB
   has resolved. js/gem-viewer.js drives the fill
   width + label text, then fades this out and
   removes body.is-gem-loading.
   ========================================== */
.gem-preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--clr-bg);
  transition: opacity 0.6s ease;
}

.gem-preloader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.gem-preloader__label {
  color: var(--clr-text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gem-preloader__bar {
  width: min(240px, 60vw);
  height: 2px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.gem-preloader__fill {
  width: 0%;
  height: 100%;
  background: var(--clr-glow);
  transition: width 0.2s ease-out;
}
