/* base */
.brand {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: 12px;
    width: fit-content;
    font-weight: var(--bold-weight);
    text-decoration: none;
}

.brand__mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    aspect-ratio: 1;
    border-radius: 50%;
    color: var(--lavanda);
    background: var(--zatmenie);
    font-family: var(--font);
    font-size: var(--normal-text);
    font-style: italic;
}

/* home */
.home-header {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 84px;
    padding: 16px clamp(20px, 5vw, 72px);
    border-bottom: 0.0625rem solid var(--lines);
    background: var(--paper);
}

.home-header__nav,
.home-header__nav form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

/* index */
.site-header {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: 0.5fr 1fr auto 1.5fr;
    align-items: center;
    min-height: 84px;
    padding: 16px clamp(20px, 5vw, 72px);
    border-bottom: 0.0625rem solid var(--lines);
    background: var(--paper);
    gap: 12px;
    /*backdrop-filter: blur(16px);*/
}

.header-categories {
    position: relative;
    justify-self: start;
    width: fit-content;
}

/* Мост */
.header-categories::after {
    position: absolute;
    top: 100%;
    left: 0;
    width: stretch;
    height: 12px;
    content: "";
}

.header-categories-container {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 240px;
    min-width: 172px;
    min-height: 48px;
    padding: 0 20px;
    border: 0.0625rem solid var(--lines);
    border-radius: var(--extra-border-radius);
    color: var(--font-on-light-bgc);
    background: var(--surface);
    box-shadow: 0 8px 24px var(--lines);
    font-family: var(--font);
    font-size: var(--medium-text);
    cursor: pointer;
    transition: color var(--motion-quick) var(--ease-out-strong),
    background-color var(--motion-quick) var(--ease-out-strong),
    border-color var(--motion-quick) var(--ease-out-strong),
    transform var(--motion-quick) var(--ease-out-strong);
}

.header-categories-main-button {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-categories__chevron {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
    transition: transform var(--motion-standard) var(--ease-out-strong);
}

.header-categories.is-open .header-categories-container {
    border-color: var(--lavanda);
    background: var(--light-lavanda);
}

.header-categories.is-open .header-categories__chevron {
    transform: rotate(180deg);
}

.header-categories-block {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    z-index: 20;
    width: min(640px, 84vw);
    /*max-height: 384px;*/
    /*overflow-y: auto;*/
    padding: 16px;
    border: 0.0625rem solid var(--lines);
    border-radius: var(--normal-border-radius);
    visibility: hidden;
    opacity: 0;
    background: var(--surface);
    box-shadow: var(--shadow);
    pointer-events: none;
    transform: translateY(-8px) scale(0.98);
    /*transform-origin: top left;*/
    transition: opacity var(--motion-quick) var(--ease-out-strong),
    transform var(--motion-standard) var(--ease-out-strong),
    visibility 0ms linear var(--motion-standard);
}

.header-categories.is-open .header-categories-block {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transition-delay: 0ms;
}

.header-categories-block__heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 4px 16px;
    border-bottom: 0.0625rem solid var(--lines);
}

.header-categories-block__heading span {
    color: var(--font-on-light-bgc);
    font-family: var(--font);
    font-size: var(--medium-text);
    font-weight: var(--bold-weight);
}

.header-categories-block__heading small {
    color: var(--space-btn);
    font-size: var(--small-text);
}

.header-categories-block__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding-top: 12px;
}

.header-category-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 8px 12px;
    border: 0;
    border-radius: var(--small-border-radius);
    color: var(--font-on-light-bgc);
    background: transparent;
    font-family: var(--font);
    font-size: var(--medium-text);
    text-align: left;
    cursor: pointer;
    transition: color var(--motion-quick) var(--ease-out-strong),
    background-color var(--motion-quick) var(--ease-out-strong),
    transform var(--motion-quick) var(--ease-out-strong);
}

.header-category-btn__check {
    display: grid;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 50%;
    opacity: 0;
    color: var(--font-on-dark-bgc);
    background: var(--lavanda);
    font-size: var(--small-text);
    transform: scale(0.8);
    transition: opacity var(--motion-quick) var(--ease-out-strong),
    transform var(--motion-standard) var(--ease-out-strong);
}

.header-category-btn.active {
    color: var(--font-on-light-bgc);
    background: var(--light-lavanda);
    font-weight: var(--bold-weight);
}

.header-category-btn.active .header-category-btn__check {
    opacity: 1;
    transform: scale(1);
}

.header-categories-container:focus-visible,
.header-category-btn:focus-visible {
    outline: 4px solid var(--zatmenie-btn);
    outline-offset: 4px;
}

