/* ============================================================================
   the-story.css — "The Story" page.
   Reuses the design tokens on :root in home.css (loaded before this), plus the
   .sg-body nav/footer chrome from scenarios.css. Adds the story layout and the
   permanently-animated "flying shopping carts" WhatsApp client in the hero.
   ========================================================================== */

/* Base + nav chrome (mirrors scenarios.css so the pages read as one site). */
.sg-body { background: var(--ivory); color: var(--text-primary); font-family: "DM Sans", system-ui, sans-serif; margin: 0; }
.sg-body nav {
  background: rgba(4, 58, 60, 0.92);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border-glass);
}
.sg-body .nav-links a.is-active { color: #fff; background: rgba(255, 255, 255, 0.12); }

/* ═══════════════════ HERO ═══════════════════ */
.story-hero {
  position: relative;
  overflow: hidden;
  color: var(--ivory);
  /* Cothon artwork backdrop — same image + treatment as the scenarios hero, so
     the pages read as one brand. Left-weighted wash keeps the copy legible;
     the 72% image position crops out the "cartaja" wordmark baked into the
     image's left third (it would otherwise duplicate the nav logo). */
  background-color: var(--bg-darkest);
  background-image:
    radial-gradient(115% 92% at 22% 46%, rgba(4,58,60,0.55) 0%, rgba(4,58,60,0.30) 40%, transparent 72%),
    linear-gradient(95deg, rgba(4,58,60,0.94) 0%, rgba(6,94,97,0.82) 34%, rgba(10,138,142,0.5) 60%, rgba(4,58,60,0.58) 100%),
    url("../assets/cothon-shopping-cart-graphic.jpg");
  background-size: auto, auto, cover;
  background-position: center, center, 72% center;
  background-repeat: no-repeat, no-repeat, no-repeat;
  padding: clamp(56px, 7vh, 88px) clamp(20px, 4vw, 56px) clamp(64px, 8vh, 104px);
}
/* faint sailing-cart doodles are drawn by JS-free CSS below (.hero-sea) */
.story-hero__inner {
  position: relative;
  z-index: 3;
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(24px, 4vw, 64px);
  align-items: center;
}
.story-hero__copy { animation: hero-fade-up .8s cubic-bezier(.4,0,.2,1) both; }
.story-hero__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .78rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ivory); opacity: .85;
  padding: 6px 14px; border: 1px solid var(--border-glass); border-radius: 999px;
  background: rgba(255,255,255,.06);
}
.story-hero__title {
  font-family: "Bricolage Grotesque", "DM Sans", sans-serif;
  font-weight: 700; line-height: 1.02; letter-spacing: -0.02em;
  font-size: clamp(2.5rem, 6vw, 4.6rem);
  margin: 20px 0 0;
}
.story-hero__title em { font-style: normal; color: var(--terracotta); }
.story-hero__lede {
  margin-top: 20px; max-width: 46ch;
  font-size: clamp(1.05rem, 1.5vw, 1.28rem); line-height: 1.6; opacity: .92;
}
.story-hero__scroll {
  margin-top: 30px; display: inline-flex; align-items: center; gap: 8px;
  font-size: .82rem; letter-spacing: .12em; text-transform: uppercase; opacity: .7;
}
.story-hero__scroll .material-symbols-outlined { animation: bob-down 1.8s ease-in-out infinite; }
@keyframes bob-down { 0%,100%{transform:translateY(0)} 50%{transform:translateY(4px)} }

/* ── The animated stage: the HOMEPAGE 3D phone (css/demo.css .iphone-frame),
   with shopping carts sailing across its WhatsApp screen ── */
