/* Shared Motion layout; each style supplies its own sculpture and caption colors. */
.home .hero-layout {
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  column-gap: clamp(32px, 4vw, 64px);
}

.home .hero-copy { min-width: 0; }
.home .hero-actions { max-width: 100%; }
.home .hero-actions > a { min-width: 0; max-width: 100%; }

.story-visual {
  --story-progress: 0;
  --story-title-color: #edf2f5;
  --story-copy-color: #aab9c7;
  --story-border: #91a9b52b;
  --story-control-color: #c6d3da;
  --story-hover-border: #d1a261a8;
  --story-hover-background: #d1a2610d;
  --story-hover-color: #f0c77f;
  --story-rail: #8ba0ad40;
  --story-accent: #d4a360;
  --story-glow-cool: #57a4c51c;
  --story-glow-warm: #c28b4b16;
  --story-title-weight: 450;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 650px;
  isolation: isolate;
}

.story-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

.story-stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 8% 2% 0;
  background:
    radial-gradient(ellipse at 48% 49%, var(--story-glow-cool), transparent 40%),
    radial-gradient(ellipse at 62% 66%, var(--story-glow-warm), transparent 47%);
  pointer-events: none;
}

.story-stage canvas,
.story-poster {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.story-stage canvas {
  z-index: 1;
  opacity: 0;
  transition: opacity .35s ease;
}

.story-stage[data-living-ready="true"] canvas { opacity: 1; }

.story-stage canvas[hidden] { display: none; }

.story-poster {
  z-index: 0;
  object-fit: contain;
  opacity: 1;
  transition: opacity .35s ease;
}

.story-stage[data-living-ready="true"] .story-poster {
  opacity: 0;
}

/* Reserve the controls' height before WebGL is ready. Showing the buttons
   must not shrink the stage and resize the sculpture on its first frame. */
.story-controls[hidden] {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

.story-caption {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  min-height: 152px;
  padding: 5px 0 12px;
  text-align: left;
  transition: opacity .35s ease, transform .55s cubic-bezier(.2,.7,.2,1), filter .35s ease;
}

.story-caption.is-changing {
  opacity: 0;
  transform: translateY(16px);
  filter: blur(2px);
}

.story-tag {
  display: block;
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.story-tag[hidden] {
  display: none;
}

.story-title {
  margin: 0 0 7px;
  color: var(--story-title-color);
  font-size: 30px;
  font-weight: var(--story-title-weight);
  line-height: 1.17;
  letter-spacing: -.045em;
  text-wrap: balance;
}

.story-description {
  max-width: 450px;
  margin: 0;
  color: var(--story-copy-color);
  font-size: 12px;
  line-height: 1.65;
}

.story-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  min-height: 44px;
  margin-top: 3px;
  flex-shrink: 0;
}

/* Keep the same stage/caption geometry before the controls become available. */
.story-controls[hidden] { display: flex !important; visibility: hidden; }

.story-step {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 1px solid var(--story-border);
  border-radius: 50%;
  background: transparent;
  color: var(--story-control-color);
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}

.story-step span {
  font-size: 17px;
  line-height: 1;
}

.story-step:hover {
  border-color: var(--story-hover-border);
  background: var(--story-hover-background);
  color: var(--story-hover-color);
}

.story-step:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.story-step:disabled { opacity: .4; cursor: default; }

.story-progress {
  position: relative;
  width: 62px;
  height: 1px;
  overflow: hidden;
  background: var(--story-rail);
}

.story-progress > span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: var(--story-accent);
  transform: scaleX(var(--story-progress, 0));
  transform-origin: left center;
}

.home .story-visual {
  height: 650px;
}

.inner-hero-grid > .story-visual {
  width: 100%;
  height: 510px;
  margin: 0;
  justify-self: center;
}

.inner-hero-grid > .story-visual .story-stage {
  min-height: 285px;
}

.inner-hero-grid > .story-visual .story-title {
  font-size: 28px;
}

.inner-hero-grid > .story-visual .story-description {
  font-size: 11px;
}

.inner-hero-grid > .story-visual .story-caption {
  min-height: 112px;
}

[data-theme="porcelain"] .story-visual {
  --story-title-color: #26343e;
  --story-copy-color: #586772;
  --story-border: #566c7a40;
  --story-control-color: #486072;
  --story-hover-border: #95652aa8;
  --story-hover-background: #b58d4910;
  --story-hover-color: #805520;
  --story-rail: #48607235;
  --story-accent: #95652a;
  --story-glow-cool: #6799b015;
  --story-glow-warm: #c1a0741b;
  --story-title-weight: 500;
}

[data-theme="cobalt"] .story-visual {
  --story-title-color: #f9fbff;
  --story-copy-color: #d0dcf0;
  --story-border: #ffffff45;
  --story-control-color: #f9fbff;
  --story-hover-border: #ffc438;
  --story-hover-background: #ffc43814;
  --story-hover-color: #ffda77;
  --story-rail: #ffffff40;
  --story-accent: #ffc438;
  --story-glow-cool: #cfddff12;
  --story-glow-warm: #ffd16710;
  --story-title-weight: 600;
}

/* Cobalt keeps a slightly wider column for its bolder headline typography. */
[data-theme="cobalt"].home .hero-layout {
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr);
}

