/* Mobile header: phone (up to 767px) */

.mheader {
    --mheader-bg: #fbf7ef;
    --mheader-text: #3b2a1e;
    --mheader-muted: #75685e;
    --mheader-accent: #c4552d;
    --mheader-accent-dark: #a8461f;
    --mheader-tint: #f6eee6;
    --mheader-hover: #f7f2eb;
    --mheader-line: #efe9df;

    position: sticky;
    top: 0;
    z-index: 100;
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Top bar */
.mheader-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 14px 0 16px;
    position: relative;
    background: var(--mheader-bg);
}

/* Valley picture behind the header, softened with a cream layer
   so the logo stays easy to read */
.mheader-bar::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg,
            rgba(251, 247, 239, 0.88) 0%,
            rgba(251, 247, 239, 0.55) 60%,
            rgba(251, 247, 239, 0.35) 100%),
        url("../../img/mobile-header-bg.jpg") center 70% / cover no-repeat;
    filter: saturate(0.75);
    pointer-events: none;
}

/* Keep logo and ☰ above the picture */
.mheader-bar > * {
    position: relative;
    z-index: 1;
}

/* Logo: big leaf + name */
.mheader-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    text-decoration: none;
}

.mheader-logo-mark {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    color: var(--mheader-accent);
}

.mheader-logo-icon {
    width: 30px;
    height: 30px;
    stroke-width: 1.8;
}

.mheader-logo-text {
    overflow: hidden;
    font-family: "Fredoka", "Plus Jakarta Sans", system-ui, sans-serif;
    font-size: 22px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--mheader-text);
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ☰ and ✕ buttons: soft square, 44px so they are easy to tap */
.mheader-toggle,
.mheader-close {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--mheader-text);
    background: var(--mheader-hover);
    border: 1px solid var(--mheader-line);
    border-radius: 12px;
    cursor: pointer;
}

.mheader-toggle svg,
.mheader-close svg {
    width: 24px;
    height: 24px;
}

.mheader-toggle:active,
.mheader-close:active {
    background: var(--mheader-tint);
}

/* Dark, slightly blurred background behind the panel */
.mheader-overlay {
    position: fixed;
    inset: 0;
    z-index: 101;
    background: rgba(40, 30, 24, 0.42);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.35s ease;
}

/* Side panel that slides in from the right */
.mheader-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 102;
    display: flex;
    flex-direction: column;
    width: min(340px, 88vw);
    padding: 12px 18px 20px;
    background: var(--mheader-bg);
    border-radius: 24px 0 0 24px;
    box-shadow: -12px 0 36px rgba(40, 30, 24, 0.18);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Closed panel is fully hidden (not just off-screen) */
.mheader-overlay[hidden],
.mheader-panel[hidden] {
    display: none;
}

.mheader.is-open .mheader-overlay {
    opacity: 1;
}

.mheader.is-open .mheader-panel {
    transform: translateX(0);
}

/* Panel top: logo + ✕ */
.mheader-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 56px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mheader-line);
}

.mheader-panel-head .mheader-logo-icon {
    width: 26px;
    height: 26px;
}

.mheader-panel-head .mheader-logo-text {
    font-size: 19px;
}