.header-categories-container:active,
.header-category-btn:active {
    transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
    .header-category-btn:hover:not(.active) {
        background: var(--light-lavanda);
    }
}

@media (prefers-reduced-motion: reduce) {
    .header-categories-container,
    .header-categories__chevron,
    .header-categories-block,
    .header-category-btn,
    .header-category-btn__check {
        transition-duration: 0ms;
    }

    .header-categories-block,
    .header-categories-container:active,
    .header-category-btn:active {
        transform: none;
    }
}

.header-level-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.header-level-block span {
    font-family: var(--font);
    font-weight: var(--bold-weight);
    font-size: var(--medium-text);
}

.level-picker {
    position: relative;
    display: flex;
    align-items: center;
    justify-self: center;
    gap: 8px;
    padding: 4px;
    border: 0.0625rem solid var(--lines);
    border-radius: 1000px;
    background: var(--surface);
    color: var(--font-on-light-bgc);
    font-size: var(--small-text);
    font-weight: var(--extra-weight);
}

.level-picker__trigger,
.level-picker__heading {
    display: none;
}

.level-picker__panel {
    display: contents;
}

.level-picker__options {
    display: flex;
    min-width: 0;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.level-picker__options::-webkit-scrollbar {
    display: none;
}

.level-picker__options button {
    flex: 0 0 auto;
    min-width: 40px;
    min-height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--extra-border-radius);
    color: var(--font-on-light-bgc);
    background: transparent;
    font-size: var(--small-text);
    font-weight: var(--extra-weight);
    cursor: pointer;
    transition: color 160ms ease-out, background-color 160ms ease-out;
}

.level-picker__options button:hover:not(.is-active) {
    background: var(--light-lavanda);
}

.level-picker__options button.is-active {
    color: var(--font-on-dark-bgc);
    background: var(--zatmenie-btn);
}

.site-header__note {
    justify-self: end;
    margin: 0;
    color: var(--surface);
    font-size: var(--small-text);
    font-weight: var(--bold-weight);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.site-account.mobile, .site-auth.mobile {
    display: none;
}

.site-auth,
.site-account {
    display: flex;
    align-items: center;
    justify-self: end;
    gap: 20px;
}

.site-account form {
    display: flex;
    margin: 0;
}

.site-account__name {
    max-width: 160px;
    /*overflow: hidden;*/
    color: var(--font-on-light-bgc);
    font-size: var(--medium-text);
    font-weight: var(--bold-weight);
    text-decoration: none;
    /*text-overflow: ellipsis;*/
    /*white-space: nowrap;*/
    cursor: pointer;
}

@media (max-width: 720px) {
    .home-header {
        min-height: 72px;
        padding: 12px 16px;
    }

    .home-header__nav {
        gap: 0;
    }

    .home-header__nav .site-header__action:not(.site-header__action--primary),
    .home-header__nav form,
    .home-header__nav a[href="/admin/words"] {
        display: none;
    }
}

@media (max-width: 480px) {
    .home-header__nav .site-header__link[href="/english"] {
        display: none;
    }

    .home-header__nav .site-header__link,
    .home-header__nav .site-header__action {
        padding: 0 12px;
    }
}

.site-header__link,
.site-header__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 0.0625rem solid transparent;
    border-radius: var(--extra-border-radius);
    background: transparent;
    font-size: var(--small-text);
    font-weight: var(--bold-weight);
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: var(--300-transition);
}

.site-header__link:hover {
    background: var(--light-lavanda);
}

.site-header__action {
    border-color: var(--lines);
    background: rgba(255, 253, 248, 0.56);
}

.site-header__action:hover {
    background: var(--lavanda);
}

.site-header__action--primary {
    border-color: var(--lines);
    color: var(--surface);
    background: var(--zatmenie-btn);
}

.site-header__link:focus-visible,
.site-header__action:focus-visible,
.level-picker__options button:focus-visible {
    outline: 4px solid var(--zatmenie-btn);
    outline-offset: 4px;
}

@media (max-width: 980px) {
    .site-auth,
    .site-account {
        gap: 0;
    }

    .header-categories-container {
        width: 148px;
        min-width: 148px;
    }
}

@media (max-width: 848px) {
    .brand-name {
        display: none;
    }
}

