/* ============================================================
   EGW Online Service — Responsive refinements
   ============================================================
   Layered AFTER platform.css / player.css / chat.css / smart-tv.css
   so it can override any rule. Organised top-down by breakpoint
   and finishes with capability queries (hover, touch, motion,
   safe-area).
   ============================================================ */

/* ============================================================
   1. WIDE LAPTOP — refine before things get tight  (≤1280px)
   ============================================================ */
@media (max-width: 1280px) {
  :root { --eos-side-w: 320px; }
  .eos-hero-title { font-size: clamp(36px, 5.4vw, 64px); }
  .eos-event-row { grid-template-columns: 96px 200px 1fr; }
}

/* ============================================================
   2. TABLET LANDSCAPE / SMALL LAPTOP  (≤1100px)
   - Hamburger nav engages
   - Watch grid stacks
   - Side panel becomes a normal section, no longer sticky
   ============================================================ */
@media (max-width: 1100px) {
  .eos-nav-links { display: none; }
  .eos-hamburger { display: inline-flex; }

  /* Watch page */
  .eos-watch {
    grid-template-columns: 1fr;
    margin-bottom: 48px;
  }
  .eos-side {
    position: static !important;
    max-height: none;
    min-height: 480px;
    margin-top: 24px;
  }
  .eos-watch-stage { min-width: 0; }

  /* Two-column page layouts */
  .eos-two-col { grid-template-columns: 1fr; }
  .eos-two-col-side {
    position: static !important;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .eos-two-col-side .eos-card-panel { flex: 1 1 280px; margin-bottom: 0; }

  /* Footer goes to 3 cols */
  .eos-footer-inner { grid-template-columns: 1.4fr 1fr 1fr; }
  .eos-footer-col:nth-child(4),
  .eos-footer-col:nth-child(5) { grid-column: span 1; }
}

/* ============================================================
   3. TABLET PORTRAIT  (≤900px)
   ============================================================ */
@media (max-width: 900px) {

  /* Section padding tighter */
  .eos-section { padding: clamp(40px, 6vw, 72px) 0; }
  .eos-container { padding: 0 20px; }

  /* Status bar */
  .eos-statusbar-inner { padding: 0 16px; gap: 12px; }
  .eos-statusbar-title { max-width: 18ch; }

  /* Hero */
  .eos-hero { min-height: clamp(440px, 64vh, 640px); }
  .eos-hero-inner { padding: clamp(80px, 12vh, 120px) 20px 40px; }
  .eos-hero-title { font-size: clamp(32px, 5.4vw, 52px); line-height: 1.05; }
  .eos-hero-tagline { font-size: 15px; }
  .eos-hero-ctas { gap: 8px; }

  /* Countdown smaller */
  .eos-countdown { gap: 10px; }
  .eos-countdown-unit { padding: 10px 14px; min-width: 64px; border-radius: 10px; }
  .eos-countdown-unit .num { font-size: 26px; }
  .eos-countdown-lg .eos-countdown-unit { padding: 14px 18px; min-width: 76px; }
  .eos-countdown-lg .num { font-size: 34px; }

  /* Filter bar: 1 search + 1 sort row */
  .eos-filter-bar {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px;
  }
  .eos-filter-search { grid-column: 1 / -1; }

  /* Card grids */
  .eos-card-grid-4 { grid-template-columns: repeat(2, 1fr); }

  /* Section heads stack */
  .eos-section-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .eos-section-head h2 { font-size: clamp(26px, 4vw, 34px); }
  .eos-section-link { align-self: flex-start; }

  /* Page head tighter */
  .eos-page-head { padding: 80px 0 32px; }
  .eos-page-head h1 { font-size: clamp(30px, 5vw, 48px); }

  /* Event row goes vertical */
  .eos-event-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .eos-event-date {
    flex-direction: row; align-items: center; gap: 10px;
    border-right: 0; border-bottom: 1px solid var(--color-border-subtle);
    padding: 0 0 12px;
  }
  .eos-event-day { font-size: 30px; }
  .eos-event-thumb img { height: 200px; }

  /* Footer 2 cols */
  .eos-footer-inner { grid-template-columns: 1fr 1fr; gap: 32px; }
  .eos-footer-brand { grid-column: 1 / -1; }

  /* Podcast row */
  .eos-podcast-row { grid-template-columns: 80px 1fr; gap: 14px; padding: 12px; }
  .eos-podcast-row img { width: 80px; height: 80px; }

  /* Slider */
  .eos-slide { aspect-ratio: 4/3; }
  .eos-slide-content { padding: 24px 28px; }
}

/* ============================================================
   4. PHONE  (≤640px)
   ============================================================ */
@media (max-width: 640px) {

  /* Container padding */
  .eos-container { padding: 0 16px; }

  /* Status bar — keep only the essentials */
  .eos-statusbar { font-size: 12px; height: 40px; }
  .eos-statusbar-cta { display: none; }
  .eos-statusbar-title { max-width: 14ch; font-size: 12px; }
  .eos-statusbar-time { font-size: 11px; }

  /* Primary nav */
  :root { --eos-nav-h: 64px; }
  .eos-nav-inner { padding: 0 16px; gap: 12px; }
  .eos-logo img.logo-light,
  .eos-logo img.logo-dark { height: 36px; }
  .eos-logo-suffix { font-size: 11px; padding: 3px 8px; }
  .eos-nav-tools button,
  .eos-nav-account { width: 38px; height: 38px; }
  .eos-nav-tools { gap: 4px; }
  /* Hide the tooltip on touch — it can't be hovered cleanly */
  .theme-toggle::after { display: none; }

  /* Hero */
  .eos-hero { min-height: clamp(420px, 70vh, 560px); }
  .eos-hero-inner { padding: 76px 16px 32px; }
  .eos-hero-title { font-size: clamp(28px, 8vw, 38px); }
  .eos-hero-tagline { font-size: 14px; margin-top: 12px; }
  .eos-hero-ctas { flex-direction: column; align-items: stretch; }
  .eos-hero-ctas .eos-btn { width: 100%; justify-content: center; padding: 14px 20px; }

  /* Marquee smaller */
  .eos-hero-marquee { padding: 10px 0; }
  .eos-marquee-track { gap: 40px; font-size: 12px; }

  /* Countdown row */
  .eos-countdown { gap: 8px; justify-content: space-between; }
  .eos-countdown-unit { padding: 8px 4px; min-width: 0; flex: 1; border-radius: 8px; }
  .eos-countdown-unit .num { font-size: 22px; }
  .eos-countdown-unit .lbl { font-size: 9px; letter-spacing: .1em; }

  /* Buttons full-width when stacked */
  .eos-btn-lg { padding: 14px 22px; font-size: 15px; }

  /* Quick-action cards */
  .eos-quick-grid { gap: 12px; }
  .eos-quick-card { padding: 22px 20px; }
  .eos-quick-icon { width: 44px; height: 44px; border-radius: 10px; margin-bottom: 12px; }
  .eos-quick-card h3 { font-size: 18px; }
  .eos-quick-card p  { font-size: 13px; }

  /* Card grids — 1 col */
  .eos-card-grid-2,
  .eos-card-grid-3,
  .eos-card-grid-4 { grid-template-columns: 1fr; gap: 16px; }

  .eos-section-head h2 { font-size: 24px; }
  .eos-section-title-md { font-size: 22px; }

  /* Filter bar fully stacked */
  .eos-filter-bar { grid-template-columns: 1fr; gap: 8px; }
  .eos-filter-search { grid-column: auto; }

  /* Form rows */
  .eos-form-row { grid-template-columns: 1fr; gap: 12px; }
  .eos-form input, .eos-form select, .eos-form textarea {
    /* iOS bumps to 16px to avoid zoom on focus */
    font-size: 16px;
  }
  .eos-card-panel { padding: 22px 20px; }

  /* Side panel becomes shorter (already not sticky from breakpoint #2) */
  .eos-side { min-height: 420px; max-height: 70vh; }
  .eos-side-tab { font-size: 11px; padding: 12px 4px; gap: 4px; }
  .eos-chat-stream { padding: 12px; }
  .eos-chat-form { padding: 10px; }
  .eos-chat-form input { font-size: 14px; }

  /* Prayer wall */
  .eos-prayer-wall { grid-template-columns: 1fr; }
  .eos-prayer-card { padding: 16px 18px; }

  /* Event card */
  .eos-event-actions { flex-direction: column; align-items: stretch; }
  .eos-event-actions .eos-btn { justify-content: center; }

  /* Slider */
  .eos-slide { aspect-ratio: 1/1; }
  .eos-slide-content { padding: 20px; }
  .eos-slider-prev, .eos-slider-next { width: 36px; height: 36px; }

  /* Player controls — bigger tap targets */
  .eos-player-controls {
    left: 8px; right: 8px; bottom: 8px;
    padding: 6px 8px;
    gap: 4px;
    overflow-x: auto;          /* allow horizontal scroll if many buttons */
    scrollbar-width: none;
  }
  .eos-player-controls::-webkit-scrollbar { display: none; }
  .eos-pc-btn { width: 44px; height: 44px; flex-shrink: 0; }

  /* Footer 1 col */
  .eos-footer { padding: 48px 0 0; }
  .eos-footer-inner { grid-template-columns: 1fr; gap: 28px; }
  .eos-footer-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* Next-steps fab — corner-pinned */
  .eos-next-steps { right: 12px; bottom: 12px; }
  .eos-next-steps-toggle { padding: 12px 16px; font-size: 13px; }
  .eos-next-steps-panel {
    width: calc(100vw - 24px);
    right: -6px;
    max-width: 320px;
  }

  /* Two-col side cards stack again on phone */
  .eos-two-col-side { flex-direction: column; }
  .eos-two-col-side .eos-card-panel { flex: 1 1 auto; }

  /* Search overlay sits closer to top */
  .eos-search-overlay.is-open { padding-top: 6vh; }
  .eos-search-inner { width: 95vw; }
  .eos-search-form input { font-size: 16px; }

  /* Account head */
  .eos-account-head-inner { flex-direction: column; align-items: flex-start; gap: 16px; }
  .eos-account-avatar { width: 64px; height: 64px; }

  /* Give grid */
  .eos-give-grid { grid-template-columns: 1fr; }

  /* Page head image scrim heavier on small screens */
  .eos-page-head-image::before {
    background: linear-gradient(180deg, rgba(11,27,50,.55), rgba(11,27,50,.85));
  }

  /* Scripture */
  .eos-scripture { font-size: 19px; line-height: 1.45; }
  .eos-quote-mark { font-size: 56px; }
}

/* ============================================================
   5. SMALL PHONE  (≤380px) — iPhone SE etc.
   ============================================================ */
@media (max-width: 380px) {
  .eos-logo-suffix { display: none; }     /* keep just the parent logo image */
  .eos-logo img.logo-light,
  .eos-logo img.logo-dark { height: 32px; }
  .eos-statusbar-title { max-width: 10ch; }
  .eos-hero-title { font-size: 26px; }
  .eos-countdown-unit .num { font-size: 20px; }
  .eos-quick-card h3 { font-size: 17px; }
  .eos-next-steps-toggle span { display: none; }
  .eos-next-steps-toggle { padding: 12px; }
}

/* ============================================================
   6. LANDSCAPE PHONE — short viewport
   ============================================================ */
@media (max-height: 480px) and (orientation: landscape) {
  .eos-hero { min-height: 100vh; }
  .eos-hero-inner { padding: 80px 24px 24px; }
  .eos-hero-title { font-size: 28px; }
  .eos-countdown-unit { padding: 6px 10px; }
  .eos-countdown-unit .num { font-size: 18px; }
}

/* ============================================================
   7. TOUCH-ONLY DEVICES — disable hover lifts
   ------------------------------------------------------------
   Touch devices fire :hover on first tap and keep it stuck.
   Wrap "lift on hover" effects in (hover: hover) so they only
   apply on devices with a fine pointer.
   ============================================================ */
@media (hover: none) {
  .eos-quick-card:hover,
  .eos-media-card:hover,
  .eos-event-card:hover,
  .eos-engage-card:hover,
  .eos-btn-primary:hover,
  .eos-btn:hover {
    transform: none;
    box-shadow: var(--elevation-card-sm);
  }
  .eos-media-card:hover .eos-media-play { opacity: 0; }
  .eos-media-card:hover .eos-media-thumb img { transform: none; }

  /* On touch, show play overlay always (so users know the card is tappable) */
  .eos-media-play { opacity: .85; }
  .eos-media-thumb::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,.4));
    pointer-events: none;
  }

  /* Player controls — keep them visible (no hover to reveal) */
  .eos-player-controls { opacity: 1; transform: none; }
}

