/* ==========================================================
   TypingTutor.Online — Universal Site Header v17.7.2
   One complete header for tutor, tests, games, kids, blog,
   certificates, information pages, sitemap, and 404.
========================================================== */

#header,
.test-site-header {
    box-sizing: border-box !important;
    position: relative;
    z-index: 1000;
    width: 100%;
    min-height: 80px;
    padding: max(9px, env(safe-area-inset-top)) 0 9px;
    background: var(--surface, #ffffff);
    border-bottom: 1px solid var(--border, #dbe4f0);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .06);
}

#header .header-inner,
.test-header-inner {
    box-sizing: border-box;
    width: min(1660px, calc(100% - 34px));
    min-height: 60px;
    margin-inline: auto;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(235px, 300px) minmax(0, 1fr) auto;
    gap: clamp(10px, 1.4vw, 24px);
    align-items: center;
}

#header .logo,
.test-logo {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-self: start;
    color: inherit;
    text-decoration: none;
}

#header .site-logo-picture,
.test-logo-stack {
    position: relative;
    display: grid;
    width: min(280px, 100%);
    min-width: 0;
}

#header .site-logo-picture,
#header .site-logo-picture-light,
#header .site-logo-picture-dark,
.test-logo-stack > img {
    grid-area: 1 / 1;
}

#header .site-logo-image,
.test-logo img {
    display: block;
    width: min(280px, 100%);
    height: auto;
    max-height: 60px;
    object-fit: contain;
    object-position: left center;
}

#header .site-logo-picture-dark,
.test-logo-dark {
    display: none !important;
}

html[data-theme="dark"] #header .site-logo-picture-light,
html[data-theme="dark"] .test-logo-light {
    display: none !important;
}

html[data-theme="dark"] #header .site-logo-picture-dark,
html[data-theme="dark"] .test-logo-dark {
    display: block !important;
}

#header .primary-mode-navigation,
.test-nav {
    min-width: 0;
    width: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(2px, .72vw, 12px);
    overflow: visible;
}

#header #modeSwitcher,
#header .mode-switcher-inner,
#header .mode-navigation {
    min-width: 0;
    width: auto;
}

#header .mode-navigation {
    display: flex;
    align-items: center;
    gap: clamp(2px, .72vw, 12px);
}

#header .mode-switcher-heading {
    display: none !important;
}

