/* ───────────────────────────────────────────────────────────────
   Sitehouse — mobile layer
   Loaded by every page. Everything here is scoped to small screens
   or is inert on desktop, so the desktop design is untouched.
   ─────────────────────────────────────────────────────────────── */

/* ── Mobile navigation ─────────────────────────────────────── */
.m-nav-toggle {
  display: none;
  width: 44px; height: 44px; flex: none;
  align-items: center; justify-content: center;
  border: 1px solid rgb(var(--c-line)); border-radius: 999px;
  background: rgb(var(--c-surface)); color: rgb(var(--c-ink)); cursor: pointer;
  transition: border-color 200ms ease, background-color 200ms ease,
              transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.m-nav-toggle:hover { border-color: rgb(var(--c-line-firm)); background: rgb(var(--c-accent-tint)); }
.m-nav-toggle:active { transform: scale(0.93); }
.m-nav-toggle svg { display: block; }

.m-drawer {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column;
  background: rgb(var(--c-paper));
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  visibility: hidden;
  overscroll-behavior: contain;
}
.m-drawer.is-open { transform: translateX(0); visibility: visible; }

.m-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid rgb(var(--c-line));
  background: color-mix(in srgb, rgb(var(--c-paper)) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.m-drawer-close {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border: 1px solid rgb(var(--c-line)); border-radius: 999px; background: rgb(var(--c-surface));
  color: rgb(var(--c-ink)); cursor: pointer;
  transition: border-color 200ms ease, background-color 200ms ease,
              transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.m-drawer-close:hover { border-color: rgb(var(--c-line-firm)); background: rgb(var(--c-accent-tint)); }
.m-drawer-close:active { transform: scale(0.93); }
.m-drawer-body { flex: 1; overflow-y: auto; padding: 1.25rem 1.25rem 2rem; }
.m-drawer-link {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; padding: 0.9rem 0.25rem;
  border-bottom: 1px solid rgb(var(--c-line));
  font-family: 'Inter','Helvetica Neue',Arial,sans-serif;
  font-weight: 600; font-size: 1.125rem; letter-spacing: -0.02em; color: rgb(var(--c-ink));
  opacity: 0; transform: translateY(6px);
}
.m-drawer.is-open .m-drawer-link { animation: m-in 360ms cubic-bezier(0.22,1,0.36,1) forwards; }
.m-drawer-link span { color: rgb(var(--c-line-firm)); font-size: 1rem; }
.m-drawer-cta {
  display: flex; align-items: center; justify-content: center;
  min-height: 56px; margin-top: 1.5rem; border-radius: 0.5rem;
  background: rgb(var(--c-accent)); color: rgb(var(--c-on-accent)); font-weight: 600; font-size: 1rem;
}
.m-drawer-note { margin-top: 1rem; font-size: 0.8125rem; line-height: 1.55; color: rgb(var(--c-ink-soft)); }

@keyframes m-in { to { opacity: 1; transform: translateY(0); } }

body.m-locked { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .m-nav-toggle, .m-drawer-close { transition: border-color 200ms ease; }
  .m-nav-toggle:active, .m-drawer-close:active { transform: none; }
}

@media (max-width: 767px) {
  .m-nav-toggle { display: inline-flex; }
  /* The cluster itself stays — it is what holds the two controls to the
     right edge. Only the links inside it go. */
  nav .m-nav-desktop > a { display: none !important; }
  /* Beat Tailwind's gap-5 and theme.css's own sizing without !important —
     both of those files load after this one. */
  nav .m-nav-desktop { gap: 0.5rem; }
  header .theme-toggle { width: 44px; height: 44px; }
}

/* ── Mobile spacing + type rhythm ──────────────────────────── */
@media (max-width: 640px) {
  /* Sections breathe on a laptop, crowd a phone. Tighten deliberately. */
  main section > div.mx-auto { padding-left: 1.25rem; padding-right: 1.25rem; }
  main section > div.py-16 { padding-top: 4rem; padding-bottom: 4rem; }
  main section > div.pt-16 { padding-top: 4rem; }
  main section > div.pb-16 { padding-bottom: 4rem; }

  .hero-title { font-size: clamp(2rem, 8.5vw, 2.4rem); line-height: 1.08; }
  .sec-title  { font-size: clamp(1.5rem, 6.4vw, 1.85rem); }
  .doc-title  { font-size: clamp(1.6rem, 7vw, 2rem); }
  .lede { font-size: 1rem; line-height: 1.6; }

  /* Comfortable minimum for anything tappable */
  .btn, .m-tap { min-height: 48px; }
}

/* ── Touch targets ─────────────────────────────────────────── */
@media (pointer: coarse) {
  a.rounded-md, button.rounded-md, .btn { min-height: 44px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
}

/* ── FAQ accordion (mobile) ────────────────────────────────── */
.m-acc-btn {
  display: flex; width: 100%; align-items: flex-start; justify-content: space-between;
  gap: 1rem; text-align: left; background: none; border: 0; padding: 1.1rem 0;
  font: inherit; color: inherit; cursor: pointer; min-height: 56px;
}
.m-acc-sign {
  flex: none; width: 28px; height: 28px; border-radius: 999px; border: 1px solid rgb(var(--c-line-firm));
  display: flex; align-items: center; justify-content: center; color: rgb(var(--c-accent-text));
  font-size: 1rem; line-height: 1; transition: transform 220ms ease, background-color 220ms ease, color 220ms ease;
}
.m-acc-btn[aria-expanded="true"] .m-acc-sign {
  transform: rotate(45deg); background: rgb(var(--c-accent)); border-color: rgb(var(--c-accent)); color: rgb(var(--c-on-accent));
}
.m-acc-panel {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 260ms cubic-bezier(0.22,1,0.36,1);
}
.m-acc-panel > div { overflow: hidden; }
.m-acc-panel.is-open { grid-template-rows: 1fr; }

/* ── Category filter chips ─────────────────────────────────── */
.m-chips {
  display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.35rem;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.m-chips::-webkit-scrollbar { display: none; }
.m-chip {
  flex: none; min-height: 40px; padding: 0.5rem 0.9rem; border-radius: 999px;
  border: 1px solid rgb(var(--c-line)); background: rgb(var(--c-surface)); color: rgb(var(--c-ink-mid));
  font-size: 0.8125rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
.m-chip:hover { border-color: rgb(var(--c-line-firm)); }
.m-chip.is-on { background: rgb(var(--c-accent)); border-color: rgb(var(--c-accent)); color: rgb(var(--c-on-accent)); }

/* ── Sticky bottom bar (checkout / builder) ────────────────── */
.m-sticky {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: color-mix(in srgb, rgb(var(--c-surface)) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid rgb(var(--c-line));
  padding: 0.75rem 1.25rem calc(0.75rem + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform 260ms cubic-bezier(0.22,1,0.36,1);
}
.m-sticky.is-up { transform: translateY(0); }
.m-sticky-row { display: flex; align-items: center; gap: 0.9rem; }
.m-sticky-figures { min-width: 0; flex: 1; }
.m-sticky-figures .one { font-family: 'Inter',sans-serif; font-weight: 600; font-size: 1.05rem; color: rgb(var(--c-ink)); }
.m-sticky-figures .sub { font-size: 0.75rem; color: rgb(var(--c-ink-soft)); margin-top: 0.1rem; }
@media (min-width: 768px) { .m-sticky { display: none; } }

/* Room so the bar never sits on top of the last control */
@media (max-width: 767px) {
  body.has-sticky-bar { padding-bottom: 5.5rem; }
}

/* ── Dashboard bottom navigation ───────────────────────────── */
.m-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: none; align-items: stretch;
  background: color-mix(in srgb, rgb(var(--c-paper)) 94%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid rgb(var(--c-line));
  padding-bottom: env(safe-area-inset-bottom);
}
.m-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.2rem; min-height: 58px; padding: 0.4rem 0.25rem;
  font-family: 'IBM Plex Mono',ui-monospace,monospace;
  font-size: 0.625rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgb(var(--c-ink-soft)); text-decoration: none;
}
.m-tab svg { width: 20px; height: 20px; }
.m-tab.is-on { color: rgb(var(--c-accent)); font-weight: 600; }
.m-tab.is-on svg { stroke: rgb(var(--c-accent)); }
@media (max-width: 767px) {
  .m-tabs { display: flex; }
  body.has-tabbar { padding-bottom: 4.75rem; }
}

/* ── Tables become cards ───────────────────────────────────── */
@media (max-width: 640px) {
  .m-cards thead { display: none; }
  .m-cards, .m-cards tbody, .m-cards tr, .m-cards td { display: block; width: 100%; }
  .m-cards tr {
    border: 1px solid rgb(var(--c-line)); border-radius: 0.5rem; background: rgb(var(--c-surface));
    padding: 0.9rem 1rem; margin-bottom: 0.6rem;
  }
  .m-cards td { border: 0; padding: 0.2rem 0; font-size: 0.875rem; }
  .m-cards td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: 'IBM Plex Mono',ui-monospace,monospace;
    font-size: 0.625rem; letter-spacing: 0.14em; text-transform: uppercase;
    color: rgb(var(--c-ink-soft)); margin-bottom: 0.15rem;
  }
  .m-cards td:empty { display: none; }
}

/* ── Motion ────────────────────────────────────────────────── */
.m-reveal { opacity: 0; transform: translateY(10px); }
.m-reveal.is-in { opacity: 1; transform: translateY(0); transition: opacity 420ms ease, transform 420ms cubic-bezier(0.22,1,0.36,1); }

.m-flash { animation: m-flash 420ms ease; }
@keyframes m-flash { 0% { color: rgb(var(--c-accent)); } 40% { color: rgb(var(--c-ink-soft)); } 100% { color: inherit; } }

@media (prefers-reduced-motion: reduce) {
  .m-drawer, .m-sticky, .m-acc-panel, .m-acc-sign { transition: none !important; }
  .m-drawer.is-open .m-drawer-link { animation: none; opacity: 1; transform: none; }
  .m-reveal { opacity: 1; transform: none; }
  .m-reveal.is-in { transition: none; }
  .m-flash { animation: none; }
}

/* Header-less label/value tables: keep the pair on one line as a card row
   rather than stacking a bare value under its label. */
@media (max-width: 640px) {
  .m-cards tr:not(:has(> td[data-label])) {
    display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  }
  .m-cards tr:not(:has(> td[data-label])) td { flex: 0 1 auto; }
  .m-cards tr:not(:has(> td[data-label])) td:first-child { color: rgb(var(--c-ink)); font-weight: 600; }
}

/* ───────────────────────────────────────────────────────────────
   iPhone hero — tighter rhythm so the offer and one CTA land on the
   first screen, with the reel arriving straight after it.
   Mobile only; the desktop composition is untouched.
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .hero > div { padding-top: 2rem; padding-bottom: 2.5rem; }
  .hero .lede { margin-top: 0.9rem; }

  /* price + payment block */
  .hero .border-y { margin-top: 1.25rem; padding-top: 1rem; padding-bottom: 1rem; }
  .hero .border-y .h-display { font-size: 1.75rem; }

  /* buttons: full width, stacked, comfortable */
  .hero a[href="signup.html"],
  .hero a[href="#industries"] { width: 100%; min-height: 52px; padding-top: 0.9rem; padding-bottom: 0.9rem; }
  .hero .mt-7.flex.flex-col { margin-top: 1.25rem; gap: 0.6rem; }

  .hero > div > p:last-child { margin-top: 2.5rem; padding-top: 1.25rem; }
}

/* The four steps become a real vertical sequence on a phone: the rule
   runs down the left, the numeral sits on it. */
@media (max-width: 639px) {
  #how ol { border-top: 0; }
  #how ol li {
    position: relative; border-bottom: 0; padding: 0 0 1.6rem 2.6rem;
  }
  #how ol li:last-child { padding-bottom: 0; }
  #how ol li::before {
    content: ""; position: absolute; left: 0.62rem; top: 1.9rem; bottom: 0.15rem;
    width: 1px; background: rgb(var(--c-line-firm));
  }
  #how ol li:last-child::before { display: none; }
  #how ol li::after {
    content: ""; position: absolute; left: 0.25rem; top: 0.75rem;
    width: 0.75rem; height: 0.75rem; border-radius: 999px;
    background: rgb(var(--c-paper)); border: 2px solid rgb(var(--c-accent));
  }
  #how ol li .step-n { font-size: 1.65rem; }
  #how ol li h3 { margin-top: 0.35rem; }
}

/* Section rhythm: compact, never cramped */
@media (max-width: 767px) {
  main section:not(.fp-hero) > div:not(.reel-stage) { padding-top: 4.25rem; padding-bottom: 4.25rem; }
  main section .mt-14 { margin-top: 2.75rem; }
  main section .mt-12 { margin-top: 2.5rem; }
  main section .mt-16 { margin-top: 3rem; }
}

/* Small iPhones: pull the hero in tighter so both CTAs stay on screen one */
@media (max-width: 380px) {
  .hero > div { padding-top: 1.5rem; padding-bottom: 2rem; }
  .hero .lede { font-size: 0.9375rem; margin-top: 0.75rem; }
  .hero .border-y { margin-top: 1rem; padding-top: 0.85rem; padding-bottom: 0.85rem; }
  .hero .border-y .h-display { font-size: 1.5rem; }
  .hero a[href="signup.html"],
  .hero a[href="#industries"] { min-height: 48px; font-size: 0.9375rem; }
  .hero .mt-7.flex.flex-col { margin-top: 1rem; }
}


/* ── Reserved media slots ───────────────────────────────────
   Empty room on a phone, held open between sections for video or
   stickers. Nothing renders in them yet and nothing renders on a
   desktop, where the side rails already carry the moving picture. */
.m-slot { display: none; }
@media (max-width: 767px) {
  .m-slot { display: block; height: 15rem; }
  .m-slot--tall { height: 20rem; }
  .m-slot--short { height: 10rem; }
}

/* ── Pull to refresh ────────────────────────────────────────
   A puck that follows the drag with resistance, a ring that fills as
   you approach the threshold, and a spin while the page reloads. The
   page itself travels a fraction of the distance so the gesture has
   something to push against. */
.ptr {
  position: fixed; z-index: 95; left: 50%; top: 0;
  width: 40px; height: 40px; margin-left: -20px;
  display: none; align-items: center; justify-content: center;
  border-radius: 999px;
  background: rgb(var(--c-paper));
  border: 1px solid rgb(var(--c-line));
  box-shadow: 0 6px 20px rgb(var(--c-shadow) / 0.16);
  color: rgb(var(--c-accent));
  opacity: 0;
  transform: translate3d(0, -46px, 0) scale(0.72);
  pointer-events: none;
}
.ptr.is-live { display: flex; }
.ptr.is-settling { transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms ease; }
.ptr svg { width: 22px; height: 22px; display: block; transform: rotate(-90deg); }
.ptr circle { fill: none; stroke-width: 2.4; stroke-linecap: round; }
.ptr .ptr-track { stroke: rgb(var(--c-line-firm)); }
.ptr .ptr-arc { stroke: currentColor; stroke-dasharray: 56.5; stroke-dashoffset: 56.5; }

/* Threshold reached — the ring closes and the puck gives a small nudge. */
.ptr.is-ready { color: rgb(var(--c-accent)); }
.ptr.is-ready .ptr-arc { stroke-dashoffset: 0 !important; }

/* Released — hand over to a spinner and stop tracking the finger. */
.ptr.is-loading svg { animation: ptr-spin 720ms linear infinite; }
.ptr.is-loading .ptr-arc { stroke-dashoffset: 40 !important; }
@keyframes ptr-spin { to { transform: rotate(270deg); } }

.ptr-shift { will-change: transform; }

@media (prefers-reduced-motion: reduce) {
  .ptr.is-loading svg { animation: none; }
  .ptr.is-settling { transition: opacity 160ms ease; }
}
