/* responsive.css. PitCanary mobile foundations
 *
 * One global file that:
 *   1. Tunes the type scale on small viewports (h1/h2/h3/display-xl)
 *      so headlines don't blow past the viewport on a 360 px phone.
 *   2. Enforces a 44 × 44 px minimum hit-target on every interactive
 *      atom (buttons, tabs, chips, icon-buttons, day-pickers).
 *   3. Exposes safe-area utilities for iOS notch / Android gesture-bar.
 *   4. Provides utility classes (.u-hide-phone, .u-show-phone,
 *      .u-stack-phone) that any component can opt-in to without
 *      a one-off media query.
 *
 * Import order:
 *   <link rel="stylesheet" href="colors_and_type.css">  // tokens
 *   ...component CSS...
 *   <link rel="stylesheet" href="responsive.css">        // always last
 *
 * Breakpoints (mirror --bp-* tokens in colors_and_type.css):
 *   --bp-sm  640  phone / large-phone cutoff
 *   --bp-md  960  tablet / desktop cutoff (rail + sidebar collapse)
 *   --bp-lg  1200 wide desktop
 *   --bp-xl  1500 max main-content width
 *
 * Convention: prefer `(max-width: 639.98px)` (just under bp-sm) for
 * "phone" rules; `(max-width: 959.98px)` for "tablet-down". The .98
 * suffix prevents single-pixel overlap with min-width counterparts.
 *
 * Touch targets: WCAG 2.5.5 requires 44×44 px minimum for any tap
 * target. The `.touch-44` helper applies it; component CSS should
 * also enforce its own padding so the rule stays semantic.
 *
 * Safe-area: iOS sets env(safe-area-inset-*) to 0 if no notch, the
 * sticky bar and overlay both add it as padding so the home indicator
 * and notch never overlap content. Requires
 * <meta name="viewport" content="width=device-width, initial-scale=1,
 * viewport-fit=cover">.
 */

/* =============================================================
   1. FLUID TYPE, clamp() pairs that shrink on phones.
   On large screens the original tokens win; below ~600 px the
   clamp() drops in. Each rule uses min(default) and max(default)
   so desktop is byte-identical to before.
   ============================================================= */
@media (max-width: 639.98px) {
  :root {
    /* h1 36 → 26 on a 360 px phone */
    --t-h1-size: clamp(24px, 4.8vw + 12px, 36px);
    --t-h2-size: clamp(18px, 2.4vw + 12px, 22px);
    --t-h3-size: 15px;
    --t-display-xl-size: clamp(36px, 8vw + 12px, 56px);

    /* slightly tighter body line-height on phones, denser cards
       benefit from the extra breathing room saved. */
    --t-body-lh: 1.45; /* @kind other */
  }

  /* the design-system display-xl helper class respects the token
     above, but page-level inline `font-size: 48px` overrides need
     a class. .h1 / .h2 / .h3 / .display-xl all read the variables. */
}

/* =============================================================
   2. SAFE-AREA INSETS, iOS notch / Android gesture handle
   ============================================================= */
:root {
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
}

/* =============================================================
   6. CONTAINER PADDING, common page-shell padding rule.
   Marketing + dashboard pages all wrap content in some outer
   .container; on phones we shrink the gutter to 16 px and add
   the safe-area inset so the content clears the notch.
   ============================================================= */
@media (max-width: 639.98px) {
  .container {
    padding-left:  max(16px, var(--safe-left));
    padding-right: max(16px, var(--safe-right));
  }
}

/* =============================================================
   8. SCROLL-LOCK helper, apply to <body> when an overlay is
   open (mobile nav, modal). Prevents the underlying page from
   scrolling. The mobile-nav.js component toggles this class.
   ============================================================= */
body.is-scroll-locked {
  overflow: hidden;
  /* iOS Safari needs position: fixed to truly stop scroll. JS
     stamps the current scrollY into --scroll-y so it can be
     restored on unlock. */
  position: fixed;
  top: calc(0px - var(--scroll-y, 0px));
  left: 0;
  right: 0;
  width: 100%;
}