#header .lesson-home-nav-button,
#header .mode-navigation > .mode-button,
#header .mode-more > summary.mode-button,
.test-nav > a,
.test-nav-more > summary {
    box-sizing: border-box;
    min-width: 0;
    min-height: 48px;
    margin: 0;
    padding: 10px clamp(9px, .78vw, 15px);
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text, #172235);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    font: inherit;
    font-size: clamp(12px, .84vw, 15px);
    font-weight: 750;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: color .16s ease, background-color .16s ease,
        border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

#header .mode-button-icon,
#header .lesson-home-nav-icon,
.test-nav .mode-button-icon,
.test-nav-more-menu .mode-button-icon {
    display: inline-flex;
    flex: 0 0 22px;
    width: 22px;
    min-width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-size: 19px;
    font-weight: 400;
    line-height: 22px;
    text-align: center;
}

#header .mode-button-text,
#header .lesson-home-nav-label,
.test-nav .mode-button-text {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

#header .lesson-home-nav-button:hover,
#header .mode-navigation > .mode-button:hover,
#header .mode-more > summary.mode-button:hover,
.test-nav > a:hover,
.test-nav-more > summary:hover,
.test-nav-more[open] > summary {
    color: var(--primary, #1769ff);
    background: var(--surface-alt, #f2f7ff);
    border-color: #dbe8fa;
}

#header .lesson-home-nav-button-active,
#header .mode-navigation > .mode-button-active,
#header .mode-more.mode-more-active > summary,
.test-nav > a[aria-current="page"],
.test-nav > a.mode-button-active,
.test-nav-more.mode-more-active > summary {
    color: #ffffff !important;
    background: linear-gradient(135deg, #246df0, #285ee5) !important;
    border-color: rgba(31, 92, 222, .58) !important;
    box-shadow: 0 10px 24px rgba(47, 103, 246, .24) !important;
}

#header .header-tools,
.test-header-inner > #themeButton {
    justify-self: end;
}

#header #themeButton,
.test-header-inner > #themeButton {
    box-sizing: border-box;
    min-width: 116px;
    min-height: 48px;
    margin: 0;
    padding: 10px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #ffffff;
    background: linear-gradient(135deg, #246df0, #285ee5);
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-size: clamp(12px, .84vw, 15px);
    font-weight: 750;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(47, 103, 246, .20);
}

#header #themeButton > span:first-child,
.test-header-inner > #themeButton > span:first-child {
    display: inline-flex;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-size: 19px;
    line-height: 22px;
}

.theme-button-arrow,
.mode-more-chevron {
    font-size: 10px;
    opacity: .8;
}

#header .mode-more,
.test-nav-more {
    position: relative;
    flex: 0 0 auto;
}

#header .mode-more > summary,
.test-nav-more > summary {
    list-style: none;
}

#header .mode-more > summary::-webkit-details-marker,
.test-nav-more > summary::-webkit-details-marker {
    display: none;
}

#header .mode-more-menu,
.test-nav-more-menu {
    box-sizing: border-box;
    position: absolute;
    z-index: 1200;
    top: calc(100% + 10px);
    right: 0;
    width: 244px;
    padding: 8px;
    display: none;
    gap: 4px;
    background: var(--surface-elevated, #ffffff);
    border: 1px solid var(--border, #dbe4f0);
    border-radius: 14px;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .18);
}

#header .mode-more[open] .mode-more-menu,
.test-nav-more[open] .test-nav-more-menu {
    display: grid;
}

#header .mode-more-menu .mode-button,
.test-nav-more-menu a,
.test-nav-more-menu button {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    color: var(--text, #172235);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

#header .mode-more-menu .mode-button:hover,
.test-nav-more-menu a:hover,
.test-nav-more-menu button:hover,
.test-nav-more-menu a[aria-current="page"] {
    color: var(--primary, #1769ff);
    background: var(--surface-alt, #f2f7ff);
    border-color: var(--border, #dbe4f0);
}

/* Theme chooser: included here so simple information pages match the app. */
.theme-menu {
    position: fixed;
    z-index: 10050;
    width: 250px;
    padding: 8px;
    background: var(--surface-elevated, #ffffff);
    border: 1px solid var(--border, #dbe4f0);
    border-radius: 14px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .22);
}
.theme-menu.hidden { display: none !important; }
.theme-option {
    display: grid;
    grid-template-columns: 36px 1fr 22px;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 10px;
    color: var(--text, #172235);
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}
.theme-option:hover,
.theme-option:focus-visible {
    background: var(--surface-alt, #f2f7ff);
    border-color: var(--border, #dbe4f0);
    outline: none;
}
.theme-option-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    background: var(--surface-alt, #f2f7ff);
    border-radius: 9px;
    font-size: 18px;
}
.theme-option-copy { display: grid; gap: 2px; }
.theme-option-copy strong { color: var(--text, #172235); font-size: 13px; }
.theme-option-copy small { color: var(--text-light, #718096); font-size: 10px; }
.theme-option-check { color: var(--primary, #1769ff); font-weight: 900; opacity: 0; }
.theme-option-selected { background: var(--primary-light, #edf4ff); border-color: var(--border, #dbe4f0); }
.theme-option-selected .theme-option-check { opacity: 1; }

html[data-theme="dark"] #header,
html[data-theme="dark"] .test-site-header {
    background: #101b2e;
    border-color: #40516a;
}
html[data-theme="dark"] #header .lesson-home-nav-button,
html[data-theme="dark"] #header .mode-navigation > .mode-button,
html[data-theme="dark"] #header .mode-more > summary.mode-button,
html[data-theme="dark"] .test-nav > a,
html[data-theme="dark"] .test-nav-more > summary,
html[data-theme="dark"] #header .mode-more-menu .mode-button,
html[data-theme="dark"] .test-nav-more-menu a,
html[data-theme="dark"] .test-nav-more-menu button {
    color: #dce7f7;
}
html[data-theme="dark"] #header .mode-more-menu,
html[data-theme="dark"] .test-nav-more-menu,
html[data-theme="dark"] .theme-menu {
    background: #101b2e;
    border-color: #40516a;
}
html[data-theme="dark"] .theme-option,
html[data-theme="dark"] .theme-option-copy strong { color: #e7eef9; }
html[data-theme="dark"] .theme-option-copy small { color: #9aabc2; }
html[data-theme="dark"] .theme-option-icon,
html[data-theme="dark"] .theme-option:hover,
html[data-theme="dark"] .theme-option:focus-visible,
html[data-theme="dark"] #header .mode-more-menu .mode-button:hover,
html[data-theme="dark"] .test-nav-more-menu a:hover,
html[data-theme="dark"] .test-nav-more-menu button:hover {
    background: #17263c;
    border-color: #304662;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] #header,
    html[data-theme="system"] .test-site-header {
        background: #101b2e;
        border-color: #40516a;
    }
    html[data-theme="system"] #header .site-logo-picture-light,
    html[data-theme="system"] .test-logo-light { display: none !important; }
    html[data-theme="system"] #header .site-logo-picture-dark,
    html[data-theme="system"] .test-logo-dark { display: block !important; }
    html[data-theme="system"] #header .lesson-home-nav-button,
    html[data-theme="system"] #header .mode-navigation > .mode-button,
    html[data-theme="system"] #header .mode-more > summary.mode-button,
    html[data-theme="system"] .test-nav > a,
    html[data-theme="system"] .test-nav-more > summary,
    html[data-theme="system"] #header .mode-more-menu .mode-button,
    html[data-theme="system"] .test-nav-more-menu a,
    html[data-theme="system"] .test-nav-more-menu button { color: #dce7f7; }
    html[data-theme="system"] #header .mode-more-menu,
    html[data-theme="system"] .test-nav-more-menu,
    html[data-theme="system"] .theme-menu {
        background: #101b2e;
        border-color: #40516a;
    }
}

@media (max-width: 1360px) {
    #header .header-inner,
    .test-header-inner {
        grid-template-columns: minmax(205px, 235px) minmax(0, 1fr) auto;
        gap: 8px;
    }
    #header .site-logo-picture,
    #header .site-logo-image,
    .test-logo-stack,
    .test-logo img { width: min(235px, 100%); }
    #header .lesson-home-nav-button,
    #header .mode-navigation > .mode-button,
    #header .mode-more > summary.mode-button,
    .test-nav > a,
    .test-nav-more > summary {
        min-height: 44px;
        padding-inline: 8px;
        gap: 6px;
        font-size: 12px;
    }
    #header #themeButton,
    .test-header-inner > #themeButton {
        min-width: 104px;
        min-height: 44px;
        padding-inline: 11px;
        font-size: 12px;
    }
}

@media (max-width: 1040px) {
    #header,
    .test-site-header {
        min-height: 0;
        padding-top: max(7px, env(safe-area-inset-top));
        padding-bottom: 7px;
    }
    #header .header-inner,
    .test-header-inner {
        width: min(100% - 22px, 1660px);
        min-height: 0;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 12px;
    }
    #header .primary-mode-navigation,
    .test-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: visible;
        padding: 2px 0 3px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    #header .primary-mode-navigation::-webkit-scrollbar,
    .test-nav::-webkit-scrollbar { display: none; }
    #header .header-tools,
    .test-header-inner > #themeButton { grid-column: 2; grid-row: 1; }
    .test-logo { grid-column: 1; grid-row: 1; }
}

@media (max-width: 590px) {
    #header .header-inner,
    .test-header-inner { width: min(100% - 14px, 1660px); }
    #header .site-logo-picture,
    #header .site-logo-image,
    .test-logo-stack,
    .test-logo img { width: min(190px, 100%); }
    #header .lesson-home-nav-button,
    #header .mode-navigation > .mode-button,
    #header .mode-more > summary.mode-button,
    .test-nav > a,
    .test-nav-more > summary {
        min-width: 68px;
        min-height: 44px;
        padding: 7px 8px;
        flex-direction: column;
        gap: 3px;
        font-size: 9px;
    }
    #header .mode-more-chevron,
    .test-nav-more .mode-more-chevron { display: none; }
    #header #themeButton,
    .test-header-inner > #themeButton {
        min-width: 48px;
        min-height: 42px;
        padding: 8px 10px;
    }
    #header #themeButton > span:nth-child(2),
    #header #themeButton > span:last-child,
    .test-header-inner > #themeButton > span:nth-child(2),
    .test-header-inner > #themeButton > span:last-child { display: none; }
}