/* Grid cell that stacks the phone and the use-cases link beneath it. */
.story-stage-col {
  justify-self: center;
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(18px, 2.4vw, 30px);
}
.story-stage {
  perspective: 1600px;                 /* 3D context the .iphone-frame spin needs */
  display: flex; align-items: center; justify-content: center;
}
/* Contextual CTA under the demo — glass pill, mirrors the hero eyebrow. */
.story-stage-link {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--terracotta); text-decoration: none;
  font-size: .92rem; font-weight: 600;
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .6); background: rgba(255, 255, 255, .92);
  transition: background .18s ease, border-color .18s ease;
}
.story-stage-link:hover { background: #fff; border-color: #fff; }
.story-stage-link .material-symbols-outlined { font-size: 20px; transition: transform .18s ease; }
.story-stage-link:hover .material-symbols-outlined { transform: translateX(3px); }
/* Reuse the homepage phone verbatim; only turn its screen into a flex column
   wearing the WhatsApp wallpaper so our static chat + carts sit inside it. */
.story-stage .iphone-screen { display: flex; flex-direction: column; background: #ECE5DD; }
.iphone-status-bar .ios-icons .material-symbols-outlined { font-size: 18px; line-height: 1; opacity: .85; }

/* ── Live scenario-player emulator embedded in the hero phone ─────────────────
   js/story-emulator.js mounts commerceGenie's WhatsappEmulator widget into
   #story-emu and loops through journeys/manifest.json. Sizing mirrors the admin
   emulator.css, but is scoped to .story-emu so it can never collide with
   demo.css's 3D .iphone-frame. The widget self-loads whatsapp-emulator.css. */
.story-emu { flex: 1 1 auto; min-height: 0; }
.story-emu,
.story-emu .nui-wa-container { height: 100%; max-width: none; }
.story-emu .nui-wa-container { border-radius: 0; }
/* Drop the WhatsApp header clear of the iOS status bar (.iphone-status-bar is 46px). */
.story-emu .nui-wa-header { padding-top: 46px; }

/* Demo-only niceties ported from emulator.css. The story page doesn't load
   skin.css, so the Cartaja tokens are replaced with literal WhatsApp-green
   values. Verified tick + "the customer picked this" selection highlights. */
.story-emu .nui-wa-verified { color: #25d366; font-size: .85em; margin-left: .15em; }
.story-emu .nui-wa-list-row.is-selected { background: rgba(37, 211, 102, .12); }
.story-emu .nui-wa-list-row.is-selected .nui-wa-list-row-title { font-weight: 600; color: #111b21; }
.story-emu .nui-wa-list-row.is-selected .nui-wa-list-row-arrow { display: none; }
.story-emu .nui-wa-list-row.is-selected::after {
  content: "\f058"; font-family: "Font Awesome 6 Free"; font-weight: 900;
  color: #25d366; font-size: 1em; flex: 0 0 auto;
}
.story-emu .nui-wa-interactive-button.is-selected {
  background: rgba(37, 211, 102, .14); border-color: rgba(37, 211, 102, .45); font-weight: 600;
}
.story-emu .nui-wa-interactive-button.is-selected .nui-wa-btn-icon::before { content: "\f00c"; color: #25d366; }
.story-emu .nui-wa-carousel-btn.is-selected { background: rgba(37, 211, 102, .14); font-weight: 600; }
.story-emu .nui-wa-carousel-btn.is-selected::before {
  content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900;
  color: #25d366; font-size: .85em;
}
/* WhatsApp header */
.wa-header {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 58px 14px 10px; background: #F0F2F5; color: #111b21;  /* clear status bar + island */
}
.wa-av {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  background: var(--crimson); display: grid; place-items: center; overflow: hidden;
}
.wa-av img { width: 26px; height: 26px; }
.wa-name { font-weight: 700; font-size: .95rem; line-height: 1.1; }
.wa-status { font-size: .72rem; color: #667781; display: flex; align-items: center; gap: 5px; }
.wa-status::before { content:""; width: 7px; height: 7px; border-radius: 50%; background: #25D366; }
/* chat area — carts fly here, clipped */
.wa-chat {
  position: relative; flex: 1 1 auto; overflow: hidden; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 10px; justify-content: flex-end;
}
.wa-bubbles { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 8px; }
.wa-msg {
  max-width: 82%; padding: 8px 11px; border-radius: 12px; font-size: .84rem; line-height: 1.4;
  box-shadow: 0 1px 1px rgba(0,0,0,.08); color: #111b21;
}
.wa-in  { align-self: flex-start; background: #fff; border-top-left-radius: 3px; }
.wa-out { align-self: flex-end; background: #D9FDD3; border-top-right-radius: 3px; }
.wa-composer {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #F0F2F5;
}
.wa-composer .bar { flex: 1; height: 34px; border-radius: 20px; background: #fff; }
.wa-composer .send { width: 34px; height: 34px; border-radius: 50%; background: #25D366; display:grid; place-items:center; }
.wa-composer .send .material-symbols-outlined { color:#fff; font-size:19px; }

/* flying carts layer inside the chat */
.wa-carts { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.cart {
  position: absolute; top: 0; left: 0; width: 50px; height: 50px;
  will-change: transform;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.18));
}

/* three sailing paths, all heading "east across the sea" (left → right, up) */
@keyframes sail1 { 0%{transform:translate(-72px,600px) rotate(-9deg)} 100%{transform:translate(392px,-72px) rotate(9deg)} }
@keyframes sail2 { 0%{transform:translate(-72px,380px) rotate(7deg)} 50%{transform:translate(184px,280px) rotate(-5deg)} 100%{transform:translate(404px,404px) rotate(7deg)} }
@keyframes sail3 { 0%{transform:translate(-64px,200px) rotate(-6deg)} 100%{transform:translate(404px,64px) rotate(6deg)} }

/* per-cart resting state (shown when motion is reduced) + flight assignment */
.cart--1 { width: 58px; transform: translate(150px,250px) rotate(-3deg); animation: sail1 16s linear infinite; animation-delay: -2s; }
.cart--2 { width: 46px; transform: translate(80px,400px) rotate(4deg);   animation: sail2 20s linear infinite; animation-delay: -9s; opacity: .96; }
.cart--3 { width: 64px; transform: translate(210px,130px) rotate(2deg);  animation: sail3 24s linear infinite; animation-delay: -5s; }
.cart--4 { width: 42px; transform: translate(40px,160px) rotate(-6deg);  animation: sail1 27s linear infinite; animation-delay: -17s; opacity: .9; }
.cart--5 { width: 50px; transform: translate(250px,340px) rotate(5deg);  animation: sail2 14s linear infinite; animation-delay: -6s; }
.cart--6 { width: 40px; transform: translate(170px,500px) rotate(-4deg); animation: sail3 30s linear infinite; animation-delay: -21s; opacity: .85; }
/* ambient (behind phone) */
.stage-sea .cart--a { width: 132px; transform: translate(40px,540px) rotate(-8deg); animation: sail1 36s linear infinite; animation-delay: -4s; }
.stage-sea .cart--b { width: 108px; transform: translate(300px,150px) rotate(6deg); animation: sail3 42s linear infinite; animation-delay: -22s; }

/* ═══════════════════ NARRATIVE ═══════════════════ */
.story-section { padding: clamp(64px, 9vh, 116px) clamp(20px, 4vw, 56px); }
.story-wrap { max-width: 760px; margin: 0 auto; }
.story-wrap--wide { max-width: 1080px; }
.sec-ivory { background: var(--ivory); color: var(--text-primary); }
.sec-warm  { background: var(--ivory-warm); color: var(--text-primary); }
.sec-teal  {
  background:
    radial-gradient(120% 120% at 15% 0%, rgba(14,180,183,.4) 0%, transparent 60%),
    linear-gradient(160deg, var(--bg-deep), var(--bg-darkest));
  color: var(--ivory);
}
.story-kicker {
  font-size: .8rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--terracotta); margin-bottom: 14px;
}
.sec-teal .story-kicker { color: #6fe3d6; }
.story-h {
  font-family: "Bricolage Grotesque","DM Sans",sans-serif; font-weight: 700;
  line-height: 1.08; letter-spacing: -0.02em; color: var(--heading-color);
  font-size: clamp(1.9rem, 3.6vw, 3rem); margin-bottom: 22px;
}
.sec-teal .story-h { color: var(--ivory); }
.story-p { font-size: clamp(1.02rem, 1.35vw, 1.18rem); line-height: 1.72; margin-bottom: 18px; }
.story-p--lead { font-size: clamp(1.1rem, 1.6vw, 1.35rem); }
.sec-ivory .story-p, .sec-warm .story-p { color: #3a4a50; }
.sec-teal .story-p { opacity: .93; }
.story-p em { color: var(--terracotta); font-style: italic; }
.sec-teal .story-p em { color: #ffd9c6; }
.story-p strong { color: var(--heading-color); }
.sec-teal .story-p strong { color: #fff; }

/* the big "CART inside CARTaja" pull-quote band */
.cart-band { text-align: center; }
.cart-band__word {
  font-family: "Bricolage Grotesque","DM Sans",sans-serif; font-weight: 800;
  font-size: clamp(2.6rem, 9vw, 6rem); letter-spacing: -0.03em; line-height: 1;
  color: var(--ivory);
}
.cart-band__word b { color: var(--terracotta); }
.cart-band__line { margin: 26px auto 0; max-width: 44ch; font-size: clamp(1.05rem,1.6vw,1.3rem); opacity: .92; }
.cart-band__punch {
  margin-top: 34px; font-family: "Bricolage Grotesque","DM Sans",sans-serif; font-weight: 700;
  font-size: clamp(1.3rem, 2.6vw, 2rem); color: #fff;
}

/* Flanking columns of the little pixel carts, marching down each side. */
.cart-band-section { position: relative; overflow: hidden; }
.cart-band__pattern {
  /* Extends above/below the section so the scroll-driven drift always has carts to reveal;
     the section's overflow:hidden clips them, so they slide under the neighbouring sections. */
  position: absolute; top: -50%; bottom: -50%; z-index: 0;
  width: clamp(64px, 12vw, 150px);
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  padding: 18px 0; pointer-events: none; opacity: 1;
  will-change: transform;
}
/* Pushed inward from each edge by ~one cart width (66% of the column) to sit nearer the centre. */
.cart-band__pattern--l { left: calc(clamp(-8px, 1vw, 28px) + clamp(42px, 8vw, 99px)); }
.cart-band__pattern--r { right: calc(clamp(-8px, 1vw, 28px) + clamp(42px, 8vw, 99px)); }
.cart-band__pattern img {
  width: 66%; image-rendering: pixelated;   /* 2/3 of the column, leaving room for the half-cart stagger */
  filter: drop-shadow(0 4px 7px rgba(0,0,0,.3));
}
/* Alternate carts pinned to opposite edges → a ~half-cart left/right zigzag down the column. */
.cart-band__pattern img:nth-child(even) { align-self: flex-start; transform: rotate(-6deg); }
.cart-band__pattern img:nth-child(odd)  { align-self: flex-end;  transform: rotate(5deg); }
.cart-band-section .cart-band { position: relative; z-index: 1; }
@media (max-width: 820px) { .cart-band__pattern { display: none; } }

/* year drop marker for the New City section */
.story-year {
  font-family: "Bricolage Grotesque","DM Sans",sans-serif; font-weight: 800;
  font-size: clamp(3rem, 8vw, 5.5rem); line-height: .9; color: var(--terracotta);
  letter-spacing: -0.03em; margin-bottom: 10px;
}
.story-year small { display:block; font-size: .9rem; font-weight:600; letter-spacing:.16em; text-transform:uppercase; color: var(--tan); margin-top: 8px; }

/* Build · Generalise · Ship cards */
.rhythm { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 36px; }
.rhythm__card {
  background: rgba(255,255,255,.06); border: 1px solid var(--border-glass);
  border-radius: 18px; padding: 24px 22px;
}
.rhythm__n { font-size: .78rem; font-weight: 700; letter-spacing: .16em; color: #6fe3d6; }
.rhythm__t { font-family:"Bricolage Grotesque","DM Sans",sans-serif; font-weight:700; font-size: 1.3rem; margin: 8px 0 8px; color:#fff; }
.rhythm__d { font-size: .96rem; line-height: 1.6; opacity: .9; }

/* studio pipeline steps */
.pipeline { list-style: none; margin: 30px 0 0; padding: 0; display: grid; gap: 0; }
.pipeline li {
  position: relative; padding: 14px 0 14px 40px; border-left: 2px solid var(--border-light);
  margin-left: 8px;
}
.pipeline li::before {
  content: ""; position: absolute; left: -9px; top: 18px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--terracotta); box-shadow: 0 0 0 4px var(--ivory-warm);
}
.pipeline li:last-child { border-left-color: transparent; }
.pipeline b { color: var(--heading-color); }

/* portfolio siblings row */
.siblings { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.sibling {
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--border-light);
  background: #fff; font-weight: 600; color: var(--heading-color); font-size: .95rem;
}
.sibling span { color: var(--tan); font-weight: 500; }

/* closing CTA */
.story-cta { text-align: center; }
.story-cta__btn {
  display: inline-block; margin-top: 26px; padding: 16px 34px; border-radius: 999px;
  background: var(--terracotta); color: #fff; font-weight: 700; font-size: 1.05rem;
  box-shadow: 0 14px 30px -10px rgba(215,111,75,.6); transition: transform .12s, box-shadow .2s;
}
.story-cta__btn:hover { transform: translateY(-2px); box-shadow: 0 20px 40px -12px rgba(215,111,75,.7); }
.story-cta__note { margin-top: 14px; font-size: .9rem; opacity: .75; }

/* ═══════════════════ RESPONSIVE ═══════════════════ */
@media (max-width: 860px) {
  .story-hero__inner { grid-template-columns: 1fr; text-align: center; }
  .story-hero__lede { margin-left: auto; margin-right: auto; }
  .story-hero__eyebrow { margin: 0 auto; }
  .story-stage { margin-top: 12px; }
  .rhythm { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .story-stage { transform: scale(.86); }
}

/* Respect reduced motion — freeze the carts at their resting scatter, no float. */
@media (prefers-reduced-motion: reduce) {
  .cart, .iphone-frame, .story-hero__scroll .material-symbols-outlined, .story-hero__copy {
    animation: none !important;
  }
  .face { visibility: hidden; }   /* without the spin they'd sit as a flat slab */
}
