/*
 * Responsive base for every page (plan 2026-11-24-responsive-site.md).
 * Loaded after each page's own styles (Site_Header::head_tags), so these
 * rules win.
 *
 * Mobile-first. The base rules are for phones (up to 767px); two
 * breakpoints add to them:
 *   - min-width: 768px  → tablet (768–1024px; iPad, Android tablets);
 *   - min-width: 1025px → desktop.
 * The same breakpoints are used in tokens.css, card.css, lead.css,
 * side-column.css and nav.css.
 *
 * Also here: media that never overflow, 44px touch targets on touch
 * screens, the iPhone notch area (safe-area insets, with the viewport's
 * `viewport-fit=cover`), no zoom when an input is focused on iOS, the
 * Android tap highlight, and Windows (Segoe UI, high-contrast mode).
 */

/* ---------- Text and fonts on every system ---------- */

html {
  /* iOS and Android must not enlarge the text on their own when the phone turns. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Android/iOS tap flash: a soft honey tint instead of the default grey box. */
  -webkit-tap-highlight-color: rgb(242 169 0 / 0.25);
}

/* Long words and links wrap instead of widening the page.
   (Fonts: Heebo, then each system's own, with Segoe UI on Windows; tokens.css.) */
body { overflow-wrap: break-word; }

/* ---------- Media never wider than their box ---------- */

img, svg, video, iframe { max-width: 100%; }
/* Element selectors only: images with a fixed box (.card-img) keep their
   class height, which is more specific, and object-fit crops them. */
img, video { height: auto; }

/* ---------- iOS: no zoom when typing ---------- */

/* Safari zooms into any field under 16px; keep them at 16px or more. */
input, select, textarea { font-size: max(16px, 1rem); }

/* ---------- The notch area (iPhone, some Androids) ---------- */

:root { --bar-h: calc(60px + env(safe-area-inset-top, 0px)); }

.bar {
  min-height: var(--bar-h);
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  padding-inline: max(var(--gutter), env(safe-area-inset-right, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
}
main, .foot {
  padding-inline: max(var(--gutter), env(safe-area-inset-right, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
}
.foot { padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
.toast { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Footer: links big enough to tap ---------- */

.foot a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }

/* With a mouse, controls still get at least 24px (WCAG 2.5.8). */
.digest-story summary { min-height: 24px; }

/* ---------- Tablet and up ---------- */

@media (min-width: 768px) {
  :root { --gutter: 24px; }
}

/* ---------- Desktop ---------- */

@media (min-width: 1025px) {
  :root { --gutter: 32px; }
  .foot a { min-height: 32px; }
}

/* ---------- Touch screens: every control at least 44×44px ---------- */

@media (pointer: coarse) {
  .btn, .tab, .text-btn, .outlets, .new-stories { min-height: 44px; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .more { height: 44px; }
  .choose-close, .invite-close { width: 44px; height: 44px; top: 2px; inset-inline-end: 2px; }
  .feed-status button, .toast button { min-height: 44px; padding: 0 8px; }
  .digest-nav a, .digest-story summary { display: inline-flex; align-items: center; min-height: 44px; }
  .menu button { min-height: 44px; }
  .switch-row input { width: 24px; height: 24px; }
}

/* ---------- Windows high-contrast mode ---------- */

@media (forced-colors: active) {
  .card, .side-block, .story-main, .story-more, .digest-story, .tab, .btn, .outlets, .chip, .search {
    border: 1px solid CanvasText;
  }
  .bar { border-bottom: 1px solid CanvasText; }
  :focus-visible { outline-color: Highlight; }
  .skeleton { background: Canvas; border: 1px solid CanvasText; }
}
