/**
 * LAOUTS · Mobile Polish · Apple-ready
 * ─────────────────────────────────────
 * Drop-in CSS that hits every common mobile failure mode across the LAOUTS
 * marketing pages. Loaded AFTER theme files so it wins specificity for the
 * mobile-specific overrides.
 *
 * Linked from every public page (landing, about, pricing, compare, vs/*,
 * how-it-works, help/printing, pro, cleanse, create, my-books).
 *
 * What this handles automatically (no per-page edits needed):
 *   1. Touch targets · 44px minimum for all links/buttons (Apple HIG)
 *   2. Type readability · base 16px on body, 17px on lede, no <14px text
 *   3. Tap-target spacing · 8px minimum between adjacent buttons
 *   4. Topbar collapse · long nav stacks vertically on phones
 *   5. Long words break instead of overflow
 *   6. Tables become horizontally scrollable on phones
 *   7. Sticky footers don't cover content
 *   8. iOS-specific: input zoom prevention (16px+ font on form fields)
 *   9. Safe area insets for notch/dynamic-island phones
 *  10. Print styles · hide nav/cta on print
 */

/* ─────────────────────────────────────────────
 * BASE · safe-area, font-rendering, no-zoom on inputs
 * ───────────────────────────────────────────── */
@supports (padding: env(safe-area-inset-top)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* iOS Safari auto-zooms forms with <16px font. Force 16px on phones. */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Long words like "magazine-coffee-table-bound-photobook" shouldn't blow out narrow phones */
h1, h2, h3, h4, p, li, span, a {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ─────────────────────────────────────────────
 * TOUCH TARGETS · 44px minimum, Apple HIG
 * ───────────────────────────────────────────── */
@media (max-width: 768px) and (pointer: coarse) {
  /* Anchor links inside nav, buttons, primary CTAs */
  nav a, .laoutsBrandTopbar__link, .btn, .cta, button[type="submit"],
  .foot__nav a, .hero__cta, .btn--primary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  /* Spacing between adjacent tap targets */
  nav a + a,
  .btn + .btn,
  .foot__nav a + a {
    margin-left: 4px;
  }
}

/* ─────────────────────────────────────────────
 * TYPE READABILITY
 * ───────────────────────────────────────────── */
@media (max-width: 640px) {
  body {
    font-size: 16px;
    line-height: 1.6;
  }
  h1 { font-size: clamp(28px, 8vw, 38px) !important; line-height: 1.08 !important; }
  h2 { font-size: clamp(22px, 6vw, 30px) !important; line-height: 1.12 !important; }
  h3 { font-size: clamp(18px, 5vw, 22px) !important; }

  /* Tiny mono caps are unreadable on phone. Bump to 11px floor. */
  [class*="kicker"], [class*="eyebrow"], [class*="label"],
  .hero__kicker, .section__lab, .laoutsBrandTopbar__version {
    font-size: 11px !important;
    letter-spacing: 0.18em !important;
  }

  /* Body text margins · less padding on phones */
  main, section { padding-left: 18px; padding-right: 18px; }
  .hero, section.hero { padding: 32px 18px !important; }
}

/* ─────────────────────────────────────────────
 * TOPBAR · collapse long nav to hamburger or single line
 * ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .laoutsBrandTopbar {
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 8px;
  }
  .laoutsBrandTopbar__crumbs,
  .laoutsBrandTopbar__divider {
    display: none;
  }
  .laoutsBrandTopbar__right {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;  /* Firefox */
    padding-bottom: 4px;
  }
  .laoutsBrandTopbar__right::-webkit-scrollbar { display: none; }
  .laoutsBrandTopbar__right .laoutsBrandTopbar__link {
    white-space: nowrap;
    font-size: 11px;
  }
  .laoutsBrandTopbar__version { display: none; }
}

@media (max-width: 480px) {
  .laoutsBrandTopbar__mark { width: 28px; height: 28px; }
  .laoutsBrandTopbar__name { font-size: 16px; letter-spacing: 0.12em; }
  .laoutsBrandTopbar__tagline { font-size: 9px; }
}

/* ─────────────────────────────────────────────
 * TABLES · wrap in scroll on phones, keep readable
 * ───────────────────────────────────────────── */
