/* Keep the animated story in separate columns except on small phones. */
.mobile-fit-chapter { display: none; }

@media (min-width: 431px) and (max-width: 760px) {
  html[data-fit-handoff-mode="mobile-scroll"]
    .software-choice-hero .product-flow-grid > .product-flow-story {
    padding-right: 12px;
  }

  html[data-fit-handoff-mode="mobile-scroll"] #how-it-works .custom-fit-slide-title {
    font-size: 30px;
    letter-spacing: 0;
  }

  html[data-fit-handoff-mode="mobile-scroll"] #how-it-works .custom-fit-lead {
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
  }

}

/* Rotation changes the hardware's facing, not its reserved column. */
@media (min-width: 601px) {
  html[data-device-rotation="true"][data-device-render="reference"][data-screen-render="live-perspective"]
    .software-choice-hero .floral-device-showcase .floral-hero-product[data-device-rotation-ready="true"]
    > .product-device-stage > .product-monitor {
    margin-left: calc(4% * (1 - var(--device-turn, 0)));
  }
}

@media (min-width: 601px) {
  html[data-device-rotation="true"][data-device-render="reference"][data-screen-render="live-perspective"] body
    .floral-hero-product[data-device-rotation-ready="true"] > .product-device-stage {
    translate: var(--device-stage-offset, 0px) 0;
  }

  html[data-device-rotation="true"][data-device-render="reference"][data-screen-render="live-perspective"] body
    .floral-device-showcase [data-device-rotation-ready="true"] .product-phone {
    translate: var(--device-phone-offset, 0px) var(--fit-hero-phone-y, 22%) !important;
  }
}

/* Preserve the device sizes; the row placement uses the space beside the copy. */
@media (min-width: 431px) and (max-width: 1280px) {
  .software-choice-hero .floral-hero-product {
    --medium-fit-phone-width: clamp(44px, 22%, 90px);
  }

  html:is([data-fit-handoff-mode="desktop"], [data-fit-handoff-mode="mobile-scroll"])
    .software-choice-hero .custom-software-card > .floral-device-showcase {
    top: max(76px, calc(var(--fit-story-sticky-top, calc(50svh - 70px)) - 48px));
  }

  html[data-device-rotation="true"][data-device-render="reference"][data-screen-render="live-perspective"]
    .software-choice-hero .floral-device-showcase .floral-hero-product[data-device-rotation-ready="true"]
    > .product-device-stage > .product-monitor {
    /* Compensate for perspective as the monitor turns; keep its size through
       the hero-to-story handoff instead of shrinking it to reserve a phone rail. */
    --medium-fit-monitor-width: calc(72% + 10.368% * var(--device-turn, 0));
    flex-basis: var(--medium-fit-monitor-width) !important;
    width: var(--medium-fit-monitor-width) !important;
    margin-left: calc(4% * (1 - var(--device-turn, 0)));
  }

  html[data-device-rotation="true"][data-device-render="reference"][data-screen-render="live-perspective"] body
    .software-choice-hero .floral-device-showcase .floral-hero-product[data-device-rotation-ready="true"] .product-phone {
    width: calc(25.1% * (1 - var(--floral-fit-progress, 0)) + var(--medium-fit-phone-width) * var(--floral-fit-progress, 0)) !important;
    right: calc(-1.6% * (1 - var(--floral-fit-progress, 0))) !important;
    bottom: calc(18.5% - 6.5% * var(--floral-fit-progress, 0)) !important;
    scale: calc(1 + (var(--fit-hero-phone-scale, 1) - 1) * (1 - var(--floral-fit-progress, 0))) !important;
    translate: var(--device-phone-offset, 0px) calc(var(--fit-hero-phone-y, 22%) * (1 - var(--floral-fit-progress, 0))) !important;
  }
}

@media (min-width: 761px) and (max-width: 1280px) {
  .software-choice-hero .software-choice-comparison.product-flow-grid {
    grid-template-columns: minmax(0, 1fr) clamp(160px, 18vw, 246px) minmax(0, 1fr);
  }
}

@media (min-width: 1025px) and (max-width: 1280px) {
  html[data-fit-handoff-mode="desktop"]
    .software-choice-hero .custom-software-card > .floral-device-showcase {
    top: max(76px, calc(var(--fit-story-sticky-top, calc(50svh - 70px)) - 80px));
  }
}

