/* v11-mobile-polish — 2026-05-11
 *
 * Site-wide mobile optimization pass. Targets gaps NOT covered by
 * deskrune-mega, v6-v8, or v9-v10:
 *
 *   1. Focus page: timer panel stacking, card grid, volume row
 *   2. Library page: lead-magnet card, grid spacing
 *   3. Wall page: layout tightening
 *   4. Games page: card grid
 *   5. Touch targets: enforce 44px minimum on all interactive elements
 *   6. Safe-area insets: notched device padding (iPhone, Pixel)
 *   7. Typography: prevent horizontal overflow from long words
 *   8. Desk page (v2): refined mobile layout for 3D scene
 *   9. General: scroll-margin for anchors, input sizing
 *
 * ~4KB. Loaded after v10-perfection.
 */

/* ═══════════════════════════════════════════════════════════════════
   1. FOCUS PAGE — /focus/
   ══════════════════════════════════════════════════════════��════════ */
@media (max-width: 640px) {
  .fs-wrap {
    padding: 32px 16px 48px;
  }
  .fs-timer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 18px 16px;
  }
  .fs-timer-display {
    font-size: 40px;
    text-align: center;
    min-width: unset;
  }
  .fs-timer-actions {
    margin-left: 0;
    justify-content: center;
  }
  .fs-timer-preset {
    justify-content: center;
    flex-wrap: wrap;
  }
  .fs-btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14px;
  }
  .fs-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .fs-card {
    padding: 16px;
  }
  .fs-card-name {
    font-size: 16px;
  }
  .fs-volume-row {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    padding: 14px 16px;
  }
  .fs-volume-row input[type="range"] {
    max-width: 100%;
    width: 100%;
  }
  .fs-dock {
    bottom: max(18px, env(safe-area-inset-bottom, 18px));
    right: max(18px, env(safe-area-inset-right, 18px));
  }
  .fs-research {
    font-size: 14px;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   2. LIBRARY PAGE — /library/
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .lead-magnet-card {
    padding: 16px;
  }
  .lead-magnet-card .lead-magnet-body h3 {
    font-size: 18px;
  }
  .lead-magnet-card .lead-bullets {
    font-size: 13px;
  }
  .library-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  .lib-card {
    padding: 16px;
  }
  .lib-card h3 {
    font-size: 16px;
  }
  .lib-cover img {
    max-height: 180px;
    object-fit: cover;
    border-radius: 6px;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   3. WALL PAGE — /wall/
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .wall-grid,
  .wall-cards {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .wall-card {
    padding: 16px;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   4. GAMES PAGE — /games/
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .games-grid,
  .game-cards {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .game-card {
    padding: 16px;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   5. TOUCH TARGETS — 44px minimum (WCAG 2.5.5 enhanced)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 760px) {
  /* Buttons and links in content areas */
  .section a:not(.lib-card):not(.lead-magnet-card):not(.az-card),
  button:not(.nav-hamburger):not(.nav-mobile-panel-close):not(.dr-theme-toggle) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Filter chips */
  .az-chip,
  .fs-btn,
  .filter-btn,
  .category-btn {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  /* Nav links in mobile panel */
  .nav-mobile-panel-links a,
  .nav-mobile-panel-links button {
    min-height: 48px;
    padding: 12px 20px;
    font-size: 16px;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   6. SAFE-AREA INSETS — notched devices (iPhone X+, Pixel)
   ═══════════════════════════════════════════════════════════════════ */
@supports (padding: env(safe-area-inset-bottom)) {
  @media (max-width: 760px) {
    body {
      padding-left: env(safe-area-inset-left, 0);
      padding-right: env(safe-area-inset-right, 0);
    }
    footer,
    footer.minimal {
      padding-bottom: calc(32px + env(safe-area-inset-bottom, 0));
    }
    /* Fixed elements: respect bottom safe area */
    .dr-crisis-float,
    .sticky-buy-bar,
    .fs-dock,
    .az-compare-tray {
      bottom: max(20px, calc(12px + env(safe-area-inset-bottom, 0)));
    }
  }
}

/* ═══════════════════════════════════════════════════════════════════
   7. TYPOGRAPHY — prevent horizontal overflow
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* Break long words/URLs that might overflow */
  main,
  article,
  .section,
  .container {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* Prevent horizontal scroll from any child */
  body {
    overflow-x: hidden;
  }

  /* Code blocks: scroll horizontally within their container */
  pre, code {
    max-width: 100%;
    overflow-x: auto;
    word-break: normal;
  }

  /* Tables: scroll within wrapper */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   8. DESK PAGE (v2) — refined mobile for 3D scene
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  /* Ensure canvas takes full viewport on mobile */
  .desk-canvas,
  #desk-canvas {
    width: 100vw !important;
    height: 100svh !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   9. GENERAL — scroll-margin, input sizing, spacing
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 760px) {
  /* Scroll margin so anchored content isn't hidden behind fixed nav */
  [id] {
    scroll-margin-top: 72px;
  }

  /* Section spacing tighter on mobile */
  .section + .section {
    margin-top: 0;
  }

  /* Hero eyebrows: smaller on mobile */
  .hero-eyebrow,
  .section-eyebrow {
    font-size: 10px;
    letter-spacing: 0.14em;
  }

  /* Full-width images on mobile */
  .section img:not(.brand-glyph):not([width="22"]) {
    max-width: 100%;
    height: auto;
  }

  /* Hide decorative elements that waste space on mobile */
  .hero-badge svg {
    width: 40px;
    height: 40px;
  }
}

/* Extra-small devices (≤380px) */
@media (max-width: 380px) {
  .fs-timer-display {
    font-size: 36px;
  }
  .fs-btn {
    font-size: 12px;
    padding: 8px 10px;
  }
  .lead-magnet-card .arrow {
    font-size: 13px;
  }
  .section-eyebrow .num {
    font-size: 9px;
  }
}