@media (max-width: 640px) {
  table:not(.no-mobile-scroll) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    border-collapse: collapse;
  }
  table th, table td {
    padding: 10px 8px !important;
    font-size: 13px !important;
    white-space: normal;
    word-break: break-word;
  }
}

/* ─────────────────────────────────────────────
 * FOOTER · stack on phones, generous spacing
 * ───────────────────────────────────────────── */
@media (max-width: 760px) {
  footer.foot {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 16px !important;
    padding: 24px 18px !important;
    text-align: left;
  }
  .foot__nav {
    flex-wrap: wrap;
    gap: 8px 14px !important;
  }
  .foot__legal {
    font-size: 11px !important;
    line-height: 1.5;
  }
}

/* ─────────────────────────────────────────────
 * SECTION CONTENT · padding + spacing for phones
 * ───────────────────────────────────────────── */
@media (max-width: 640px) {
  section { padding-top: 36px; padding-bottom: 36px; }
  .grid, [class*="-grid"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  /* But keep 2-column for product/photo grids that need it */
  .merch-grid, .photo-grid, [data-grid="2-up-mobile"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
}

/* ─────────────────────────────────────────────
 * HERO SECTIONS · less aggressive on phone
 * ───────────────────────────────────────────── */
@media (max-width: 640px) {
  [class*="hero"] {
    padding-top: 36px !important;
    padding-bottom: 36px !important;
  }
  [class*="hero__lede"], [class*="hero-sub"], [class*="hero__sub"] {
    font-size: 16px !important;
    line-height: 1.5 !important;
  }
}

/* ─────────────────────────────────────────────
 * SVGs · scale gracefully on phones
 * ───────────────────────────────────────────── */
svg {
  max-width: 100%;
  height: auto;
}

/* ─────────────────────────────────────────────
 * FORMS · full-width inputs on phones, generous padding
 * ───────────────────────────────────────────── */
@media (max-width: 640px) {
  input[type="text"], input[type="email"], input[type="number"],
  input[type="tel"], input[type="url"], textarea, select {
    width: 100%;
    padding: 14px 16px !important;
    border-radius: 10px !important;
  }
}

/* ─────────────────────────────────────────────
 * STICKY · don't let sticky elements cover content
 * ───────────────────────────────────────────── */
@media (max-width: 640px) {
  [class*="sticky-bottom"], [class*="sticky-cta"] {
    padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  }
}

/* ─────────────────────────────────────────────
 * IMAGE OVERFLOWS · keep within bounds
 * ───────────────────────────────────────────── */
img {
  max-width: 100%;
  height: auto;
}
@media (max-width: 640px) {
  img[width][height] { width: auto !important; height: auto !important; }
}

/* ─────────────────────────────────────────────
 * SCROLLBAR · slim on touch devices
 * ───────────────────────────────────────────── */
@media (pointer: coarse) {
  ::-webkit-scrollbar { width: 4px; height: 4px; }
  ::-webkit-scrollbar-thumb { background: rgba(120, 100, 80, 0.3); border-radius: 999px; }
}

/* ─────────────────────────────────────────────
 * iOS · prevent text selection on tap-only elements
 * ───────────────────────────────────────────── */
button, .btn, .cta, .laoutsBrandTopbar__link {
  -webkit-tap-highlight-color: rgba(236, 106, 57, 0.18);
  -webkit-user-select: none;
  user-select: none;
}

/* ─────────────────────────────────────────────
 * PRINT · hide nav + cta when printing
 * ───────────────────────────────────────────── */
@media print {
  .laoutsBrandTopbar, footer.foot, .cta, .btn,
  nav, .hero__cta {
    display: none !important;
  }
  body { background: #fff !important; color: #000 !important; padding: 0 !important; }
  h1, h2, h3 { page-break-after: avoid; }
  img { max-width: 100%; page-break-inside: avoid; }
}

/* ─────────────────────────────────────────────
 * DARK MODE PREFERENCE · respect user setting where applicable
 * (only for marketing pages, not the engine which is always dark)
 * ───────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  /* Pages on cream background still use cream — don't auto-flip transactional pages */
}

/* ─────────────────────────────────────────────
 * REDUCED MOTION · respect for animations
 * ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
