/* Features — Figma 10080:41726 (1728 x ~1065; six states, one per active item).
   Layout at 1728: headline at y=140, list at y=372 (left), phone mockup top-aligned with the list on the right,
   cropped by the section's bottom edge. The phone PNGs are 477x730 (@1x) with ~20px of baked-in shadow
   margin around the phone, so the image sits 38px above / 37px right of the Figma phone frame. */
.features {
  --shot-w: clamp(300px, calc(477 / 1728 * 100vw), 477px);
  --shot-bleed: calc(var(--shot-w) * 37 / 477);
  --shot-lift: calc(var(--shot-w) * 38 / 477);
  --item-gap: clamp(20px, calc(36 / 1728 * 100vw), 36px);
  --ease-out: cubic-bezier(0.22, 0.8, 0.24, 1);
  padding: clamp(56px, calc(140 / 1728 * 100vw), 140px) var(--gutter) 0;
}

/* Decorative glow sitting mostly above the frame */
.features-glow { position: absolute; left: 143px; top: -589px; width: 616px; height: 613px; pointer-events: none; }
.features-glow img { position: absolute; left: -81.17%; top: -81.57%; width: 262.34%; height: 263.14%; }

.features-inner {
  position: relative; max-width: 1440px; margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) calc(var(--shot-w) - var(--shot-bleed));
  column-gap: clamp(24px, 3vw, 64px);
}

.features-title {
  grid-column: 1 / -1; display: flex; flex-direction: column; max-width: 1084px; text-wrap: balance;
  font-size: clamp(36px, calc(54.74 / 1728 * 100vw), 54.74px); line-height: 1.2057;
  margin-bottom: clamp(40px, calc(100 / 1728 * 100vw), 100px);
}
.features-title-accent { color: var(--text-success); }

/* ---- List ---- */
.features-list {
  grid-column: 1; grid-row: 2; align-self: start; display: flex; flex-direction: column; gap: var(--item-gap);
  padding-bottom: clamp(48px, calc(80 / 1728 * 100vw), 80px);
}
.features-heading { font: inherit; }
.features-trigger {
  display: block; padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
  font-size: clamp(26px, calc(38.02 / 1728 * 100vw), 38.02px); line-height: normal;
  color: var(--text-secondary);
  transition: color 0.3s ease-out;
}
.features-trigger:hover,
.features-item.is-active .features-trigger { color: var(--text-primary); }
.features-item.is-active .features-trigger { cursor: default; }
.features-trigger:focus-visible { outline: 2px solid var(--brand-dark-green); outline-offset: 6px; border-radius: 4px; }

/* Collapsible description: animates 0fr -> 1fr so the height eases without measuring in JS. */
.features-panel {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.45s var(--ease-out);
}
.features-item.is-active .features-panel { grid-template-rows: 1fr; }
.features-panel-inner { min-height: 0; overflow: hidden; }
.features-desc {
  /* 24px above, 95px from description to the next heading at 1728 (59 + the 36 list gap) */
  padding: clamp(12px, calc(24 / 1728 * 100vw), 24px) 0 clamp(16px, calc(59 / 1728 * 100vw), 59px);
  max-width: 725px;
  font-family: var(--font-body);
  font-size: clamp(17px, calc(22 / 1728 * 100vw), 22px); line-height: normal; color: var(--text-primary);
  opacity: 0; transform: translateY(-6px);
  transition: opacity 0.3s ease-out, transform 0.45s var(--ease-out);
}
.features-item.is-active .features-desc { opacity: 1; transform: none; transition-delay: 0.1s, 0s; }

/* ---- Phone mockup stage ---- */
.features-stage {
  grid-column: 2; grid-row: 2; align-self: end; justify-self: start;
  position: relative; width: var(--shot-w); aspect-ratio: 477 / 730;
  margin-top: calc(var(--shot-lift) * -1);
}
.features-shot {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; visibility: hidden; transform: translateY(40px);
  /* The PNGs carry a flat #fafafa margin around the phone's shadow; feather it so it never shows as a box over the glow. */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 3.5%, #000 96.5%, transparent), linear-gradient(to bottom, transparent, #000 2.5%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 3.5%, #000 96.5%, transparent), linear-gradient(to bottom, transparent, #000 2.5%);
  mask-composite: intersect;
  transition: opacity 0.4s ease-out, transform 0.45s var(--ease-out), visibility 0s linear 0.45s;
}
.features-shot.is-active {
  z-index: 2; opacity: 1; visibility: visible; transform: none;
  transition: opacity 0.4s ease-out 0.06s, transform 0.45s var(--ease-out) 0.06s, visibility 0s;
}
.features-shot.is-leaving {
  z-index: 1; visibility: visible; opacity: 0; transform: translateY(-24px) scale(0.98);
  transition: opacity 0.3s ease-out, transform 0.35s var(--ease-out), visibility 0s;
}

/* Tablet: same two columns, mockup a little larger relative to the viewport than plain scaling */
@media (max-width: 1199px) {
  .features { --shot-w: clamp(300px, 34vw, 408px); }
}

