/* A continuous, scroll-controlled opening in the portfolio's own palette. */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  background: rgba(248, 249, 246, 0.91);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.header-inner { min-height: 78px; }
body.story-active .site-header,
body.story-active .site-header.is-scrolled {
  background: rgba(248, 249, 246, 0.8);
  box-shadow: none;
}
body.story-active .header-inner { border-bottom-color: rgba(24, 34, 30, 0.1); }
body.story-active .ambient-ai-layer { opacity: 0; }
body.story-active:not(:has([data-story-phase="0"])) .ambient-completion { animation-play-state: paused; }
body.story-active:has([data-story-phase="0"]) .ambient-ai-layer { opacity: 1; }
body.story-active .ambient-ai-figure { bottom: 64px; }
.ambient-ai-layer { transition: opacity 300ms ease; }

.scroll-story {
  position: relative;
  width: 100%;
  background: var(--paper);
  isolation: isolate;
  --story-progress: 0;
}
.story-viewport {
  position: relative;
  padding: 145px 0 88px;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(155deg, #f8f9f6 8%, #f1f5fb 55%, #eaf0fc 100%);
}
.story-viewport::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(ellipse at 74% 62%, rgba(110, 157, 255, 0.12), transparent 50%);
  pointer-events: none;
}
.story-canvas { display: none; }
.story-intro {
  position: relative;
  width: min(1160px, calc(100% - 64px));
  margin: 0 auto;
  padding-bottom: 64px;
  text-align: center;
}
.story-overline {
  margin-bottom: 32px;
  color: #526b86;
  font: 13px/1.6 var(--mono);
  letter-spacing: 0.12em;
}
.story-overline::before {
  display: inline-block;
  content: "";
  width: 5px;
  height: 5px;
  margin-right: 12px;
  background: var(--blue);
  vertical-align: 2px;
}
.story-title {
  margin: 0 0 29px;
  color: #172420;
  font-size: clamp(72px, 7.5vw, 116px);
  font-weight: 540;
  line-height: 1.1;
  letter-spacing: -0.065em;
}
.story-title > span { display: block; }
.story-title .accent { color: #2155e8; }
.story-lead {
  width: min(560px, 100%);
  margin: 0 auto;
  color: #55645e;
  font-size: 16px;
  line-height: 1.85;
  text-wrap: balance;
}
.story-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 30px;
  margin-top: 32px;
}
.story-actions .button-primary {
  min-height: 48px;
  background: #2155e8;
  border-color: #2155e8;
  padding-inline: 23px;
  border-radius: 4px;
  font-size: 14px;
}
.story-actions .button-primary:hover { background: #183cac; border-color: #183cac; }
.story-explore {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 48px;
  padding: 9px 0;
  border: 0;
  border-bottom: 1px solid #b6c3d0;
  color: #284132;
  background: transparent;
  font-size: 14px;
}
.story-explore > span:last-child { color: #2155e8; }
.story-explore:hover { color: #2155e8; border-color: #2155e8; }
.story-caption,
.story-files,
.story-core,
.story-hud { display: none; }

.story-workbench {
  position: relative;
  width: min(1160px, calc(100% - 112px));
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #d4deec;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(40, 83, 146, 0.1), 0 4px 14px rgba(33, 61, 106, 0.04);
  transform-origin: center center;
}
.board-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 30px;
  padding: 10px 24px;
  border-bottom: 1px solid #e3e9f0;
  background: #fbfcfd;
}
.board-dots { display: inline-flex; align-items: center; gap: 5px; }
.board-dots i { display: block; width: 5px; height: 5px; border-radius: 50%; background: #c3cdd9; }
.board-dots i:first-child { background: #91acd9; }
.board-heading { padding: 25px 32px 23px; }
.board-heading h2 { margin: 0; font-size: 31px; line-height: 1.25; letter-spacing: -0.045em; }
.board-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  padding: 0 32px 26px;
}
.board-project { min-width: 0; }
.board-project > img {
  width: 100%;
  aspect-ratio: 1.72;
  object-fit: cover;
  border-radius: 3px;
  background: #e7eef4;
}
.board-project > div { padding-top: 17px; }
.board-project h3 { margin: 0 0 10px; font-size: 20px; letter-spacing: -0.03em; line-height: 1.4; }
.board-project .project-open { min-height: 36px; font-size: 14px; gap: 10px; }
.story-closing { width: min(900px, calc(100% - 64px)); margin: 60px auto 0; text-align: center; }
.story-closing h2 { margin: 0 0 16px; font-size: clamp(34px, 4vw, 58px); line-height: 1.25; letter-spacing: -0.055em; text-wrap: balance; }
.story-closing .text-link { gap: 20px; border-bottom-color: #a6b8d0; color: #2155e8; font-size: 16px; }

/* Only an initialized scene creates the scroll track. */
body.story-ready .scroll-story { height: 270svh; }
body.story-ready .story-viewport {
  position: sticky;
  top: 0;
  height: 100svh;
  min-height: 0;
  padding: 0;
  clip-path: inset(var(--scene-inset, 0px) round var(--scene-radius, 0px));
}
body.story-ready .story-canvas {
  display: block;
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  contain: strict;
}
body.story-ready .story-intro {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(1160px, calc(100% - 96px));
  margin: 0;
  padding: 0;
  opacity: var(--intro-opacity, 1);
  transform: translate(-50%, calc(-50% + var(--intro-y, 0px))) scale(var(--intro-scale, 1));
  will-change: opacity, transform;
}
body.story-ready .story-caption {
  display: block;
  position: absolute;
  z-index: 3;
  top: 15%;
  left: 50%;
  width: min(850px, calc(100% - 64px));
  text-align: center;
  opacity: var(--caption-opacity, 0);
  transform: translateX(-50%);
  pointer-events: none;
}
.story-caption .story-overline { margin: 0 0 15px; max-width: none; color: #466ab2; font: 12px/1.5 var(--mono); letter-spacing: 0.1em; }
.story-caption .story-overline::before { display: none; }
.story-caption h2 { margin: 0 0 12px; font-size: clamp(36px, 4.1vw, 60px); line-height: 1.18; letter-spacing: -0.055em; }
.story-caption p { margin: 0 auto; max-width: 500px; color: #52645a; font-size: 15px; line-height: 1.7; text-wrap: balance; }
body.story-ready .story-files { display: block; position: absolute; z-index: 2; inset: 0; opacity: var(--scatter-opacity, 0); pointer-events: none; }
.story-file {
  --file-from-x: -60vw;
  --file-from-y: -180px;
  --file-to-x: -228px;
  --file-to-y: -70px;
  --file-angle: -18deg;
  position: absolute;
  top: 57%;
  left: 50%;
  width: 182px;
  min-height: 177px;
  padding: 18px 20px 19px;
  border: 1px solid #cbd9eb;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(36, 80, 150, 0.09), 0 2px 7px rgba(36, 80, 150, 0.03);
  transform: translate(
      calc(-50% + var(--file-from-x) + (var(--file-to-x) - var(--file-from-x)) * var(--scatter-progress, 0)),
      calc(-50% + var(--file-from-y) + (var(--file-to-y) - var(--file-from-y)) * var(--scatter-progress, 0))
    ) rotate(calc(var(--file-angle) * (1 - var(--scatter-progress, 0)))) scale(calc(0.8 + var(--scatter-progress, 0) * 0.2));
  will-change: transform;
}
.story-file[data-story-card="sheet"] { --file-from-x: 64vw; --file-from-y: -210px; --file-to-x: 228px; --file-angle: 20deg; }
.story-file[data-story-card="production"] { --file-from-x: -54vw; --file-from-y: 270px; --file-to-y: 140px; --file-angle: 17deg; }
.story-file[data-story-card="video"] { --file-from-x: 58vw; --file-from-y: 280px; --file-to-x: 228px; --file-to-y: 140px; --file-angle: -14deg; }
.story-file-icon { display: block; width: 27px; height: 27px; margin-bottom: 15px; color: #2155e8; }
.story-file-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.story-file strong { display: block; margin-bottom: 16px; font-size: 18px; line-height: 1.4; font-weight: 500; }
.story-file-lines { display: grid; gap: 5px; }
.story-file-lines i { display: block; width: 100%; height: 3px; background: #e5edf6; }
.story-file-lines i:nth-child(2) { width: 77%; }
.story-file-lines i:nth-child(3) { width: 48%; background: #c4d7fb; }
body.story-ready .story-core {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: absolute;
  z-index: 3;
  top: calc(57% + 35px);
  left: 50%;
  width: 100px;
  height: 100px;
  border: 1px solid #4f7ff5;
  border-radius: 17px;
  background: #2155e8;
  color: #fff;
  box-shadow: 0 0 0 12px rgba(94, 139, 250, 0.045), 0 14px 52px rgba(33, 85, 232, 0.2);
  opacity: var(--core-opacity, 0);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.story-core > span { font-size: 37px; font-weight: 500; line-height: 1.3; letter-spacing: -0.04em; }
body.story-ready .story-workbench {
  position: absolute;
  z-index: 4;
  top: 52%;
  left: 50%;
  margin: 0;
  opacity: var(--board-opacity, 0);
  transform: perspective(1600px) translate(-50%, calc(-50% + var(--board-y, 80px))) rotateX(var(--board-rotate, 14deg)) scale(var(--board-scale, 0.44));
  will-change: opacity, transform;
}
body.story-ready .story-closing {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  width: min(900px, calc(100% - 64px));
  margin: 0;
  opacity: var(--closing-opacity, 0);
  transform: translate(-50%, calc(-50% + var(--closing-y, 60px)));
  will-change: transform, opacity;
}
body.story-ready .story-closing h2 { font-size: clamp(49px, 5.8vw, 88px); }
body.story-ready .story-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: absolute;
  z-index: 6;
  left: 56px;
  right: 56px;
  bottom: 29px;
  color: #74818a;
  font: 13px/1.5 var(--mono);
  letter-spacing: 0.04em;
}
.story-chapters { display: flex; align-items: center; gap: 13px; }
.story-chapters > span { display: block; width: 8px; height: 8px; border-radius: 50%; background: #adbdcb; transition: background 180ms ease, box-shadow 180ms ease; }
.story-chapters > span.is-active,
.story-chapters > span[aria-current="step"] { background: #2155e8; box-shadow: 0 0 0 3px rgba(33, 85, 232, 0.1); }
.story-scroll { margin-left: auto; margin-right: 27px; color: #5f7184; }
.story-progress { width: 94px; height: 2px; background: #cdd8e5; overflow: hidden; }
.story-progress > i { display: block; width: 100%; height: 100%; background: #2155e8; transform: scaleX(var(--story-progress, 0)); transform-origin: left; }

html:lang(en) .story-title { font-size: clamp(68px, 7.4vw, 112px); line-height: 1.04; }
html:lang(en) .story-caption h2 { font-size: clamp(35px, 3.8vw, 55px); }
html:lang(en) .board-project h3 { font-size: 19px; }

@media (max-width: 1100px) {
  .story-title { font-size: clamp(65px, 8.2vw, 88px); }
  .story-workbench { width: calc(100% - 72px); }
  .board-heading { padding: 24px 25px 21px; }
  .board-grid { gap: 16px; padding: 0 25px 23px; }
  .board-project h3 { font-size: 18px; }
  body.story-ready .story-hud { left: 36px; right: 36px; }
  .story-scroll { margin-right: 18px; }
}
@media (max-width: 900px) {
  .header-inner { min-height: 74px; }
  .story-file { --file-to-x: -188px; --file-to-y: -70px; width: 164px; min-height: 167px; padding: 16px; }
  .story-file[data-story-card="sheet"] { --file-to-x: 188px; }
  .story-file[data-story-card="production"] { --file-to-y: 126px; }
  .story-file[data-story-card="video"] { --file-to-x: 188px; --file-to-y: 126px; }
  body.story-ready .story-core { top: calc(57% + 28px); width: 84px; height: 84px; border-radius: 14px; }
  .story-core > span { font-size: 32px; }
  .story-progress { width: 68px; }
}
@media (max-width: 760px) {
  .header-inner { min-height: 68px; }
  .story-viewport { padding: 132px 0 58px; }
  .story-intro { width: calc(100% - 40px); padding-bottom: 45px; }
  .story-overline { font-size: 12px; letter-spacing: 0.08em; margin-bottom: 24px; }
  .story-overline::before { margin-right: 7px; width: 4px; height: 4px; vertical-align: 1px; }
  .story-title { font-size: clamp(46px, 11.3vw, 80px); line-height: 1.16; letter-spacing: -0.06em; margin-bottom: 24px; }
  .story-lead { width: min(400px, 100%); font-size: 16px; line-height: 1.7; }
  .story-actions { gap: 24px; margin-top: 28px; }
  .story-actions .button-primary { min-height: 45px; font-size: 14px; padding-inline: 18px; }
  .story-explore { min-height: 45px; font-size: 14px; gap: 12px; }
  .story-workbench { width: calc(100% - 36px); border-radius: 8px; }
  .board-topbar { min-height: 28px; padding: 8px 16px; gap: 9px; }
  .board-dots { gap: 3px; }
  .board-dots i { width: 4px; height: 4px; }
  .board-heading { padding: 18px 18px 17px; }
  .board-heading h2 { font-size: 25px; }
  .board-grid { grid-template-columns: 1fr; gap: 13px; padding: 0 18px 18px; }
  .board-project { display: grid; grid-template-columns: 34% minmax(0, 1fr); align-items: center; gap: 13px; }
  .board-project > img { height: 88px; aspect-ratio: auto; }
  .board-project > div { padding-top: 0; }
  .board-project h3 { font-size: 17px; margin-bottom: 4px; line-height: 1.35; }
  .board-project .project-open { min-height: 34px; font-size: 14px; }
  .story-closing { width: calc(100% - 40px); margin-top: 42px; }
  .story-closing h2 { font-size: 34px; }
  body.story-ready .scroll-story { height: 250svh; }
  body.story-ready .story-intro { width: calc(100% - 40px); top: 46%; }
  body.story-ready .story-caption { top: 15%; width: calc(100% - 40px); }
  .story-caption .story-overline { font-size: 12px; margin-bottom: 12px; }
  .story-caption h2 { font-size: clamp(30px, 7.4vw, 46px); margin-bottom: 12px; }
  .story-caption h2 > span { display: block; }
  .story-caption p { max-width: 340px; font-size: 14px; }
  .story-file { --file-from-x: -85vw; --file-from-y: -240px; --file-to-x: -87px; --file-to-y: -83px; top: 58%; width: 141px; min-height: 141px; padding: 14px 15px; border-radius: 5px; }
  .story-file[data-story-card="sheet"] { --file-from-x: 91vw; --file-from-y: -190px; --file-to-x: 87px; }
  .story-file[data-story-card="production"] { --file-from-x: -89vw; --file-from-y: 290px; --file-to-y: 109px; }
  .story-file[data-story-card="video"] { --file-from-x: 95vw; --file-from-y: 320px; --file-to-x: 87px; --file-to-y: 109px; }
  .story-file-icon { width: 23px; height: 23px; margin-bottom: 10px; }
  .story-file strong { font-size: 16px; margin-bottom: 12px; }
  .story-file-lines { gap: 4px; }
  .story-file-lines i { height: 2px; }
  body.story-ready .story-core { top: calc(58% + 14px); width: 50px; height: 50px; border-radius: 9px; box-shadow: 0 0 0 5px rgba(94, 139, 250, 0.05), 0 8px 30px rgba(33, 85, 232, 0.17); }
  .story-core > span { font-size: 23px; line-height: 1.1; }
  body.story-ready .story-workbench { top: 52%; }
  body.story-ready .story-closing { top: 48%; width: calc(100% - 42px); }
  body.story-ready .story-closing h2 { font-size: clamp(35px, 9vw, 59px); line-height: 1.27; }
  body.story-ready .story-hud { left: 20px; right: 20px; bottom: 26px; gap: 15px; }
  .story-chapters { gap: 12px; }
  .story-chapters > span { width: 7px; height: 7px; }
  .story-scroll { display: none; }
  .story-progress { flex: 0 0 42px; }
  html:lang(en) .story-title { font-size: clamp(44px, 11vw, 78px); line-height: 1.06; }
  html:lang(en) .story-lead { max-width: 340px; }
  html:lang(en) .story-caption h2 { font-size: clamp(30px, 7.8vw, 46px); }
  html:lang(en) .board-heading h2 { font-size: 24px; }
  html:lang(en) .board-project h3 { font-size: 16px; }
}
@media (max-width: 380px) {
  .story-title { font-size: clamp(36px, 10.8vw, 41px); }
  .story-actions { gap: 19px; }
  .story-actions .button-primary { padding-inline: 15px; }
  .story-explore { gap: 8px; }
  .story-file { --file-to-x: -79px; width: 131px; }
  .story-file[data-story-card="sheet"],
  .story-file[data-story-card="video"] { --file-to-x: 79px; }
  .board-heading { padding-inline: 15px; }
  .board-heading h2 { font-size: 23px; }
  .board-grid { padding-inline: 15px; gap: 12px; }
  .board-project { gap: 12px; }
  .board-project h3 { font-size: 16px; }
  .board-project > img { height: 84px; }
}
@media (min-width: 761px) and (max-height: 760px) {
  .story-title { font-size: min(8vw, 86px); }
  html:lang(en) .story-title { font-size: min(8vw, 86px); }
  .story-overline { margin-bottom: 19px; }
  .story-title { margin-bottom: 20px; }
  .story-actions { margin-top: 24px; }
  body.story-ready .story-intro { top: 51%; }
  body.story-ready .story-caption { top: 15%; }
  .story-caption h2 { font-size: 39px; }
  body.story-ready .story-files { transform: scale(0.84); transform-origin: center 52%; }
  .story-file strong { font-size: 20px; }
  body.story-ready .story-core { width: 75px; height: 75px; }
  .story-workbench { width: min(1040px, calc(100% - 144px)); }
  .board-heading { padding: 20px 26px 18px; }
  .board-heading h2 { font-size: 28px; }
  .board-grid { padding: 0 26px 19px; }
  .board-project > img { aspect-ratio: 2.1; }
  .board-project > div { padding-top: 11px; }
  .board-project h3 { font-size: 17px; margin-bottom: 5px; }
  .board-project .project-open { min-height: 34px; }
}
@media (max-width: 760px) and (max-height: 740px) {
  body.story-ready .story-intro { top: 48%; }
  .story-overline { margin-bottom: 21px; }
  .story-title { margin-bottom: 20px; }
  .story-actions { margin-top: 23px; }
  body.story-ready .story-caption { top: 16%; }
  .story-caption h2 { font-size: 29px; }
  .story-caption p { font-size: 14px; }
  .story-file { top: 60%; --file-to-y: -62px; min-height: 119px; padding-block: 11px; }
  .story-file[data-story-card="production"],
  .story-file[data-story-card="video"] { --file-to-y: 99px; }
  .story-file-icon { width: 20px; height: 20px; margin-bottom: 7px; }
  .story-file strong { margin-bottom: 8px; font-size: 16px; }
  .story-file-lines { gap: 3px; }
  body.story-ready .story-core { top: calc(60% + 19px); width: 42px; height: 42px; border-radius: 8px; }
  .story-core > span { font-size: 21px; }
  .board-heading { padding-block: 14px 13px; }
  .board-heading h2 { font-size: 23px; }
  .board-grid { gap: 10px; padding-bottom: 14px; }
  .board-project > img { height: 74px; }
  .board-project h3 { font-size: 16px; }
  .board-project .project-open { min-height: 34px; font-size: 14px; }
  body.story-ready .story-hud { bottom: 20px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  body.story-ready .scroll-story { height: auto; }
  body.story-ready .story-viewport { position: relative; height: auto; padding: 110px 0 50px; clip-path: none; }
  body.story-ready .story-intro,
  body.story-ready .story-workbench,
  body.story-ready .story-closing { position: relative; top: auto; left: auto; transform: none; opacity: 1; margin-inline: auto; will-change: auto; }
  body.story-ready .story-intro { margin-bottom: 50px; }
  body.story-ready .story-closing { margin-top: 45px; }
  body.story-ready .story-canvas,
  body.story-ready .story-caption,
  body.story-ready .story-files,
  body.story-ready .story-core,
  body.story-ready .story-hud { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  body.story-ready .scroll-story { height: auto; }
  body.story-ready .story-viewport { position: relative; height: auto; min-height: 0; padding: 145px 0 75px; clip-path: none; }
  body.story-ready .story-intro,
  body.story-ready .story-workbench,
  body.story-ready .story-closing { position: relative; top: auto; left: auto; opacity: 1; transform: none; margin-inline: auto; will-change: auto; }
  body.story-ready .story-intro { padding-bottom: 60px; }
  body.story-ready .story-closing { margin-top: 55px; }
  body.story-ready .story-canvas,
  body.story-ready .story-caption,
  body.story-ready .story-files,
  body.story-ready .story-core,
  body.story-ready .story-hud { display: none; }
}
@media print {
  .site-header { position: static; backdrop-filter: none; }
  body.story-ready .scroll-story { height: auto; }
  body.story-ready .story-viewport { position: relative; height: auto; padding: 40px 0; overflow: visible; clip-path: none; background: #fff; }
  body.story-ready .story-intro,
  body.story-ready .story-workbench,
  body.story-ready .story-closing { position: relative; top: auto; left: auto; opacity: 1; transform: none; margin: 0 auto 30px; }
  body.story-ready .story-canvas,
  body.story-ready .story-caption,
  body.story-ready .story-files,
  body.story-ready .story-core,
  body.story-ready .story-hud { display: none; }
}
