/* ─────────────────────────────────────────────────────────────────
   css/responsive-topbar.css

   Wave 7.1 (2026-05-09) — 100% mobile-friendly topbar across the
   builder + use surfaces. Documented breakpoints (kept in sync
   with docs/responsive-breakpoints.md):

     xs   ≤ 360px   — iPhone SE 1st gen, oldest Android
     sm   361-480   — std phone portrait
     md   481-768   — phone landscape / iPad mini portrait
     lg   769-1024  — iPad landscape / narrow laptop
     xl   1025-1280 — std laptop
     2xl  ≥ 1281    — desktop

   THE BUG THIS FIXES (Luke 2026-05-09):
     "huge issue its not mobile friendly — half the shit, the bar
      at the top, once it gets smaller I can't access anything."

   THE FIX:
     1. Pills don't shrink past readability. Past audit had them
        going to 0.72rem font-size + 0.4rem padding on phone —
        unreadable AND tap-targets below WCAG 44px floor.
     2. Topbar-actions becomes a horizontal scroller on ≤768px
        with momentum scroll on iOS (-webkit-overflow-scrolling).
        Swipe to access every pill.
     3. Right-edge fade gradient hints "more content →" so the
        user knows there's swipe room. Without this hint, NN/g
        research shows ~40% of users miss horizontal scroll.
     4. Push to Devices (primary CTA) + user pill stay PINNED to
        the right edge OUTSIDE the scroll, so the ship action is
        always one tap away.
     5. ⋯ "More" overflow menu (mounted by topbar-overflow.js)
        gives a non-swipe path to every control — accessibility
        for users with motor difficulties + dwell-click users.

   Loaded LAST in the cascade so its !important overrides win
   over wave7-mobile.css's tap-target floor (we keep the floor,
   but enforce it on the scrollable pills with stronger sizing).

   LABEL: PILOT-READY. Live test on iOS Safari + Android Chrome
   + iPad Safari before PRODUCTION-READY (overflow-x: auto +
   sticky positioning interact subtly across browsers).
───────────────────────────────────────────────────────────────── */

/* ── Builder topbar — collapse to ⋯ menu on ≤768px ──────────
   2026-05-09 (Luke flag v2): the prior horizontal-scroll approach
   hid pills behind a fade gradient that desktop users don't
   naturally swipe past. They saw "everything's gone." Real fix:
   on phone + small tablet, HIDE every secondary pill (display:
   none) and surface the SINGLE primary action (Push to Devices)
   inline. ⋯ More button is the obvious + universal path to
   everything else — no scrolling, no hidden gradient, no
   guesswork. The topbar-overflow.js BottomSheet lists every
   action including the hidden ones, so nothing's lost. */
@media (max-width: 768px) {
  .topbar {
    overflow: hidden;
    flex-wrap: nowrap;
    gap: 0.4rem;
  }

  /* Topbar-actions: shrinks to fit only what's inline. */
  .topbar-actions {
    flex: 0 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 0.3rem;
  }

  /* Hide every secondary pill — Save / Download / Print / Worksheet
     / Settings + the JS-mounted Select / Lock / Students / Saved
     Boards. All accessible via ⋯ menu.
     2026-05-09 (Codex stop-gate fix): use DESCENDANT selectors
     (.topbar #foo) instead of direct-child (.topbar > #foo). The
     JS-mounted pills (board-lock.js / bulk-edit.js / students-panel.js
     / library-panel.js) insert themselves INSIDE .topbar-actions
     using settingsBtn as the anchor — they're grandchildren of
     .topbar, not direct children. The earlier .topbar > selector
     never matched and those 4 pills stayed visible. */
  .topbar #saveBtn,
  .topbar #exportBtn,
  .topbar #printBtn,
  .topbar #worksheetBtn,
  .topbar #settingsBtn,
  .topbar #topbarBulkBtn,
  .topbar #topbarLockBtn,
  .topbar #topbarStudentsBtn,
  .topbar #topbarLibraryBtn {
    display: none !important;
  }

  /* Push (primary CTA) stays inline — keep readable. */
  .topbar-actions > .topbar-btn-primary {
    flex-shrink: 0;
    font-size: 0.82rem !important;
    padding: 0.55rem 0.75rem !important;
    min-height: 44px !important;
  }

  /* Brand: drop the tagline, keep the logo recognizable. */
  .topbar-brand {
    flex-shrink: 0;
  }
  .topbar-brand-tag {
    display: none;
  }

  /* Board name input — give it the leftover middle space so the
     user can still see what they're editing. Cap to 35vw so it
     doesn't push primary controls off-screen. */
  .board-name-input {
    flex: 1 1 auto;
    max-width: 35vw;
    min-width: 80px;
  }
  .topbar:focus-within .board-name-input {
    max-width: 50vw;
  }

  /* User pill / Sign Up / Sign In stay where they are
     (sibling of .topbar-actions). They're already pinned to the
     right by flex order. Just enforce sizing. */
  .topbar > #topbarUser,
  .topbar > #topbarSignIn,
  .topbar > #topbarSignUp {
    flex-shrink: 0;
    font-size: 0.78rem !important;
    padding: 0.5rem 0.65rem !important;
    min-height: 44px !important;
  }
}

