/* Shell behavior only. Canonical shell visuals live in design-system.css. */
:root {
    --hq-shell-header-height: 4.125rem;
    --site-header-clearance: clamp(5.25rem, 4.5rem + 1.5vw, 6.75rem);
    --hq-shell-overlay: rgba(9, 9, 11, 0.5);
    --hq-shell-content-start: 6.5rem;
    --hq-shell-gutter: 1rem;
    --hq-page-start: var(--site-header-clearance, 4.5rem);
}

.hq-page-start--catalog { --hq-page-start: clamp(6.75rem, 5.5rem + 2vw, 8rem); }

html { max-width: 100%; overflow-x: clip; }
body { position: relative; max-width: 100%; overflow-x: clip; }
body.hq-overlay-open { overflow: hidden; }

/* One shell-clearance token for active templates. Hero padding remains owned
 * by each template; this only positions its outer page canvas. */
main#main-content.hq-page-start { padding-block-start: var(--hq-page-start); }
main#main-content.hq-page-start--authority { padding-block-start: var(--site-header-clearance); }
main#main-content { padding-block-end: clamp(2.5rem, 2rem + 1.5vw, 4rem); }
main#main-content.hq-page-start > [id^="template-"],
main#main-content.hq-page-start--authority > [id^="template-"] { border-bottom-width: 0; }

/* The fixed header owns one predictable clearance. Templates may keep their
 * section rhythm, but cannot add a second page-top offset on the shell edge. */
#hq-content-shell {
    width: 100%;
    padding-block-start: var(--hq-shell-content-start);
}
#hq-content-shell > :first-child {
    padding-block-start: 0;
    padding-block-end: 0;
}

/* Footer spacing belongs to page content, not the shared shell. This wrapper
 * only supplies the same responsive gutter as the main page canvas. */
.hq-shell-footer-wrap {
    box-sizing: border-box;
    width: calc(100% - 1rem);
    max-width: 1600px;
    margin-block-start: 0;
    margin-inline: auto;
    padding-block: 0 1rem;
}

.site-footer { border-radius: 2rem; }

/* Build and Wishlist live in the working drawer below the desktop handoff. */
.hq-site-nav__desktop-action { display: none; }

/* Keep final shell ownership over the earlier generic glass primitive. */
#hq-main-nav[class~="hq-site-nav"] {
    position: fixed;
    border-color: rgba(228, 228, 231, .5);
    box-shadow: 0 8px 30px rgba(16, 185, 129, .08);
}
html.dark #hq-main-nav[class~="hq-site-nav"] {
    border-color: rgba(255, 255, 255, .1);
    color: rgb(244, 244, 245);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .15);
}

/* Tailwind's unlayered form reset outranks the layered canonical bundle.
 * Reassert the reference header controls here, in the same unlayered cascade. */
.hq-brand { border-radius: 1.5rem; }
#search-toggle,
#hq-acct-trigger {
    gap: .25rem;
    padding: .625rem;
    border-radius: 9999px;
    background: #f4f4f5;
}
html.dark #search-toggle,
html.dark #hq-acct-trigger { background: rgba(255, 255, 255, .05); }
#mega-menu-trigger {
    min-width: 7.375rem;
    gap: .5rem;
    padding: .625rem 1rem;
    border-radius: 1.5rem;
    background: rgba(244, 244, 245, .8);
    border: 1px solid rgba(228, 228, 231, .5);
    font: 700 .75rem/1rem var(--hq-font-display);
    letter-spacing: .05em;
}
html.dark #mega-menu-trigger { border-color: rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .05); color: rgb(212, 212, 216); }
#hq-header-btt {
    position: relative;
    top: -4px;
    gap: .375rem;
    padding: 0 .75rem 0 .625rem;
    border: 1px solid rgba(228, 228, 231, .7);
    background: rgba(244, 244, 245, .7);
    color: #52525b;
}
#hq-header-btt span { font-weight: 600; }
#hq-header-btt svg { width: 14px; height: 14px; }
#hq-header-btt.hq-btt-pill--visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
html.dark #hq-header-btt {
    border-color: rgba(255, 255, 255, .1);
    background: rgba(255, 255, 255, .05);
    color: #d4d4d8;
}

