/* ==========================================================================
   SAJ Dental Clinic — "Our Story / From Consultation to Confident Smile"
   Scope: everything lives under .smile-story (and .story-scene inside it).

   Layouts
   - Panel layout  (min-width 992px AND min-height 620px): intro + the
     arched panels side by side. JS pins it and scrubs through the scenes.
       >= 1200px  intro on the left (~30%), panels on the right
       992–1199px intro across the top, panels full width below
   - Vertical layout (everything else: iPad portrait, phones, short
     screens): one scene after another with a drawn rail on the left.
   Without JS (or with reduced motion) both layouts are fully readable.
   ========================================================================== */

.smile-story {
  /* ---- Brand ---- */
  --ss-navy: #0B3478;
  --ss-navy-deep: #082B63;
  --ss-blue: #1D6FD8;
  --ss-orange: #F36A21;
  --ss-soft-blue: #EAF5FF;
  --ss-light-blue: #F5FAFF;
  --ss-text: #52698F;
  --ss-white: #FFFFFF;

  --ss-font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --ss-font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --ss-ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* ---- Scene metrics (vertical layout defaults) ---- */
  --ss-gutter: clamp(16px, 4vw, 48px);
  --ss-icon: 56px;
  --ss-visual-h: clamp(240px, 72vw, 380px);
  --ss-rail: 36px;            /* left column holding the vertical rail */

  box-sizing: border-box;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  overflow: clip;
  padding: clamp(64px, 9vw, 100px) 0;
  background:
    radial-gradient(60% 50% at 70% 40%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 70%),
    linear-gradient(160deg, #F5FAFF 0%, #EAF3FD 55%, #E2EEFB 100%);
  font-family: var(--ss-font-body);
  color: var(--ss-text);
  -webkit-font-smoothing: antialiased;
}

.smile-story *,
.smile-story *::before,
.smile-story *::after {
  box-sizing: border-box;
}

/* ==========================================================================
   Background (depth layer 1)
   ========================================================================== */
.smile-story__background {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.smile-story__bg-layer {
  position: absolute;
}

.smile-story__bg-drift,
.smile-story__bg-shape {
  display: block;
  width: 100%;
  height: 100%;
}

.smile-story__bg-layer--waves {
  inset: 0;
}

.smile-story__bg-layer--blob-a {
  top: -16%;
  left: -12vw;
  width: 48vw;
  height: 70%;
}

.smile-story__bg-shape--blob-a {
  border-radius: 58% 42% 46% 54% / 50% 56% 44% 50%;
  background: radial-gradient(closest-side, rgba(176, 210, 242, 0.55), rgba(176, 210, 242, 0));
}

.smile-story__bg-layer--blob-b {
  right: -12vw;
  bottom: -20%;
  width: 52vw;
  height: 72%;
}

.smile-story__bg-shape--blob-b {
  border-radius: 44% 56% 60% 40% / 56% 44% 56% 44%;
  background: radial-gradient(closest-side, rgba(186, 216, 244, 0.6), rgba(186, 216, 244, 0));
}

.smile-story__bg-layer--tooth {
  top: clamp(10px, 2vw, 30px);
  left: clamp(-40px, 1vw, 30px);
  width: clamp(130px, 15vw, 270px);
  aspect-ratio: 400 / 440;
  opacity: 0.85;
}

.smile-story__tooth {
  overflow: visible;
  transform: rotate(-8deg);
  filter: blur(0.6px) drop-shadow(0 20px 30px rgba(29, 111, 216, 0.12));
}

/* ==========================================================================
   Container + intro
   ========================================================================== */
.smile-story__container {
  position: relative;
  z-index: 1;
  width: min(100% - var(--ss-gutter) * 2, 1560px);
  margin: 0 auto;
}

.smile-story__intro {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.smile-story__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ss-navy);
}

.smile-story__eyebrow-line {
  display: block;
  width: 42px;
  height: 2px;
  border-radius: 2px;
  background: var(--ss-orange);
}

.smile-story__heading {
  margin: 18px 0 18px;
  font-family: var(--ss-font-display);
  font-size: clamp(34px, 8.6vw, 52px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.015em;
  color: var(--ss-navy);
}

.smile-story__heading-line {
  display: inline;
}

.smile-story__heading-accent {
  font-style: italic;
  font-weight: 600;
  color: var(--ss-orange);
}

.smile-story__description {
  max-width: 30em;
  margin: 0 auto;
  font-size: clamp(15px, 1.2vw, 17px);
  line-height: 1.65;
  color: var(--ss-text);
}

.smile-story__cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  padding: 15px 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, #F7803F, var(--ss-orange) 55%, #E85A14);
  box-shadow: 0 14px 28px -12px rgba(243, 106, 33, 0.65);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  color: var(--ss-white);
  text-decoration: none;
  transition: transform 0.4s var(--ss-ease), box-shadow 0.4s var(--ss-ease);
}

.smile-story__cta-arrow {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s var(--ss-ease);
}

.smile-story__cta:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 18px 34px -12px rgba(243, 106, 33, 0.7);
}

