/* ==========================================================
   TypingTutor.Online
   Unified Main + Tests Header v17.4.6
========================================================== */

/* Both the tutor and standalone test pages now use the same shell. */
#header,
.test-site-header {
    box-sizing: border-box;
    position: relative;
    z-index: 100;
    width: 100%;
    min-height: 78px;
    padding-top: max(9px, env(safe-area-inset-top));
    padding-bottom: 9px;
    background: var(--surface, #ffffff);
    border-bottom: 1px solid var(--border, #dbe4f0);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(15, 23, 42, .08));
}

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

/* Identical logo footprint on every page. */
#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: block;
    width: min(280px, 100%);
    min-width: 0;
}

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

/* Identical navigation positioning. */
#header .primary-mode-navigation,
.test-nav {
    min-width: 0;
    width: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(4px, 1.1vw, 18px);
    overflow: visible;
}

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

#header .mode-navigation {
    gap: clamp(4px, 1.1vw, 18px);
}

/* Shared button geometry and typography. */
#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: 46px;
    margin: 0;
    padding: 10px clamp(12px, 1.15vw, 17px);
    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: 11px;
    font: inherit;
    font-size: clamp(12px, .92vw, 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 20px;
    width: 20px;
    min-width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-size: 18px;
    font-weight: 400;
    line-height: 20px;
    text-align: center;
    transform: translateY(-1px);
}

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

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

#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;
}

/* Active button has the same appearance regardless of the current page. */
#header .lesson-home-nav-button-active,
#header .mode-navigation > .mode-button-active,
.test-nav > a[aria-current="page"] {
    color: #ffffff !important;
    background: linear-gradient(135deg, #246df0, #285ee5) !important;
    border-color: rgba(31, 92, 222, .55) !important;
    box-shadow: 0 10px 23px rgba(47, 103, 246, .24) !important;
}

#header .lesson-home-nav-button-active:hover,
#header .mode-navigation > .mode-button-active:hover,
.test-nav > a[aria-current="page"]:hover {
    color: #ffffff !important;
    background: linear-gradient(135deg, #2165df, #2457d5) !important;
    border-color: rgba(31, 92, 222, .64) !important;
}

/* Theme control occupies the same final grid column. */
#header .header-tools,
.test-header-inner > #themeButton {
    justify-self: end;
}

#header #themeButton,
.test-header-inner > #themeButton {
    box-sizing: border-box;
    min-width: 108px;
    min-height: 46px;
    margin: 0;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: #ffffff;
    background: var(--primary, #1769ff);
    border: 0;
    border-radius: 11px;
    font: inherit;
    font-size: clamp(12px, .92vw, 15px);
    font-weight: 750;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

#header #themeButton:hover,
.test-header-inner > #themeButton:hover {
    color: #ffffff;
    background: var(--primary-hover, #0f5ae0);
}

/* Dropdown alignment is identical in both templates. */
#header .mode-more,
.test-nav-more {
    position: relative;
    flex: 0 0 auto;
}

#header .mode-more-menu,
.test-nav-more-menu {
    top: calc(100% + 10px);
    right: 0;
}

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 {
    color: #dce7f7;
}

html[data-theme="dark"] #header .lesson-home-nav-button:hover,
html[data-theme="dark"] #header .mode-navigation > .mode-button:hover,
html[data-theme="dark"] #header .mode-more > summary.mode-button:hover,
html[data-theme="dark"] .test-nav > a:hover,
html[data-theme="dark"] .test-nav-more > summary:hover,
html[data-theme="dark"] .test-nav-more[open] > summary {
    color: #ffffff;
    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 .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 {
        color: #dce7f7;
    }
}

@media (max-width: 1180px) {
    #header .header-inner,
    .test-header-inner {
        grid-template-columns: minmax(190px, 225px) minmax(0, 1fr) auto;
        gap: 10px;
    }

    #header .site-logo-picture,
    #header .site-logo-image,
    .test-logo-stack,
    .test-logo img {
        width: min(225px, 100%);
    }

    #header .primary-mode-navigation,
    #header .mode-navigation,
    .test-nav {
        gap: 3px;
    }

    #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: 42px;
        padding-inline: 10px;
        font-size: 12px;
    }

    #header #themeButton,
    .test-header-inner > #themeButton {
        min-height: 42px;
        font-size: 12px;
    }
}

@media (max-width: 900px) {
    #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, 1480px);
        min-height: 0;
        display: grid;
        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: 560px) {
    #header .header-inner,
    .test-header-inner {
        width: min(100% - 14px, 1480px);
    }

    #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: 42px;
        padding: 7px 8px;
        flex-direction: column;
        gap: 3px;
        font-size: 9px;
    }

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

    #header #themeButton,
    .test-header-inner > #themeButton {
        min-width: 88px;
        min-height: 42px;
        padding-inline: 10px;
        font-size: 11px;
    }

    #header .mode-button-icon,
    #header .lesson-home-nav-icon,
    .test-nav .mode-button-icon,
    .test-nav-more-menu .mode-button-icon {
        flex-basis: 19px;
        width: 19px;
        min-width: 19px;
        height: 19px;
        font-size: 17px;
        line-height: 19px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #header .lesson-home-nav-button,
    #header .mode-navigation > .mode-button,
    #header .mode-more > summary.mode-button,
    .test-nav > a,
    .test-nav-more > summary {
        transition: none;
    }
}


/* ==========================================================
   SHARED SECTION FOOTER v17.5.2
========================================================== */
.test-footer,
.certificate-footer,
.blog-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    width: min(1480px, calc(100% - 32px));
    margin: 28px auto 0;
    padding: 24px 0 30px;
    color: var(--muted, #64748b);
    font-size: 13px;
}

.shared-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 9px 17px;
}

.shared-footer-links a {
    color: inherit;
    text-decoration: none;
}

.shared-footer-links a:hover,
.shared-footer-links a:focus-visible {
    color: var(--primary, #1769ff);
}

@media (max-width: 760px) {
    .test-footer,
    .certificate-footer,
    .blog-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}