/* Mobile-only parts: chip tabs + per-item mockup card (hidden at >=900px, so desktop/tablet are untouched). */
.features-num, .features-chips, .features-mshot { display: none; }

/* Mobile — Figma 10108:4257 (402 wide): headline, a row of chips (Booking, Clients, …), then one swipeable
   panel per item: the phone in a rounded gradient card, then the feature name and description.
   js/features.js wires chips ⇄ swipe and shortens the card so headline → description fits one screen. */
@media (max-width: 899px) {
  .features { padding: 56px 0; }
  .features-glow { display: none; }
  .features-inner { display: block; }
  .features-title, .features-chips, .features-list { padding-left: var(--gutter); padding-right: var(--gutter); }
  .features-title { font-size: min(27.58px, 7.3vw); line-height: normal; margin-bottom: 24px; text-wrap: wrap; }
  .features-stage { display: none; }

  /* Chips: scroll sideways, bleed off the right edge */
  .features-chips {
    position: relative; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
  }
  .features-chips::-webkit-scrollbar { display: none; }
  .features-chip {
    flex: none; padding: 12px 16px; border-radius: 100px; cursor: pointer;
    border: 1px solid var(--border-default); background: #fff; color: var(--text-secondary);
    font-family: var(--font-body); font-size: 15.96px; line-height: normal; white-space: nowrap;
  }
  .features-chip[aria-current="true"] { background: var(--text-primary); border-color: var(--text-primary); color: #fff; }
  .features-chip:focus-visible { outline: 2px solid var(--brand-dark-green); outline-offset: 2px; }

  /* Swipe track: one panel per item */
  .features-list {
    position: relative; flex-direction: row; gap: calc(2 * var(--gutter)); margin-top: 16px; padding-bottom: 0; /* gap ≥ both gutters: no peek of the next panel */
    overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 var(--gutter);
    overscroll-behavior-x: contain; scrollbar-width: none;
  }
  .features-list::-webkit-scrollbar { display: none; }
  .features-item { flex: 0 0 100%; min-width: 0; display: flex; flex-direction: column; scroll-snap-align: start; scroll-snap-stop: always; }
  .features-num { display: none; }
  .features-panel, .features-panel-inner { display: contents; }

  /* Card: 352×488 gradient with two soft glows; phone 250 wide at (51, 51), cropped by the card's bottom. */
  .features-mshot {
    order: -1; display: block; position: relative; overflow: hidden; height: var(--features-card-h, 488px);
    border-radius: 20px;
    background:
      url("../assets/features/m-glow-7.svg") 65.45px 155.9px / 489.94px 488.835px no-repeat,
      url("../assets/features/m-glow-8.svg") -420.1px 205.9px / 706.178px 704.178px no-repeat,
      linear-gradient(to bottom, var(--bg-secondary), #e8e8f2);
  }
  /* The phone runs off the card's bottom edge like the Figma frame (no gap under it). The PNG is 477×730 (@1x) with
     a flat #fafafa margin round the phone (~21px at the sides, ~21px on top), and the phone is already cut off at its
     bottom edge. So: pin it to the card's bottom, size it so the phone's top lands at y≈51 (293.2px wide → phone ≈ 267px),
     trim the picture to the phone's outline (clip-path, 40px corners) so the pale margin never shows against the
     card's lavender, and draw the phone's drop shadow ourselves (::before) — Shane feedback.
     --features-k < 1 on short phones (js): the phone shrinks with the card. */
  .features-mshot img {
    position: absolute; z-index: 1; left: calc(50% - 146.6px * var(--features-k, 1)); bottom: 0;
    width: calc(293.2px * var(--features-k, 1)); height: auto; max-width: none;
    clip-path: inset(2.9% 4.5% 0 4.5% round calc(24.6px * var(--features-k, 1)) calc(24.6px * var(--features-k, 1)) 0 0);
  }
  .features-mshot::before {
    content: ""; position: absolute; left: calc(50% - 133.4px * var(--features-k, 1)); bottom: 0;
    width: calc(266.8px * var(--features-k, 1)); height: calc(435.7px * var(--features-k, 1));
    border-radius: calc(24.6px * var(--features-k, 1)) calc(24.6px * var(--features-k, 1)) 0 0;
    box-shadow: 0 0 12.811px rgba(0, 0, 0, 0.15); /* Figma phone frame shadow */
  }

  .features-heading { margin-top: 24px; }
  .features-trigger, .features-item.is-active .features-trigger,
  .features-trigger:hover { color: var(--text-primary); cursor: default; font-size: 22.98px; line-height: normal; }
  .features-desc, .features-item.is-active .features-desc {
    padding: 16px 0 0; max-width: none; font-size: 13.3px; line-height: normal; opacity: 1; transform: none; transition: none;
  }
}
/* Short phones: tighter gaps (js shortens the card for the rest). */
@media (max-width: 899px) and (max-height: 760px) {
  .features-title { margin-bottom: 16px; }
  .features-heading { margin-top: 16px; }
  .features-desc, .features-item.is-active .features-desc { padding-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .features-trigger,
  .features-panel,
  .features-desc,
  .features-shot,
  .features-shot.is-active,
  .features-shot.is-leaving { transition: none; }
}