.smile-story__cta:hover .smile-story__cta-arrow {
  transform: translateX(4px);
}

.smile-story__cta:focus-visible {
  outline: 3px solid var(--ss-navy);
  outline-offset: 4px;
}

/* Active-step statement box: only used by the pinned desktop story */
.smile-story__statement {
  display: none;
}

/* ==========================================================================
   Scenes — vertical layout (default)
   ========================================================================== */
.smile-story__experience {
  margin-top: clamp(40px, 8vw, 64px);
}

.smile-story__scenes {
  position: relative;
  display: grid;
  gap: clamp(28px, 6vw, 44px);
  max-width: 640px;
  margin: 0 auto;
  padding-left: var(--ss-rail);
}

.smile-story__connection {
  display: none;
}

.smile-story__rail {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.smile-story__rail-track,
.smile-story__rail-path {
  fill: none;
  stroke-linecap: round;
}

.smile-story__rail-track {
  stroke: var(--ss-blue);
  stroke-opacity: 0.14;
  stroke-width: 1.5;
}

.smile-story__rail-path {
  stroke: var(--ss-blue);
  stroke-width: 2;
}

/* ---- A scene ---- */
.story-scene {
  position: relative;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 8px 8px 24px;
}

/* Rail marker (vertical layout) */
.story-scene::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: calc(var(--ss-rail) / -2 - 7px);
  top: 34px;
  width: 14px;
  height: 14px;
  border: 3px solid var(--ss-white);
  border-radius: 50%;
  background: #B9D5F2;
  box-shadow: 0 0 0 1px rgba(29, 111, 216, 0.25);
  transition: background-color 0.5s var(--ss-ease), box-shadow 0.5s var(--ss-ease);
}

.story-scene.is-active::before {
  background: var(--ss-orange);
  box-shadow: 0 0 0 5px rgba(243, 106, 33, 0.18);
}

/* Arched glass card */
.story-scene__frame {
  position: absolute;
  z-index: 0;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 50cqw 50cqw 26px 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.78) 60%);
  box-shadow: 0 30px 60px -36px rgba(11, 52, 120, 0.35);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Arched image */
.story-scene__visual {
  position: relative;
  z-index: 1;
  height: var(--ss-visual-h);
  overflow: hidden;
  border-radius: calc(50cqw - 8px) calc(50cqw - 8px) 0 0;
  background: #DCE9F6;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7);
  will-change: transform;
}

.story-scene__visual::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 26%;
  background: linear-gradient(180deg, rgba(245, 250, 255, 0), rgba(245, 250, 255, 0.92));
  pointer-events: none;
}

.story-scene__media {
  width: 100%;
  height: 100%;
}

.story-scene__image {
  display: block;
  width: 100%;
  height: 112%;
  margin-top: -6%;
  object-fit: cover;
  object-position: 50% 30%;
}

.story-scene__image--right {
  object-position: 68% 30%;
}

/* Floating icon on the image edge */
.story-scene__icon {
  position: absolute;
  z-index: 3;
  left: calc(50% - var(--ss-icon) / 2);
  top: calc(8px + var(--ss-visual-h) - var(--ss-icon) / 2);
  width: var(--ss-icon);
  height: var(--ss-icon);
}

