/* ==========================================================================
   Overrides & Extensions (keep small and scoped)
   ========================================================================== */

/* Example blocks (Пример N: ...) */
.example-box {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-md);
    border: 2px solid var(--color-border-secondary);
    background-color: var(--color-background-secondary);
    border-radius: var(--border-radius-md);
}

.example-box> :first-child {
    margin-top: 0;
}

.example-box> :last-child {
    margin-bottom: 0;
}

/* More prominent multiplication dot in formulas */
.math-mul-dot {
    display: inline-block;
    font-weight: 700;
    font-size: 1.2em;
    line-height: 1;
    vertical-align: middle;
}

/* Page loading state */
.global-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    text-align: center;
}

.global-loader .page-loading-text {
    max-width: 280px;
}

.global-loader .page-error {
    max-width: 400px;

    min-height: 0;
    margin: 0;
}

.page-error {
    min-height: calc(100dvh - var(--header-height));
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    text-align: center;
}

.error-icon {
    font-family: "Material Symbols Rounded";
    font-size: 32px;
    line-height: 1;
    color: var(--color-semantic-negative);
    font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 32;
}

.error-retry-button {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-max);
    border: none;
    background-color: var(--color-black);
    color: var(--color-white);
    font-weight: var(--font-weight-bold);
    cursor: pointer;
}


.error-retry-icon {
    font-family: "Material Symbols Rounded";
    font-size: 20px;
    line-height: 1;
    font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}

.page-error a {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-half);
    padding: var(--spacing-0) var(--spacing-half);
    border-radius: var(--border-radius-max);
    color: var(--color-link);
    text-decoration: underline;
    font-weight: var(--font-weight-bold);
}

@media (hover: hover) and (pointer: fine) {
    .page-error a:hover {
        background-color: var(--color-background-tertiary);
    }
}

