/* ─────────────────────────────────────────────────────────────
   SCROLL STORY
   Premium scroll-scrubbed product story for My Tradie App.
   Works alongside styles.css (which keeps the form styling).
   ───────────────────────────────────────────────────────────── */

:root {
  --story-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Story landing uses a dark canvas; override the light body default. */
body.story-landing {
  background: #1c2026;
  color: #fff;
}

/* Visibility is decided by JS once it knows the mode. Until then,
   show the stacked version so no-JS / slow-JS users still get content. */
#story { display: none; }
#story-stacked { display: block; }

body.mode-story #story { display: block; }
body.mode-story #story-stacked { display: none; }
body.mode-story .brand-bar { display: flex; }

body.mode-stacked #story { display: none; }
body.mode-stacked #story-stacked { display: block; }
body.mode-stacked .brand-bar { display: none; }

/* ─── FIXED BRAND BAR (story mode only, fades in after hero) ─── */
.brand-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(20px, 6vw, 64px);
  pointer-events: none;
}

.brand-mark {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  color: #fff;
  transform-origin: left center;
  will-change: transform, opacity;
}

.brand-mark .brand-dot {
  display: none;
}

.brand-mark .brand-word {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  color: #fff;
  white-space: nowrap;
}

.hero-brand-title {
  transform-origin: left center;
  max-width: min(100%, 38vw);
}

.brand-cta {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  transition: background 160ms ease, transform 160ms ease;
}

.brand-cta:hover { background: rgba(255, 255, 255, 0.18); transform: translateY(-1px); }
.brand-cta:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ─── PINNED STORY ─── */
.story {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

.story-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #1c2026;
}

.story-bg-layer {
  position: absolute;
  inset: -22% 0;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.035) 20%,
      rgba(0, 0, 0, 0.12) 80%,
      rgba(0, 0, 0, 0) 100%
    ),
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 0%,
      var(--stage-bg, #1c2026) 18%,
      var(--stage-bg, #1c2026) 82%,
      rgba(0, 0, 0, 0) 100%
    );
  mask-image: linear-gradient(180deg, transparent 0%, black 16%, black 84%, transparent 100%);
  will-change: transform, opacity;
}

/* Hero-only: faint blurred screenshot cards floating in the background.
   Sits outside the masked bg layer; fades with stage-0 exit. */
