/* ============================================================
   POLISH OVERRIDES — keeps existing design, no visual rework.
   - Consistent typography across pages (Inter body, Gloock display)
   - Safer mobile layout (no horizontal overflow)
   - Image / media safety
   - Tighter nav on small screens
   ============================================================ */

/* Typography consistency – every page uses the same family stack */
html, body {
  font-family: var(--font-sans) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4,
.hero-headline, .section-title,
.pillar-title, .pillar-hero h1,
.col-text h2, .cta-section h2,
.scene-label, .nav-logo-name {
  font-family: var(--font-serif) !important;
}
.nav-tagline, .hero-badge, .section-label,
.btn-primary, .btn-secondary, .btn-card, .btn-ghost,
.nav-links a, .pillar-nav a, .hero-pill,
nav, p, li, span, cite, blockquote, .pillar-desc, .hero-sub {
  font-family: var(--font-sans);
}

/* Global overflow safety */
html, body { max-width: 100%; overflow-x: hidden; }

/* Responsive media safety */
img, video, svg, canvas, iframe { max-width: 100%; height: auto; }
.hero-poster-img, .col-art-fill { object-fit: cover; }

/* Long words / URLs shouldn't blow out narrow screens */
p, li, blockquote, h1, h2, h3, h4, .pillar-desc, .hero-sub {
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Nav logo — keep block tight and prevent wrap break on phones */
.nav-logo { min-width: 0; flex: 1 1 auto; }
.nav-logo > div { min-width: 0; }
.nav-logo-name, .nav-tagline {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* ============================================================
   MOBILE SAFE PADDING (always breathing room left & right)
   ============================================================ */
@media (max-width: 980px) {
  :root { --gutter: 1.25rem; --side-pad: 1.25rem; }

  section,
  .hero,
  .pillar-hero,
  .page-section,
  .quote-strip,
  .about-section {
    padding-left: var(--side-pad) !important;
    padding-right: var(--side-pad) !important;
  }

  .pillars-grid,
  .gallery-track,
  .cards-grid,
  .scriptures-grid,
  .attrs-grid {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

@media (max-width: 640px) {
  :root { --side-pad: 1.25rem; }

  .hero-poster { width: 100%; min-height: 320px; }
  .hero-poster-text { left: var(--side-pad); right: var(--side-pad); bottom: var(--side-pad); }
  .quote-strip blockquote { padding-inline: 0.25rem; }
  .open-quote { left: -0.25rem; }
  .pillar-hero h1 { line-height: 1; }
  .hero-scripture { padding: 0.9rem var(--side-pad); }
  .pillar-nav { flex-wrap: wrap; justify-content: center; }
  .pillar-nav a { flex: 1 1 auto; min-width: 0; text-align: center; }
  .cards-grid, .scriptures-grid, .attrs-grid, .footer-grid {
    grid-template-columns: 1fr !important;
  }
  .footer-cta-bar, .footer-card { width: 100%; }
  .gallery-controls { gap: 0.5rem; }
}

/* ============================================================
   PERFORMANCE — lighten heavy effects on phones
   ============================================================ */
@media (max-width: 980px) {
  #luxury-canvas { display: none !important; }
  .noise-overlay { display: none !important; }
  .vignette { opacity: 0.5; }

  nav, .nav-links, .hero-pill, .glb-backdrop, .glb-dialog,
  .footer-card, .scripture-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  [data-parallax-speed], .parallax-card, .parallax-layer {
    transform: none !important;
  }

  :root {
    --shadow: 0 8px 24px rgba(8, 63, 62, 0.10);
    --shadow-soft: 0 6px 16px rgba(8, 63, 62, 0.08);
    --shadow-xl: 0 14px 40px rgba(8, 63, 62, 0.12);
  }
}

.reveal, .pillar-card, .gallery-card, .card, .scripture-card {
  will-change: transform, opacity;
}

/* Extra small */
@media (max-width: 380px) {
  .hero-headline { font-size: clamp(2.2rem, 12vw, 3rem) !important; }
  .pillar-hero h1 { font-size: clamp(2.4rem, 13vw, 3.4rem) !important; }
  .nav-logo-name { font-size: 0.78rem !important; }
  .hero-badge { font-size: 0.65rem; padding: 0.45rem 0.85rem; }
  .hero-pill { font-size: 0.68rem; }
}

/* Tap targets */
@media (max-width: 720px) {
  a, button, .gallery-card, .pillar-card a { min-height: 44px; }
  .nav-toggle { width: 44px; height: 44px; }
}

/* Reduce motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Lightbox sizing on phones */
@media (max-width: 640px) {
  .glb-dialog { width: calc(100% - 1rem); }
  .glb-prev { left: 0.5rem; }
  .glb-next { right: 0.5rem; }
  .glb-media { height: min(70vh, 560px); }
}

/* Nav menu open: lock body scroll feel */
body:has(.nav-links.is-open) { overflow: hidden; }

/* ============================================================
   GRACEFUL MISSING-IMAGE HANDLING
   Images aren't bundled in this preview build. Hide broken alt
   text and replace the image area with a soft branded gradient
   so the layout still looks clean and intentional.
   ============================================================ */
img {
  /* Make broken image alt text invisible */
  font-size: 0;
  color: transparent;
  text-indent: -9999px;
  background: linear-gradient(135deg,
              rgba(13, 107, 99, 0.12),
              rgba(212, 106, 60, 0.10) 60%,
              rgba(149, 169, 143, 0.14));
  border-radius: inherit;
}
img[src=""], img:not([src]) { visibility: hidden; }

/* Logo + decorative SVGs already inside icon wraps don't need bg */
.pillar-icon, .preloader-logo img { background: none !important; }

/* Hero poster + col-art images: keep their parent's shape, fade in */
.hero-poster-img, .col-art-fill {
  opacity: 0.92;
}

/* Nav logo image: use a clean monogram fallback when missing */
.nav-logo img {
  background: linear-gradient(135deg, var(--brand-teal-deep), var(--brand-orange));
  border-radius: 10px;
  min-width: 44px;
}

/* Gallery placeholder cards: keep aspect & branded look */
.gallery-card img,
.gallery-item img {
  background: linear-gradient(135deg,
              rgba(13, 107, 99, 0.18),
              rgba(212, 106, 60, 0.14));
  min-height: 180px;
}

/* ============================================================
   MOBILE POLISH (≤640px) – tighter rhythm, neater cards
   ============================================================ */
@media (max-width: 640px) {
  :root {
    --section-pad-y: clamp(3rem, 9vw, 5rem);
    --radius-lg: 18px;
    --radius-md: 14px;
  }

  /* Reduce the chunky vertical gaps between sections */
  section { padding-top: var(--section-pad-y); padding-bottom: var(--section-pad-y); }

  /* Hero – breathing room, less crowding */
  .hero { padding-top: 100px; padding-bottom: 2.5rem; }
  .hero-content { gap: 1.25rem; row-gap: 1.25rem; }
  .hero-headline { margin-bottom: 0.5rem; letter-spacing: -0.01em; }
  .hero-sub { font-size: 0.95rem; line-height: 1.6; max-width: 36ch; }
  .hero-meta { gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
  .hero-pill { font-size: 0.7rem; padding: 0.45rem 0.8rem; }
  .hero-cta { flex-direction: column; align-items: stretch; width: 100%; max-width: 320px; margin-inline: auto; }
  .hero-cta a { width: 100%; justify-content: center; text-align: center; }

  /* Pillars – cleaner card stack */
  .pillars-grid { gap: 1rem; padding: 0 0.25rem; }
  .pillar-card { border-radius: 16px; }
  .pillar-img-wrap, .pillar-visual { height: 160px; }
  .pillar-body, .pillar-content { padding: 1.1rem 1.2rem 1.25rem; }
  .pillar-title { font-size: 1.35rem; line-height: 1.15; }
  .pillar-desc { font-size: 0.9rem; line-height: 1.55; margin-bottom: 1rem; }
  .pillar-verse { font-size: 0.7rem; letter-spacing: 0.18em; }
  .pillar-btn, .btn-card { padding: 0.7rem 1rem; font-size: 0.72rem; }

  /* Section headings */
  .section-title { font-size: clamp(1.85rem, 7.5vw, 2.6rem); line-height: 1.05; margin-bottom: 0.75rem; }
  .section-subtitle, .pillars-header p { font-size: 0.92rem; line-height: 1.6; max-width: 38ch; margin-inline: auto; }
  .section-label { font-size: 0.65rem; letter-spacing: 0.22em; }

  /* Quote strip – more compact */
  .quote-strip { padding: 2.5rem var(--side-pad); }
  .quote-strip blockquote { font-size: clamp(1.15rem, 5vw, 1.8rem); line-height: 1.35; }
  .quote-strip cite { font-size: 0.78rem; margin-top: 1rem; }
  .open-quote { font-size: 3.5rem; top: -1.5rem; left: -0.25rem; }

  /* Gallery */
  .gallery-shell { padding: 0; }
  .gallery-controls { display: none; }
  .gallery-track { gap: 0.75rem; padding: 0 var(--side-pad); }
  .gallery-card { border-radius: 14px; }

  /* Footer / contact */
  .footer-card, .contact-card { padding: 1.25rem; border-radius: 16px; }
  .footer-card h4, .contact-card h2, .contact-card h3 { font-size: 1.15rem; margin-bottom: 0.75rem; }
  .footer-bottom { font-size: 0.7rem; line-height: 1.5; padding: 1rem var(--side-pad); }

  /* Pillar pages – inner pages */
  .pillar-hero { padding: 100px var(--side-pad) 2.5rem; min-height: auto; }
  .pillar-hero h1 { font-size: clamp(2.4rem, 12vw, 3.6rem); line-height: 1.0; margin: 0.5rem 0 1rem; }
  .pillar-hero-sub { font-size: 0.95rem; line-height: 1.6; }
  .pillar-badge { font-size: 0.65rem; padding: 0.4rem 0.85rem; }
  .pillar-nav { gap: 0.4rem; flex-wrap: wrap; margin-top: 1.25rem; }
  .pillar-nav a { font-size: 0.7rem; padding: 0.55rem 0.9rem; min-height: 40px; flex: 1 1 30%; }

  .page-section { padding: 2.5rem var(--side-pad); }
  .two-col { gap: 1.5rem; }
  .col-text h2 { font-size: clamp(1.7rem, 7vw, 2.4rem); line-height: 1.1; margin-bottom: 0.75rem; }
  .col-text p { font-size: 0.95rem; line-height: 1.65; margin-bottom: 0.85rem; }
  .col-text h3 { font-size: 1.2rem; margin-top: 1.5rem !important; margin-bottom: 0.5rem; }
  .col-art { min-height: 280px; border-radius: 16px; }
  .col-art-poster { padding: 1rem 1.1rem; border-radius: 12px; }
  .col-art-poster .poster-quote { font-size: clamp(1.05rem, 4.5vw, 1.4rem); line-height: 1.25; }

  .cards-grid, .scriptures-grid, .attrs-grid { gap: 0.85rem; }
  .card, .scripture-card, .attr-item, .timeline-item { padding: 1.1rem 1.15rem; border-radius: 14px; }
  .card h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }
  .card p, .attr-item p { font-size: 0.9rem; line-height: 1.55; }
  .card-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }

  .scripture-card blockquote { font-size: 1rem; line-height: 1.5; }
  .scripture-card cite { font-size: 0.78rem; }

  .footer-cta-bar {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem var(--side-pad) !important;
    gap: 0.85rem;
  }
  .cta-bar-text h2 { font-size: 1.25rem !important; line-height: 1.2; }
  .cta-bar-text p { font-size: 0.88rem; }
  .cta-icon-circle { margin: 0 auto; }

  .passage-highlight { padding: 1.25rem !important; border-radius: 14px; }
  .passage-highlight p { font-size: 1.05rem !important; line-height: 1.5; }

  /* Reveal cards: ensure no horizontal pop */
  .reveal { transform: translateY(12px); }

  /* Decorative scroll indicator */
  .scroll-indicator { display: none; }
}

/* Smaller phones */
@media (max-width: 380px) {
  .hero-headline { font-size: clamp(2.1rem, 11.5vw, 2.8rem) !important; }
  .pillar-hero h1 { font-size: clamp(2.1rem, 11.5vw, 3rem) !important; }
  .section-title { font-size: clamp(1.65rem, 7vw, 2.3rem); }
  .pillar-nav a { font-size: 0.65rem; padding: 0.5rem 0.7rem; }
}

/* Tablet refinement */
@media (min-width: 641px) and (max-width: 980px) {
  .pillars-grid { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
  .pillars-grid .pillar-card:last-child { grid-column: 1 / -1; max-width: 480px; justify-self: center; }
}
