/*
  Third section placement. Desktop copy is Figma frame `copy`: 635×800,
  section-title 635×160 (bottom stroke #c0c8d4), items area 635×640.
  ideas.js sequences the steps. ideas-graphics.js owns each [data-ideas-graphic].
  product-story.js releases --story-dark when .next-section's top edge reaches viewport center.
*/

.ideas {
  --ideas-clearance: calc(var(--space-24) + var(--header-block) + var(--space-16));
  --ideas-stack-gap: var(--space-48);
  --ideas-kicker: #f18715;
  --ideas-body: #424843;
  --ideas-divider: #c0c8d4;
  --ideas-shift: var(--space-88);
  /* 200px is the desktop gap after product-story. Narrower cuts follow layout.css. */
  --ideas-lead: 200px;

  padding-top: var(--ideas-lead);
  padding-inline: var(--page-gutter);
  /* --story-dark comes from product-story.js; at 1 this matches .product-story's black, so the seam stays hidden until the section top releases it. */
  --ideas-canvas: color-mix(in srgb, var(--color-ideas-canvas), var(--color-black) calc(var(--story-dark, 0) * 100%));
  background: var(--ideas-canvas);
  color: color-mix(in srgb, var(--color-lp-headline), var(--color-white) calc(var(--story-dark, 0) * 100%));
}

/* Outside the measured pin track so the final item can leave the viewport naturally. */
.ideas-scroll-runway {
  min-height: max(60svh, var(--space-96));
  background: var(--color-ideas-canvas);
}

.ideas .next-section__title {
  color: inherit;
}

.ideas[data-ideas-moving] .ideas__item-copy,
.ideas[data-ideas-moving] .ideas__visual {
  will-change: opacity, transform;
}

.ideas__pin {
  position: sticky;
  top: var(--ideas-clearance);
  display: grid;
  align-items: center;
  min-height: calc(100svh - var(--ideas-clearance));
}

.how-it-works {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--space-48);
  align-items: center;
  width: min(100%, 720px);
  margin-inline: auto;
}

.ideas__section-title {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
  padding-bottom: var(--space-24);
}

.ideas__section-title::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--ideas-divider);
}

.ideas__kicker {
  margin: 0;
  color: var(--ideas-kicker);
}

.ideas__steps {
  display: grid;
  grid-template-rows: auto auto;
  row-gap: var(--space-48);
  min-height: 240px;
}

.ideas__scroll-indicator {
  display: none;
}

/* Frame 2147236580: one 34px track, 4px dots, 8px gaps, and a 7px scroll thumb.
   ideas.js shares the copy's progress; CSS easing here would make the indicator lag behind it. */
.ideas__scroll-step {
  position: relative;
  flex-shrink: 0;
  width: var(--space-4);
  height: calc(var(--space-4) + 30px * var(--ideas-step-expansion, 0));
  overflow: clip;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-soft-black) var(--ideas-step-opacity, 20%), transparent);
}

.ideas__scroll-step::after {
  content: "";
  position: absolute;
  top: calc((100% - 7px * var(--ideas-step-expansion, 0)) * var(--ideas-step-progress, 0));
  left: 0;
  width: 100%;
  height: calc(7px * var(--ideas-step-expansion, 0));
  border-radius: inherit;
  background: var(--color-soft-black);
  opacity: var(--ideas-step-expansion, 0);
}

.ideas__item {
  grid-area: 1 / 1;
}

.ideas__visual {
  display: grid;
  grid-area: 2 / 1;
  align-items: center;
  min-width: 0;
}

.ideas__visual--product {
  transform-style: preserve-3d;
}

.ideas__visual-product {
  /* calendar-data.js fixes the scene at 1420×900. Fit its height to the Figma 5:4 crop without reflowing the calendar. */
  --visual-stage-scale: 1;
  --visual-stage-end-x: 0deg;
  --visual-stage-end-y: 0deg;
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% * 1420 / 1125);
  scale: 1;
  transform: none;
}

.ideas__product-frame {
  position: relative;
  width: min(100%, 804px);
  margin-inline: auto;
  aspect-ratio: 5 / 4;
  overflow: hidden;
}

.ideas__product-frame::before,
.ideas__product-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Frame 2147236576-g / overgrad: a centered ellipse, transparent through 60.098%, canvas at the edge. */
.ideas__product-frame::after {
  z-index: 1;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, transparent 60.098%, var(--ideas-canvas) 100%);
}

/* Fade a separate cover instead of a VP ancestor; visual-product.css relies on that distinction to preserve tile depth. */
.ideas__product-frame::before {
  z-index: 2;
  background: var(--ideas-canvas);
  opacity: calc(1 - var(--ideas-graphic-opacity, 1));
}

.ideas[data-ideas-moving] .ideas__visual--product {
  will-change: auto;
}

.ideas[data-ideas-moving] .ideas__product-frame::before {
  will-change: opacity;
}

.ideas__item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-self: stretch;
  min-height: 0;
  /* ideas.js moves the inner copy; this stationary crop keeps it below the section-title divider. */
  overflow: clip;
  width: 100%;
}

.ideas__item-copy {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: var(--space-24);
  width: 100%;
}

.ideas__item-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-8);
}

.ideas__item-badge {
  margin: 0;
  padding-inline: var(--space-8);
  border-radius: var(--space-4);
  background: color-mix(in srgb, var(--color-light-sky) 25%, transparent);
  color: var(--color-deep-ocean);
  font: normal 500 var(--font-size-16) / var(--line-height-24) var(--font-text);
  white-space: nowrap;
}

