/**
 * Site header — Ο.Σ.Α. on the jm-starter header (grow-into-menu model).
 *
 * ⚠ Rules this file depends on (THEME.md gotchas #1 #4):
 *   • .site-header gets NO backdrop-filter / filter / transform: any of them makes it the
 *     containing block for fixed descendants (that is exactly how v1's phone menu collapsed).
 *   • Edges are box-shadow, never border.
 *   • The mobile menu is ABSOLUTE inside the header and only takes pointer events when open,
 *     so the closed menu can never sit over the page and eat clicks.
 */

:root { --header-height: var(--oms-header-h); }

body.has-site-header { padding-top: var(--oms-header-h); }

.skip-link:focus { position: fixed !important; z-index: 10001; }

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--oms-header-h);
    background: var(--oms-cyan);
    box-shadow: 0 2px 10px rgba(0, 60, 62, 0.16);
    transition: height 0.46s var(--oms-ease), box-shadow 0.3s ease;
}
.site-header.is-scrolled { box-shadow: 0 6px 22px rgba(0, 60, 62, 0.26); }

/* Logged-in admin bar (WP pins it ≥601px; below that it scrolls away with the page) */
body.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { body.admin-bar .site-header { top: 46px; } }
@media (max-width: 600px) { body.admin-bar .site-header { top: 0; } }

.header-container {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: var(--container-max);
    height: var(--oms-header-h);
    margin: 0 auto;
    padding: 0 24px;
}
@media (max-width: 768px) { .header-container { padding: 0 12px 0 16px; } }

/* ── Logo ─────────────────────────────────────────────────────────── */
.header-logo { display: block; flex: none; line-height: 0; border-radius: 50%; }
.header-logo .logo-image {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}
@media (max-width: 768px) { .header-logo .logo-image { width: 48px; height: 48px; } }

/* ── Desktop navigation ───────────────────────────────────────────── */
.header-nav { display: none; margin-left: auto; }
@media (min-width: 1025px) { .header-nav { display: block; } }

.primary-menu { display: flex; align-items: center; gap: 6px; list-style: none; margin: 0; padding: 0; }
.primary-menu > li { position: relative; }

.primary-menu > li > a {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    border-radius: 4px;
    color: #fff;
    font-size: 15.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 2px rgba(0, 70, 72, 0.35);  /* white on cyan needs the help */
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}
@media (hover: hover) {
    .primary-menu > li:not(.current-menu-item):not(.current-menu-ancestor):not(.current_page_ancestor) > a:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }
}
.primary-menu > .current-menu-item > a,
.primary-menu > .current-menu-ancestor > a,
.primary-menu > .current_page_ancestor > a { background: #fff; color: #111; text-shadow: none; }

.primary-menu .menu-item-has-children > a::after {
    content: "";
    width: 7px; height: 7px;
    border: solid currentColor; border-width: 0 2px 2px 0;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.2s ease;
}
.primary-menu .menu-item-has-children:hover > a::after,
.primary-menu .menu-item-has-children.is-open > a::after { transform: translateY(1px) rotate(-135deg); }

.primary-menu .sub-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    min-width: 280px;
    margin: 0;
    padding: 8px;
    list-style: none;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 40, 42, 0.18), 0 2px 6px rgba(0, 0, 0, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
.primary-menu .sub-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; } /* hover bridge */
.primary-menu .menu-item-has-children:hover > .sub-menu,
.primary-menu .menu-item-has-children.is-open > .sub-menu,
.primary-menu .menu-item-has-children:focus-within > .sub-menu {
    opacity: 1; visibility: visible; transform: translate(-50%, 0);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}
.primary-menu .sub-menu a {
    display: block;
    padding: 10px 14px;
    border-radius: 6px;
    color: var(--oms-ink);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
}
@media (hover: hover) { .primary-menu .sub-menu a:hover { background: var(--oms-pale); color: var(--oms-cyan-ink); } }
.primary-menu .sub-menu .current-menu-item > a { background: var(--oms-pale); color: var(--oms-cyan-ink); font-weight: 600; }

/* ── Menu toggle (jm-starter hamburger, white) ────────────────────── */
.header-actions { display: flex; align-items: center; margin-left: auto; }
@media (min-width: 1025px) { .header-actions { display: none; } }

.menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .menu-toggle:hover { background: rgba(255, 255, 255, 0.16); } }
.hamburger-box { position: relative; display: block; width: 28px; height: 20px; }
.hamburger-line {
    position: absolute; left: 0;
    width: 100%; height: 3px;
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 70, 72, 0.25);
    transition: transform 0.32s var(--oms-ease), opacity 0.2s ease, top 0.32s var(--oms-ease);
}
.hamburger-line:nth-child(1) { top: 0; }
.hamburger-line:nth-child(2) { top: 8.5px; }
.hamburger-line:nth-child(3) { top: 17px; }
.menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) { top: 8.5px; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) { opacity: 0; transform: scaleX(0.2); }
.menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) { top: 8.5px; transform: rotate(-45deg); }

