/* ===========================
   Header & Navigation
   =========================== */

/* Skip link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--color-dark);
    color: var(--color-white);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius);
    z-index: 9999;
    text-decoration: none;
    transition: top 0.1s;
}
.skip-link:focus { top: 0.5rem; }

/* ——————————————————————————————
   Site header
   —————————————————————————————— */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-white);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.3s ease;
}

.site-header.is-scrolled {
    border-bottom-color: var(--color-border);
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06);
}

.site-header.is-hidden {
    transform: translateY(-100%);
}

/* ——————————————————————————————
   Inner layout
   —————————————————————————————— */
.header-inner {
    display: flex;
    align-items: center;
    height: var(--header-height);
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-pad);
    gap: 2rem;
}

/* ——————————————————————————————
   Logo
   —————————————————————————————— */
.site-logo {
    flex-shrink: 0;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.site-logo img {
    height: 25px;
    width: auto;
    display: block;
}

@media (max-width: 1023px) {
    .site-logo img { height: 22px; }
}

@media (max-width: 639px) {
    .site-logo img { height: 20px; }
}

.site-name {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-dark);
    letter-spacing: -0.03em;
    line-height: 1;
}

/* ——————————————————————————————
   Desktop nav
   —————————————————————————————— */
.nav-primary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu > .menu-item > a {
    display: block;
    padding: 0.5rem 0.875rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}

.nav-menu > .menu-item > a:hover,
.nav-menu > .current-menu-item > a,
.nav-menu > .current-page-ancestor > a,
.nav-menu > .current-menu-ancestor > a {
    color: var(--color-dark);
    background: var(--color-bg);
}

/* Desktop dropdown */
.nav-menu .menu-item-has-children { position: relative; }

.nav-menu .sub-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    min-width: 200px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    list-style: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
}

.nav-menu .menu-item-has-children:hover > .sub-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.nav-menu .sub-menu a {
    display: block;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius);
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
}

.nav-menu .sub-menu a:hover {
    color: var(--color-dark);
    background: var(--color-bg);
}

/* ——————————————————————————————
   Header actions (right side)
   —————————————————————————————— */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
}

/* ——————————————————————————————
   Search button
   —————————————————————————————— */
.header-search-btn {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--color-muted);
    flex-shrink: 0;
    transition: background 0.18s ease, color 0.18s ease;
}

.header-search-btn:hover {
    background: var(--color-bg);
    color: var(--color-dark);
}

/* ——————————————————————————————
   Search overlay
   —————————————————————————————— */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: clamp(4rem, 14vh, 9rem);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.search-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* Dark blurred backdrop */
.search-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Modal card */
.search-overlay__modal {
    position: relative;
    z-index: 1;
    width: calc(100% - 3rem);
    max-width: 600px;
    background: var(--color-white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.06);
    transform: translateY(-10px) scale(0.98);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-overlay.is-open .search-overlay__modal {
    transform: translateY(0) scale(1);
}

/* Input row */
.search-overlay__form {
    display: flex;
    align-items: center;
    padding: 0 1.125rem;
    border-bottom: 1px solid var(--color-border);
    gap: 0.75rem;
}

.search-overlay__icon {
    display: flex;
    color: var(--color-muted);
    flex-shrink: 0;
}

.search-overlay__input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    padding: 1.125rem 0;
    font-size: 1.0625rem;
    font-family: var(--font-body);
    color: var(--color-dark);
    background: transparent;
}

.search-overlay__input::placeholder { color: var(--color-muted); }

/* Hide browser's native × on search inputs */
.search-overlay__input::-webkit-search-cancel-button,
.search-overlay__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

/* Clear (×) button — visible only when input has text */
.search-overlay__clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--color-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--color-muted);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.search-overlay__clear:hover {
    background: var(--color-border);
    color: var(--color-dark);
}

/* Results list */
.search-overlay__results {
    max-height: 360px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    text-decoration: none;
    border-bottom: 1px solid var(--color-bg);
    transition: background 0.12s;
    cursor: pointer;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.is-active { background: var(--color-bg); }

.search-result-item__thumb {
    width: 54px;
    height: 46px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--color-bg);
}

