/* ==========================================================================
   Platform — one dark green panel with group pills on top. Desktop: the open
   group's feature names; the chosen feature's sentence and screenshot below.
   Phones: the open group's features as cards to swipe through.
   ========================================================================== */

.platform-panel {
  padding-top: 16px;
  border-radius: var(--border-radius-lg);
  background: var(--brand-primary);
  color: #fff;
  text-align: center;
  overflow: hidden;
}

/* Group pills in one soft track */
.platform-groups {
  display: inline-flex;
  gap: 2px;
  max-width: calc(100% - 32px);
  padding: 6px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.08);
  overflow-x: auto;
  scrollbar-width: none;

  button {
    flex-shrink: 0;
    padding: 8px 12px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: #fff;
    font: inherit;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.3s var(--ease), color 0.3s var(--ease);

    &.is-active {
      background: #fff;
      color: var(--brand-primary);
    }

    &:focus-visible {
      outline: 2px solid var(--brand-accent);
      outline-offset: 4px;
    }
  }
}

.platform-group:not(.is-active) {
  display: none;
}

.platform-names {
  display: none;
}

.platform-feature {
  h4 {
    margin: 0;
    color: #fff;
    font-size: 18px;
    font-weight: 500;
  }

  p {
    max-width: 44ch;
    margin: 0 auto;
    color: #fff;
    font-size: 16px;
    line-height: 1.5;
  }
}

/* The screenshot frame is a .points-box; only its layout is reset here */
.platform-feature figure {
  display: block;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 30px;

  img,
  video {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
    background: #fff;
  }
}

/* Round buttons over the media: pause / play, view full size (phones), close the viewer */
.platform-video-toggle,
.platform-expand,
.platform-viewer-close {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.3s var(--ease);

  svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
  }

  @media (hover: hover) {
    &:hover {
      background: rgb(0 0 0 / 0.75);
    }
  }

  &:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
  }
}

.platform-expand,
.platform-viewer-close {
  svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

.platform-video-toggle {
  right: 42px;
  bottom: 42px;

  .platform-video-pause,
  &.is-playing .platform-video-play {
    display: none;
  }

  &.is-playing .platform-video-pause {
    display: block;
  }
}

.platform-expand {
  display: none;
}

/* Phones: a screenshot or video full size, over a dark screen */
.platform-viewer {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  --pad-y: 72px;
  padding: var(--pad-y) 16px;
  border: 0;
  background: rgb(0 0 0 / 0.9);

  /* a phone on its side: room for the close button at the side, so the media can be taller */
  @media (orientation: landscape) {
    --pad-y: 16px;
    padding-inline: 72px;
  }

  &[open] {
    display: grid;
    place-items: center;
    animation: platform-viewer-in 0.25s var(--ease);
  }

  &::backdrop {
    background: none;
  }

  img,
  video {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100dvh - 2 * var(--pad-y));
    border-radius: 12px;
    background: #fff;
  }
}

.platform-viewer-close {
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: rgb(255 255 255 / 0.15);
}

@keyframes platform-viewer-in {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .platform-viewer[open] {
    animation: none;
  }
}

/* ── Phones: the features as cards in a row that snaps, the next one peeking in ── */
@media (max-width: 768px) {
  .platform-features {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-inline: 16px;
    scroll-padding-inline: 16px;
    scroll-snap-type: x mandatory;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .platform-feature {
    display: flex;
    flex: 0 0 92%;
    flex-direction: column;
    gap: 8px;
    padding: 24px 20px 0;
    border-radius: 20px;
    background: rgb(255 255 255 / 0.06);
    text-align: left;
    overflow: hidden;
    scroll-snap-align: start;

    p {
      margin: 0;
      font-size: 15px;
    }
  }

  /* No frame here: the screenshot sits low in the card, full height, and runs off its right edge */
  .platform-feature figure {
    width: auto;
    cursor: zoom-in;
    margin: auto -20px 0 0;
    padding: 24px 0 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;

    &::before,
    &::after {
      display: none;
    }

    img,
    video {
      width: 150%;
      max-width: none;
      border-radius: 12px 0 0 0;
    }
  }

  .platform-video-toggle {
    right: 12px;
    bottom: 12px;
  }

  .platform-expand {
    display: grid;
    top: 36px;
    right: 12px;
  }

  /* Where the row is: js/platform.js sets --count and --at (0 to count - 1) */
  .platform-progress {
    width: 96px;
    height: 2px;
    margin: 24px auto 32px;
    border-radius: 2px;
    background: rgb(255 255 255 / 0.2);
    overflow: hidden;

    span {
      display: block;
      width: calc(100% / var(--count, 1));
      height: 100%;
      background: var(--brand-accent);
      transform: translateX(calc(var(--at, 0) * 100%));
    }
  }
}

/* ── Tablet and desktop: features as tabs over one shared stage ── */
@media (min-width: 769px) {
  .platform-feature h4,
  .platform-progress {
    display: none;
  }

  .platform-groups {
    gap: 6px;
  }

  .platform-groups button {
    padding: 10px 24px;
    font-size: 16px;
  }

  /* Feature names: small and dim; the chosen one is white with a green line under it,
     the only green in the panel */
  .platform-names {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 32px;
    margin-top: 32px;

    button {
      position: relative;
      padding: 0 0 8px;
      border: 0;
      background: none;
      color: var(--brand-primary-300);
      font: inherit;
      font-size: 15px;
      cursor: pointer;
      transition: color 0.3s var(--ease);

      &::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 2px;
        background: var(--brand-accent);
        transform: scaleX(0);
        transition: transform 0.3s var(--ease);
      }

      &.is-active {
        color: #fff;

        &::after {
          transform: scaleX(1);
        }
      }

      &:focus-visible {
        outline: 2px solid var(--brand-accent);
        outline-offset: 4px;
      }
    }
  }

  @media (hover: hover) {
    .platform-groups button:not(.is-active):hover {
      opacity: 0.6;
    }

    .platform-names button:hover {
      color: #fff;
    }
  }

  /* Every feature of the group shares one cell; only the chosen one shows, crossfading */
  .platform-features {
    display: grid;
    margin-top: 16px;
  }

  /* The sentence is centred in a row as tall as the longest one, so the screenshot is
     always in the same place */
  .platform-feature {
    display: grid;
    grid-area: 1 / 1;
    grid-template-rows: 1fr auto;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.4s var(--ease), visibility 0.4s;

    &.is-active {
      visibility: visible;
      opacity: 1;
    }

    p {
      font-size: 18px;
    }
  }

  /* The frame runs 40px off the bottom of the panel */
  .platform-feature figure {
    width: min(100%, 780px);
    margin: 56px auto -40px;

    img,
    video {
      border-radius: 16px;
    }
  }
}