@media (min-width: 1500px) {
  .home .story-visual {
    height: 710px;
  }

  .inner-hero-grid > .story-visual {
    height: 550px;
  }
}

@media (max-width: 1150px) {
  .home .story-visual {
    height: 570px;
  }

  .story-title {
    font-size: 27px;
  }

  .inner-hero-grid > .story-visual {
    height: 430px;
  }

  .inner-hero-grid > .story-visual .story-stage {
    min-height: 225px;
  }
}

@media (max-width: 900px) {
  .home .story-visual {
    height: 540px;
  }

  .inner-hero-grid > .story-visual {
    height: 400px;
  }

  .inner-hero-grid > .story-visual .story-title {
    font-size: 25px;
  }

  .inner-hero-grid > .story-visual .story-caption {
    min-height: 104px;
  }
}

@media (max-width: 800px) {
  .home .hero-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    gap: 20px;
  }

  .home .hero-copy { width: 100%; padding: 52px 0 0; }
  .home .story-visual { width: 100%; max-width: 680px; height: 500px; align-self: center; }
}

@media (min-width: 641px) and (max-width: 740px) {
  [data-theme="cobalt"].home .service-card,
  [data-theme="cobalt"].home .service-card:first-child {
    padding-left: 12px;
    padding-right: 12px;
  }

  [data-theme="cobalt"].home .service-card h3 { font-size: 21px; }
}

@media (max-width: 640px) {
  .home .hero-layout { gap: 8px; }

  .home .story-visual {
    width: 100%;
    height: auto;
    margin-top: 0;
  }

  .story-stage {
    flex: 0 0 315px;
    min-height: 0;
  }

  .story-caption {
    min-height: 132px;
    padding-top: 4px;
  }

  .story-title {
    font-size: 24px;
    line-height: 1.2;
  }

  .story-description {
    max-width: 390px;
    font-size: 11px;
  }

  .story-controls {
    gap: 10px;
    margin: 4px 0 5px;
  }

  .inner-hero-grid > .story-visual {
    width: 100%;
    max-width: 430px;
    height: auto;
    margin: 0 auto;
    align-self: center;
  }

  .inner-hero-grid > .story-visual .story-stage {
    flex: 0 0 275px;
    min-height: 0;
  }

  .inner-hero-grid > .story-visual .story-caption {
    min-height: 104px;
  }

  .inner-hero-grid > .story-visual .story-title {
    font-size: 24px;
  }

  .inner-hero-grid > .story-visual .story-description {
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  .story-stage {
    flex-basis: 275px;
  }

  .inner-hero-grid > .story-visual .story-stage {
    flex-basis: 250px;
  }

  .story-title,
  .inner-hero-grid > .story-visual .story-title {
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-stage canvas,
  .story-poster,
  .story-caption,
  .story-step {
    transition: none;
  }
}

@media print {
  .story-visual {
    display: none;
  }
}