.search-result-item__no-thumb {
    width: 54px;
    height: 46px;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-border);
}

.search-result-item__info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.search-result-item__cat {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-muted);
}

.search-result-item__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.search-result-item__excerpt {
    font-size: 0.8125rem;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* No results / loading states */
.search-state {
    padding: 2.25rem 1.25rem;
    text-align: center;
    color: var(--color-muted);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.search-state strong { color: var(--color-text); }

.search-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-dark);
    border-radius: 50%;
    animation: aeg-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.5rem;
}

@keyframes aeg-spin { to { transform: rotate(360deg); } }

/* Footer hint bar */
.search-overlay__footer {
    padding: 0.625rem 1.25rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.search-overlay__footer span {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.search-overlay__footer kbd {
    display: inline-block;
    padding: 0.1em 0.45em;
    font-size: 0.6875rem;
    font-family: inherit;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    color: var(--color-text);
}

/* ——————————————————————————————
   Hamburger
   —————————————————————————————— */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: end;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.18s ease;
    flex-shrink: 0;
}

.menu-toggle:hover { background: var(--color-bg); }

.menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--color-muted);
    border-radius: 2px;
    transform-origin: center;
    transition: transform 0.25s ease, opacity 0.2s ease, background 0.18s ease;
}

.menu-toggle:hover span { background: var(--color-dark); }

/* Animate to × when menu is open */
body.menu-open .menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.menu-open .menu-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0); }
body.menu-open .menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ——————————————————————————————
   Page overlay (mobile menu)
   —————————————————————————————— */
.menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--color-dark);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s;
}

body.menu-open .menu-overlay {
    display: block;
    opacity: 0.5;
}

/* ——————————————————————————————
   Mobile drawer
   —————————————————————————————— */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    background: var(--color-white);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

.mobile-menu.is-open { transform: translateX(0); }

/* Drawer header */
.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.mobile-menu-site-name {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--color-dark);
}

.menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--color-text);
    flex-shrink: 0;
    transition: background 0.15s;
}

.menu-close:hover { background: var(--color-bg); }

/* Drawer nav */
.mobile-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.mobile-nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-nav-menu .menu-item { position: relative; }

.mobile-nav-menu > .menu-item > a {
    display: block;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.mobile-nav-menu > .menu-item > a:hover,
.mobile-nav-menu > .current-menu-item > a {
    color: var(--color-dark);
    background: var(--color-bg);
    border-left-color: var(--color-dark);
}

/* Submenu toggle */
.submenu-toggle {
    position: absolute;
    right: 1rem;
    top: 0.5rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.125rem;
    color: var(--color-muted);
    transition: background 0.15s;
}

.submenu-toggle:hover { background: var(--color-bg); }

.mobile-nav-menu .sub-menu {
    display: none;
    list-style: none;
    padding: 0.25rem 0 0.5rem;
    background: var(--color-bg);
}

.mobile-nav-menu .menu-item-has-children.is-open > .sub-menu { display: block; }

.mobile-nav-menu .sub-menu a {
    display: block;
    padding: 0.6rem 1.5rem 0.6rem 2.75rem;
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--color-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.mobile-nav-menu .sub-menu a:hover { color: var(--color-dark); }

/* ——————————————————————————————
   Responsive
   —————————————————————————————— */
@media (max-width: 1023px) {
    .nav-primary    { display: none; }
    .menu-toggle    { display: flex; }
    .header-actions { margin-left: auto; }
    .header-inner   { gap: 0; }
}

@media (max-width: 639px) {
    .search-overlay        { padding-top: 4rem; align-items: flex-start; }
    .search-overlay__modal { width: calc(100% - 2rem); border-radius: 12px; }
    .header-search-btn     { width: 48px; height: 48px; }
    .menu-toggle           { width: 48px; height: 48px; }
    .menu-toggle span      { width: 20px; }
    .header-actions        { gap: 0; margin-left: auto; }
}