/* ========================================
   MOBILE MENU — the cyan bar grows into it
   ======================================== */
.mobile-nav {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}
@media (min-width: 1025px) { .mobile-nav { display: none; } }

body.jm-menu-open { overflow: hidden; }
body.jm-menu-open .site-header {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    box-shadow: none;
}
@media (min-width: 601px) and (max-width: 782px) {
    body.admin-bar.jm-menu-open .site-header { height: calc(100dvh - 46px); }
}

.mobile-nav.is-open { pointer-events: auto; }

/* The bar stays an opaque strip while the menu is open, so rows scrolled upward pass BEHIND the
   logo and close button instead of showing through them. */
body.jm-menu-open .header-container { background: var(--oms-cyan); }

.mobile-nav__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: calc(var(--oms-header-h) + 18px) 20px max(28px, env(safe-area-inset-bottom));
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.3s ease, visibility 0s linear 0.3s;
}
/* Natural heights: when the menu is taller than the screen the panel SCROLLS. Without this the
   flex column squashes the card (it has overflow:hidden) and clips its last rows. */
.mobile-nav__inner > * { flex-shrink: 0; }

.mobile-nav.is-open .mobile-nav__inner {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.3s ease 0.14s, transform 0.3s ease 0.14s, visibility 0s;
}

/* The live site's white card list */
.mobile-menu {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 0;
    list-style: none;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 60, 62, 0.25);
    overflow: hidden;
}
.mobile-menu > li + li { border-top: 1px solid #eef1f2; }
.mobile-menu a {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 56px;
    padding: 12px 18px;
    color: #1a1a1a;
    font-size: 17px;
    font-weight: 500;
    text-align: center;
    -webkit-tap-highlight-color: rgba(0, 214, 216, 0.15);
}
.mobile-menu > .current-menu-item > a,
.mobile-menu > .current-menu-ancestor > a,
.mobile-menu > .open > a { background: #111; color: #fff; }

.mobile-menu .menu-item-has-children > a::after {
    content: "";
    width: 8px; height: 8px;
    border: solid currentColor; border-width: 0 2px 2px 0;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.25s ease;
}
.mobile-menu .open > a::after { transform: translateY(1px) rotate(-135deg); }

/* Accordion without measuring: the parent <li> is a two-row grid and its second row animates
   0fr → 1fr. No max-height guess, so long sub-menus never get cut off. */
.mobile-menu > .menu-item-has-children {
    display: grid;
    grid-template-rows: auto 0fr;
    transition: grid-template-rows 0.3s var(--oms-ease);
}
.mobile-menu > .menu-item-has-children.open { grid-template-rows: auto 1fr; }
.mobile-menu .sub-menu {
    min-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    list-style: none;
    background: #f7fbfb;
}
.mobile-menu .sub-menu a { min-height: 50px; font-size: 15.5px; color: #333; }
.mobile-menu .sub-menu .current-menu-item > a { color: var(--oms-cyan-ink); font-weight: 700; }

/* Social + contact at the foot */
.mobile-foot { margin: 0 auto; padding-top: 36px; width: 100%; max-width: 560px; text-align: center; color: #fff; }
.mobile-foot__title {
    margin: 0 auto 16px;
    padding-bottom: 12px;
    max-width: 280px;
    font-size: 20px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.75);
    text-shadow: 0 1px 3px rgba(0, 70, 72, 0.35);
}
.mobile-foot__contact {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px;
    margin: 20px 0 0;
}
.mobile-foot__contact a {
    display: inline-flex; align-items: center; gap: 8px;
    color: #053b3d;
    font-weight: 600;
    font-size: 15px;
}
.mobile-foot__contact .oms-icon { width: 18px; height: 18px; }

/* Rows arrive in sequence rather than all at once */
.mobile-nav.is-open .mobile-menu > li,
.mobile-nav.is-open .mobile-foot { animation: oms-menu-row 0.45s var(--oms-ease) both; }
.mobile-nav.is-open .mobile-menu > li:nth-child(1) { animation-delay: 0.16s; }
.mobile-nav.is-open .mobile-menu > li:nth-child(2) { animation-delay: 0.2s; }
.mobile-nav.is-open .mobile-menu > li:nth-child(3) { animation-delay: 0.24s; }
.mobile-nav.is-open .mobile-menu > li:nth-child(4) { animation-delay: 0.28s; }
.mobile-nav.is-open .mobile-menu > li:nth-child(n+5) { animation-delay: 0.32s; }
.mobile-nav.is-open .mobile-foot { animation-delay: 0.36s; }
@keyframes oms-menu-row { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .site-header, .mobile-nav__inner, .hamburger-line, .mobile-menu > .menu-item-has-children { transition: none; }
    .mobile-nav.is-open .mobile-menu > li, .mobile-nav.is-open .mobile-foot { animation: none; }
}
