/* ============================================================
   FormuVet — 3D phone (js/fv3d)
   Hero: live phone with a fly-in. Features: one pinned phone whose
   screen follows the feature being read. Stills are the fallback.
   ============================================================ */

/* position: sticky needs the VIEWPORT as its scrollport. `overflow-x: hidden`
   on body and on .section turns each into a scroll container of its own
   (overflow-y computes to auto), and a sticky child then "sticks" to a box that
   never scrolls. `clip` cuts the same horizontal overflow without doing that. */
@supports (overflow: clip) {
  body { overflow-x: clip !important; }
  #section-features { overflow-x: clip; }
}

/* ---- shared ---- */
.fv3d { position: relative; }
.fv3d__canvas {
  position: absolute;
  display: block;
  pointer-events: none;           /* the host takes the drag; the canvas may overhang its neighbours */
  opacity: 0;
  transition: opacity 0.45s ease;
}
.fv3d--live > .fv3d__canvas { opacity: 1; }
.fv3d__poster,
.fv3d__still {
  display: block;
  transition: opacity 0.3s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.fv3d--live > .fv3d__poster,
.fv3d--live > .fv3d__still { opacity: 0; visibility: hidden; }
.fv3d__still.is-swapping { opacity: 0; }
.fv3d.is-dragging { cursor: grabbing; }

/* ---- hero ---- */
.fv3d--hero {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  cursor: grab;
  touch-action: pan-y;            /* vertical swipes still scroll the page */
}
.fv3d--hero > .fv3d__canvas { left: -35%; top: -16%; width: 170%; height: 132%; }
/* out of flow: an in-flow 900px-wide image would set the grid column's min-content width and push the hero wider than a phone screen */
.fv3d--hero > .fv3d__poster { position: absolute; left: 50%; top: 50%; height: 112%; width: auto; max-width: none; transform: translate(-50%, -50%); }
/* while the live phone boots, keep the still back so the fly-in is the first thing seen */
html.fv3d-boot .fv3d--hero:not(.fv3d--static) > .fv3d__poster { opacity: 0; }
.fv3d--hero.fv3d--static > .fv3d__poster { animation: fv3dPosterIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes fv3dPosterIn { from { opacity: 0; transform: translate(-50%, calc(-50% + 24px)); } to { opacity: 1; transform: translate(-50%, -50%); } }

@media (min-width: 1025px) {
  .hero__visual { height: clamp(480px, 66vh, 700px); }
}
@media (max-width: 1024px) {
  .hero__visual { height: 480px; }
  .fv3d--hero > .fv3d__canvas { left: -10%; top: -10%; width: 120%; height: 120%; }
  .fv3d--hero > .fv3d__poster { height: 104%; }
}
@media (max-width: 768px) {
  .hero__visual { height: 440px; padding-top: 0; }
  .fv3d--hero > .fv3d__canvas { left: 0; width: 100%; }
}

/* ---- features: pinned phone ---- */
.story__stage { display: none; }
.story__still {
  display: block;
  width: min(300px, 84%);
  height: auto;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

@media (min-width: 1024px) {
  .story {
    /* one step and the pinned stage share a height, and the stage is centred in the
       viewport: the phone is then fully in view for the first and the last step alike */
    --story-h: 76vh;
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    column-gap: var(--space-10);
    align-items: start;
    max-width: 1180px;
    margin: 0 auto;
    counter-reset: fvstep;
  }
  .story .story__steps { display: flex; flex-direction: column; gap: 0; padding-bottom: 12vh; }

  /* a step is plain text beside the phone, not a card */
  .story .story__step {
    counter-increment: fvstep;
    min-height: var(--story-h);
    justify-content: center;
    align-items: flex-start;
    text-align: left;
    gap: var(--space-5);
    padding: var(--space-8) 0;
    background: none !important;
    border: 0;
    border-radius: 0;
    box-shadow: none !important;
    overflow: visible;
  }
  .story .story__step::before,
  .story .story__step::after { display: none; }
  .story .story__step > * { transition: opacity 0.45s ease; }
  .story .story__step:not(.is-current) > * { opacity: 0.3; }
  .story .feature-card__content { flex: 0 0 auto; }
  .story .feature-card__content::before {
    content: counter(fvstep, decimal-leading-zero);
    display: block;
    margin-bottom: var(--space-3);
    font-family: var(--font-family-title);
    font-size: var(--font-size-sm);
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--card-color);
  }
  .story .feature-card__title {
    font-size: clamp(1.9rem, 2.7vw, 2.6rem);
    line-height: 1.12;
    letter-spacing: -0.025em;
    margin-bottom: var(--space-3);
  }
  .story .feature-card__desc {
    font-size: var(--font-size-lg);
    line-height: 1.65;
    max-width: 30em;
    margin: 0;
  }
  /* the chat step shows the real chat screen on the phone; its mock chat cards are for the card layout */
  .story .chat-system-visual { display: none; }
  .story .feature-card--chat-system {
    flex-direction: column !important;
    align-items: flex-start !important;
    padding: var(--space-8) 0 !important;
    gap: var(--space-5) !important;
  }
  .story .feature-card--chat-system .feature-card__content { flex: 0 0 auto; max-width: none; }
  .story .feature-card--chat-system .feature-card__icon { margin: 0; }
  .story__still { display: none; }

  .story__stage {
    display: block;
    position: sticky;
    top: calc((100vh - var(--story-h)) / 2);
    height: var(--story-h);
  }
  .fv3d--story {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: pan-y;
  }
  .fv3d--story > .fv3d__canvas { left: -8%; top: -12%; width: 116%; height: 124%; }
  .fv3d--story > .fv3d__still { max-height: 104%; width: auto; max-width: 100%; flex-shrink: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .fv3d--hero.fv3d--static > .fv3d__poster { animation: none; }
  .story .story__step > *,
  .fv3d__canvas,
  .fv3d__poster,
  .fv3d__still { transition: none; }
}

/* ---- Section labels (2026-11-16) ----
   "KEY FEATURES" and "ER & ICU MODE" were loose coloured text with a stray
   icon (the ER one was a dollar sign). Now a pill, like the hero badge. */
.features__label {
  gap: 8px;
  padding: 8px 16px 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  background: rgba(var(--accent-rgb), 0.08);
  font-family: var(--font-family-title);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
  color: var(--color-green);
  margin-bottom: var(--space-5);
}
.features__label svg { width: 16px; height: 16px; flex-shrink: 0; }
.features__label--dark {
  color: #FF7A8A;
  border-color: rgba(237, 21, 56, 0.45);
  background: rgba(237, 21, 56, 0.12);
  box-shadow: 0 0 24px rgba(237, 21, 56, 0.18);
}
.features__label--dark svg { animation: fvPulse 1.6s ease-in-out infinite; }
@keyframes fvPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.features__title--dark { font-size: clamp(2rem, 4vw, 2.75rem); letter-spacing: -0.03em; }
@media (prefers-reduced-motion: reduce) { .features__label--dark svg { animation: none; } }

/* ---- Chat feature card (2026-11-16) ----
   It now shows the real chat screen like the other cards. At tablet width the
   grid is two columns, so the seventh card spans both rather than sitting alone. */
@media (min-width: 769px) and (max-width: 1023px) {
  .story__steps > .story__step:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
