/* Scroll story section (pages/story.php, assets/js/story.js) */
.rn-story-area {
  --story-heading: #ffffff;
  --story-body: #c4cfde;
  --story-card-bg: rgba(33, 36, 40, 0.55);
  --story-card-border: rgba(255, 255, 255, 0.08);
  --story-accent: #40a2d8;
  --story-line: rgba(255, 255, 255, 0.14);
  --story-progress: 0;
  position: relative;
}

.white-version .rn-story-area {
  --story-heading: #1e2125;
  --story-body: #3c3e41;
  --story-card-bg: rgba(236, 240, 243, 0.66);
  --story-card-border: rgba(11, 96, 176, 0.12);
  --story-accent: #0b60b0;
  --story-line: rgba(11, 96, 176, 0.18);
}

/* Hero to story: a soft line that fades at both ends with a faint accent glow
   in the middle, instead of the hard 1px rule other sections use */
.rn-story-area.section-separator::after {
  z-index: 3;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08) 20%, rgba(64, 162, 216, 0.55) 50%, rgba(255, 255, 255, 0.08) 80%, transparent);
  filter: drop-shadow(0 0 6px rgba(64, 162, 216, 0.7));
}

.white-version .rn-story-area.section-separator::after {
  background: linear-gradient(90deg, transparent, rgba(11, 96, 176, 0.1) 20%, rgba(11, 96, 176, 0.45) 50%, rgba(11, 96, 176, 0.1) 80%, transparent);
  filter: drop-shadow(0 0 5px rgba(64, 162, 216, 0.5));
}

/* style.css sets body { overflow: hidden } below 1200px, which makes body a
   scroll container and breaks position: sticky. clip blocks sideways overflow
   the same way without creating a scroll container. */
@media only screen and (max-width: 1199px) {
  body {
    overflow: visible;
    overflow-x: clip;
  }
}

/* Canvas pinned behind the chapters while the section scrolls past. The track
   spans exactly the section, so the sticky stage stops at the section's end
   instead of spilling into the next section. */
.story-stage-track {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.story-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  --story-glow-at: 70% 50%;
}

/* Soft glow behind the shape so it sits in light, not on a flat page.
   It stays dim until the lightbulb switches on (.is-lit, set by story.js). */
.story-stage::before,
.story-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.story-stage::before {
  z-index: 0;
  background: radial-gradient(ellipse 34% 48% at var(--story-glow-at), rgba(21, 101, 192, 0.22), transparent 72%);
  opacity: 0.2;
  transition: opacity 1.6s ease-out;
}

.white-version .story-stage::before {
  background: radial-gradient(ellipse 34% 48% at var(--story-glow-at), rgba(64, 162, 216, 0.2), rgba(255, 255, 255, 0.35) 45%, transparent 75%);
}

.is-lit .story-stage::before {
  opacity: 1;
}

/* One flash of light when the bulb switches on */
.story-stage::after {
  z-index: 2;
  background: radial-gradient(circle at var(--story-glow-at), rgba(140, 200, 255, 0.45), rgba(64, 162, 216, 0.12) 30%, transparent 60%);
  opacity: 0;
}

.white-version .story-stage::after {
  background: radial-gradient(circle at var(--story-glow-at), rgba(255, 255, 255, 0.9), rgba(64, 162, 216, 0.18) 30%, transparent 60%);
}

.is-lit .story-stage::after {
  animation: story-flash 1.3s ease-out 1 both;
}

@keyframes story-flash {
  0% { opacity: 0; }
  12% { opacity: 1; }
  100% { opacity: 0; }
}

.story-stage .story-canvas,
.story-stage .story-rail {
  position: relative;
  z-index: 1;
}

.story-stage .story-rail {
  position: absolute;
}

/* Light theme: story.js draws dark "ink" on a white canvas; multiply makes the
   white vanish into the page so only the ink and the glow behind it show */
.white-version .story-canvas {
  mix-blend-mode: multiply;
}

.story-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.story-chapters {
  position: relative;
  z-index: 1;
}

.story-chapter {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
}

/* ---- Cards ---- */
.story-card {
  position: relative;
  max-width: 500px;
  padding: 44px 40px 40px;
  border-radius: 12px;
  background: var(--story-card-bg);
  border: 1px solid var(--story-card-border);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  opacity: 0.2;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.story-chapter.is-active .story-card {
  opacity: 1;
  transform: none;
}

/* Rows span the full width over the rail; only the cards take clicks */
.story-chapters {
  pointer-events: none;
}

.story-card {
  pointer-events: auto;
}

/* Accent line that draws in along the card's top edge */
.story-card[data-num]::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 40px;
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--story-accent), transparent);
  transition: width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.3s;
}

.story-chapter.is-active .story-card[data-num]::after {
  width: 120px;
}

/* Text link under a card (e.g. to the link building portfolio) */
.story-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--story-accent);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: opacity 0.6s ease 0.85s, transform 0.3s ease;
}

.story-link:hover,
.story-link:focus-visible {
  color: var(--story-accent);
  transform: translateX(4px);
}

.is-split .story-chapter:not(.is-active) .story-link {
  opacity: 0;
}

