:root {
    --nav-width: 26rem;
    --header-height: 4.5rem;
}

header {
    height: var(--header-height);
    background-color: rgba(17, 17, 16, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    gap: 1rem;
}

.logo-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 2.25rem;
}

#site-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    transition: color var(--transition);
}

#site-logo:hover .logo-text {
    color: var(--accent);
}

.header-nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color var(--transition);
    position: relative;
    padding: 0.375rem 0;
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform var(--transition);
}

.nav-link.active::after {
    transform: scaleX(1);
}

header nav {
    position: relative;
    width: var(--nav-width);
    flex-shrink: 0;
}

.search-wrapper {
    position: relative;
}

.searchBar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    width: 1.05rem;
    height: 1.05rem;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

#searchQueryInput {
    width: 100%;
    height: 2.5rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 1.25rem 0 2.625rem;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

#searchQueryInput::placeholder {
    color: var(--text-dim);
}

#searchQueryInput:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

#navBarContainer {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 20rem;
    overflow-y: auto;
    overflow-x: hidden;
}

#navBarContainer::-webkit-scrollbar {
    width: 4px;
}

#navBarContainer::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

#keywords_list {
    padding: 0.375rem;
}

.keyword_suggestion {
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.keyword_suggestion a {
    display: block;
    padding: 0.6rem 0.875rem;
    font-size: 0.9rem;
    color: var(--text);
    text-decoration: none;
    transition: color var(--transition);
}

.keyword_suggestion:hover {
    background: var(--accent-dim);
}

.keyword_suggestion:hover a {
    color: var(--accent-hover);
}

/* ── Theme toggle pill ────────────────────────────── */

/*
  Pill contains two icon slots (☀ left, 🌙 right).
  A ::before circle slides under the active icon.
  Light mode → sun slot lit   Dark mode → moon slot lit
*/
.theme-toggle {
    position: relative;
    display: grid;
    grid-template-columns: 2rem 2rem;
    align-items: center;
    padding: 0.25rem;
    width: 4.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    background: var(--surface-2);
    border: 1px solid var(--border-accent);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color var(--transition);
}

/* Sliding accent circle behind the active icon */
.theme-toggle::before {
    content: '';
    position: absolute;
    width: 2rem;
    height: 2rem;
    top: 0.25rem;
    left: 0.25rem;
    background: var(--accent);
    border-radius: 50%;
    transition: transform 0.25s ease;
    z-index: 0;
}

/* Dark mode: slide circle to moon slot (second column) */
[data-theme="dark"] .theme-toggle::before {
    transform: translateX(2rem);
}

.icon-sun,
.icon-moon {
    width: 1rem;
    height: 1rem;
    justify-self: center;
    position: relative;
    z-index: 1;
    pointer-events: none;
    transition: color 0.2s ease;
}

/* Light mode: sun is active (on circle) — use bg for contrast on accent */
[data-theme="light"] .icon-sun  { color: var(--bg); }
[data-theme="light"] .icon-moon { color: var(--text-dim); }

/* Dark mode: moon is active (on circle) — use bg for contrast on accent */
[data-theme="dark"]  .icon-moon { color: var(--bg); }
[data-theme="dark"]  .icon-sun  { color: var(--text-dim); }

@media (max-width: 640px) {
    header {
        padding: 0 1.25rem;
    }

    header nav {
        width: auto;
        flex: 1;
    }
}
