/* ═══════════════════════════════════════════
   KAI 3D: Kai is the chat button (bottom-right corner)
   Engine: js/kai-stage.js · Plan: docs/kai-3d-project.md
═══════════════════════════════════════════ */
#kai3d-root { position: fixed; inset: 0; z-index: 990; pointer-events: none; }
.kai3d-canvas {
  position: absolute; inset: 0; display: block;
  opacity: 0; transition: opacity .7s ease;
}
#kai3d-root.is-in .kai3d-canvas { opacity: 1; }

.kai3d-hit, .kai3d-approve {
  position: absolute; top: 0; left: 0;
  pointer-events: auto; cursor: pointer;
  background: transparent; border: 0; padding: 0; margin: 0;
  border-radius: 45% 45% 40% 40%;
}
.kai3d-approve { border-radius: 8px; z-index: 1; }
.kai3d-hit:focus-visible, .kai3d-approve:focus-visible {
  outline: 2px solid var(--blue, #2D5F8A); outline-offset: 4px;
}
.kai3d-hit[hidden], .kai3d-approve[hidden] { display: none; }

.kai3d-bubble {
  position: absolute;
  right: var(--kai-right, 24px); bottom: var(--kai-bottom, 140px);
  max-width: 240px;
  padding: 10px 14px 11px;
  background: #fff;
  color: var(--text, #1A1A1A);
  font: 500 14px/1.4 var(--font, Inter, sans-serif);
  border-radius: 14px 14px 4px 14px;
  box-shadow: var(--kd-2, 0 6px 20px rgba(15,30,60,.14));
  pointer-events: auto;
  opacity: 1; transition: opacity .35s ease;
  animation: kai3d-bubble-in .35s ease both;
}
.kai3d-bubble.is-link { cursor: pointer; }
.kai3d-ask {
  display: block; margin-top: 6px;
  font: 600 12px/1.3 var(--font, Inter, sans-serif);
  color: var(--blue, #2D5F8A); text-decoration: underline; text-underline-offset: 3px;
}
.kai3d-bubble.is-link:hover { box-shadow: var(--kd-3, 0 10px 28px rgba(15,30,60,.18)); }
@keyframes kai3d-bubble-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.kai3d-bubble p { margin: 0; }
.kai3d-bubble.is-out, .kai3d-bubble.is-blocked { opacity: 0; pointer-events: none; }
.kai3d-bubble[hidden] { display: none; }
.kai3d-hide {
  margin-top: 6px; padding: 0; border: 0; background: none;
  font: 500 12px/1.4 var(--font, Inter, sans-serif);
  color: var(--text-mid, #555); text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.kai3d-debug { position: absolute; inset: 0; pointer-events: none; }

/* Once Kai has come out of it, the chat button steps aside: Kai is the button. */
#kai-widget .kai-trigger { transition: opacity .35s ease, transform .35s ease, visibility 0s linear 0s; }
body.kai3d-on #kai-widget .kai-trigger {
  opacity: 0; transform: scale(.6); visibility: hidden; pointer-events: none;
  transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
}
/* While the chat is open, Kai stays (smaller, looking up at the panel); clicking him closes it. The panel has its own close button. */

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

/* Room at the end of the page so nothing sits under Kai in his corner. */
body.clarity-home footer, body.clarity-audit-report footer { padding-bottom: 150px; }
@media (max-width: 767px) { body.clarity-home footer, body.clarity-audit-report footer { padding-bottom: 104px; } }

/* ═══════════════════════════════════════════
   A LIGHT SENSE OF DEPTH (homepage only)
   One light from the top left, same as Kai's key light.
   Shadows fall down and to the right. Text is never transformed in 3D.
═══════════════════════════════════════════ */
:root {
  --kd-ink: 15, 30, 60;
  --kd-1: 1px 1px 1px rgba(var(--kd-ink), .05), 2px 3px 8px -3px rgba(var(--kd-ink), .12);
  --kd-2: 1px 2px 2px rgba(var(--kd-ink), .04), 6px 12px 28px -12px rgba(var(--kd-ink), .20);
  --kd-3: 2px 3px 3px rgba(var(--kd-ink), .04), 12px 26px 54px -20px rgba(var(--kd-ink), .26);
  --kd-edge: inset 0 1px 0 rgba(255, 255, 255, .9);
}

/* Cards sit one step off the back wall. */
.home-services .service-paths > div,
.home-services .hp-insights-grid > a {
  box-shadow: var(--kd-edge), var(--kd-1);
  transition: box-shadow .3s ease, transform .3s ease;
}
.home-services .workday-teaser,
.home-services .hero-proof,
.home-services .lab-output {
  box-shadow: var(--kd-edge), var(--kd-2);
}
.home-services .scan-report { box-shadow: var(--kd-3); }

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .home-services .service-paths > div:hover,
  .home-services .hp-insights-grid > a:hover {
    box-shadow: var(--kd-edge), var(--kd-2);
    transform: translateY(-2px);
  }
}

/* A soft pool of light from the top left on the dark sections. */
.home-services .hero::after,
.home-services .final-cta::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 90% at 12% -10%, rgba(255, 255, 255, .075), transparent 62%);
  pointer-events: none;
}
.home-services .final-cta { position: relative; overflow: hidden; }
.home-services .final-cta > * { position: relative; z-index: 1; }

/* ── Depth in motion (js/kai-depth.js). Off for reduced motion. ── */

/* Objects: settle flat on the way in, lean toward the pointer. Text blocks are never tilted. */
.kd-rel { position: relative; }
.kd-obj.is-live {
  transform: perspective(1100px) rotateX(calc(var(--kd-rx, 0) * 1deg)) rotateY(calc(var(--kd-ry, 0) * 1deg));
  transform-origin: 50% 62%;
  will-change: transform;
  /* the shadow slides away from the side that lifts */
  box-shadow:
    var(--kd-edge),
    calc(6px - var(--kd-ry, 0) * 2.4px) calc(13px + var(--kd-rx, 0) * 3px) calc(30px + var(--kd-rx, 0) * 4px) -13px rgba(var(--kd-ink), .24);
}
.kd-glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at calc(50% + var(--kd-ry, 0) * 14%) calc(42% - var(--kd-rx, 0) * 14%), rgba(255, 255, 255, .55), transparent 58%);
  mix-blend-mode: soft-light;
  opacity: var(--kd-g, 0);
}

