/* Shared top bar for every page. Generated markup comes from scripts/sync_nav.py.
   Colors come from each page's own :root variables, so the bar picks up the
   page's accent color; the fallbacks are the site defaults. */

.site-nav {
    position: sticky;
    top: 0.5rem;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0.45rem 0.5rem 0.45rem 1rem;
    background: rgba(19, 26, 46, 0.86);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border, #283560);
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
}

.site-nav a { text-decoration: none; }

.sn-brand {
    font-weight: 800;
    font-size: 1.02rem;
    letter-spacing: 0.01em;
    color: var(--text-primary, #e8eaf6);
    white-space: nowrap;
    padding: 0.35rem 0;
}
.sn-brand:hover { color: var(--accent, #64ffda); }

.sn-menus { display: flex; align-items: center; gap: 0.4rem; }

/* Menu buttons are outlined pills in the page's accent color, so they read
   as buttons rather than plain text. */
.sn-menu > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    padding: 0.42rem 0.75rem 0.42rem 0.85rem;
    border: 1px solid var(--border, #283560);
    border-color: color-mix(in srgb, var(--accent, #64ffda) 45%, transparent);
    border-radius: 999px;
    color: var(--text-primary, #e8eaf6);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sn-count {
    display: inline-block;
    min-width: 1.45em;
    margin-left: 0.4em;
    padding: 0.05em 0.4em;
    border-radius: 999px;
    background: var(--accent, #64ffda);
    color: var(--bg-primary, #0a0e1a);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.5;
    text-align: center;
}
.sn-menu > summary::-webkit-details-marker { display: none; }
.sn-menu > summary::after {
    content: '';
    display: inline-block;
    width: 0.4em;
    height: 0.4em;
    margin-left: 0.45em;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-0.2em) rotate(45deg);
    transition: transform 0.15s ease;
}
.sn-menu[open] > summary::after { transform: translateY(0.05em) rotate(225deg); }
.sn-menu > summary:hover,
.sn-menu[open] > summary {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--accent, #64ffda);
}
.sn-menu > summary.sn-current { color: var(--accent, #64ffda); }
.sn-menu > summary:focus-visible,
.sn-search:focus-visible,
.sn-brand:focus-visible,
.sn-panel a:focus-visible { outline: 2px solid var(--accent, #64ffda); outline-offset: 2px; }

.sn-search {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 9px;
    font-size: 1rem;
}
.sn-search:hover { background: rgba(255, 255, 255, 0.06); }

/* The panel spans the whole bar, so it lines up on every page width. */
.sn-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.5rem);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 0.5rem 1.25rem;
    padding: 1rem 1.1rem 1.1rem;
    background: var(--bg-secondary, #131a2e);
    border: 1px solid var(--border, #283560);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    animation: sn-drop 0.14s ease-out;
}
@keyframes sn-drop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}

.sn-heading {
    margin: 0 0 0.3rem;
    padding: 0 0.55rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted, #8892cc);
}

.sn-group { display: flex; flex-direction: column; }
.sn-panel a {
    display: block;
    padding: 0.38rem 0.55rem;
    border-radius: 8px;
    color: var(--text-secondary, #9fa8da);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.12s ease, color 0.12s ease;
}
.sn-panel a:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-primary, #e8eaf6); }
.sn-panel a.active { color: var(--accent, #64ffda); background: rgba(255, 255, 255, 0.05); font-weight: 600; }

@media (max-width: 640px) {
    .site-nav { padding: 0.35rem 0.35rem 0.35rem 0.75rem; gap: 0.25rem; top: 0.35rem; margin-bottom: 1.5rem; }
    .sn-brand { font-size: 0.92rem; }
    .sn-menus { gap: 0.3rem; }
    .sn-menu > summary { padding: 0.36rem 0.5rem 0.36rem 0.6rem; font-size: 0.82rem; }
    .sn-menu > summary::after { margin-left: 0.3em; }
    .sn-count { margin-left: 0.3em; font-size: 0.66rem; }
    .sn-search { width: 2.1rem; height: 2.1rem; }
    .sn-panel { grid-template-columns: 1fr 1fr; gap: 0.25rem 0.5rem; padding: 0.85rem 0.6rem; }
    .sn-panel a { font-size: 0.85rem; padding: 0.4rem 0.45rem; white-space: normal; }
    .sn-panel .sn-group { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; column-gap: 0.5rem; }
    .sn-panel .sn-heading { grid-column: 1 / -1; margin-top: 0.4rem; }
}

/* Narrow phones: trim the logo, never the menus, so the bar stays on one
   line: "funfacts.space", then "funfacts", then just the planet icon. */
@media (max-width: 480px) {
    .sn-brand .sn-tld { display: none; }
}
@media (max-width: 400px) {
    .sn-brand .sn-name { display: none; }
    .sn-brand { font-size: 1.15rem; }
}
@media (max-width: 350px) {
    .sn-menu > summary::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sn-panel { animation: none; }
    .sn-menu > summary::after { transition: none; }
}