@media (max-width: 820px) {
    /*.site-account, .site-auth {*/
    /*    display: none;*/
    /*}*/
    /*.site-account__name {*/
    /*    display: none;*/
    /*}*/
    .site-header__action {
        display: none;
    }

    .site-account a, .site-auth a {
        min-height: auto;
    }

    .header-level-block {
        grid-column: span 2;
    }

    .site-header {
        display: flex;
        justify-content: space-between;
        gap: 12px;
    }

    .header-categories-block {
        width: fit-content;
    }

    .header-categories-block__heading {
        width: 100%;
        flex-direction: column;
        gap: 4px;
    }

    .header-categories-block__grid {
        grid-template-columns: repeat(1, minmax(0, 1fr))
    }

    .header-categories.is-open .header-categories-block {
        left: 0;
        width: max-content;
    }

    .level-picker {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
    }

    .level-picker__options {
        flex: 1;
    }

    .level-picker__options button {
        flex: 1 0 40px;
    }

    .site-header__note {
        grid-column: 2;
        grid-row: 1;
    }


}

@media (max-width: 620px) {
    .header-categories-main-button {
        font-family: var(--font);
        font-size: var(--small-text);
        font-weight: var(--bold-weight);
    }

    .header-categories-container, .level-picker__trigger {
        min-height: auto;
        padding: 8px 12px;
        min-width: fit-content;
        width: auto;
    }

    .header-level-block {
        align-items: stretch;
    }

    .level-picker {
        display: block;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .level-picker__trigger {
        display: inline-flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 140px;
        border: 0.0625rem solid var(--lines);
        border-radius: var(--extra-border-radius);
        color: var(--font-on-light-bgc);
        background: var(--surface);
        box-shadow: 0 8px 24px var(--lines);
        font-family: var(--font);
        font-size: var(--small-text);
        font-weight: var(--bold-weight);
        cursor: pointer;
        transition: color var(--motion-quick) var(--ease-out-strong),
        background-color var(--motion-quick) var(--ease-out-strong),
        border-color var(--motion-quick) var(--ease-out-strong),
        transform var(--motion-quick) var(--ease-out-strong);
    }

    .level-picker__trigger strong {
        color: var(--zatmenie-btn);
    }

    .level-picker__trigger span {
        font-size: var(--small-text);
    }

    .level-picker__chevron {
        flex: 0 0 auto;
        width: 16px;
        height: 16px;
        fill: none;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-width: 1.5;
        transition: transform var(--motion-standard) var(--ease-out-strong);
    }

    .level-picker__panel {
        position: absolute;
        top: calc(100% + 12px);
        right: 0;
        z-index: 20;
        display: block;
        width: 224px;
        padding: 16px;
        border: 0.0625rem solid var(--lines);
        border-radius: var(--normal-border-radius);
        visibility: hidden;
        opacity: 0;
        background: var(--surface);
        box-shadow: var(--shadow);
        pointer-events: none;
        transform: translateY(-8px) scale(0.98);
        transform-origin: top right;
        transition: opacity var(--motion-quick) var(--ease-out-strong),
        transform var(--motion-standard) var(--ease-out-strong),
        visibility 0ms linear var(--motion-standard);
    }

    .level-picker:not(.is-open) .level-picker__panel {
        transition: none;
    }

    .level-picker__heading {
        display: flex;
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
        padding: 4px 4px 12px;
        border-bottom: 0.0625rem solid var(--lines);
    }

    .level-picker__heading span {
        color: var(--font-on-light-bgc);
        font-size: var(--medium-text);
        font-weight: var(--bold-weight);
    }

    .level-picker__heading small {
        color: var(--space-btn);
        font-size: var(--small-text);
    }

    .level-picker__options {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding-top: 12px;
        overflow: visible;
    }

    .level-picker__options button {
        width: 100%;
        min-height: 44px;
    }

    .level-picker.is-open .level-picker__trigger {
        border-color: var(--lavanda);
        background: var(--light-lavanda);
    }

    .level-picker.is-open .level-picker__chevron {
        transform: rotate(180deg);
    }

    .level-picker.is-open .level-picker__panel {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0) scale(1);
        transition-delay: 0ms;
    }

    .level-picker__trigger:focus-visible {
        outline: 4px solid var(--zatmenie-btn);
        outline-offset: 4px;
    }

    .level-picker__trigger:active {
        transform: scale(0.97);
    }
}