/* xs — extra-small phones ≤360px get the most aggressive layout */
@media (max-width: 360px) {
  .topbar { gap: 0.25rem; padding: 0 0.4rem; }
  .topbar-brand-name { font-size: 0.92rem; }
  .topbar-actions > .topbar-btn-primary {
    font-size: 0.75rem !important;
    padding: 0.5rem 0.6rem !important;
  }
  .board-name-input { max-width: 30vw; min-width: 60px; font-size: 0.85rem !important; }
  /* On the smallest phones, hide Sign Up too — Sign In + ⋯ menu
     get the user to signup via a /signup link. */
  .topbar > #topbarSignUp {
    display: none !important;
  }
}

/* lg+ — restore everything inline on tablet landscape and larger. */
@media (min-width: 769px) and (max-width: 1024px) {
  /* In this band, decide which pills stay inline. Currently we
     show ALL inline above 768px; ⋯ button is hidden via the rule
     below. Future split could collapse Print/Worksheet here. */
}

/* ── Pinned-right primary CTA + user pill ──────────────────── */
/* On ≤768px, the user pill area + Push to Devices need to stay
   visible so the ship-action and account access aren't buried
   in the scroller. The .topbar-overflow-pinned wrapper is added
   by JS (topbar-overflow.js); CSS pins it to the right side
   OUTSIDE the scrolling area. */
@media (max-width: 768px) {
  .topbar-overflow-pinned {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
  }
  /* The ⋯ More button sits inside .topbar-overflow-pinned.
     Made eye-catching (amber accent) so users find it without
     needing a tooltip. NN/g #6 recognition — the button needs
     to LOOK like the path to "everything else" or users assume
     features were removed. */
  .topbar-overflow-btn {
    flex-shrink: 0;
    background: rgba(232, 168, 56, 0.15);
    border: 1.5px solid var(--amber, #E8A838);
    color: var(--amber, #E8A838);
    border-radius: 10px;
    padding: 0.55rem 0.85rem;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    min-height: 44px;
    min-width: 48px;
    /* Subtle glow so the button is the first thing the eye lands
       on after the brand. */
    box-shadow: 0 2px 8px rgba(232, 168, 56, 0.2);
  }
  .topbar-overflow-btn:hover,
  .topbar-overflow-btn[aria-expanded="true"] {
    background: var(--amber, #E8A838);
    color: #1A1A2E;
    box-shadow: 0 4px 14px rgba(232, 168, 56, 0.4);
  }
  .topbar-overflow-btn:active {
    transform: translateY(1px);
  }
}
@media (min-width: 769px) {
  /* On lg+, no overflow menu needed — all pills inline. Hide the
     ⋯ button if the JS module decided to mount it anyway. */
  .topbar-overflow-btn { display: none; }
  /* Strip the mask-image fade on desktop; not needed when nothing
     is scrolling. */
  .topbar-actions {
    -webkit-mask-image: none;
            mask-image: none;
  }
}

/* ── BottomSheet content for the ⋯ menu ────────────────────── */
.topbar-overflow-sheet {
  width: min(360px, 92vw);
  background: #FFF;
  border-radius: 16px;
  padding: 0.5rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  max-height: 70vh;
  overflow-y: auto;
}
.topbar-overflow-sheet h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(0, 0, 0, 0.55);
  margin: 0.5rem 0.6rem 0.4rem;
  font-weight: 700;
}
.topbar-overflow-sheet button {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  background: transparent;
  border: none;
  text-align: left;
  padding: 0.85rem 0.85rem;
  border-radius: 10px;
  font-size: 0.95rem;
  color: #1A1A2E;
  cursor: pointer;
  min-height: 44px;
}
.topbar-overflow-sheet button:hover {
  background: rgba(232, 168, 56, 0.08);
}
.topbar-overflow-sheet button:active {
  background: rgba(232, 168, 56, 0.16);
}

/* ── Use.html topbar — same horizontal-scroll pattern ──────── */
/* Use.html topbar markup is different (no .topbar-actions wrapper)
   but the same pile-up problem exists once the language pill +
   network pill mount. Apply the same scrollable-row pattern by
   targeting the .topbar itself on phone. */
@media (max-width: 600px) {
  /* Only when use.html is the surface — the .topbar-mode +
     .topbar-install combination only exists there. Builder's
     topbar uses .topbar-actions. */
  body:has(.topbar-mode) .topbar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent 100%);
            mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent 100%);
  }
  body:has(.topbar-mode) .topbar::-webkit-scrollbar { display: none; }
  body:has(.topbar-mode) .topbar > * {
    flex-shrink: 0;
  }
  body:has(.topbar-mode) .topbar-title {
    /* Title can shrink — it's the variable-width element; pills
       around it are fixed-shape. */
    flex-shrink: 1;
    min-width: 60px;
  }
}