.page-error a::after {
    content: '';
    width: 20px;
    height: 20px;
    background-image: url('../assets/arrow_right.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}




@media (hover: hover) and (pointer: fine) {
    .error-retry-button:hover {
        background-color: #1f1f1f;
    }
}


.page-loading {
    min-height: calc(100dvh - var(--header-height));
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    text-align: center;
}

.page-loading-text {
    font-size: 16px;
    color: var(--color-text-secondary);
    white-space: normal;
    overflow-wrap: anywhere;
}

.loader {
    width: 64px;
    height: 64px;
    border: 6px solid #d5d5d5;
    border-bottom-color: #000000;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


/* App logo (sidebar) */
.logo-image {
    display: block;
    height: 52px;
    width: auto;
    max-width: 100%;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
    .logo-link:hover .logo-image {
        opacity: 0.9;
        transform: translateY(-1px);
    }
}

.logo-link:active .logo-image {
    opacity: 0.82;
    transform: translateY(0);
}

/* Checklist (Чеклист) lists: green Material check icon instead of bullets */
.checklist-list {
    list-style: none;
    padding-left: 0 !important;
}

.checklist-list li {
    position: relative;
    padding-left: calc(24px + var(--spacing-xs));
}

.checklist-list li::before {
    content: 'check_circle';
    position: absolute;
    left: 0;
    top: 0.05em;
    width: 24px;
    height: 24px;
    font-family: "Material Symbols Rounded";
    font-size: 24px;
    line-height: 1;
    color: var(--color-semantic-positive);
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

@supports ((-webkit-mask-image: url('../assets/check_circle.svg')) or (mask-image: url('../assets/check_circle.svg'))) {
    .checklist-list li::before {
        content: '';
        background-color: var(--color-semantic-positive);
        -webkit-mask-image: url('../assets/check_circle.svg');
        -webkit-mask-repeat: no-repeat;
        -webkit-mask-position: center;
        -webkit-mask-size: 24px 24px;
        mask-image: url('../assets/check_circle.svg');
        mask-repeat: no-repeat;
        mask-position: center;
        mask-size: 24px 24px;
    }
}

/* Sidebar nav: show tooltip only when JS adds `data-tooltip` */
.nav-link[data-tooltip] {
    position: relative;
}

.nav-link[data-tooltip]::after {
    max-width: clamp(0px, 100%, 260px);
}

/* Leaf (inner) pages: doc header icon above title, left-aligned */
.main-content.is-leaf-page .doc-header-top {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.main-content.is-leaf-page .doc-header-text {
    flex: 0 1 auto;
}

.main-content.is-leaf-page .doc-icon {
    width: clamp(104px, 18vw, 132px);
    height: clamp(104px, 18vw, 132px);
}

/* Static pages (about/contacts/contribute): icon above title */
.doc-header-top--stacked {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.doc-header-top--stacked .doc-header-text {
    flex: 0 1 auto;
}

/* Mobile heading scale (tweak these values) */
@media (max-width: 600px) {
    :root {
        --mobile-h1-size: 1.70rem;
        --mobile-h2-size: 1.30rem;
        --mobile-h3-size: 1.10rem;
        --mobile-h4-size: 1.00rem;
        --mobile-h5-size: 0.94rem;
        --mobile-h6-size: 0.90rem;
    }

    .page-content h1 {
        font-size: var(--mobile-h1-size);
    }

    .page-content h2 {
        font-size: var(--mobile-h2-size);
    }

    .page-content h3 {
        font-size: var(--mobile-h3-size);
    }

    .page-content h4 {
        font-size: var(--mobile-h4-size);
    }

    .page-content h5 {
        font-size: var(--mobile-h5-size);
    }

    .page-content h6 {
        font-size: var(--mobile-h6-size);
    }
}

/* Static pages: decorative background (symbols scattered near edges) */
.decorated-page {
    isolation: isolate;
    --decor-scale: 0.9;
}

.decorated-page__bg {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--sidebar-width);
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.decorated-page__content {
    position: relative;
    z-index: 1;
}

.decor-item {
    position: absolute;
    top: var(--decor-top, auto);
    right: var(--decor-right, auto);
    bottom: var(--decor-bottom, auto);
    left: var(--decor-left, auto);
    width: var(--decor-size, 180px);
    height: auto;
    opacity: var(--decor-opacity, 0.08);
    transform: rotate(var(--decor-rotate, 0deg)) scale(var(--decor-scale, 1));
    filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.08));
    border-radius: 0 !important;
    user-select: none;
    pointer-events: none;
}

@media (max-width: 600px) {
    .decor-item {
        filter: none;
    }
}

@media (max-width: 900px) {
    .decorated-page__bg {
        left: 0;
    }
}

/* Cookie banner (bottom-right, non-modal) */
.cookie-banner {
    --cookie-banner-offset: 44px;
    position: fixed;
    right: var(--cookie-banner-offset);
    bottom: calc(var(--cookie-banner-offset) + env(safe-area-inset-bottom));
    z-index: 120;
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    max-width: min(360px, calc(100vw - (2 * var(--cookie-banner-offset))));
    padding: var(--spacing-md);
    border: 2px solid var(--color-border-primary);
    border-radius: var(--border-radius-md);
    background-color: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
}

.cookie-banner[hidden] {
    display: none;
}

.cookie-banner-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.cookie-banner-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    min-width: 0;
}

.cookie-banner-title {
    margin: 0;
    font-weight: var(--font-weight-bold);
    font-family: var(--font-family-heading);
    line-height: 1.15;
}

.cookie-banner-text {
    margin: 0;
    color: var(--color-text-secondary);
    line-height: 1.35;
}

.cookie-banner-button {
    align-self: flex-start;
    background-color: var(--color-black);
    color: var(--color-white);
    border: none;
    border-radius: var(--border-radius-max);
    padding: calc(var(--spacing-xs) + 2px) var(--spacing-lg);
    min-height: 44px;
    font-weight: var(--font-weight-bold);
    font-size: 1.05rem;
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    .cookie-banner-button:hover {
        background-color: #1f1f1f;
    }
}

@media (max-width: 600px) {
    .cookie-banner {
        max-width: min(360px, calc(100vw - (2 * var(--cookie-banner-offset))));
    }

    .cookie-banner-icon {
        width: 52px;
        height: 52px;
    }
}