@media (max-width: 560px) {
    .site-header {
        grid-template-columns: 1fr auto;
        min-height: 0;
        padding: 12px 16px;
    }

    .level-picker {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
    }

    .brand__mark {
        width: 36px;
    }

    .header-categories {
        justify-self: end;
    }

    /*.header-categories-container {*/
    /*    width: 184px;*/
    /*    min-width: 0;*/
    /*    max-width: 184px;*/
    /*    min-height: 40px;*/
    /*    padding: 0 16px;*/
    /*}*/
    .header-categories-main-button {
        max-width: 124px;
    }

    .header-categories-block {
        right: 0;
        left: auto;
        width: min(360px, calc(100vw - 32px));
        transform-origin: top right;
    }

    .header-categories::after {
        right: 0;
        left: auto;
        width: min(360px, calc(100vw - 32px));
    }

    .header-categories-block__heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .header-categories-block__grid {
        grid-template-columns: 1fr;
    }

    .site-header__note {
        display: none;
    }

    /*.site-account__name {*/
    /*    display: none;*/
    /*}*/
    .site-auth,
    .site-account {
        gap: 4px;
    }

    .site-header__link,
    .site-header__action {
        min-height: 36px;
        padding: 0 12px;
    }


}

@media (max-width: 620px) and (prefers-reduced-motion: reduce) {
    .level-picker__trigger,
    .level-picker__chevron,
    .level-picker__panel {
        transition-duration: 0ms;
    }

    .level-picker__panel,
    .level-picker__trigger:active {
        transform: none;
    }
}

/* auth */
.auth-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 80px;
    padding: 16px clamp(20px, 5vw, 72px);
    border-bottom: 0.0625rem solid var(--lines);
    background: var(--paper);
    backdrop-filter: blur(16px);
}

.auth-header__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: 0.0625rem solid var(--lines);
    border-radius: var(--extra-border-radius);
    background: var(--paper);
    font-size: var(--small-text);
    font-weight: var(--bold-weight);
    text-decoration: none;
}

.auth-header__back:focus-visible {
    outline: 4px solid var(--zatmenie);
    outline-offset: 4px;
}

@media (max-width: 560px) {
    .auth-header {
        min-height: 72px;
        padding: 12px 16px;
    }

    .auth-header__back {
        padding: 8px 12px;
    }


}

/* profile */
.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 80px;
    padding: 16px clamp(20px, 5vw, 72px);
    border-bottom: 0.0625rem solid var(--lines);
    background: var(--paper);
    backdrop-filter: blur(16px);
}

.profile-header__actions,
.profile-header__actions form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.profile-header__actions a,
.profile-header__actions button {
    min-height: 40px;
    padding: 0 16px;
    border: 0.0625rem solid var(--lines);
    border-radius: var(--extra-border-radius);
    color: var(--font-on-light-bgc);
    background: var(--surface);
    font-size: var(--small-text);
    font-weight: var(--extra-weight);
    text-decoration: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-header__actions a:focus-visible,
.profile-header__actions button:focus-visible {
    outline: 4px solid var(--zatmenie);
    outline-offset: 4px;
}

@media (max-width: 560px) {
    .profile-header {
        padding: 12px 16px;
    }

    .profile-header__actions a {
        display: none;
    }


}

/* admin */
.admin-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 84px;
    padding: 16px clamp(20px, 5vw, 72px);
    border-bottom: 0.0625rem solid var(--lines);
    background: var(--paper);
    backdrop-filter: blur(16px);
}

.admin-nav {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 0.0625rem solid var(--lines);
    border-radius: var(--extra-border-radius);
    background: var(--paper);
}

.admin-nav a {
    padding: 12px 16px;
    border-radius: var(--extra-border-radius);
    font-size: var(--small-text);
    font-weight: var(--bold-weight);
    text-decoration: none;
}

.admin-nav a:hover {
    background: var(--paper);
}

.admin-nav a[aria-selected="true"],
.admin-nav a[aria-current="page"] {
    color: white;
    background: var(--zatmenie);
}

.admin-account {
    display: flex;
    align-items: center;
    justify-self: end;
    gap: 16px;
    font-size: var(--small-text);
}

.admin-account > div {
    display: grid;
    text-align: right;
}

.admin-account span {
    color: var(--lavanda);
}

.admin-account a,
.admin-account button {
    padding: 8px 0;
    border: 0;
    background: none;
    font-weight: var(--bold-weight);
    cursor: pointer;
}

@media (max-width: 900px) {
    .admin-header {
        grid-template-columns: 1fr auto;
        row-gap: 12px;
    }

    .admin-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: center;
    }
}

@media (max-width: 640px) {
    .admin-header {
        position: static;
        align-items: start;
    }

    .admin-account > div {
        display: none;
    }

    .admin-account {
        flex-wrap: wrap;
        justify-content: end;
    }
}

@media (max-width: 430px) {
    .header-categories-container, .level-picker__trigger {
        gap: 0;
        width: auto;
    }

    .language-level {
        display: none;
    }

    .header-categories.is-open .header-categories-block {
        width: 64vw;
        height: 50vh;
        overflow-y: auto;
        transform-origin: top left;
    }
}
