/**
 * 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(--opse-header-h); }

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

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

.site-header {
    --opse-bar-h: 84px;
    position: fixed;
    top: 6px;
    left: 10px;
    right: 10px;
    z-index: 1000;
    height: var(--opse-bar-h);
    background: var(--opse-red);
    border-radius: 44px;
    box-shadow: 0 6px 20px rgba(34, 0, 0, 0.28);
    transition: height 0.46s var(--opse-ease), top 0.3s ease, left 0.3s ease, right 0.3s ease, border-radius 0.3s ease, box-shadow 0.3s ease;
}
.site-header.is-scrolled { --opse-bar-h: 72px; box-shadow: 0 8px 26px rgba(34, 0, 0, 0.34); }
@media (max-width: 768px) {
    .site-header { --opse-bar-h: 66px; left: 8px; right: 8px; border-radius: 34px; }
    .site-header.is-scrolled { --opse-bar-h: 60px; }
}

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

.header-container {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 24px;
    width: 100%;
    height: var(--opse-bar-h);
    margin: 0 auto;
    padding: 0 28px 0 12px;
    border-radius: inherit;
    transition: height 0.3s var(--opse-ease);
}
@media (max-width: 768px) { .header-container { padding: 0 10px 0 10px; } }

/* ── Logo ─────────────────────────────────────────────────────────── */
.header-logo { display: block; flex: none; line-height: 0; border-radius: 50%; }
.header-logo .logo-image {
    width: calc(var(--opse-bar-h) - 12px); height: calc(var(--opse-bar-h) - 12px);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: width 0.3s var(--opse-ease), height 0.3s var(--opse-ease);
}

/* ── 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 22px;
    border-radius: 30px;
    color: #fff;
    font-size: 15.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    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: #000; }

.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(34, 0, 0, 0.22), 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(--opse-ink);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
}
@media (hover: hover) { .primary-menu .sub-menu a:hover { background: var(--opse-pale); color: var(--opse-red-ink); } }
.primary-menu .sub-menu .current-menu-item > a { background: var(--opse-pale); color: var(--opse-red-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;
    transition: transform 0.32s var(--opse-ease), opacity 0.2s ease, top 0.32s var(--opse-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 red 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 {
    top: 0;
    left: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
}
body.admin-bar.jm-menu-open .site-header { top: 32px; height: calc(100dvh - 32px); }
@media (max-width: 782px) { body.admin-bar.jm-menu-open .site-header { top: 46px; height: calc(100dvh - 46px); } }
@media (max-width: 600px) { body.admin-bar.jm-menu-open .site-header { top: 0; height: 100dvh; } }

.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(--opse-red); border-radius: 0; }

.mobile-nav__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: calc(var(--opse-bar-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(34, 0, 0, 0.3);
    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(131, 7, 7, 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(--opse-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: #fbf5ef;
}
.mobile-menu .sub-menu a { min-height: 50px; font-size: 15.5px; color: #333; }
.mobile-menu .sub-menu .current-menu-item > a { color: var(--opse-red-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);
}
.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: #fff;
    font-weight: 500;
    font-size: 15px;
}
.mobile-foot__contact .opse-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: opse-menu-row 0.45s var(--opse-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 opse-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; }
}
