/* ===========================================
   CHURCH WEBSITE - MOBILE RESPONSIVENESS
   Optimized for all device sizes (320px+)
   =========================================== */

/* ===== TABLET & MEDIUM SCREENS (768px - 1024px) ===== */
@media (max-width: 1024px) {
  :root {
    --container-max: 90%;
    --space-xl: 1.5rem;
    --space-2xl: 2.5rem;
  }

  .container {
    padding: 0 var(--space-lg);
  }

  /* Navbar Adjustments */
  .nav-menu-left,
  .nav-menu-right {
    gap: var(--space-md);
  }

  .nav-menu-left {
    padding-right: 30px;
  }

  .nav-menu-right {
    padding-left: 30px;
  }

  .nav-link {
    font-size: 0.95rem;
    padding: var(--space-sm) var(--space-md);
  }

  /* Grid Adjustments */
  .grid {
    gap: var(--space-lg);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Section Spacing — named selectors only, no blanket !important */
  .welcome-section,
  .quick-links,
  .doctrine-hub {
    padding: var(--space-2xl) 0;
  }

  h1 {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
  }

  h2 {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
  }

  h3 {
    font-size: clamp(1.1rem, 3vw, 1.8rem);
  }
}

/* ===== MOBILE DEVICES (max-width: 768px) ===== */
@media (max-width: 768px) {
  :root {
    --nav-height: 56px;
    --space-lg: 1.25rem;
    --space-xl: 1.25rem;
    --space-2xl: 2rem;
    --space-3xl: 2.5rem;
  }

  html {
    font-size: 15px;
  }

  /* overflow-x:hidden removed — masks real overflow bugs (F-21) */

  /* Container & Grid */
  .container {
    padding: 0 var(--space-lg);
    width: 100%;
    max-width: 100%;
  }

  .page-wrapper {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    margin-top: var(--space-2xl);
  }

  .main-content {
    width: 100%;
  }

  /* Navigation - Mobile Optimized */
  .navbar {
    height: var(--nav-height);
  }

  .navbar-inner {
    padding: 0 var(--space-md);
  }

  .menu-toggle {
    display: flex !important;
    right: var(--space-md);
    z-index: 1003;
    color: #1a3a52;
  }

  .nav-menu-left,
  .nav-menu-right {
    display: none;
  }

  /* Ensure nav-menu is interactive when active */
  .nav-menu {
    display: flex !important;
    opacity: 0;
    visibility: hidden;
  }

  .nav-menu.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
  }

  /* nav-menu definition removed — single source in components.css (F-03) */

  .nav-menu .nav-item {
    width: 100%;
    border-bottom: 1px solid rgba(212, 165, 116, 0.1);
    margin: 0;
    padding: 0;
    list-style: none;
    flex-shrink: 0;
  }

  .nav-menu .nav-link {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    padding: 16px 24px !important;
    color: #1a3a52 !important;
    text-shadow: none !important;
    font-size: 1.05rem !important;
    font-weight: 600 !important;
    border-left: 4px solid transparent !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    box-sizing: border-box !important;
    min-height: 52px !important;
    line-height: 1.5 !important;
    white-space: nowrap !important;
    overflow: visible !important;
  }

  .nav-menu .nav-link:hover,
  .nav-menu .nav-link.active {
    border-left-color: #d4a574;
    background: rgba(212, 165, 116, 0.08);
  }

  /* Dropdown accordion icon */
  .dropdown-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #d4a574;
  }

  .dropdown-icon svg {
    width: 16px;
    height: 16px;
  }

  /* Rotate icon when dropdown is open */
  .nav-item.dropdown-open .dropdown-icon {
    transform: rotate(180deg);
  }

  .dropdown-menu {
    position: static;
    background: rgba(212, 165, 116, 0.05);
    border: none;
    box-shadow: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .nav-item.has-dropdown .dropdown-menu.active {
    max-height: 500px;
  }

  .dropdown-link {
    padding-left: var(--space-2xl);
  }

  /* Logo Sizing */
  .navbar-logo {
    flex: 0 0 auto;
  }

  .navbar .navbar-logo,
  .navbar .navbar-title-img {
    color: #1a3a52;
    filter: none;
    text-shadow: none;
  }

  .favicon {
    width: auto;
    height: 44px;
    max-width: 130px;
    transition: all 0.3s ease;
  }

  .navbar.scrolled .favicon {
    height: 36px;
  }

  /* Hero Section */
  .hero,
  .hero-home,
  .splash-page {
    height: 55vh;
    min-height: 320px;
  }

  .hero-title,
  .splash-title {
    font-size: clamp(1.5rem, 5vw, 2rem);
    line-height: 1.2;
  }

  .hero-subtitle,
  .splash-tagline {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    line-height: 1.5;
  }

  /* Breadcrumbs */
  .breadcrumbs {
    padding: var(--space-md) var(--space-lg);
    font-size: 0.85rem;
  }

  /* Typography */
  h1 {
    font-size: clamp(2rem, 7vw, 3rem);
    margin-bottom: var(--space-lg);
    line-height: 1.2;
  }

  h2 {
    font-size: clamp(1.6rem, 6vw, 2.4rem);
    margin-bottom: var(--space-md);
    line-height: 1.3;
  }

  h3 {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    line-height: 1.4;
  }

  p {
    font-size: 1.02rem;
    line-height: 1.7;
  }

  /* Forms */
  .form-group {
    margin-bottom: 1.25rem;
  }

  .form-input,
  .form-textarea {
    font-size: 16px;
    /* Prevents zoom on iOS */
    padding: var(--space-md);
    min-height: 44px;
    /* Touch target */
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .btn,
  .btn-primary,
  button {
    min-height: 48px;
    /* Touch target */
    font-size: 1rem;
    padding: 12px 24px;
  }

  /* Cards & Grids */
  .grid {
    gap: var(--space-md);
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-4 {
    grid-template-columns: 1fr;
  }

  .link-card,
  .sermon-card,
  .contact-card,
  .service-item {
    padding: var(--space-lg);
  }

  .contact-cards {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  /* Section Spacing — named selectors only */
  .welcome-section,
  .quick-links,
  .doctrine-hub,
  .sermon-section {
    padding: 1rem 0;
  }

  /* Footer */
  .footer-content {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .footer-block {
    padding: 18px;
  }

  address {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  /* Modal/Overlay */
  .modal-content,
  .modal {
    max-width: 90vw;
  }

  /* Images */
  img {
    max-width: 100%;
    height: auto;
  }

  .founder-image,
  .avatar {
    width: 50px;
    height: 50px;
  }

  /* Parallax Disable on Mobile */
  .hero-parallax img {
    transform: none !important;
  }

  /* Remove Complex Animations on Mobile */
  @media (prefers-reduced-motion: no-preference) {
    .nav-link::before {
      display: none;
    }

    .contact-card::before {
      display: none;
    }
  }
}

/* ===== SMALL MOBILE DEVICES (max-width: 480px) ===== */
@media (max-width: 480px) {
  :root {
    --nav-height: 56px;
    --space-lg: 1rem;
    --space-xl: 1rem;
    --space-2xl: 1.5rem;
    --space-md: 0.75rem;
    --container-max: 300px;
  }

  html {
    font-size: 15px;
    /* was 14px — 15px maintains readability (F-12, F-24) */
  }

  .container {
    max-width: var(--container-max);
    padding: 0 0.6rem;
  }

  /* Navbar Ultra-Compact */
  .navbar {
    height: var(--nav-height);
  }

  .menu-toggle {
    right: var(--space-md);
    z-index: 1003;
    color: #1a3a52;
  }

  /* Ensure nav menu items are fully visible on small screens */
  .nav-menu {
    padding: 70px 0 20px 0;
  }

  .nav-menu .nav-link {
    font-size: 0.95rem !important;
    padding: 14px 16px !important;
    min-height: 50px !important;
  }

  .favicon {
    width: auto;
    height: 32px;
    max-width: 100px;
  }

  .navbar.scrolled .favicon {
    height: 28px;
  }

  /* Typography - Extra Small */
  h1 {
    font-size: clamp(1.4rem, 5vw, 2rem);
    margin-bottom: var(--space-md);
  }

  h2 {
    font-size: clamp(1.1rem, 4vw, 1.6rem);
  }

  h3 {
    font-size: clamp(0.95rem, 3vw, 1.3rem);
  }

  .hero-subtitle {
    font-size: 0.85rem;
  }

  /* Button Sizing */
  .btn,
  button {
    font-size: 0.95rem;
    padding: 11px 20px;
    min-height: 44px;
  }

  /* Form Input */
  .form-input,
  .form-textarea {
    font-size: 16px;
    min-height: 44px;
    padding: 11px 12px;
  }

  /* Grid Full Width */
  .grid,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  /* Section Spacing Compact — named selectors */
  .welcome-section,
  .quick-links,
  .doctrine-hub,
  .sermon-section {
    padding: 1rem 0;
  }

  /* Footer Full Width */
  .footer {
    padding: var(--space-xl) 0;
  }

  .footer-content {
    gap: var(--space-lg);
  }

  /* Remove/Simplify Complex Elements */
  .hidden-mobile {
    display: none !important;
  }

  /* Adjust Hero Height */
  .hero,
  .hero-home {
    height: 60vh;
    min-height: 300px;
  }

  /* Scroll Indicator */
  .scroll-indicator {
    bottom: 20px;
  }

  /* Breadcrumbs Compact */
  .breadcrumbs {
    padding: var(--space-md) var(--space-md);
    gap: 4px;
  }

  .breadcrumb-separator {
    margin: 0 2px;
  }
}

/* ===== EXTRA SMALL MOBILE (max-width: 375px) ===== */
@media (max-width: 375px) {
  .container {
    max-width: 280px;
    padding: 0 6px;
  }

  .hero,
  .hero-home {
    height: 55vh;
    min-height: 280px;
  }

  .hero-title {
    font-size: 1.3rem;
  }

  h1 {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
  }

  h2 {
    font-size: clamp(1rem, 4vw, 1.4rem);
  }

  .footer-phone {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .footer-block-title {
    font-size: 0.75rem;
  }
}

/* ===== DOCTRINE & STUDY PAGES (TEXT-HEAVY) ===== */
@media (max-width: 768px) {
  .doctrine-page {
    padding: 40px 0 60px;
  }

  .doctrine-body {
    padding: 28px 20px;
    border-radius: 16px;
    margin: 0 12px;
  }

  .doctrine-title {
    font-size: 1.6rem;
    margin-bottom: 28px;
    padding-bottom: 16px;
  }

  .doctrine-body h3 {
    font-size: 1.2rem;
    margin: 28px 0 16px;
  }

  .doctrine-body h4 {
    font-size: 1rem;
    margin: 20px 0 12px;
  }

  .doctrine-body p,
  .doctrine-body li {
    font-size: 0.95rem;
    line-height: 1.8;
    text-align: left !important;
  }

  .doctrine-body ul,
  .doctrine-body ol {
    margin: 16px 0 16px 20px;
    line-height: 1.8;
  }

  .page-nav {
    gap: 10px;
  }

  .page-nav-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 18px;
  }

  .study-layout {
    flex-direction: column;
    gap: 16px;
    padding: 10px 0 50px;
    max-width: 100%;
  }

  .study-sidebar {
    width: 100%;
  }

  .sidebar-nav {
    position: static;
    top: auto;
    padding: 18px;
  }

  .study-body {
    padding: 24px 18px;
    border-radius: 14px;
  }

  .study-title {
    font-size: 1.4rem;
    margin-bottom: 20px;
    padding-bottom: 12px;
  }

  .study-body h3 {
    font-size: 1.05rem;
    margin: 24px 0 12px;
  }

  .study-body p,
  .study-body li {
    font-size: 0.95rem;
    line-height: 1.8;
    text-align: left !important;
  }

  .study-body ul,
  .study-body ol {
    margin: 16px 0 16px 20px;
    line-height: 1.8;
  }

  .scripture-ref {
    padding: 16px 18px;
    line-height: 1.8;
  }
}

@media (max-width: 480px) {
  .doctrine-body {
    padding: 22px 14px;
    margin: 0 8px;
  }

  .doctrine-title {
    font-size: 1.4rem;
  }

  .doctrine-body h3 {
    font-size: 1.05rem;
  }

  .doctrine-body p,
  .doctrine-body li {
    font-size: 0.92rem;
  }

  .doctrine-body ul,
  .doctrine-body ol {
    margin-left: 18px;
  }

  .page-nav {
    margin-top: 30px;
  }

  .page-nav-btn {
    font-size: 0.85rem;
    padding: 10px 16px;
  }

  .sidebar-nav {
    padding: 16px;
  }

  .sidebar-list a {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .lang-toggle a {
    font-size: 0.8rem;
    padding: 10px 12px;
  }

  .study-body {
    padding: 20px 14px;
  }

  .study-title {
    font-size: 1.25rem;
  }

  .study-body p,
  .study-body li {
    font-size: 0.92rem;
  }

  .scripture-ref {
    padding: 14px 16px;
  }
}

@media (max-width: 360px) {
  .doctrine-body {
    padding: 18px 12px;
    margin: 0 6px;
  }

  .doctrine-title {
    font-size: 1.25rem;
  }

  .study-body {
    padding: 18px 12px;
  }

  .study-title {
    font-size: 1.15rem;
  }

  .doctrine-body p,
  .doctrine-body li,
  .study-body p,
  .study-body li {
    font-size: 0.9rem;
  }
}

/* ===== ABOUT & TESTIMONY PAGES ===== */
@media (max-width: 768px) {
  .doctrine-hub {
    padding: 40px 0 60px;
  }

  .intro-section {
    margin: 0 auto 36px;
    padding: 0 12px;
  }

  .journey-timeline {
    padding: 20px 0;
  }

  .journey-timeline::before {
    left: 16px;
    transform: none;
  }

  .journey-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 28px;
    padding-left: 32px;
  }

  .journey-item:nth-child(odd),
  .journey-item:nth-child(even) {
    flex-direction: column;
  }

  .journey-number {
    position: static;
    transform: none;
    width: 40px;
    height: 40px;
    font-size: 0.95rem;
    margin-left: -32px;
  }

  .journey-content {
    width: 100%;
    padding: 18px 16px;
    border-radius: 16px;
    text-align: left;
  }

  .journey-item:nth-child(odd) .journey-content,
  .journey-item:nth-child(even) .journey-content {
    margin: 0;
    text-align: left;
  }

  .journey-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 12px;
  }

  .journey-item:nth-child(odd) .journey-icon {
    margin-left: 0;
  }

  .journey-content h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
  }

  .journey-content p {
    font-size: 0.92rem;
    line-height: 1.7;
  }

  .journey-marker {
    margin-left: 0;
  }

  .timeline-progress-line {
    left: 12px;
    transform: none;
    width: 3px;
  }

  .testimony-page {
    padding: 40px 0 60px;
  }

  .testimony-layout {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 0 12px;
  }

  .testimony-sidebar {
    position: static;
    top: auto;
  }

  .toc-card {
    padding: 18px 16px;
    border-radius: 16px;
  }

  .toc-title {
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .toc-link {
    padding: 9px 12px;
    font-size: 0.82rem;
  }

  .toc-number {
    width: 24px;
    height: 24px;
    line-height: 22px;
    font-size: 0.7rem;
    margin-right: 8px;
  }

  .testimony-content {
    padding: 0;
  }

  .testimony-section {
    padding: 18px 16px;
    border-radius: 16px;
  }

  .testimony-header h2 {
    font-size: 1.2rem;
  }

  .testimony-header .author {
    font-size: 0.85rem;
  }

  .testimony-body p {
    font-size: 0.92rem;
    line-height: 1.8;
    text-align: left;
  }

  .content-card,
  .section-card,
  .info-card,
  .feature-card,
  .service-card,
  .contact-card,
  .filter-card,
  .sermon-item,
  .gallery-card,
  .gallery-item,
  .toc-card,
  .testimony-content,
  .testimony-section {
    padding: 16px 14px;
    border-radius: 14px;
  }
}

@media (max-width: 480px) {
  .intro-section {
    margin-bottom: 28px;
  }

  .journey-item {
    padding-left: 28px;
  }

  .journey-number {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
    margin-left: -28px;
  }

  .journey-content {
    padding: 16px 14px;
  }

  .testimony-layout {
    padding: 0 8px;
  }

  .toc-card {
    padding: 16px 14px;
  }

  .toc-link {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .toc-number {
    width: 22px;
    height: 22px;
    line-height: 20px;
    font-size: 0.68rem;
    margin-right: 6px;
  }

  .testimony-section {
    padding: 14px 12px;
  }

  .testimony-body p {
    font-size: 0.9rem;
    line-height: 1.7;
  }

  .doctrine-body {
    padding: 18px 12px;
    margin: 0 6px;
  }

  .doctrine-body p,
  .doctrine-body li {
    font-size: 0.9rem;
    line-height: 1.7;
  }

  .study-body {
    padding: 18px 12px;
  }

  .study-body p,
  .study-body li {
    font-size: 0.9rem;
    line-height: 1.7;
  }

  .timeline-progress-line {
    left: 10px;
    width: 2px;
  }

  .content-card,
  .section-card,
  .info-card,
  .feature-card,
  .service-card,
  .contact-card,
  .filter-card,
  .sermon-item,
  .gallery-card,
  .gallery-item,
  .toc-card,
  .testimony-content,
  .testimony-section {
    padding: 14px 12px;
    border-radius: 12px;
  }
}

@media (max-width: 360px) {
  .journey-content {
    padding: 12px 10px;
  }

  .journey-content h3 {
    font-size: 1rem;
  }

  .testimony-layout {
    padding: 0 6px;
  }

  .testimony-section {
    padding: 12px 10px;
  }

  .testimony-header h2 {
    font-size: 1.1rem;
  }

  .doctrine-body {
    padding: 16px 10px;
    margin: 0 4px;
  }

  .study-body {
    padding: 16px 10px;
  }

  .content-card,
  .section-card,
  .info-card,
  .feature-card,
  .service-card,
  .contact-card,
  .filter-card,
  .sermon-item,
  .gallery-card,
  .gallery-item,
  .toc-card,
  .testimony-content,
  .testimony-section {
    padding: 12px 10px;
    border-radius: 10px;
  }
}

/* ===== LANDSCAPE MODE (max-height: 500px) ===== */
@media (max-height: 500px) and (orientation: landscape) {

  .hero,
  .hero-home,
  .splash-page {
    height: 100vh;
    height: 100dvh;
    max-height: 50vh;
    /* prevent hero from filling entire landscape viewport */
    min-height: auto;
  }

  .hero-overlay,
  .hero-home-content {
    padding: var(--space-lg);
  }

  .welcome-section,
  .quick-links,
  .doctrine-hub {
    padding: var(--space-xl) 0;
  }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {

  /* Disable hover effects on touch devices */
  .btn:hover,
  .card-hover:hover {
    transform: none;
  }

  /* Increase touch targets — scoped to interactive elements only (F-02) */
  button,
  .btn,
  .nav-link,
  .dropdown-link {
    min-height: 44px;
    min-width: 44px;
  }

  /* Add active state feedback */
  .btn:active,
  button:active {
    opacity: 0.8;
    transform: scale(0.98);
    transition: all 0.1s ease;
  }

  /* Remove hover animations */
  .nav-link::before {
    display: none;
  }

  .contact-card::before {
    display: none;
  }

  /* Touch feedback — scoped to interactive elements (F-22) */
  a,
  button,
  input,
  .btn,
  .nav-link,
  .dropdown-link {
    -webkit-tap-highlight-color: rgba(212, 165, 116, 0.1);
  }
}

/* ===== HIGH DPI SCREENS (Retina) ===== */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: subpixel-antialiased;
    text-rendering: optimizeLegibility;
  }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
  .nav-menu {
    background: rgba(26, 58, 82, 0.98);
  }

  .nav-menu .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
  }

  .nav-menu .nav-link:hover {
    background: rgba(212, 165, 116, 0.1);
  }

  /* Adjust form colors for dark mode */
  .form-input,
  .form-textarea {
    background: #1a3a52;
    color: white;
    border-color: rgba(212, 165, 116, 0.5);
  }

  .form-input::placeholder,
  .form-textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
  }
}

/* ===== PREVENT COMMON MOBILE ISSUES ===== */

/* Disable automatic zoom on input focus (iOS) */
input,
textarea,
select {
  font-size: 16px;
}

/* html,body { height:100% } removed — min-height:100vh is sufficient (F-10) */

/* Prevent double-tap zoom */
a,
button,
input,
textarea {
  touch-action: manipulation;
}

/* Prevent pull-to-refresh only, allow elastic bounce (F-23) */
body {
  overscroll-behavior-y: none;
}

/* Better text rendering */
* {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* ===========================================
   PHASE 27 — MOBILE RESPONSIVENESS HARDENING
   Real-device fixes beyond layout breakpoints
   =========================================== */

/* ===== GLOBAL HARDENING (all viewports) ===== */

/* M-15 — Prevent sideways scroll from long words, URLs, scripture refs */
p,
li,
h1,
h2,
h3,
h4,
h5,
h6,
a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* M-17 — Prevent layout jump when scrollbar appears/disappears */
html {
  scrollbar-gutter: stable;
}

/* M-18 — Prevent keyboard covering focused inputs */
:focus {
  scroll-margin-top: 90px;
}

/* M-19 — Improve tap accuracy on checkboxes/radios */
input[type="checkbox"],
input[type="radio"] {
  min-width: 20px;
  min-height: 20px;
}

/* M-10 — Global media max-width guard */
video,
iframe,
embed,
object {
  max-width: 100%;
}

/* M-20 — Responsive embedded videos (YouTube sermons) */
.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.video-wrapper iframe {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

/* M-21 — Balanced heading text-wrap for long translations */
h1,
h2,
h3 {
  text-wrap: balance;
}

/* M-22 — Ensure touch-action covers nav drawer & footer links */
.nav-menu a,
.nav-menu button,
.footer a,
.footer button,
select {
  touch-action: manipulation;
}

/* M-23 — Prevent CLS from unloaded images */
img[width][height] {
  height: auto;
  aspect-ratio: attr(width) / attr(height);
}

/* M-14 — Safe-area insets for notches & home indicators */
@supports (padding: env(safe-area-inset-left)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .footer {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .navbar {
    padding-top: env(safe-area-inset-top);
  }
}

/* M-13 — Dynamic viewport units for hero (modern Chrome/Safari) */
@supports (height: 100dvh) {
  .hero-home {
    min-height: 100dvh;
  }
}

/* M-08 — Legacy Safari fill-available fallback */
.hero-home {
  min-height: -webkit-fill-available;
}

/* M-16 — iOS momentum scroll inside mobile nav drawer */
@media (max-width: 1024px) {
  .nav-menu {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ===== BREAKPOINT-SPECIFIC HARDENING ===== */

/* M-12 — Breadcrumb spacing reduced at ≤768px */
@media (max-width: 768px) {
  .breadcrumb-spacing {
    padding-top: 70px;
  }
}

/* M-09 — Footer 3-col → 1-col at ≤640px (supplements 768px rule) */
@media (max-width: 640px) {
  .footer-content {
    grid-template-columns: 1fr;
  }
}

/* M-01 through M-06 at ≤480px */
@media (max-width: 480px) {

  /* M-01 — Search flex row wrapping */
  .search-flex-row {
    flex-wrap: wrap;
  }

  /* M-02 — Contact form padding reduction */
  .contact-form-wrapper {
    padding: 24px 16px;
  }

  /* M-04 — Doctrines grid single-column */
  .doctrines-grid {
    grid-template-columns: 1fr !important;
  }

  /* M-05 — Cards grid single-column */
  .cards-grid {
    grid-template-columns: 1fr;
  }

  /* M-06 — Scripture quote narrow-screen padding */
  .scripture-quote {
    padding: 20px 16px;
  }
}

/* M-07 & M-11 at ≤375px */
@media (max-width: 375px) {

  /* M-07 — YouTube link wrap */
  .yt-link {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }

  /* M-11 — No-sermons padding */
  .no-sermons {
    padding: 30px 16px;
  }
}

/* ===========================================
   INDEX.HTML — MOBILE HARDENING (H-01 → H-20)
   !important required: index.html's inline <style>
   loads AFTER mobile.css and overrides same-specificity rules
   =========================================== */

/* ===== ≤768px — Tablet & Mobile ===== */
@media (max-width: 768px) {

  /* H-01 — Section paddings (inline: 120-140px) */
  .welcome-section {
    padding: 60px 0 !important;
  }

  .quick-links {
    padding: 60px 0 !important;
  }

  .scripture-banner {
    padding: 60px 0 !important;
  }

  .cta-section {
    padding: 60px 0 !important;
  }

  .values-section {
    padding: 60px 0 !important;
  }

  .recent-sermons {
    padding: 60px 0 !important;
  }

  /* H-07 — Hero verse side padding */
  .hero-home-verse {
    padding: 20px 20px !important;
    font-size: clamp(0.85rem, 2vw, 1rem) !important;
    line-height: 1.7 !important;
    border-left-width: 2px !important;
    border-right-width: 2px !important;
  }

  /* H-08 — Hero content (inline: max-width 840px, padding 28px 32px) */
  .hero-home-content {
    padding: 20px 16px !important;
    max-width: 100% !important;
    gap: 8px !important;
  }

  /* Hero home height fix */
  .hero-home {
    height: auto !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    padding: calc(var(--nav-height) + 20px) 16px 40px !important;
  }

  /* Hero logo smaller */
  .hero-logo {
    width: 80px !important;
    height: 80px !important;
  }

  /* Hero title responsive */
  .hero-home-title {
    font-size: clamp(1.6rem, 5vw, 2.2rem) !important;
    margin-bottom: 8px !important;
    line-height: 1.2 !important;
  }

  /* Hero subtitle badge */
  .hero-home-subtitle {
    font-size: 0.7rem !important;
    letter-spacing: 2px !important;
    padding: 8px 20px !important;
  }

  /* Founder badge */
  .hero-founder-badge {
    padding: 10px 20px !important;
    margin: 8px 0 12px !important;
    gap: 10px !important;
  }

  .hero-founder-badge span {
    font-size: 0.82rem !important;
    white-space: normal !important;
    text-align: center !important;
    letter-spacing: 0.5px !important;
  }

  /* Hero reference */
  .hero-home-reference {
    margin-bottom: 18px !important;
    font-size: 0.9rem !important;
  }

  .hero-home-reference::before,
  .hero-home-reference::after {
    display: none !important;
  }

  /* H-13 — Hero CTA button (inline: padding 18px 48px) */
  .hero-home-cta {
    padding: 14px 28px !important;
    font-size: 0.75rem !important;
    letter-spacing: 2px !important;
    width: auto !important;
  }

  /* Scroll indicator */
  .scroll-indicator {
    display: none !important;
  }

  /* H-09 — Link cards (inline: padding 50px 38px) */
  .link-card {
    padding: 28px 20px !important;
  }

  .link-card-icon {
    width: 68px !important;
    height: 68px !important;
    margin-bottom: 18px !important;
  }

  .link-card-icon svg {
    width: 28px !important;
    height: 28px !important;
  }

  .link-card h3 {
    font-size: 1.15rem !important;
  }

  .link-card-number {
    font-size: 2.5rem !important;
  }

  /* H-10 — Value cards (inline: padding 45px 32px) */
  .value-card {
    padding: 28px 20px !important;
  }

  .value-icon {
    width: 56px !important;
    height: 56px !important;
  }

  .value-icon svg {
    width: 28px !important;
    height: 28px !important;
  }

  .value-card h3 {
    font-size: 1.15rem !important;
  }

  /* Doctrine cards (inline: padding 45px 32px) */
  .doctrine-card {
    padding: 28px 20px !important;
  }

  .doctrine-icon {
    width: 64px !important;
    height: 64px !important;
    margin-bottom: 16px !important;
  }

  .doctrine-icon svg {
    width: 32px !important;
    height: 32px !important;
  }

  .doctrine-card h3 {
    font-size: 1.1rem !important;
  }

  /* Grids → single column */
  .doctrines-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    margin: 30px 0 20px !important;
  }

  .links-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .sermons-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .values-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    margin-top: 30px !important;
  }

  .welcome-stats {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
    padding: 24px 0 !important;
  }

  .stat-item::after {
    display: none !important;
  }

  .stat-number {
    font-size: 2.2rem !important;
  }

  /* Section headers */
  .section-header {
    margin-bottom: 30px !important;
  }

  .section-header h2 {
    font-size: 1.6rem !important;
  }

  .quick-links-header {
    margin-bottom: 24px !important;
  }

  .quick-links-header h2 {
    font-size: 1.6rem !important;
  }

  .quick-links-header p {
    font-size: 0.95rem !important;
  }

  .welcome-wrap h2 {
    font-size: 1.8rem !important;
    margin-bottom: 16px !important;
  }

  .welcome-lead {
    font-size: 0.95rem !important;
    line-height: 1.7 !important;
  }

  .welcome-founder-line {
    flex-direction: column !important;
    gap: 8px !important;
  }

  /* CTA section */
  .cta-content h2 {
    font-size: 1.6rem !important;
  }

  .cta-content p {
    font-size: 0.95rem !important;
    margin-bottom: 28px !important;
  }

  .cta-buttons {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .btn-light,
  .btn-outline {
    width: 100% !important;
    text-align: center !important;
    padding: 14px 24px !important;
    box-sizing: border-box !important;
  }

  .btn-primary {
    padding: 14px 28px !important;
    font-size: 0.8rem !important;
  }

  /* Scripture banner */
  .scripture-banner blockquote {
    font-size: clamp(1.2rem, 3vw, 1.6rem) !important;
    padding: 0 16px !important;
  }

  .scripture-banner .container::before,
  .scripture-banner .container::after {
    display: none !important;
  }

  .scripture-banner::after {
    font-size: 8rem !important;
  }

  /* Floating prayer button */
  .floating-prayer-btn {
    width: 52px !important;
    height: 52px !important;
    bottom: 16px !important;
    right: 16px !important;
    font-size: 18px !important;
  }

  @supports (padding: env(safe-area-inset-bottom)) {
    .floating-prayer-btn {
      bottom: calc(16px + env(safe-area-inset-bottom)) !important;
    }
  }

  /* Announcement bar */
  .announcement-content {
    font-size: 0.78rem !important;
    gap: 8px !important;
  }
}

/* ===== ≤480px — Small Mobile ===== */
@media (max-width: 480px) {

  /* Further compress sections */
  .welcome-section,
  .quick-links,
  .scripture-banner,
  .cta-section,
  .values-section,
  .recent-sermons {
    padding: 40px 0 !important;
  }

  /* Hero ultra-compact */
  .hero-home {
    padding: calc(var(--nav-height) + 12px) 12px 30px !important;
  }

  .hero-logo {
    width: 70px !important;
    height: 70px !important;
  }

  .hero-home-title {
    font-size: clamp(1.3rem, 5vw, 1.8rem) !important;
  }

  .hero-home-subtitle {
    font-size: 0.65rem !important;
    padding: 6px 14px !important;
    letter-spacing: 1.5px !important;
  }

  .hero-founder-badge {
    padding: 8px 16px !important;
  }

  .hero-founder-badge span {
    font-size: 0.78rem !important;
  }

  .hero-home-verse {
    padding: 14px 14px !important;
    font-size: 0.85rem !important;
  }

  .hero-home-cta {
    padding: 12px 20px !important;
    font-size: 0.7rem !important;
    width: 100% !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }

  /* Cards compact */
  .link-card {
    padding: 24px 16px !important;
  }

  .value-card {
    padding: 24px 16px !important;
  }

  .doctrine-card {
    padding: 24px 16px !important;
  }

  /* Buttons full width */
  .btn-primary {
    padding: 12px 20px !important;
    width: 100% !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }

  .btn-light,
  .btn-outline {
    padding: 12px 20px !important;
  }

  /* Section headers */
  .section-header h2,
  .quick-links-header h2 {
    font-size: 1.3rem !important;
  }

  .welcome-wrap h2 {
    font-size: 1.5rem !important;
  }

  .stat-number {
    font-size: 1.8rem !important;
  }

  .cta-content h2 {
    font-size: 1.3rem !important;
  }

  .scripture-banner blockquote {
    font-size: clamp(1rem, 4vw, 1.3rem) !important;
  }
}

/* ===== ≤375px — Extra Small ===== */
@media (max-width: 375px) {

  .hero-home-verse {
    padding: 12px 10px !important;
    font-size: 0.8rem !important;
  }

  .hero-founder-badge {
    padding: 8px 12px !important;
    gap: 6px !important;
  }

  .hero-founder-badge span {
    font-size: 0.72rem !important;
    letter-spacing: 0.2px !important;
  }

  .hero-home-title {
    font-size: clamp(1.1rem, 5vw, 1.5rem) !important;
  }

  .scripture-banner blockquote {
    font-size: clamp(0.95rem, 4vw, 1.2rem) !important;
  }

  .cta-content p {
    font-size: 0.85rem !important;
    margin-bottom: 20px !important;
  }

  .welcome-wrap h2 {
    font-size: 1.3rem !important;
  }

  .section-header h2,
  .quick-links-header h2 {
    font-size: 1.15rem !important;
  }
}

/* ===== EXTRA SMALL DEVICES (max-width: 360px) ===== */
@media (max-width: 360px) {
  :root {
    --container-max: 240px;
  }

  .container {
    max-width: var(--container-max);
    padding: 0 4px;
  }
}