/* =========================================================
   AIC EGERTON CHAPEL: compact "glass" header for small screens
   Loaded from header.html, so every page gets it.
   The selectors are deliberately specific so they win over the
   older header rules that are written inside each page.
========================================================= */

/* Link icons are only shown on small screens */
@media (min-width: 851px) {
  header.site-header .nav-links .nav-ico { display: none; }
}

@media (max-width: 850px) {

  /* ---------- header bar: slimmer, glass ---------- */
  body { padding-top: 86px; }

  header.site-header {
    height: 56px;
    padding: 0 14px !important;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 6px 24px rgba(30, 10, 50, .18) !important;
    /* the glass is painted by ::before so the dropdown panel can blur the page behind it too */
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  header.site-header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg, rgba(88, 38, 128, .62), rgba(48, 22, 74, .58));
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    backdrop-filter: blur(18px) saturate(170%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
  }
  header.site-header .container { padding: 0; gap: 10px; }

  /* ---------- logo and name: smaller ---------- */
  header.site-header .logo { gap: 9px; min-width: 0; }
  header.site-header .logo1 { width: 34px; height: 34px; border-width: 1.5px; box-shadow: none; }
  header.site-header .church-name {
    font-size: .86rem;
    letter-spacing: .3px;
    text-shadow: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ---------- menu button: small glass square on the right ---------- */
  header.site-header .menu-toggle {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    margin-left: auto;
    padding: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .26);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: none;
    transition: background .2s ease;
  }
  header.site-header .menu-toggle:hover,
  header.site-header .menu-toggle.active { background: rgba(255, 255, 255, .26); }
  header.site-header .menu-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
  header.site-header .menu-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
  }
  header.site-header .menu-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  header.site-header .menu-toggle.active span:nth-child(2) { opacity: 0; transform: scaleX(.4); }
  header.site-header .menu-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* ---------- dropdown panel: compact glass card, links on the left ---------- */
  header.site-header nav ul.nav-links {
    display: flex;
    position: fixed;
    top: 64px;
    right: 10px;
    left: auto;
    bottom: auto;
    width: min(264px, calc(100vw - 20px));
    height: auto;
    max-height: calc(100vh - 76px);
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px;
    margin: 0;
    list-style: none;
    background: linear-gradient(160deg, rgba(88, 38, 128, .70), rgba(40, 18, 64, .78));
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 18px;
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    box-shadow: 0 18px 40px rgba(20, 8, 36, .38), inset 0 1px 0 rgba(255, 255, 255, .2);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px) scale(.97);
    transform-origin: top right;
    transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
  }
  header.site-header nav ul.nav-links.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition-delay: 0s;
  }

  header.site-header .nav-links li,
  header.site-header .nav-links.active li {
    opacity: 1;
    transform: none;
    transition: none;
    list-style: none;
  }

  header.site-header .nav-links li a {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    min-height: 44px;
    margin: 0;
    padding: 10px 12px;
    text-align: left;
    font-size: .95rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .94);
    background: transparent;
    border-radius: 12px;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    transition: background .2s ease, color .2s ease;
  }
  header.site-header .nav-links li a::before { display: none; }
  header.site-header .nav-links li a .nav-ico {
    display: inline-block;
    flex: none;
    width: 20px;
    text-align: center;
    font-size: .95rem;
    color: rgba(255, 255, 255, .82);
  }
  header.site-header .nav-links li a:hover,
  header.site-header .nav-links li a:focus-visible {
    background: rgba(255, 255, 255, .16);
    transform: none;
    color: #fff;
  }
  header.site-header .nav-links li a:focus-visible { outline: 2px solid rgba(255, 255, 255, .85); outline-offset: -2px; }
  header.site-header .nav-links li a.active,
  header.site-header .nav-links li a[aria-current="page"] {
    background: rgba(255, 255, 255, .2);
    box-shadow: inset 3px 0 0 #ff8fa0;
    color: #fff;
    font-weight: 600;
  }

  /* donate: compact pill at the bottom of the panel */
  header.site-header .nav-links li a.donate-btn {
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    margin-top: 6px;
    padding: 10px 14px;
    font-size: .95rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #ff6b81, #ff4b2b);
    box-shadow: 0 8px 18px rgba(255, 75, 43, .35);
  }
  header.site-header .nav-links li a.donate-btn::after { display: none; }
  header.site-header .nav-links li a.donate-btn:hover { background: linear-gradient(135deg, #ff7d90, #ff5d3f); }
  header.site-header .nav-links li a.donate-btn.active { box-shadow: 0 8px 18px rgba(255, 75, 43, .35); }

  /* browsers without backdrop-filter get a more solid panel */
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    header.site-header::before { background: rgba(58, 26, 90, .96); }
    header.site-header nav ul.nav-links { background: rgba(48, 22, 74, .98); }
  }
}

@media (max-width: 480px) {
  body { padding-top: 82px; }
  header.site-header { height: 52px; padding: 0 12px !important; }
  header.site-header .logo1 { width: 32px; height: 32px; }
  header.site-header .church-name { font-size: .8rem; letter-spacing: .2px; }
  header.site-header .menu-toggle { width: 38px; height: 38px; border-radius: 11px; }
  header.site-header nav ul.nav-links { top: 60px; right: 8px; width: min(256px, calc(100vw - 16px)); max-height: calc(100vh - 70px); max-height: calc(100dvh - 70px); }
}

@media (max-width: 340px) {
  header.site-header .church-name { font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
  header.site-header nav ul.nav-links,
  header.site-header .menu-toggle,
  header.site-header .menu-toggle span { transition: none; }
}