.hq-footer-actions {
    display: grid;
    gap: .5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.hq-footer-actions a {
    display: flex;
    min-height: 44px;
    align-items: center;
    padding: .65rem .85rem;
    border: 1px solid rgba(161, 161, 170, .35);
    border-radius: .75rem;
    color: #3f3f46;
    font-size: .875rem;
    font-weight: 700;
    text-decoration: none;
}
.hq-footer-actions a:hover,
.hq-footer-actions a:focus-visible {
    border-color: var(--theme-500, #10b981);
    color: var(--theme-700, #047857);
}
.hq-footer-actions a:focus-visible {
    outline: 2px solid var(--theme-500, #10b981);
    outline-offset: 2px;
}
html.dark .hq-footer-actions a { color: #d4d4d8; }
html.dark .hq-footer-actions a:hover,
html.dark .hq-footer-actions a:focus-visible { color: var(--theme-300, #6ee7b7); }

#mega-menu-container { position: relative; }
#mega-menu-dropdown,
.hq-index-menu,
#hq-acct-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, 1rem) scale(.98);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform .3s ease, opacity .3s ease, visibility .3s ease;
}
#hq-acct-menu {
    left: auto;
    right: 0;
    transform: translateY(1rem) scale(.98);
}
#mega-menu-dropdown[data-state="open"],
.hq-index-menu[data-state="open"] {
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    transform: translate(-50%, 0) scale(1) !important;
}
#hq-acct-menu[data-state="open"] {
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
}
#mega-menu-dropdown,
.hq-index-menu {
    width: min(44rem, calc(100vw - 2rem));
    max-height: none;
    overflow: visible;
    border-radius: 1.5rem !important;
    z-index: 50;
}
#mega-menu-dropdown .hq-shell-category-scroll {
    max-height: calc(100dvh - 8rem);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.5rem 1.75rem;
    border-radius: 1.5rem;
}
.hq-index-menu__grid { display: block; column-count: 2;
    column-gap: 2.5rem;
    column-fill: balance;
}
@media (max-width: 639px) { .hq-index-menu__grid { column-count: 1; column-gap: 0; } }
.hq-index-menu__group {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 1.5rem;
}
.hq-index-menu__hub {
    display: flex;
    align-items: center;
    gap: .625rem;
    margin-bottom: .5rem;
    padding-bottom: .35rem;
    border-bottom: 1px solid rgba(161, 161, 170, .2);
    font-size: .8125rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #10b981;
}
.hq-index-menu__hub svg { width: 1.125rem; height: 1.125rem; flex: 0 0 1.125rem; fill: none; stroke: currentColor; }
.hq-shell-category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 32px;
    padding: .35rem .5rem;
    border-radius: .5rem;
    font-size: .875rem;
    font-weight: 600;
    color: #3f3f46;
    text-decoration: none;
    transition: all .15s ease;
}
html.dark .hq-shell-category-link { color: #d4d4d8; }
.hq-shell-category-link:hover {
    color: #059669;
    background: rgba(16, 185, 129, .08);
}
html.dark .hq-shell-category-link:hover {
    color: #34d399;
    background: rgba(16, 185, 129, .15);
}
.hq-shell-category-link svg {
    width: 1rem;
    height: 1rem;
    margin-right: .5rem;
    flex-shrink: 0;
    opacity: .7;
}
.hq-shell-category-count {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: .75rem;
    color: #a1a1aa;
    margin-left: auto;
}
.hq-index-menu__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .625rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(161, 161, 170, .2);
}
.hq-index-menu__footer a { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: .625rem 1.25rem; border-radius: .75rem; background: rgba(244,244,245,.8); color: #27272a; text-decoration: none; font-weight: 700; font-size: .875rem; }
.hq-index-menu__footer .hq-index-menu__footer-primary { background: #18181b; color: #fff; }
html.dark .hq-index-menu__footer a { background: rgba(255,255,255,.1); color: #e4e4e7; }
html.dark .hq-index-menu__footer .hq-index-menu__footer-primary { background: #10b981; color: #09090b; }
.hq-mobile-category-label { overflow-wrap: anywhere; }

.hq-mobile-menu,
.hq-search-dialog,
#mobile-menu,
#search-modal {
    position: fixed !important;
    inset: 0 !important;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    z-index: 60;
}
.hq-mobile-menu,
#mobile-menu {
    transform: translateX(100%);
    transition: transform .45s cubic-bezier(0.25, 1, 0.5, 1), opacity .25s ease;
}
.hq-search-dialog,
#search-modal {
    z-index: 70;
    background: rgba(0, 0, 0, 0.65) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}
.hq-mobile-menu[data-state="open"],
.hq-search-dialog[data-state="open"],
#mobile-menu[data-state="open"],
#search-modal[data-state="open"] {
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
}
.hq-mobile-menu[data-state="open"],
#mobile-menu[data-state="open"] {
    transform: translateX(0) !important;
    pointer-events: auto !important;
}
#search-modal-content {
    background: rgba(255, 255, 255, 0.98) !important;
    color: #18181b !important;
    border: 1px solid rgba(228, 228, 231, 0.9) !important;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.35) !important;
    border-radius: 1.5rem !important;
}
html.dark #search-modal-content {
    background: rgba(12, 16, 14, 0.98) !important;
    color: #fafafa !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7) !important;
}
#search-modal[data-state="open"] #search-modal-content {
    transform: scale(1) !important;
}
.hq-search-dialog input[type="search"],
.hq-search-dialog__field input[type="search"] {
    min-height: 52px;
    box-sizing: border-box;
    padding-left: 3.25rem !important;
    -webkit-appearance: none;
}
.hq-search-dialog__field input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    display: none;
}