/* ============================================================
   8. HIGH-DPI / RETINA — sharper SVG borders
   ============================================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .eos-live-dot { box-shadow: 0 0 0 0.5px var(--eos-live); }
}

/* ============================================================
   9. IOS SAFE AREA (notch / home indicator)
   ============================================================ */
@supports (padding: env(safe-area-inset-bottom)) {
  .eos-next-steps { bottom: calc(12px + env(safe-area-inset-bottom)); right: calc(12px + env(safe-area-inset-right)); }
  .eos-footer-bottom { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .eos-mobile-nav { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  body.eos-tv-mode .eos-player { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}

/* ============================================================
   10. KEYBOARD-AWARE LAYOUT  (mobile chat form)
   Dynamic viewport units keep the chat input visible when the
   on-screen keyboard appears on iOS / Android.
   ============================================================ */
@supports (height: 100dvh) {
  .eos-side {
    max-height: calc(100dvh - var(--eos-nav-h) - var(--eos-statusbar-h) - 24px);
  }
}

/* ============================================================
   11. PRINT — strip chrome for sermon notes / scripture exports
   ============================================================ */
@media print {
  .eos-statusbar, .eos-nav, .eos-next-steps,
  .eos-footer, .eos-side, .eos-hero-marquee,
  .eos-player-controls, .eos-section-link,
  .eos-pagination, .eos-filter-bar { display: none !important; }
  .eos-section { padding: 24px 0; }
  body { background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
}

/* ============================================================
   12. REDUCED-DATA preferences (Save-Data header)
   ============================================================ */
@media (prefers-reduced-data: reduce) {
  .eos-hero-bg { animation: none; }
  .eos-marquee-track { animation: none; }
}

/* ============================================================
   13. FORCED COLOURS (Windows high-contrast)
   ============================================================ */
@media (forced-colors: active) {
  .eos-quick-card, .eos-media-card, .eos-event-card,
  .eos-card-panel, .eos-prayer-card, .eos-testimony-card {
    border: 1px solid CanvasText;
  }
  .eos-live-dot { background: Highlight; }
  .eos-btn-primary { background: Highlight; color: HighlightText; }
}