/* Background in two layers behind each tinted section. They lag behind the content while scrolling. */
.kd-sec { position: relative; isolation: isolate; overflow: clip; }
.kd-back { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.kd-far, .kd-mid {
  position: absolute; left: 0; right: 0;
  top: calc(var(--kd-room, 160px) * -1); bottom: calc(var(--kd-room, 160px) * -1);
  will-change: transform;
}
/* far: a fine dot grid that fades out toward the text column */
.kd-far {
  background-image: radial-gradient(circle, var(--kd-dot) 1.1px, transparent 1.6px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 62% 58% at var(--kd-at, 82%) 46%, #000 8%, transparent 74%);
  mask-image: radial-gradient(ellipse 62% 58% at var(--kd-at, 82%) 46%, #000 8%, transparent 74%);
}
/* mid: one large soft field of light */
.kd-mid { background: radial-gradient(ellipse 46% 40% at var(--kd-at, 82%) 62%, var(--kd-pool), transparent 70%); }
.kd-back--left { --kd-at: 16%; }
.kd-back--light { --kd-dot: rgba(var(--kd-ink), .16); --kd-pool: rgba(255, 255, 255, .62); }
.kd-back--dark { --kd-dot: rgba(255, 255, 255, .17); --kd-pool: rgba(96, 140, 255, .15); }
@media (max-width: 767px) {
  .kd-far { background-size: 22px 22px; -webkit-mask-image: radial-gradient(ellipse 110% 46% at 70% 40%, #000 0, transparent 78%); mask-image: radial-gradient(ellipse 110% 46% at 70% 40%, #000 0, transparent 78%); }
  .kd-back--light { --kd-dot: rgba(var(--kd-ink), .11); }
  .kd-back--dark { --kd-dot: rgba(255, 255, 255, .12); }
}

/* ── Hero stage (js/kai-depth.js): the comparison card lies on the three supplier quotes it summarises. ── */
.kd-stage {
  position: relative;
  transform-style: preserve-3d;
  transform: perspective(1300px) rotateX(calc(var(--kd-rx, 0) * 1deg)) rotateY(calc(var(--kd-ry, 0) * 1deg));
  transform-origin: 50% 55%;
}
.kd-stage.kd-obj.is-live { box-shadow: none; will-change: transform; }
.kd-stage > .workday-teaser {
  transform-style: preserve-3d;
  transform: translateZ(0);
  /* the card's shadow falls on the hero and slides away from the side that lifts */
  box-shadow:
    inset 0 1px 0 #fff,
    calc(10px - var(--kd-ry, 0) * 5px) calc(28px + var(--kd-rx, 0) * 5px) 60px -10px rgba(4, 12, 32, .55),
    calc(3px - var(--kd-ry, 0) * 1.5px) calc(8px + var(--kd-rx, 0) * 1.5px) 16px -6px rgba(4, 12, 32, .35);
}
/* the three paper quotes now sit behind the card, so the small icon is not needed */
.kd-hero .kd-stage .supplier-documents { display: none; }
.kd-hero .kd-stage .supplier-board { grid-template-columns: minmax(0, 1fr); }

/* depth inside the card: the comparison sits on its own raised layer, its tags a step higher */
.kd-stage .supplier-board {
  transform-style: preserve-3d;
  transform: translateZ(26px);
  box-shadow: calc(2px - var(--kd-ry, 0) * 2px) calc(6px + var(--kd-rx, 0) * 2px) 16px -6px rgba(23, 49, 101, .28);
}
.kd-stage .supplier-matrix { transform: translateZ(10px); box-shadow: calc(1px - var(--kd-ry, 0) * 1.2px) calc(3px + var(--kd-rx, 0) * 1.2px) 8px -3px rgba(23, 49, 101, .22); }
.kd-stage .supplier-matrix td span:is(.scope-included, .scope-confirm) {
  box-shadow: calc(0px - var(--kd-ry, 0) * .7px) calc(1px + var(--kd-rx, 0) * .7px) 2px rgba(23, 49, 101, .22), inset 0 1px 0 #ffffffb0;
}

/* the quotes: one sheet per supplier, fanned out behind the card. Each peeks out at the top with its
   letterhead colour and its label (Offer A, B, C), so they read as three different documents. */
.kd-sheet {
  position: absolute; inset: 0;
  border-radius: 12px;
  background: #f7f6f2;
  border-top: 4px solid var(--kd-ink-sheet, #8fa6d1);
  pointer-events: none;
  box-shadow: 4px 14px 30px -12px rgba(4, 12, 32, .55);
}
.kd-sheet-head {
  position: absolute; top: 5px; right: 16px;
  font: 600 .7rem/1 Inter, system-ui, sans-serif; letter-spacing: .01em;
  color: var(--kd-ink-sheet, #4b5f86);
}
.kd-sheet-head::before {   /* the supplier's logo mark */
  content: ''; display: inline-block; width: 9px; height: 9px; margin-right: 6px; vertical-align: -1px;
  border-radius: 2px; background: currentColor; opacity: .75;
}
.kd-sheet--1 { --kd-ink-sheet: #2f5fbf; transform: translate3d(14px, -20px, -16px) rotate(-.6deg); }
.kd-sheet--2 { --kd-ink-sheet: #b46a2a; transform: translate3d(28px, -40px, -32px) rotate(-1.2deg); filter: brightness(.95); }
.kd-sheet--3 { --kd-ink-sheet: #2f8f7a; transform: translate3d(42px, -60px, -48px) rotate(-1.8deg); filter: brightness(.9); }

/* hero background in layers: the diagonal bands drift a little with the pointer and scroll */
.kd-hero .home-offers::before {
  inset: -40px;
  transform: translate3d(calc(var(--kd-px, 0) * -8px), calc(var(--kd-py, 0) * -6px + var(--kd-sy, 0) * 1px), 0);
}

@media (max-width: 900px) {
  /* stacked layout: smaller offsets so the sheets stay inside the screen */
  /* stacked layout: room above the card for the three tabs, smaller offsets so they stay on screen */
  .kd-stage { margin-top: 44px; }
  .kd-sheet--1 { transform: translate3d(3px, -16px, -10px) rotate(-.3deg); }
  .kd-sheet--2 { transform: translate3d(6px, -32px, -20px) rotate(-.6deg); }
  .kd-sheet--3 { transform: translate3d(9px, -48px, -30px) rotate(-.9deg); }
  .kd-sheet-head { right: 22px; top: 4px; font-size: .7rem; }
}
@media (prefers-reduced-motion: reduce) {
  .kd-hero .home-offers::before { transform: none; }
}
