/* =========================================
   Mobile Responsiveness Overrides
   Purpose: reduce oversized text and improve scanability on phones/tablets
========================================= */

/* Unified radius system: all box/card surfaces share the same moderate curvature */
:root {
  --kegm-surface-radius: 10px;
}

/* Legal pages: cleaner typography and section rhythm */
.legal-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 8px 0 20px;
  color: #172033;
}

.legal-page h1 {
  margin: 0 0 18px;
  font-size: clamp(28px, 3.4vw, 38px);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.legal-page article {
  background: #ffffff;
  border: 1px solid #e5e9f0;
  border-radius: var(--kegm-surface-radius);
  padding: 22px 24px;
}

.legal-page h2 {
  margin: 0 0 14px;
  font-size: clamp(21px, 2.3vw, 27px);
  line-height: 1.3;
}

.legal-page h3 {
  margin: 18px 0 8px;
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.35;
}

.legal-page p {
  margin: 0;
  font-size: 15px;
  line-height: 1.78;
  color: #2a3446;
}

.legal-page p + p {
  margin-top: 10px;
}

.legal-page hr {
  border: 0;
  border-top: 1px solid #e6eaf1;
  margin: 22px 0;
}

.legal-page a {
  color: #174a9b;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.legal-page a:hover,
.legal-page a:focus-visible {
  color: #0f3775;
}

.departments-hero,
.departments-note,
.departments-stat,
.department-card,
.departments-flow__item,
.departments-cta,
.pp-card,
.schedule-card,
.notice-card,
.quick-card.simple,
.kegm-directions .dir-card,
.worship-card,
.worship-events,
.worship-event-list li,
.kegm-login-form-wrap,
.kegm-login-error,
.mega-panel,
.mega-inner section,
[class*="card"],
[class*="box"],
[class*="panel"] {
  border-radius: var(--kegm-surface-radius) !important;
}

@media (max-width: 992px) {
  /* Prevent duplicate page titles on mobile (Astra entry header + custom page header). */
  body.page .entry-header {
    display: none;
  }

  html {
    scroll-padding-top: 74px;
  }

  [id] {
    scroll-margin-top: 74px;
  }

  html,
  body {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  html::-webkit-scrollbar,
  body::-webkit-scrollbar {
    display: none;
  }

  :root {
    --kegm-menu-size: clamp(15px, 3.6vw, 17px);
    --kegm-mega-size: clamp(14px, 3.4vw, 16px);
    --kegm-mobile-summary-size: clamp(18px, 4.9vw, 21px);
    --kegm-mobile-link-size: clamp(15px, 4.2vw, 17px);
  }

  body {
    font-size: 15px;
    line-height: 1.6;
  }

  .site-main,
  .entry-content {
    overflow-wrap: anywhere;
  }

  .entry-content h1,
  .entry-content h2,
  .entry-content h3 {
    line-height: 1.35;
    letter-spacing: -0.01em;
  }

  .entry-content h1 { font-size: clamp(26px, 6vw, 32px); }
  .entry-content h2 { font-size: clamp(22px, 5.2vw, 28px); }
  .entry-content h3 { font-size: clamp(19px, 4.6vw, 24px); }

  .legal-page {
    padding: 4px 0 14px;
  }

  .legal-page article {
    padding: 16px 14px;
  }

  .legal-page h1 {
    margin-bottom: 14px;
  }

  .legal-page h2 {
    margin-bottom: 10px;
  }

  .legal-page h3 {
    margin-top: 14px;
  }

  .legal-page p {
    font-size: 14px;
    line-height: 1.7;
  }

  .legal-page hr {
    margin: 16px 0;
  }

  .page-header__wrap {
    margin: 30px auto;
    padding: 0 14px;
  }

  .page-header__wrap h1 {
    font-size: clamp(24px, 6vw, 30px);
  }

  .page-header__wrap .lead {
    font-size: 14px;
  }

  .hero-banner {
    min-height: 70svh;
    min-height: 70vh;
  }

  .hero-banner h3 {
    font-size: clamp(14px, 3.8vw, 17px);
    margin-bottom: 10px;
  }

  .hero-banner h2 {
    font-size: clamp(22px, 6.6vw, 30px);
    line-height: 1.3;
    margin-bottom: 4px;
    word-break: keep-all;
  }

  .hero-banner p {
    font-size: clamp(13px, 3.8vw, 15px);
    line-height: 1.5;
  }

  .home-hero-slider {
    min-height: 66svh;
    min-height: 66vh;
  }

  .home-hero-slide__content h2 {
    font-size: clamp(24px, 7.2vw, 34px);
    line-height: 1.28;
    letter-spacing: -0.015em;
  }

  .home-hero-slide__content p {
    font-size: clamp(13px, 3.8vw, 16px);
    line-height: 1.55;
  }

  .home-hero-slider__arrow {
    width: 44px;
    height: 44px;
    font-size: 32px;
    border: 0 !important;
    border-radius: 999px;
    background: transparent !important;
    backdrop-filter: none;
    box-shadow: none;
    color: #ffffff;
    opacity: 0;
    pointer-events: none;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .45);
    transition: opacity .2s ease, background .2s ease;
  }

  .home-hero-slider:hover .home-hero-slider__arrow,
  .home-hero-slider:focus-within .home-hero-slider__arrow {
    opacity: 1;
    pointer-events: auto;
    background: transparent !important;
  }

  .home-essentials {
    padding-left: 14px;
    padding-right: 14px;
  }

  .schedule-card .card-head,
  .notice-card .card-head {
    padding: 14px 14px 12px;
  }

  .schedule-card h2,
  .notice-card h2 {
    font-size: 20px;
  }

  .schedule-item {
    padding: 12px 14px;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .schedule-item .meta {
    justify-content: flex-start;
    white-space: normal;
  }

  .quick-card.simple {
    min-height: 116px;
    padding: 16px;
  }

  .quick-grid.simple-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .quick-card.simple {
    min-height: 108px;
    padding: 14px;
  }

  .quick-card.simple .icon-wrap {
    width: 46px;
    height: 46px;
  }

  .quick-card.simple .icon-wrap svg {
    width: 20px;
    height: 20px;
  }

  .quick-card.simple .text {
    font-size: 15px;
    line-height: 1.25;
  }

  .notice-card .kboard-list td {
    padding: 10px 6px;
    font-size: 14px;
  }

  .departments-page {
    margin: 32px auto 60px;
    padding: 0 14px;
  }

  .departments-page h1 {
    font-size: clamp(28px, 7.2vw, 38px);
    line-height: 1.1;
  }

  .departments-lead {
    font-size: 15px;
    line-height: 1.75;
  }

  .departments-section__header h2 {
    font-size: clamp(22px, 5vw, 28px);
  }

  .kegm-drawer-nav {
    padding: 10px 14px calc(16px + env(safe-area-inset-bottom)) 14px;
    gap: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100dvh - 64px);
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .kegm-drawer-nav details {
    padding: 2px 2px;
    border-bottom: 0;
    border-radius: 0;
  }

  .kegm-drawer-head {
    position: sticky;
    top: 0;
    z-index: 3;
    min-height: 56px;
    padding: 10px 14px;
    background: #0c3c78;
    border-bottom: 0;
  }

  .kegm-close {
    position: absolute;
    top: 10px;
    right: 14px;
    width: 36px;
    height: 36px;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 8px;
    background: #08264e !important;
    font-size: 24px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .kegm-drawer-nav summary {
    font-size: clamp(21px, 6.6vw, 25px);
    font-weight: 600;
    line-height: 1.28;
    padding: 6px 0;
  }

  .kegm-drawer-nav summary::after {
    font-size: 16px;
  }

  .kegm-drawer-nav ul {
    margin: 4px 0 0 0;
    padding-left: 10px;
    gap: 4px;
  }

  .kegm-drawer-nav a {
    font-size: clamp(19px, 5.7vw, 21px);
    line-height: 1.32;
    letter-spacing: -0.01em;
  }

  .kegm-drawer-nav::-webkit-scrollbar {
    display: none;
  }

  .kegm-login-page {
    margin: 56px auto 84px;
    padding: 0 14px;
  }

  .kegm-login-form-wrap {
    max-width: 100%;
    padding: 16px 14px;
  }

  .kegm-directions .dir-map iframe {
    height: 340px;
  }

  img,
  iframe,
  video,
  canvas,
  svg {
    max-width: 100%;
    height: auto;
  }
}

@media (max-width: 640px) {
  .quick-grid.simple-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .quick-card.simple {
    min-height: 110px;
    padding: 14px;
  }

  .quick-card.simple .icon-wrap {
    width: 48px;
    height: 48px;
  }

  .quick-card.simple .icon-wrap svg {
    width: 20px;
    height: 20px;
  }

  .quick-card.simple .text {
    font-size: 15px;
    line-height: 1.25;
  }

  .hero-banner {
    min-height: 62svh;
    min-height: 62vh;
  }

  .home-hero-slider {
    min-height: 60svh;
    min-height: 60vh;
  }

  .home-hero-slide__content h2 {
    font-size: clamp(21px, 7.4vw, 28px);
  }

  .home-hero-slide__content p {
    font-size: 13px;
  }

  .card-foot .more,
  .btn,
  #kegm-loginform #wp-submit {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .quick-grid.simple-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .quick-card.simple {
    min-height: 100px;
    padding: 12px;
  }

  .quick-card.simple .icon-wrap {
    width: 42px;
    height: 42px;
  }

  .quick-card.simple .icon-wrap svg {
    width: 18px;
    height: 18px;
  }

  .quick-card.simple .text {
    font-size: 14px;
  }

  .entry-content h1 { font-size: clamp(24px, 7.2vw, 28px); }
  .entry-content h2 { font-size: clamp(20px, 6.2vw, 24px); }
  .entry-content h3 { font-size: clamp(18px, 5.6vw, 21px); }

  .hero-banner h2 {
    font-size: clamp(20px, 7.6vw, 26px);
  }

  .schedule-card h2,
  .notice-card h2 {
    font-size: 18px;
  }

  .quick-card.simple .text {
    font-size: 16px;
  }

  .kegm-drawer {
    width: min(84vw, 312px);
  }
}

/* Extreme zoom / tiny viewport fallback (e.g., desktop browser zoom 400~500%) */
@media (max-width: 420px), (max-height: 520px) {
  .kegm-drawer {
    width: min(92vw, 300px);
  }

  .kegm-drawer-head {
    min-height: 48px;
    padding: 8px 10px;
  }

  .kegm-close {
    top: 6px;
    right: 10px;
    width: 30px;
    height: 30px;
    font-size: 20px;
  }

  .kegm-drawer-nav {
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom)) 10px;
    gap: 4px;
  }

  .kegm-drawer-nav details {
    padding: 2px 0;
  }

  .kegm-drawer-nav summary {
    font-size: 19px;
    line-height: 1.25;
    padding: 5px 0;
    letter-spacing: 0;
    word-break: keep-all;
  }

  .kegm-drawer-nav summary::after {
    font-size: 13px;
    margin-left: 8px;
    flex: 0 0 auto;
  }

  .kegm-drawer-nav ul {
    margin-top: 4px;
    padding-left: 10px;
    gap: 3px;
  }

  .kegm-drawer-nav a {
    font-size: 17px;
    line-height: 1.28;
    letter-spacing: 0;
  }
}