.story-scene__icon-disc {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 4px solid var(--ss-white);
  border-radius: 50%;
  background: linear-gradient(145deg, #3D8BEA, var(--ss-navy) 85%);
  box-shadow: 0 12px 24px -10px rgba(8, 43, 99, 0.55);
}

.story-scene__icon svg {
  width: 44%;
  height: 44%;
  fill: none;
  stroke: var(--ss-white);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Text */
.story-scene__body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--ss-icon) / 2 + 16px) 16px 0;
  text-align: center;
}

.story-scene__number {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ss-soft-blue);
  font-family: var(--ss-font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--ss-navy);
  transition: background-color 0.5s var(--ss-ease), color 0.5s var(--ss-ease);
}

.story-scene.is-active .story-scene__number {
  background: var(--ss-navy);
  color: var(--ss-white);
}

.story-scene__title {
  margin: 12px 0 6px;
  font-family: var(--ss-font-display);
  font-size: clamp(24px, 6vw, 30px);
  font-weight: 700;
  line-height: 1.15;
  color: var(--ss-navy-deep);
}

.story-scene__statement {
  margin: 0 0 8px;
  font-family: var(--ss-font-display);
  font-size: 18px;
  font-style: italic;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ss-orange);
}

.story-scene__text {
  max-width: 28em;
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ss-text);
}

