/* Спільний хедер Code Bloom (підключається після CSS сторінки) */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    width: 100%;
    height: 76px;
    padding: 0 32px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.62);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
    border-bottom: 1px solid rgba(42, 143, 255, 0.22);
    box-shadow: 0 1px 24px -6px rgba(42, 143, 255, 0.35);
}

.header .left_part,
.header .middle_part,
.header .right_part {
    flex: none;
    height: auto;
    background: transparent;
}

.header .left_part { justify-content: flex-start; }

.header .logo_div { padding-left: 0; }

.header .logo_div a {
    gap: 10px;
    transition: opacity 0.25s, transform 0.25s;
}

.header .logo_div a:hover { opacity: 0.85; }
.header .logo_div a:active { transform: scale(0.98); }

.header .logo_img { height: 34px; width: auto; }
.header .logo_img + .logo_img { height: 26px; }

/* Навігація: ненав'язливі пігулки */
.header .middle_part {
    gap: 4px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
}

.header .header_link {
    padding: 8px 18px;
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    transition: color 0.25s, background 0.25s;
}

.header .header_link::after { display: none; }

.header .header_link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.header .header_link[aria-current="page"] {
    color: #fff;
    background: rgb(42, 143, 255);
    box-shadow: 0 6px 18px -6px rgba(42, 143, 255, 0.8);
}

/* Права частина */
.header .right_part {
    justify-content: flex-end;
    gap: 12px;
}

.header .search_input {
    width: 220px;
    max-width: 100%;
    height: 38px;
    padding: 0 16px 0 40px;
    box-sizing: border-box;
    font: inherit;
    font-size: 15px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E")
        no-repeat 14px center / 16px;
    border: 1px solid transparent;
    border-radius: 999px;
    outline: none;
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.header .search_input::placeholder { color: #8e8e93; }

.header .search_input:focus {
    width: 280px;
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgb(42, 143, 255);
    box-shadow: 0 0 0 4px rgba(42, 143, 255, 0.22);
}

.header .avatar_link { display: flex; border-radius: 50%; }

.header .avatar_link img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
    transition: box-shadow 0.25s;
}

.header .avatar_link:hover img { box-shadow: 0 0 0 2px rgb(42, 143, 255); }

.header .theme_switch {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    margin: 0;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    transition: background 0.25s, transform 0.25s;
}

.header .theme_switch:hover { background: rgba(42, 143, 255, 0.5); }
.header .theme_switch:active { transform: scale(0.92); }

.header a:focus-visible,
.header button:focus-visible {
    outline: 2px solid rgb(42, 143, 255);
    outline-offset: 3px;
}

@media (max-width: 1000px) {
    .header { padding: 0 16px; gap: 12px; }
    .header .search_input,
    .header .search_input:focus { width: 150px; }
    .header .header_link { padding: 8px 12px; font-size: 15px; }
}

@media (max-width: 760px) {
    .header { grid-template-columns: auto 1fr; height: 64px; }
    .header .logo_img + .logo_img,
    .header .search_input { display: none; }
    .header .middle_part { justify-self: end; }
    .header .right_part { display: none; }
    .header .header_link { padding: 6px 10px; font-size: 14px; }
}

/* ---------- Стан входу ---------- */
html:not(.logged-in) .user-only { display: none !important; }
html.logged-in .guest-only { display: none !important; }

.header .logout {
    height: 38px;
    padding: 0 16px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.header .logout:hover { color: #fff; background: rgba(255, 69, 58, 0.55); }

@media (max-width: 1000px) { .header .logout { padding: 0 12px; } }