#search-modal[data-search-state="loading"] #hq-search-spinner {
    display: flex !important;
}
#search-modal[data-search-state="loading"] #hq-live-search-results,
#search-modal[data-search-state="results"] #hq-live-search-results,
#search-modal[data-search-state="empty"] #hq-live-search-results,
#search-modal[data-search-state="error"] #hq-live-search-results {
    display: block !important;
}
#search-modal[data-search-state="loading"] #hq-search-trending,
#search-modal[data-search-state="results"] #hq-search-trending,
#search-modal[data-search-state="empty"] #hq-search-trending,
#search-modal[data-search-state="error"] #hq-search-trending {
    display: none !important;
}
#search-modal[data-search-state="idle"] #hq-live-search-results { display: none !important; }
#search-modal[data-search-state="idle"] #hq-search-trending { display: block !important; }

/* Compare results are a live region whose text must remain readable in dark mode. */
html.dark .hq-compare #compare-search-results {
    background: rgba(6, 12, 10, .98);
    color: rgb(250, 250, 250);
}

.hq-shell-count-badge[hidden] { display: none !important; }
.hq-shell-count-badge:not([hidden]) { display: flex; }
.hq-mobile-menu__auth { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; padding-top: 1rem; border-top: 1px solid rgba(161,161,170,.3); }
.hq-mobile-menu__auth a, .hq-mobile-menu__auth button { display: flex; min-height: 48px; align-items: center; justify-content: center; gap: .5rem; padding: .6rem .8rem; border: 1px solid rgba(4,120,87,.4); border-radius: .75rem; background: transparent; color: #065f46; font-weight: 700; text-align: center; text-decoration: none; }
.hq-mobile-menu__auth button { grid-column: 1 / -1; }
.hq-mobile-menu__auth button svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.hq-mobile-menu__auth .hq-mobile-menu__signup { border: 0; background: #18181b; color: #fff; }
html.dark .hq-mobile-menu__auth a, html.dark .hq-mobile-menu__auth button { color: #6ee7b7; }
html.dark .hq-mobile-menu__auth .hq-mobile-menu__signup { background: #10b981; color: #09090b; }

@media (max-width: 767px) {
    #search-modal { min-height: 100dvh; }
    #search-modal-content { max-height: calc(100dvh - 1.5rem); }
    .hq-shell-category-link { min-height: 3rem; }
}

@media (min-width: 768px) {
    :root {
        --hq-shell-content-start: 7.5rem;
        --hq-shell-gutter: 1rem;
    }
    body.admin-bar { --hq-shell-content-start: 9.5rem; }
    .hq-shell-footer-wrap { width: calc(100% - 2rem); padding-bottom: 1.5rem; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hq-site-nav__inner { padding-inline: 2rem; }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    .hq-site-nav__inner { padding-inline: 2.5rem; }
}

@media (max-width: 1279px) {
    #mobile-menu-toggle {
        gap: normal;
        padding: .5rem;
        border-radius: 0;
        background: transparent;
    }
    #mobile-menu-toggle svg { width: 28px; height: 28px; }
    html.dark #mobile-menu-toggle { background: transparent; }
}

@media (min-width: 640px) {
    .site-footer { border-radius: 1.5rem; }
}

@media (min-width: 1280px) {
    .hq-site-nav__inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        gap: 1.25rem;
        padding-inline: 2.5rem;
    }
    .hq-site-nav__desktop {
        display: flex;
        height: 100%;
        align-items: center;
        justify-content: center;
        gap: .5rem;
    }
    .hq-mobile-menu-toggle,
    #mobile-menu-toggle {
        display: none !important;
    }
    .hq-site-nav__desktop-action { display: inline-flex; }
    #hq-acct-trigger { min-width: 56px; }
}

@media (min-width: 1280px) and (max-height: 700px) {
    #mega-menu-dropdown .hq-shell-category-scroll {
        max-height: calc(100dvh - 7rem);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (prefers-reduced-motion: reduce) {
    #mobile-menu,
    #search-modal,
    #search-modal-content,
    #mega-menu-dropdown,
    #hq-acct-menu {
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Megamenu Opacity Fix */
.dark #mega-menu-dropdown .hq-surface--nav,
.dark .hq-index-menu .hq-surface--nav,
.dark #hq-acct-menu .hq-surface--nav {
    background: rgba(6, 12, 10, 0.97) !important;
    backdrop-filter: blur(36px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(36px) saturate(200%) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 30px 70px -15px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}
#mega-menu-dropdown .hq-surface--nav,
.hq-index-menu .hq-surface--nav,
#hq-acct-menu .hq-surface--nav {
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(36px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(36px) saturate(200%) !important;
    border: 1px solid rgba(228, 228, 231, 0.9) !important;
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.15) !important;
}

/* MEGA-MENU HIGH-OPACITY SOLID & POLISH */
#mega-menu-dropdown {
    background: #ffffff !important;
    border-radius: 1.5rem !important;
}
html.dark #mega-menu-dropdown,
.dark #mega-menu-dropdown {
    background: #060c0a !important;
}
#mega-menu-dropdown .hq-surface--nav,
#mega-menu-dropdown .hq-shell-category-scroll {
    background: #ffffff !important;
    border: 1px solid rgba(228, 228, 231, 0.95) !important;
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.25) !important;
}
html.dark #mega-menu-dropdown .hq-surface--nav,
html.dark #mega-menu-dropdown .hq-shell-category-scroll,
.dark #mega-menu-dropdown .hq-surface--nav,
.dark #mega-menu-dropdown .hq-shell-category-scroll {
    background: #060c0a !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.28) !important;
    box-shadow: 0 30px 80px -15px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}