@media (max-width: 399.98px) {
  .smile-story {
    --ss-rail: 28px;
    --ss-icon: 50px;
  }

  .story-scene__body {
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* ==========================================================================
   Panel layout (wide AND tall enough to pin)
   ========================================================================== */
@media (min-width: 992px) and (min-height: 620px) {
  .smile-story {
    --ss-icon: clamp(46px, 3.6vw, 60px);
    /* Usable viewport height. A page with a sticky header sets
       --ss-pin-offset to that header's height (the pin then starts below
       it); standalone the offset is 0, i.e. plain vh. */
    --ss-vh: calc((100vh - var(--ss-pin-offset, 0px)) / 100);
    --ss-visual-h: clamp(220px, calc(var(--ss-vh) * 44), 440px);

    display: flex;
    align-items: center;
    min-height: calc(var(--ss-vh) * 100);
    padding: clamp(28px, calc(var(--ss-vh) * 6), 80px) 0;
  }

  .smile-story__container {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: clamp(20px, calc(var(--ss-vh) * 3), 36px);
  }

  /* 992–1199: compact intro across the top */
  .smile-story__intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 48px;
    align-items: end;
    max-width: none;
    text-align: left;
  }

  .smile-story__eyebrow,
  .smile-story__heading,
  .smile-story__cta {
    grid-column: 1;
  }

  .smile-story__heading {
    margin: 10px 0 0;
    font-size: clamp(34px, 3.6vw, 46px);
  }

  .smile-story__description,
  .smile-story__statement {
    grid-column: 2;
  }

  .smile-story__description {
    grid-row: 1 / span 2;
    align-self: end;
    margin: 0;
  }

  .smile-story__cta {
    grid-row: 3;
    justify-self: start;
    margin-top: 16px;
    padding: 13px 24px;
    font-size: 15px;
  }

  .smile-story__experience {
    margin-top: 0;
  }

  .smile-story__scenes {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: start;
    gap: clamp(10px, 1.1vw, 18px);
    max-width: none;
    padding-left: 0;
  }

  .smile-story__rail,
  .story-scene::before {
    display: none;
  }

  .smile-story__connection {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
  }

  .smile-story__connection-track,
  .smile-story__connection-path {
    fill: none;
    stroke-linecap: round;
  }

  .smile-story__connection-track {
    stroke: var(--ss-blue);
    stroke-opacity: 0.16;
    stroke-width: 1.5;
  }

  .smile-story__connection-path {
    stroke: var(--ss-blue);
    stroke-width: 2;
  }

  .smile-story__connection-node {
    fill: #9CC3EE;
    stroke: var(--ss-white);
    stroke-width: 2.5;
    transition: fill 0.5s var(--ss-ease);
  }

  .smile-story__connection-node.is-passed {
    fill: var(--ss-blue);
  }

  /* Gentle wave across the panels */
  .story-scene {
    margin-top: var(--ss-offset, 0px);
    padding: 7px 7px 18px;
  }

  .story-scene:nth-of-type(5n + 2) { --ss-offset: clamp(10px, 2.4vh, 22px); }
  .story-scene:nth-of-type(5n + 3) { --ss-offset: clamp(18px, 4.4vh, 40px); }
  .story-scene:nth-of-type(5n + 4) { --ss-offset: clamp(8px, 2vh, 18px); }

  .story-scene__visual {
    border-radius: calc(50cqw - 7px) calc(50cqw - 7px) 0 0;
  }

  .story-scene__icon {
    top: calc(7px + var(--ss-visual-h) - var(--ss-icon) / 2);
  }

  .story-scene__body {
    padding: calc(var(--ss-icon) / 2 + 10px) clamp(10px, 1vw, 16px) 0;
  }

  .story-scene__number {
    width: clamp(34px, 2.6vw, 42px);
    height: clamp(34px, 2.6vw, 42px);
    font-size: clamp(15px, 1.2vw, 18px);
  }

  .story-scene__title {
    margin: 8px 0 6px;
    font-size: clamp(19px, 1.7vw, 27px);
  }

  /* The statement moves to the intro box on desktop; keep it for screen readers */
  .story-scene__statement {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .story-scene__text {
    font-size: clamp(12.5px, 0.95vw, 15px);
    line-height: 1.55;
  }

  /* Statement box (shown only when the cinematic JS is running) */
  .smile-story--cinematic .smile-story__statement {
    position: relative;
    display: block;
    min-height: 2.8em;
    margin-top: 14px;
    font-family: var(--ss-font-display);
    font-size: clamp(17px, 1.4vw, 22px);
    font-style: italic;
    font-weight: 500;
    line-height: 1.35;
    color: var(--ss-navy);
  }

  .smile-story--cinematic .smile-story__statement {
    grid-row: 3;
    align-self: end;
  }

  .smile-story__statement-item {
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 0;
  }

  .smile-story__statement-step {
    flex: 0 0 auto;
    font-family: var(--ss-font-body);
    font-size: 12px;
    font-style: normal;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--ss-orange);
  }
}

/* 992–1199: shorter images so intro + panels fit one screen */
@media (min-width: 992px) and (max-width: 1199.98px) and (min-height: 620px) {
  .smile-story {
    --ss-visual-h: clamp(190px, calc(var(--ss-vh) * 30), 320px);

    padding: clamp(18px, calc(var(--ss-vh) * 3.5), 40px) 0;
  }
}

/* ≥ 1200: intro on the left, panels on the right */
@media (min-width: 1200px) and (min-height: 620px) {
  .smile-story__container {
    grid-template-columns: minmax(270px, 0.36fr) minmax(0, 1fr);
    gap: clamp(36px, 4vw, 80px);
  }

  .smile-story__intro {
    display: block;
  }

  .smile-story__heading {
    margin: 22px 0 22px;
    font-size: clamp(44px, 4.1vw, 74px);
    line-height: 1.04;
  }

  .smile-story__heading-line {
    display: block;
  }

  .smile-story__description {
    max-width: 21em;
  }

  .smile-story__cta {
    margin-top: 30px;
    padding: 15px 28px;
    font-size: 16px;
  }

  .smile-story--cinematic .smile-story__statement {
    max-width: 18em;
    min-height: 3.2em;
    margin-top: clamp(24px, 4vh, 40px);
    padding-top: clamp(16px, 2.4vh, 24px);
    border-top: 1px solid rgba(11, 52, 120, 0.12);
  }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .smile-story__cta,
  .smile-story__cta-arrow,
  .story-scene::before,
  .story-scene__number,
  .smile-story__connection-node {
    transition: none;
  }

  .smile-story__cta:hover,
  .smile-story__cta:hover .smile-story__cta-arrow {
    transform: none;
  }

  .story-scene__visual {
    will-change: auto;
  }
}

/* Standalone preview page only */
body.smile-story-preview {
  margin: 0;
  background: #FFFFFF;
}