/* Small "MENU" label */
.mheader-label {
    margin: 20px 0 8px 4px;
    color: var(--mheader-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* Links: icon tile + name + › arrow */
.mheader-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mheader-link {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 54px;
    padding: 0 8px;
    color: var(--mheader-text);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 14px;
    transition: background-color 0.2s ease;
}

.mheader-link:active {
    background: var(--mheader-hover);
}

.mheader-link-icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: var(--mheader-accent);
    background: #fff;
    border: 1px solid var(--mheader-line);
    border-radius: 11px;
}

.mheader-icon {
    flex-shrink: 0;
    width: 19px;
    height: 19px;
}

.mheader-link-label {
    flex: 1;
}

.mheader-link-arrow {
    width: 18px;
    height: 18px;
    color: #b9aa9b;
}

/* Current page: tinted row, filled icon, accent arrow */
.mheader-link.is-active {
    color: var(--mheader-accent);
    background: var(--mheader-tint);
}

.mheader-link.is-active .mheader-link-icon {
    color: #fff;
    background: var(--mheader-accent);
    border-color: var(--mheader-accent);
}

.mheader-link.is-active .mheader-link-arrow {
    color: var(--mheader-accent);
}

/* Bottom: Book button + location */
.mheader-panel-foot {
    margin-top: auto;
    padding-top: 20px;
}

.mheader-book {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 54px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    background: var(--mheader-accent);
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(196, 85, 45, 0.28);
}

.mheader-book:active {
    background: var(--mheader-accent-dark);
}

/* Login: outline button under Book */
.mheader-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 50px;
    margin-top: 10px;
    color: var(--mheader-text);
    font-size: 15.5px;
    font-weight: 600;
    text-decoration: none;
    background: #fff;
    border: 1.5px solid #e2d8ca;
    border-radius: 999px;
}

.mheader-login:active,
.mheader-login.is-active {
    color: var(--mheader-accent);
    border-color: var(--mheader-accent);
}

.mheader-place {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 14px 0 0;
    color: var(--mheader-muted);
    font-size: 12.5px;
    font-weight: 500;
}

.mheader-place-icon {
    width: 14px;
    height: 14px;
    color: var(--mheader-accent);
}

/* Panel opening: links slide in one by one, then the bottom part */
@keyframes mheader-item-in {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.mheader.is-open .mheader-label,
.mheader.is-open .mheader-links li,
.mheader.is-open .mheader-panel-foot {
    animation: mheader-item-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.mheader.is-open .mheader-label                { animation-delay: 0.08s; }
.mheader.is-open .mheader-links li:nth-child(1) { animation-delay: 0.12s; }
.mheader.is-open .mheader-links li:nth-child(2) { animation-delay: 0.17s; }
.mheader.is-open .mheader-links li:nth-child(3) { animation-delay: 0.22s; }
.mheader.is-open .mheader-links li:nth-child(4) { animation-delay: 0.27s; }
.mheader.is-open .mheader-links li:nth-child(5) { animation-delay: 0.32s; }
.mheader.is-open .mheader-links li:nth-child(6) { animation-delay: 0.37s; }
.mheader.is-open .mheader-panel-foot           { animation-delay: 0.4s; }

/* Keyboard focus ring */
.mheader a:focus-visible,
.mheader button:focus-visible {
    outline: 3px solid var(--mheader-accent);
    outline-offset: 2px;
}

/* Stop page scrolling while the panel is open */
body.mheader-lock {
    overflow: hidden;
}

/* Opening animation (first visit in a session)
   1. Logo slides in smoothly from the left
   2. ☰ button fades in */
@keyframes mheader-slide-in {
    from {
        opacity: 0;
        transform: translateX(-70px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes mheader-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.mheader-bar > .mheader-logo {
    animation: mheader-slide-in 1.6s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.mheader-toggle {
    animation: mheader-fade-in 1.1s ease-out 0.9s backwards;
}

/* Already seen this session: no animation when moving between pages */
.menu-no-intro .mheader-bar > .mheader-logo,
.menu-no-intro .mheader-toggle {
    animation: none;
}

/* People who prefer less movement */
@media (prefers-reduced-motion: reduce) {
    .mheader-overlay,
    .mheader-panel {
        transition: none;
    }

    .mheader-bar > .mheader-logo,
    .mheader-toggle,
    .mheader.is-open .mheader-label,
    .mheader.is-open .mheader-links li,
    .mheader.is-open .mheader-panel-foot {
        animation: none;
    }
}

/* Small star-flower between "Ba Kuti" and "Aama Kuti" */
.mheader-logo-sep {
    display: inline-flex;
    align-items: center;
    margin: 0 2px;
    color: var(--mheader-accent);
    vertical-align: middle;
    transform: translateY(-1px);
}

.mheader-logo-sep-icon {
    width: 11px;
    height: 11px;
    fill: currentColor;
    stroke: none;
}