.hero-floaters {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.hero-floater {
  position: absolute;
  width: clamp(220px, 24vw, 420px);
  border-radius: 12px;
  opacity: 0.22;
  filter: blur(6px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  user-select: none;
  --drift-x: 0vw;
  --drift-y: 0vh;
}

.hero-floater--top {
  top: 12%;
  left: 18%;
  width: clamp(280px, 36vw, 540px);
  opacity: 0.24;
  transform: translate(var(--drift-x), var(--drift-y)) rotate(200deg);
  transform-origin: 50% 0%;
}

.hero-floater--right {
  top: 29%;
  right: -5%;
  transform: translate(var(--drift-x), var(--drift-y)) rotate(45deg);
  transform-origin: 100% 55%;
}

.hero-floater--br {
  bottom: 12%;
  right: -14%;
  transform: translate(var(--drift-x), var(--drift-y)) rotate(340deg);
}

/* Static transparent decor on the left — fades into stage colour */
.story-bg-decor {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.story-bg-decor__left {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 95%;
  transform: translateX(-20%);
  opacity: 0.12;
  object-fit: cover;
  object-position: left center;
  -webkit-mask-image: linear-gradient(90deg, #fff 0%, rgba(255, 255, 255, 0.6) 18%, transparent 62%);
  mask-image: linear-gradient(90deg, #fff 0%, rgba(255, 255, 255, 0.6) 18%, transparent 62%);
  user-select: none;
}

/* soft radial glow, parallaxed slower than the foreground for depth.
   A real element (not ::after) so GSAP can transform it. */
.story-glow {
  position: absolute;
  inset: -12%;
  z-index: 2;
  background:
    radial-gradient(55% 55% at 78% 28%, rgba(255, 255, 255, 0.11), transparent 62%),
    radial-gradient(45% 45% at 14% 78%, rgba(255, 255, 255, 0.04), transparent 58%),
    radial-gradient(50% 50% at 12% 80%, rgba(0, 0, 0, 0.32), transparent 60%);
  pointer-events: none;
  will-change: transform;
}

.story-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 clamp(20px, 6vw, 64px);
  display: grid;
  grid-template-columns: 40% 55%;
  gap: 5%;
  align-items: center;
}

/* LEFT: stacked panels that crossfade */
.story-left {
  position: relative;
  z-index: 2;
  height: 64vh;
}

.story-panels {
  position: relative;
  height: 100%;
}

.story-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  will-change: opacity, transform;
}

.story-eyebrow {
  margin: 0 0 18px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--stage-accent, #6ea8ff);
}

.story-title {
  margin: 0;
  font-weight: 700;
  font-size: clamp(2rem, 3.4vw, 3.3rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: #fff;
}

.story-body {
  margin: 22px 0 0;
  max-width: 46ch;
  font-size: clamp(1rem, 1.15vw, 1.18rem);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.72);
}

.story-tagline {
  margin: 18px 0 0;
  font-weight: 600;
  font-size: clamp(1.2rem, 2vw, 1.9rem);
  line-height: 1.4;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.92);
  transform-origin: left top;
  max-width: min(100%, 28vw);
}

/* Hero panel: oversized brand title */
.story-panel.is-hero .story-title {
  font-size: clamp(3rem, 8vw, 7rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.story-bullets {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  display: grid;
  gap: 18px;
  width: fit-content;
  grid-template-columns: repeat(2, 200px);
  grid-auto-rows: 200px;
  --block-text: rgba(255, 255, 255, 0.82);
  --block-border: rgba(255, 255, 255, 0.82);
}

.story-bullets li {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 200px;
  padding: 20px;
  box-sizing: border-box;
  background: transparent;
  border: 2px dashed var(--block-border);
  border-radius: 6px;
  box-shadow: none;
}

.story-bullet-label {
  display: block;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--block-text);
}

/* 3 blocks: corner, below, to the side — no overlap
   [1] [3]
   [2]     */
.story-bullets:has(> li:nth-child(3):last-child) > li:nth-child(1) { grid-area: 1 / 1; }
.story-bullets:has(> li:nth-child(3):last-child) > li:nth-child(2) { grid-area: 2 / 1; }
.story-bullets:has(> li:nth-child(3):last-child) > li:nth-child(3) { grid-area: 1 / 2; }

/* 4 blocks: 2 above, 2 below */
.story-bullets:has(> li:nth-child(4):last-child) > li:nth-child(1) { grid-area: 1 / 1; }
.story-bullets:has(> li:nth-child(4):last-child) > li:nth-child(2) { grid-area: 1 / 2; }
.story-bullets:has(> li:nth-child(4):last-child) > li:nth-child(3) { grid-area: 2 / 1; }
.story-bullets:has(> li:nth-child(4):last-child) > li:nth-child(4) { grid-area: 2 / 2; }

.story-bullets li::before {
  display: none;
}

.story-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 30px;
}

/* RIGHT: 3D product scene */
.story-right {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 78vh;
  perspective: 1500px;
  perspective-origin: 60% 42%;
}

.story-scene {
  position: relative;
  width: min(100%, 960px);
  height: min(78vh, 750px);
  transform-style: preserve-3d;
  will-change: transform;
}

.scene-grid {
  position: absolute;
  inset: -8%;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(circle at 55% 45%, black, transparent 72%);
  transform: translateZ(-360px) rotateX(58deg);
  pointer-events: none;
  will-change: transform;
}

.story-card {
  position: absolute;
  left: 2%;
  top: 50%;
  z-index: 1;
  width: min(98%, 900px);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 34px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.035),
    0 0 70px -28px var(--stage-accent, #6ea8ff);
  transition: box-shadow 600ms var(--story-ease);
  transform-style: preserve-3d;
  transform-origin: center center;
  backface-visibility: hidden;
  will-change: opacity, transform, filter;
}

.story-card .shot-fallback {
  position: relative;
  aspect-ratio: 16 / 10;
}

.app-window-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  background: #0d1a2c;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-window-bar .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #2b3b52;
}
.app-window-bar .dot.red { background: #ff5f57; }
.app-window-bar .dot.amber { background: #febc2e; }
.app-window-bar .dot.green { background: #28c840; }

.app-window-title {
  margin-left: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
}

.app-window-body {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #0a1422;
  transform-style: preserve-3d;
}

.story-shot img {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
}

.shot-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
  color: rgba(255, 255, 255, 0.55);
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.03),
      rgba(255, 255, 255, 0.03) 12px,
      rgba(255, 255, 255, 0.06) 12px,
      rgba(255, 255, 255, 0.06) 24px
    );
}

.shot-fallback strong { font-size: 0.95rem; color: rgba(255, 255, 255, 0.8); }
.shot-fallback span { font-size: 0.8rem; word-break: break-all; }

.story-shot.is-missing img { display: none; }
.story-shot.is-missing .shot-fallback { display: flex; }
.stacked-shot .app-window-body.is-missing img { display: none; }
.stacked-shot .app-window-body.is-missing .shot-fallback { display: flex; }

/* minimal vertical workflow step indicator (story mode only) */
.story-steps {
  position: absolute;
  right: clamp(14px, 1.8vw, 28px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
}

.story-steps li {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  opacity: 0.38;
  transition: opacity 400ms var(--story-ease);
}

.story-steps li .lbl {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 400ms var(--story-ease), transform 400ms var(--story-ease);
}

.story-steps li .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transition: background 400ms var(--story-ease), transform 400ms var(--story-ease), box-shadow 400ms var(--story-ease);
}

.story-steps li.is-active { opacity: 1; }
.story-steps li.is-active .lbl { opacity: 1; transform: translateX(0); }
.story-steps li.is-active .dot {
  background: var(--stage-accent, #6ea8ff);
  transform: scale(1.3);
  box-shadow: 0 0 14px var(--stage-accent, #6ea8ff);
}

/* First-paint guards: GSAP controls panel visibility after init.
   Only hide non-hero panels until GSAP sets inline styles. */
body.mode-story #story .story-panel:not(.is-hero) {
  visibility: hidden;
}
body.mode-story #story .story-panel.is-hero {
  visibility: visible;
}
body.mode-story #story-scene .story-card { opacity: 0; }
body.mode-story #story-scene #shot-0 { opacity: 1; }
body.mode-story .brand-cta { opacity: 0; }

/* progress hint at the bottom of the pinned scene */
.story-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.08);
}