.ideas__item-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--type-h3-size);
  line-height: var(--type-h3-line-height);
  letter-spacing: var(--type-h2-letter-spacing);
}

.ideas__item-body {
  display: grid;
  gap: var(--space-16);
  color: color-mix(in srgb, var(--ideas-body), var(--color-lp-on-dark) calc(var(--story-dark, 0) * 100%));
  font: var(--type-body-1-font);
}

.ideas__item-body p {
  margin: 0;
}

/*
  Stack measured from the supplied screenshot, with the Google card as the width anchor.
  Apple sits above and Microsoft below; both are narrower and tucked behind Google.
*/
.ideas__cards {
  position: relative;
  width: min(640px, 100%);
  margin-inline: auto;
  aspect-ratio: 1000 / 510;
}

.ideas__card {
  position: absolute;
  height: auto;
  opacity: 0;
  transform: translate3d(var(--space-64), 0, 0);
  transition:
    opacity 680ms ease,
    transform 680ms cubic-bezier(0.16, 1, 0.3, 1);
}

.ideas__cards.is-moving .ideas__card {
  will-change: opacity, transform;
}

.ideas__cards.is-shown .ideas__card {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.ideas__card--google {
  z-index: 3;
  top: 24.93%;
  left: 0;
  width: 100%;
  transition-delay: 0ms;
}

.ideas__card--apple {
  z-index: 1;
  top: 5px;
  left: 5.33%;
  width: 89.35%;
  transition-delay: 160ms;
}

.ideas__card--microsoft {
  z-index: 2;
  top: calc(61.36% - 20px);
  left: 7.39%;
  width: 89.24%;
  transition-delay: 320ms;
}

@media (max-width: 1365px) {
  .ideas {
    --ideas-lead: var(--space-96);
  }
}

@media (max-width: 743px) {
  .ideas {
    --ideas-lead: var(--space-48);
    --ideas-stack-gap: 0px;
    height: auto !important;
    /* Lets the graphic's top edge reach the viewport center on a short page. */
    padding-bottom: 50svh;
  }

  .ideas__pin {
    position: static;
    height: auto;
    min-height: 0;
  }

  .how-it-works {
    row-gap: var(--space-40);
  }

  .ideas__steps {
    display: flex;
    flex-direction: column;
    gap: var(--ideas-stack-gap);
    min-height: 0;
  }

  .ideas__item + .ideas__visual {
    margin-block-start: var(--space-48);
  }

  .ideas__visual + .ideas__item {
    margin-block-start: var(--space-96);
  }

  .ideas__item,
  .ideas__visual {
    grid-area: auto;
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
  }

  .ideas__item:empty,
  .ideas__visual:empty {
    display: none;
  }
}

@media (min-width: 1024px) and (max-width: 1365px) {
  .ideas__pin {
    height: min(800px, calc(100svh - var(--ideas-clearance)));
    min-height: 0;
    top: max(var(--ideas-clearance), calc((100svh - 800px) / 2));
  }

  .how-it-works {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(160px, max-content) minmax(0, 1fr);
    column-gap: var(--space-48);
    row-gap: 0;
    width: min(100%, var(--section-track));
    height: 100%;
  }

  .ideas__section-title {
    grid-column: 1;
    grid-row: 1;
  }

  .ideas__steps {
    display: contents;
    min-height: 0;
  }

  .ideas__item {
    grid-column: 1;
    grid-row: 2;
  }

  .ideas__visual {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    width: 100%;
  }
}

@media (min-width: 1366px) {
  .ideas__pin {
    height: 800px;
    min-height: 0;
    top: max(var(--ideas-clearance), calc((100svh - 800px) / 2));
  }

  .how-it-works {
    grid-template-columns: 635px minmax(0, 1fr);
    grid-template-rows: 160px 640px;
    column-gap: var(--space-72);
    row-gap: 0;
    align-items: stretch;
    width: min(100%, var(--section-track));
    height: 800px;
  }

  .ideas__section-title {
    grid-column: 1;
    grid-row: 1;
    width: 635px;
    height: 160px;
  }

  .ideas__steps {
    display: contents;
    min-height: 0;
  }

  .ideas__item {
    grid-column: 1;
    grid-row: 2;
    width: 635px;
    height: 640px;
  }

  .ideas__visual {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    width: 100%;
    height: auto;
  }

  .ideas__item-title {
    font-size: 40px;
    line-height: 40px;
  }
}

@media (min-width: 1367px) and (prefers-reduced-motion: no-preference) {
  .ideas[data-ideas-mode="snap"] .ideas__scroll-indicator {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    grid-column: 1;
    grid-row: 2;
    align-self: center;
    justify-self: end;
    width: var(--space-4);
    /* Center in the existing column gap; Figma puts it 12px above the item midpoint. */
    transform: translate(calc((var(--space-72) + var(--space-4)) / 2), calc(-1 * (var(--space-8) + var(--space-4))));
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ideas {
    height: auto !important;
  }

  .ideas__pin {
    position: static;
    height: auto;
    min-height: 0;
  }

  .how-it-works {
    height: auto;
    grid-template-rows: auto;
  }

  .ideas__steps {
    display: flex;
    flex-direction: column;
    gap: var(--ideas-stack-gap);
    min-height: 0;
  }

  .ideas__item,
  .ideas__visual {
    grid-area: auto;
    width: 100%;
    height: auto;
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
  }

  .ideas__item:empty,
  .ideas__visual:empty {
    display: none;
  }

  .ideas__card {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