/* MOBILE MENU SOLID CANVAS & HIGH CONTRAST */
.hq-mobile-menu__panel {
    background: #ffffff !important;
}
html.dark .hq-mobile-menu__panel,
.dark .hq-mobile-menu__panel {
    background: #060c0a !important;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}
html.dark .hq-mobile-menu__categories > a,
.dark .hq-mobile-menu__categories > a {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    color: #f4f4f5 !important;
}
html.dark .hq-mobile-menu__categories > a:hover,
.dark .hq-mobile-menu__categories > a:hover {
    background: rgba(16, 185, 129, 0.1) !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    color: #34d399 !important;
}
html.dark .hq-mobile-menu__links a,
.dark .hq-mobile-menu__links a {
    color: #d4d4d8 !important;
}
html.dark .hq-mobile-menu__links a:hover,
.dark .hq-mobile-menu__links a:hover {
    color: #34d399 !important;
}
html.dark .hq-mobile-menu__top button,
.dark .hq-mobile-menu__top button {
    color: #e4e4e7 !important;
}

/* Clean bottom of templates: remove legacy heavy border-b-8 divider on templates */
#template-homepage,
[id^="template-"] {
    border-bottom: 0 !important;
    border-bottom-width: 0 !important;
    margin-bottom: 0 !important;
}