.story-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--stage-accent, #6ea8ff);
  transition: background 600ms var(--story-ease);
}

/* ─── CTA BUTTONS (shared, dark theme) ─── */
.story-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 14px 26px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.story-button:hover { transform: translateY(-2px); }
.story-button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.story-button.primary {
  color: #06121f;
  background: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.story-button.primary:hover { background: #eaf1ff; }

.story-button.ghost {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}
.story-button.ghost:hover { background: rgba(255, 255, 255, 0.16); }

/* ─── STACKED FALLBACK (mobile / reduced motion) ─── */
.story-stacked {
  position: relative;
  padding: 0 0 40px;
}

.stacked-header {
  position: relative;
  overflow: hidden;
  padding: clamp(64px, 12vh, 120px) clamp(20px, 6vw, 64px) 40px;
  text-align: left;
  background: #1c2026;
}

.stacked-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--story-bg-decor-image, url("public/screenshots/background-image.jpg")) no-repeat -20% center / cover;
  opacity: 0.12;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, #fff 0%, rgba(255, 255, 255, 0.6) 18%, transparent 62%);
  mask-image: linear-gradient(90deg, #fff 0%, rgba(255, 255, 255, 0.6) 18%, transparent 62%);
}

.stacked-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: clamp(2.4rem, 9vw, 4rem);
  letter-spacing: -0.04em;
  margin: 0;
}

.stacked-tagline {
  margin: 16px 0 0;
  font-size: clamp(1.2rem, 5vw, 1.7rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
}

.stacked-lead {
  margin: 14px 0 0;
  max-width: 52ch;
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.7);
}

.stacked-list {
  display: grid;
  gap: 18px;
  padding: 0 clamp(20px, 6vw, 64px);
}

.stacked-card {
  padding: 24px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stacked-card .story-eyebrow { margin-bottom: 12px; }

.stacked-card h2 {
  margin: 0;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #fff;
}

.stacked-card p {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.6;
}

.stacked-card .story-bullets { margin-top: 18px; }

.stacked-shot {
  margin-top: 20px;
  border-radius: 14px;
  overflow: hidden;
  background: #0a1422;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stacked-shot .app-window-bar { border-radius: 0; }

.stacked-shot .app-window-body {
  aspect-ratio: 16 / 10;
}

.stacked-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 22px;
}

/* ─── REQUEST ACCESS SECTION (wraps existing form) ─── */
.access-section {
  position: relative;
  background: #050b14;
  padding: clamp(64px, 12vh, 120px) clamp(20px, 6vw, 64px);
}

.access-section .access-head {
  max-width: 560px;
  margin: 0 auto 28px;
  text-align: center;
}

.access-section .access-head .story-eyebrow {
  --stage-accent: #6ea8ff;
}

.access-section .access-head h2 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.03em;
  color: #fff;
}

.access-section .access-head p {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
}

/* The form keeps its light card styling from styles.css. */
.access-section .container { margin: 0 auto; }

.story-footer {
  padding: 30px clamp(20px, 6vw, 64px) 40px;
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.85rem;
}

.story-footer a { color: rgba(255, 255, 255, 0.7); text-decoration: underline; text-underline-offset: 3px; }

.story-footer-links {
  margin: 10px 0 0;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1100px) {
  .story-inner { grid-template-columns: 42% 53%; gap: 4%; }
}

/* Below ~900px we never use the pinned story (JS enforces this too). */
@media (max-width: 900px) {
  #story { display: none !important; }
  #story-stacked { display: block !important; }
  .brand-bar { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .story-button:hover,
  .brand-cta:hover,
  .button:hover { transform: none; }
}