/* Tool / project chips */
.story-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.story-chips li {
  margin: 0;
  padding: 5px 12px;
  border: 1px solid var(--story-line);
  border-radius: 999px;
  color: var(--story-heading);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.is-split .story-chips li {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.is-split .story-chapter.is-active .story-chips li {
  opacity: 1;
  transform: none;
}

.story-chips li:nth-child(1) { transition-delay: 0.55s; }
.story-chips li:nth-child(2) { transition-delay: 0.6s; }
.story-chips li:nth-child(3) { transition-delay: 0.65s; }
.story-chips li:nth-child(4) { transition-delay: 0.7s; }
.story-chips li:nth-child(5) { transition-delay: 0.75s; }
.story-chips li:nth-child(6) { transition-delay: 0.8s; }

/* Canvas fades in as the section arrives and out as it leaves (--story-fade set by story.js) */
.story-canvas {
  opacity: var(--story-fade, 1);
}

/* Big outlined chapter number behind each card */
.story-card[data-num]::before {
  content: attr(data-num);
  position: absolute;
  top: -0.62em;
  right: 18px;
  font-size: 150px;
  font-weight: 800;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px var(--story-accent);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.9s ease 0.2s, transform 0.9s ease 0.2s;
  pointer-events: none;
}

.story-chapter.is-active .story-card[data-num]::before {
  opacity: 0.35;
  transform: none;
}

.story-intro .story-card {
  background: transparent;
  border-color: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding-left: 0;
}

.story-step {
  display: block;
  margin-bottom: 14px;
  color: var(--story-accent);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.story-title {
  margin-bottom: 18px;
  color: var(--story-heading);
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1.18;
}

.story-intro .story-title {
  font-size: clamp(38px, 5vw, 68px);
}

/* Word-by-word title reveal (spans added by story.js) */
.story-title .w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: 0.08em;
}

.story-title .w > span {
  display: inline-block;
  transform: translateY(105%);
  transition: transform 0.75s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(var(--i) * 55ms + 120ms);
}

.story-chapter.is-active .story-title .w > span {
  transform: none;
}

.story-card p {
  margin: 0;
  color: var(--story-body);
  font-size: 18px;
  line-height: 1.7;
}

.is-split .story-card p,
.is-split .story-actions {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s ease 0.45s, transform 0.6s ease 0.45s;
}

.is-split .story-chapter.is-active .story-card p,
.is-split .story-chapter.is-active .story-actions {
  opacity: 1;
  transform: none;
}

.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 28px;
}

.story-scroll-cue {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 36px;
  color: var(--story-accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.story-scroll-cue i {
  position: relative;
  width: 2px;
  height: 44px;
  overflow: hidden;
  background: var(--story-line);
}

.story-scroll-cue i::after {
  content: "";
  position: absolute;
  left: 0;
  top: -50%;
  width: 100%;
  height: 50%;
  background: var(--story-accent);
  animation: story-cue 1.8s ease-in-out infinite;
}

@keyframes story-cue {
  to { top: 100%; }
}

/* ---- Progress rail (under the shape, desktop) ---- */
.story-rail {
  position: absolute;
  left: 52%;
  right: 12%;
  bottom: 7vh;
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 18px 0 0;
  opacity: calc(0.4 + var(--story-progress) * 6);
}

.story-rail::before,
.story-rail::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--story-line);
  right: 0;
}

.story-rail::after {
  right: auto;
  width: calc(var(--story-progress) * 100%);
  background: var(--story-accent);
}

.story-rail a {
  margin: 0;
  padding: 6px 0;
  color: var(--story-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.45;
  pointer-events: auto;
  transition: opacity 0.4s ease, color 0.4s ease;
}

.story-rail a:hover,
.story-rail a:focus-visible {
  opacity: 1;
  color: var(--story-accent);
}

.story-rail a .num {
  margin-right: 8px;
  color: var(--story-accent);
}

.story-rail a.is-done {
  opacity: 0.75;
}

.story-rail a.is-active {
  opacity: 1;
  color: var(--story-heading);
}

/* Without WebGL the chapters read as a plain list */
.rn-story-area.no-webgl .story-stage-track {
  display: none;
}

.rn-story-area.no-webgl .story-chapter {
  min-height: 0;
  padding: 50px 0;
}

.rn-story-area.no-webgl .story-card,
.rn-story-area.no-webgl .story-card p,
.rn-story-area.no-webgl .story-actions,
.rn-story-area.no-webgl .story-chips li,
.rn-story-area.no-webgl .story-title .w > span {
  opacity: 1;
  transform: none;
}

.rn-story-area.no-webgl .story-card[data-num]::before,
.rn-story-area.no-webgl .story-scroll-cue {
  display: none;
}

@media only screen and (max-width: 991px) {
  .story-chapter {
    align-items: flex-end;
    padding-bottom: 6vh;
  }

  .story-card {
    margin: 0 auto;
    padding: 30px 24px 26px;
  }

  .story-intro .story-card {
    padding-left: 24px;
  }

  .story-card[data-num]::before {
    font-size: 96px;
  }

  .story-card p {
    font-size: 16px;
  }

  .story-rail {
    display: none;
  }

  .story-stage {
    --story-glow-at: 50% 28%;
  }
}

/* Phones: keep cards short so the shape above stays visible */
@media only screen and (max-width: 575px) {
  .story-chapter {
    padding-bottom: 3vh;
  }

  .story-card {
    padding: 24px 20px 22px;
  }

  .story-title {
    margin-bottom: 12px;
    font-size: 26px;
  }

  .story-card p {
    font-size: 15px;
    line-height: 1.6;
  }

  .story-chips {
    gap: 6px;
    margin-top: 14px;
  }

  .story-chips li {
    padding: 3px 10px;
    font-size: 12px;
  }

  .story-actions {
    flex-wrap: nowrap;
    gap: 10px;
    margin-top: 18px;
  }

  .story-actions .rn-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    line-height: 1.2;
    padding: 0 10px;
    font-size: 12px;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-card,
  .story-card[data-num]::before,
  .story-title .w > span,
  .is-split .story-card p,
  .is-split .story-actions,
  .is-split .story-chips li,
  .story-card[data-num]::after {
    transition: none;
  }

  .story-scroll-cue i::after {
    animation: none;
  }
}
