/* SPDX-FileCopyrightText: 2026 Projex Labs <opensource@projexlabs.com>
   SPDX-License-Identifier: LicenseRef-PolyForm-Perimeter-1.0.0

   Phones (#4511). Lophie: "the phones need a different experience tailored
   to phones and the experiences the phone introduce." This sheet, with
   phone.js, turns the designed screens into ones made for a thumb: swipes,
   snaps, a story, a bottom sheet, a bar in reach. Every rule sits inside the
   one phone query below (test/mobile.test.ts holds that), so tablets keep
   mobile.css alone and a desktop renders exactly what the design draws.
   Colours, type and spacing are the design's own tokens. */

@media (max-width: 767px),
  (hover: none) and (pointer: coarse) and (max-width: 932px) and (max-height: 500px) {
  /* ---- Hero: the whole screen, the visitor's store first ---------------------- */
  .page.hero {
    min-height: 100svh;
    justify-content: flex-end;
    padding-bottom: 28px;
  }
  .hero > .bg {
    transform: translate3d(var(--m-tx, 0px), var(--m-ty, 0px), 0) scale(1.06);
    transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .hero .stores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .hero .stores .store {
    flex: none;
    min-height: 52px;
    padding: 8px 12px;
  }
  .hero .stores .store:first-child {
    grid-column: 1 / -1;
    min-height: 60px;
    justify-content: center;
  }
  .hero .stores .store:not(:first-child) strong {
    font-size: 14.5px;
  }
  .hero .links {
    gap: 2px 24px;
  }

  /* ---- The app wall: a stream for the thumb, and a row to swipe ---------------- */
  .m-stream {
    position: relative;
    height: 216px;
    margin: 6px -4px 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(
      180deg,
      transparent,
      var(--ink) 18%,
      var(--ink) 82%,
      transparent
    );
    mask-image: linear-gradient(180deg, transparent, var(--ink) 18%, var(--ink) 82%, transparent);
  }
  .m-stream::-webkit-scrollbar {
    display: none;
  }
  .m-stream.m-held {
    scroll-snap-type: y proximity;
  }
  .m-stream .m-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 64px 4px;
  }
  .m-stream .pill {
    scroll-snap-align: center;
    opacity: 1;
    transform: none;
    padding: 7px 14px 7px 7px;
    min-width: 0;
  }
  .m-stream .pill .nm {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tri-cards {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 calc(-1 * var(--gutter));
    padding: 12px var(--gutter) 16px;
    scroll-padding: 0 var(--gutter);
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .tri-cards::-webkit-scrollbar {
    display: none;
  }
  .tri-cards .tcard {
    flex: 0 0 82%;
    scroll-snap-align: start;
    flex-direction: column;
    align-items: flex-start;
    transform: none;
  }
  .tri-cards .tcard.on {
    transform: none;
  }
  .tri-cards .viz {
    flex: none;
    width: 72px;
    height: 72px;
  }

  /* ---- Outcomes: a story, step by step ---------------------------------------- */
  .reel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 14px 16px 20px;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
  }
  .reel .tabs {
    order: -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
  }
  .reel .tab {
    min-height: 32px;
    padding: 14px 0 0;
    font-size: 12px;
    gap: 6px;
    color: var(--muted);
  }
  .reel .tab i {
    height: 3px;
  }
  .reel .tab.m-past i::after {
    transform: scaleX(1);
    animation: none;
  }
  .reel .reel-side {
    gap: 10px;
  }
  .reel .rn {
    font-size: clamp(60px, 18vw, 84px);
  }

  /* ---- Draw your line: a list the thumb pulls the line through ------------------ */
  .fence-track {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0;
    padding: 0;
    margin: 14px 0 6px;
    cursor: default;
    touch-action: pan-y;
  }
  .fence-track .tool {
    margin: 4px 0;
    min-height: 44px;
    padding: 0 16px;
    text-align: left;
    place-items: center start;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transform: none;
  }
  .fence-track .tool.in {
    transform: translateX(6px);
  }
  .fence-track .fence-line {
    display: block;
    left: -6px;
    right: -6px;
    top: calc(var(--x, 37.5) * 1%);
    bottom: auto;
    width: auto;
    height: 4px;
    margin: -2px 0 0;
    transition: top 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
    touch-action: none;
    cursor: ns-resize;
    background: linear-gradient(90deg, var(--blue), var(--violet), var(--orange));
  }
  .fence-track .fence-line::before {
    inset: -20px 0;
  }
  .fence-track .fence-line i {
    left: auto;
    right: 8px;
  }
  .fence-track .fence-line i::before,
  .fence-track .fence-line i::after {
    top: 13px;
    bottom: auto;
    left: 11px;
    right: 11px;
    width: auto;
    height: 2px;
  }
  .fence-track .fence-line i::after {
    top: 19px;
  }
  .fence.dragging .fence-line {
    transition: none;
  }
  .fence-top .tally b {
    display: inline-block;
  }
  .fence-top .tally b.m-tick {
    animation: m-tick 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  @keyframes m-tick {
    40% {
      transform: scale(1.35);
      color: var(--accent);
    }
  }

  /* ---- Under the hood: cards to swipe, one peeking ------------------------------ */
  .specs {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 calc(-1 * var(--gutter));
    padding: 8px var(--gutter) 18px;
    scroll-padding: 0 var(--gutter);
    scrollbar-width: none;
    perspective: 1200px;
  }
  .specs::-webkit-scrollbar {
    display: none;
  }
  .specs .sweep {
    display: none;
  }
  .specs .spec {
    flex: 0 0 76%;
    min-height: 168px;
    scroll-snap-align: start;
    transform-style: preserve-3d;
    cursor: pointer;
  }
  .specs .spec.m-turn {
    animation: m-turn 0.36s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  @keyframes m-turn {
    50% {
      transform: rotateY(90deg);
    }
  }

  /* ---- Pricing: one plan a screen, a segmented switch, a sheet for add-ons ------ */
  .bill {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .bill button {
    min-height: 48px;
  }
  .plans > *,
  .cloudset {
    min-width: 0;
  }
  .cplans {
    position: relative;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0;
    padding: 4px 0 6px;
    scrollbar-width: none;
  }
  .cplans::-webkit-scrollbar {
    display: none;
  }
  .cplans .plan {
    flex: 0 0 86%;
    scroll-snap-align: center;
  }
  .m-dots {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-top: 2px;
  }
  .m-dots button {
    width: 32px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    display: grid;
    place-items: center;
  }
  .m-dots button::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 7px;
    background: var(--muted);
    opacity: 0.55;
    transition:
      width 0.35s cubic-bezier(0.2, 0.7, 0.2, 1),
      background 0.3s ease;
  }
  .m-dots button[aria-current='true']::before {
    width: 22px;
    background: var(--accent);
    opacity: 1;
  }
  .livegrid .addons {
    display: none;
  }
  .m-open-sheet {
    width: 100%;
  }
  .m-scrim {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: var(--ink);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .m-scrim.on {
    opacity: 0.62;
    pointer-events: auto;
  }
  .m-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 71;
    max-height: 86svh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
    border-radius: 26px 26px 0 0;
    background: var(--ink-2);
    border-top: 1px solid var(--line);
    box-shadow: 0 -30px 80px var(--ink);
    transform: translateY(105%);
    transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
    visibility: hidden;
  }
  .m-sheet.on {
    transform: translateY(var(--m-dy, 0px));
    visibility: visible;
  }
  .m-sheet.m-drag {
    transition: none;
  }
  .m-grab {
    display: grid;
    place-items: center;
    height: 28px;
    touch-action: none;
    cursor: grab;
  }
  .m-grab::before {
    content: '';
    width: 42px;
    height: 5px;
    border-radius: 5px;
    background: var(--muted);
    opacity: 0.6;
  }
  .m-sheet .addons {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  /* ---- A bar in thumb reach once the hero has gone ----------------------------- */
  .top .btn {
    display: none;
  } /* the bar below carries it, in reach */
  .m-getbar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 50;
    transform: translateY(140%);
    transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .m-getbar.on {
    transform: none;
  }
  .m-getbar .store {
    width: 100%;
    justify-content: center;
    min-height: 56px;
    background: var(--ink-2);
  }
  body.m-sheet-open .m-getbar {
    transform: translateY(140%);
  }
  .foot {
    padding-bottom: 84px;
  }

  /* ---- Screens come in as they enter ------------------------------------------ */
  .m-enter {
    opacity: 0;
    transform: translateY(28px) scale(0.985);
    transition:
      opacity 0.8s ease,
      transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .m-enter.m-in {
    opacity: 1;
    transform: none;
  }

  /* ---- Asked for calm: everything still arrives, nothing travels ---------------- */
  @media (prefers-reduced-motion: reduce) {
    .hero > .bg {
      transform: none;
      transition: none;
    }
    .m-enter {
      transform: none;
      transition: opacity 0.4s ease;
    }
    .fence-track .fence-line,
    .fence-track .tool.in,
    .m-sheet,
    .m-getbar {
      transition: none;
    }
    .specs .spec.m-turn {
      animation: none;
    }
  }

  /* ---- Landscape phones: short screens, so nothing insists on a full one -------- */
  @media (orientation: landscape) {
    .page.hero {
      min-height: 0;
      padding-top: 96px;
    }
    .m-stream {
      height: 160px;
    }
    .cplans .plan,
    .tri-cards .tcard {
      flex-basis: 46%;
    }
    .specs .spec {
      flex-basis: 40%;
    }
    .m-getbar {
      left: auto;
      width: 300px;
    }
  }
}
