/* ==========================================================================
   Site chrome: fixed top bar + left sidebar (YouTube-style)
   Layout tokens (--topbar-h, --sidebar-full, --sidebar-rail) live in mysite.css
   ========================================================================== */

/* ------------------------------ Top bar --------------------------------- */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    z-index: 40;
    box-sizing: border-box;
    color: #fff;
    padding: 0 clamp(0.6rem, 2vw, 1.1rem);
    background:
        radial-gradient(120% 160% at 50% 0%, rgba(253, 216, 53, 0.18), transparent 55%),
        linear-gradient(90deg, #000 0%, var(--myred) 50%, #000 100%);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}

.topbar-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
    align-items: center;
    gap: 0.6rem;
    height: 100%;
    font-size: clamp(0.95rem, 1vw, 1.05rem);
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    justify-self: start;
    min-width: 0;
    overflow: hidden;
}

.site-title {
    color: var(--myyellow);
    text-decoration: none;
    font-size: clamp(1rem, 1.6vw, 1.45rem);
    line-height: 1.1;
    white-space: nowrap;
    display: inline-block;
}

.site-title:hover {
    text-decoration: none;
}

.site-title-short {
    display: none;
}

.site-title-full {
    display: inline;
}

/* Hamburger: toggles the rail on desktop, the drawer on mobile */
.nav-toggle {
    display: inline-flex;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.28);
    cursor: pointer;
    padding: 9px 8px;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 999px;
    background: #fff;
}

/* -------------------------- Search (top bar) ---------------------------- */
.top-search {
    justify-self: center;
    width: 100%;
    max-width: 640px;
}

.search-form form {
    display: flex;
    align-items: center;
    gap: 0;
}

.search-input-shell {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    min-width: 120px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    padding: 0.3rem 0.3rem 0.3rem 0.45rem;
    background: rgba(255, 255, 255, 0.95);
}

.search-scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.22);
    background: rgba(128, 0, 0, 0.08);
    color: #3a0000;
    padding: 0.18rem 0.3rem 0.18rem 0.5rem;
    white-space: nowrap;
}

.search-scope-chip-label {
    font-size: 0.84rem;
    line-height: 1;
    font-weight: 600;
}

.search-scope-chip-clear {
    width: 1.1rem;
    height: 1.1rem;
    border: none;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    color: #2a0000;
    font-size: 0.92rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.search-scope-chip-clear:hover {
    background: rgba(0, 0, 0, 0.16);
}

.search-scope-chip.is-hidden {
    display: none;
}

.search-form input[type="text"] {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    border-radius: 0;
    padding: 0.18rem 0.12rem;
    background: transparent;
}

.search-form input[type="text"]:focus {
    outline: none;
}

.search-submit {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #555;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
}

.search-submit:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #1a1a1a;
}

/* -------------------------- Header actions ------------------------------ */
.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 40px;
    justify-self: end;
}

.header-actions .nav-link,
.login-link {
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.header-actions .nav-link:hover,
.login-link:hover {
    color: var(--myyellow);
}

.profile-menu {
    position: relative;
}

.profile-toggle {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    min-width: 210px;
    padding: 0.45rem;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 50;
}

.profile-dropdown.is-open {
    display: grid;
    gap: 0.2rem;
}

.profile-username {
    color: #555;
    font-size: 0.86rem;
    padding: 0.28rem 0.5rem;
}

.profile-link {
    color: #1f1f1f;
    text-decoration: none;
    border-radius: 7px;
    padding: 0.42rem 0.5rem;
}

.profile-link:hover {
    background: rgba(128, 0, 0, 0.1);
    text-decoration: none;
}

.profile-link-button {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

/* ------------------------------ Sidebar --------------------------------- */
.site-sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-full);
    z-index: 30;
    box-sizing: border-box;
    background: var(--mybackground);
    border-right: 1px solid var(--myborder);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.75rem 0.6rem;
    transition: width 0.18s ease, transform 0.22s ease;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.6rem 0.7rem;
    border-radius: 10px;
    color: var(--mydarkgray);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
    background: rgba(128, 0, 0, 0.08);
    text-decoration: none;
}

.sidebar-link.is-active {
    background: rgba(128, 0, 0, 0.12);
    color: var(--myred);
    font-weight: 600;
}

.sidebar-icon {
    flex-shrink: 0;
    width: 1.6rem;
    text-align: center;
    font-size: 1.2rem;
    line-height: 1;
}

.sidebar-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Collapsed icon rail (desktop) */
.sidebar-collapsed .site-sidebar {
    width: var(--sidebar-rail);
}

.sidebar-collapsed .sidebar-link {
    justify-content: center;
    gap: 0;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.sidebar-collapsed .sidebar-label {
    display: none;
}

/* Mobile drawer backdrop */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 44;
    border: 0;
}

.sidebar-backdrop[hidden] {
    display: none;
}

/* ------------------------------ Misc ------------------------------------ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.topbar a:focus-visible,
.topbar button:focus-visible,
.topbar input:focus-visible {
    outline: 2px solid var(--myyellow);
    outline-offset: 2px;
}

/* ------------------------------ Responsive ------------------------------ */
@media (max-width: 900px) {
    .topbar-nav {
        display: flex;
        gap: 0.45rem;
    }

    .top-search {
        flex: 1 1 0;
        min-width: 0;
        order: 2;
    }

    .header-actions {
        order: 3;
        flex-shrink: 0;
    }

    .site-title-full {
        display: none;
    }

    .site-title-short {
        display: inline;
        font-size: 1.25rem;
        font-weight: 700;
    }

    /* Sidebar becomes an off-canvas drawer that overlays the content */
    .site-sidebar {
        top: 0;
        width: min(80vw, var(--sidebar-full));
        padding-top: calc(var(--topbar-h) + 0.5rem);
        z-index: 45;
        transform: translateX(-100%);
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    }

    .site-sidebar.drawer-open {
        transform: translateX(0);
    }

    /* Ignore the desktop rail collapse while in drawer mode */
    .sidebar-collapsed .site-sidebar {
        width: min(80vw, var(--sidebar-full));
    }

    .sidebar-collapsed .sidebar-link {
        justify-content: flex-start;
        gap: 0.85rem;
        padding-left: 0.7rem;
        padding-right: 0.7rem;
    }

    .sidebar-collapsed .sidebar-label {
        display: block;
    }
}