@media (max-width: 430px) {
  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"] {
    --mobile-fit-art-growth: .75;
  }

  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    .software-choice-hero .product-flow-grid > .product-flow-story {
    grid-column: 1 / -1;
    z-index: 2;
    padding-right: 0;
  }

  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    .software-choice-hero .product-flow-grid > .custom-software-card {
    z-index: 1;
    pointer-events: none;
  }

  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    #how-it-works .custom-fit-slide {
    min-height: max(460px, 72svh) !important;
    padding: 24px 0 96px !important;
  }

  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    #how-it-works .custom-fit-slide-copy {
    width: 100%;
    max-width: 440px;
    padding: 0 10px 18px;
    border: 0;
  }

  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    #how-it-works .mobile-fit-chapter {
    display: block;
    margin: 0 0 14px;
    color: #91aaa6;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    letter-spacing: 0;
  }

  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    #how-it-works .custom-fit-slide-title {
    max-width: 100%;
    font-family: var(--font-body);
    font-size: 29px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: 0;
    text-transform: none;
    text-shadow: none;
  }

  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    #how-it-works .custom-fit-lead {
    max-width: 100%;
    margin-top: 20px;
    color: #d3dfe4;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
    text-shadow: 0 1px 4px #05090f, 0 2px 12px #05090f;
  }

  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    #how-it-works .custom-fit-slide :is(.custom-fit-slide-title, .custom-fit-lead) {
    scale: 1;
  }

  /* Fade GPU shells, live screens and the tag together after the hero handoff. */
  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    .software-choice-hero .floral-device-showcase .product-device-stage {
    transform-origin: 100% var(--fit-story-monitor-center, 41.7%);
    transform: scale(calc(1 + var(--mobile-fit-art-growth) * var(--floral-fit-progress, 0)));
    translate: 0 calc(128px * var(--floral-fit-progress, 0));
    -webkit-mask-image: linear-gradient(145deg,
      rgb(0 0 0 / calc(1 - var(--floral-fit-progress, 0))) 30%,
      rgb(0 0 0 / calc(1 - .96 * var(--floral-fit-progress, 0))) 48%,
      rgb(0 0 0 / calc(1 - .68 * var(--floral-fit-progress, 0))) 62%,
      #000 82%);
    mask-image: linear-gradient(145deg,
      rgb(0 0 0 / calc(1 - var(--floral-fit-progress, 0))) 30%,
      rgb(0 0 0 / calc(1 - .96 * var(--floral-fit-progress, 0))) 48%,
      rgb(0 0 0 / calc(1 - .68 * var(--floral-fit-progress, 0))) 62%,
      #000 82%);
    -webkit-mask-size: calc(100% + 24px) calc(100% + 80px);
    mask-size: calc(100% + 24px) calc(100% + 80px);
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-clip: no-clip;
    mask-clip: no-clip;
  }

  html[data-device-render="reference"][data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    .software-choice-hero .floral-device-showcase .product-monitor
    > :is(.monitor-price-hardware, .product-monitor-frame, .device-shell-canvas, .device-shell-piece) {
    -webkit-mask-image: none;
    mask-image: none;
  }

  html[data-device-render="reference"][data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    .software-choice-hero .floral-device-showcase .floral-hero-product .product-phone {
    width: calc(25.1% + 3.4% * var(--floral-fit-progress, 0)) !important;
    right: calc(-1.6% + 1.6% * var(--floral-fit-progress, 0)) !important;
    bottom: calc(18.5% - 16.5% * var(--floral-fit-progress, 0)) !important;
  }
}

@media (max-width: 360px) {
  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    #how-it-works .custom-fit-slide-title {
    font-size: 26px;
  }

  html[data-fit-handoff-mode="mobile-scroll"][data-mobile-fit-art="fade"]
    #how-it-works .custom-fit-lead {
    font-size: 16px;
  }
}

/* Compact screens use the progress track beside their sticky bubbles. */
@media (max-width: 600px) {
  #how-it-works .custom-fit-stage::before,
  #how-it-works .custom-fit-stage::after {
    content: none;
    display: none;
  }
}

#how-it-works .custom-fit-slide .custom-fit-slide-copy {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
}

@media (min-width: 601px) {
  #how-it-works .custom-fit-stage::before,
  #how-it-works .custom-fit-stage::after {
    content: "";
    display: block;
    left: 0;
  }

  #how-it-works .custom-fit-slide .custom-fit-slide-copy {
    padding-inline: 18px;
  }
}

#how-it-works .custom-fit-slide:not(:last-child) {
  margin-bottom: clamp(32px, 4svh, 48px) !important;
}

/* Narrow desktop windows keep the same two-column story without reserving a
   phone-sized viewport for every paragraph. The bubbles start below 601px. */
@media (min-width: 601px) and (max-width: 760px) {
  #how-it-works .custom-fit-stage::before,
  #how-it-works .custom-fit-stage::after {
    position: absolute;
    top: 24px;
    bottom: 16px;
    z-index: 0;
    width: 2px;
    border-radius: 999px;
    pointer-events: none;
  }

  #how-it-works .custom-fit-stage::before {
    background: rgba(174, 198, 211, .14);
  }

  #how-it-works .custom-fit-stage::after {
    background: linear-gradient(180deg, #79f2c0, #48e0ba);
    box-shadow: 0 0 8px rgba(121, 242, 192, .28);
    transform: scaleY(var(--custom-fit-rail-progress, 0));
    transform-origin: top center;
  }

  html[data-fit-handoff-mode="mobile-scroll"] #how-it-works .custom-fit-slide {
    min-height: 0 !important;
    padding-block: clamp(24px, 4svh, 36px) !important;
  }

  html[data-fit-handoff-mode="mobile-scroll"]
    .software-choice-hero .product-flow-grid > .product-flow-story {
    padding-inline: 0;
    padding-top: clamp(48px, 8svh, 72px);
  }
}

@media (min-width: 761px) {
  #how-it-works .custom-fit-slide .custom-fit-slide-title {
    font-size: clamp(34px, 3.8vw, 64px);
    line-height: 1.02;
  }

  #how-it-works .custom-fit-slide .custom-fit-lead {
    max-width: 100%;
    margin-top: 20px;
    font-size: clamp(16px, 1.2vw, 18px);
    line-height: 1.55;
  }
}
