/* ===================================
   SITEWIDE CONSISTENCY & STATE STYLES
   Shared polish layer loaded after page-specific CSS.
   =================================== */

html {
    scroll-behavior: smooth;
    scroll-padding-top: 96px;
}

body {
    min-width: 320px;
    overflow-x: hidden;
}

img,
video,
canvas,
iframe {
    max-width: 100%;
}

:where([id], .page-header, .mcq-list, .section-panel, .admin-section, .question-panel, .question-card, .material-content) {
    scroll-margin-top: 96px;
}

.page-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 58%, #0ea5e9 100%) !important;
    color: #ffffff;
    padding: clamp(2.25rem, 5vw, 3.5rem) 0 !important;
    position: relative;
    overflow: hidden;
}

.page-header::before {
    opacity: 0.12 !important;
}

.page-header .container {
    position: relative;
    z-index: 1;
}

.page-header h1 {
    color: #ffffff !important;
    line-height: 1.18;
    letter-spacing: 0;
}

.page-header p {
    color: rgba(255, 255, 255, 0.88) !important;
    max-width: 760px;
}

.page-header .back-link {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.14) !important;
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: none !important;
}

.page-header .back-link:hover {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
}

.site-state-section,
.access-denied-container.site-state-section,
.access-denied.site-state-section {
    min-height: calc(100dvh - 84px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(2rem, 6vw, 4rem) 1rem;
    background:
        radial-gradient(circle at 18% 18%, rgba(37, 99, 235, 0.12), transparent 28%),
        linear-gradient(135deg, #f8fafc 0%, #e0f2fe 100%);
}

.site-state-card,
.access-denied-card.site-state-card,
.denied-content.site-state-card {
    width: min(100%, 520px);
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
    padding: clamp(1.5rem, 4vw, 2.75rem);
    text-align: center;
}

.site-state-icon,
.site-state-card .denied-icon {
    width: 82px;
    height: 82px;
    border-radius: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    color: #ffffff;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    box-shadow: 0 18px 36px rgba(37, 99, 235, 0.24);
}

.site-state-icon.is-danger,
.site-state-card .denied-icon {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 18px 36px rgba(239, 68, 68, 0.24);
}

.site-state-icon.is-warning {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    box-shadow: 0 18px 36px rgba(245, 158, 11, 0.24);
}

.site-state-icon i,
.site-state-card .denied-icon i {
    font-size: 2.2rem;
    color: #ffffff;
}

.site-state-card h1,
.site-state-card h2 {
    color: var(--dark-color);
    font-size: clamp(1.45rem, 4vw, 1.9rem);
    line-height: 1.2;
    margin-bottom: 0.65rem;
}

.site-state-card p,
.site-state-card .subtitle {
    color: var(--secondary-color);
    line-height: 1.65;
}

.site-state-actions,
.denied-actions.site-state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.85rem;
    margin-top: 1.5rem;
}

.site-state-actions .btn,
.site-state-actions a {
    min-height: 44px;
    border-radius: 10px;
}

.payment-modal-overlay,
.login-modal-overlay,
.purchase-modal-overlay {
    padding: 1rem;
    background: rgba(15, 23, 42, 0.68) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.payment-modal,
.login-modal,
.purchase-modal {
    width: min(100%, 440px) !important;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    border-radius: 16px !important;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24) !important;
    animation: none !important;
}

.payment-modal .modal-header,
.login-modal .modal-header,
.purchase-modal .modal-header {
    background: linear-gradient(135deg, #2563eb, #0ea5e9) !important;
    color: #ffffff !important;
    padding: 1.35rem 1.25rem 1rem !important;
    text-align: center;
}

.payment-modal .modal-header h3,
.login-modal .modal-header h3,
.purchase-modal .modal-header h3 {
    color: #ffffff !important;
}

.payment-modal .modal-icon,
.login-modal .modal-icon,
.purchase-modal .modal-header > i {
    background: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
}

.login-modal .modal-icon.warning {
    background: rgba(245, 158, 11, 0.24) !important;
}

.payment-modal .modal-body,
.login-modal .modal-body,
.purchase-modal .modal-body {
    padding: 1.25rem !important;
}

.payment-modal .modal-footer,
.login-modal .modal-footer,
.purchase-modal .modal-actions {
    padding: 0 1.25rem 1.25rem !important;
    gap: 0.75rem !important;
}

.payment-modal .modal-footer .btn,
.login-modal .modal-footer .btn,
.purchase-modal .modal-actions .btn {
    min-height: 44px !important;
    border-radius: 10px !important;
    justify-content: center !important;
}

.payment-modal .modal-body p,
.login-modal .modal-body p,
.purchase-modal .modal-body p {
    color: var(--secondary-color) !important;
    line-height: 1.6 !important;
}

.table-container,
.mcq-pagination-wrap,
.pagination {
    -webkit-overflow-scrolling: touch;
}

.pagination button,
.mcq-page-btn {
    min-width: 42px;
    min-height: 42px;
}

@media (max-width: 768px) {
    html {
        scroll-padding-top: 78px;
    }

    :where([id], .page-header, .mcq-list, .section-panel, .admin-section, .question-panel, .question-card, .material-content) {
        scroll-margin-top: 78px;
    }

    .page-header {
        padding: 2rem 0 1.65rem !important;
    }

    .page-header .container {
        text-align: left;
    }

    .page-header h1 {
        font-size: clamp(1.55rem, 7vw, 2.1rem) !important;
    }

    .page-header p {
        font-size: 0.95rem !important;
    }

    .page-header .back-link {
        margin-bottom: 0.9rem;
    }

    .site-state-section,
    .access-denied-container.site-state-section,
    .access-denied.site-state-section {
        min-height: calc(100dvh - 72px);
        padding: 1.5rem 0.85rem;
    }

    .site-state-card,
    .access-denied-card.site-state-card,
    .denied-content.site-state-card {
        padding: 1.4rem;
        border-radius: 14px;
    }

    .site-state-icon,
    .site-state-card .denied-icon {
        width: 70px;
        height: 70px;
        border-radius: 18px;
    }

    .site-state-icon i,
    .site-state-card .denied-icon i {
        font-size: 1.85rem;
    }

    .site-state-actions,
    .denied-actions.site-state-actions {
        flex-direction: column;
    }

    .site-state-actions .btn,
    .site-state-actions a {
        width: 100%;
        justify-content: center;
    }

    .payment-modal,
    .login-modal,
    .purchase-modal {
        width: 100% !important;
        max-height: calc(100dvh - 1.25rem);
    }

    .payment-modal .modal-footer,
    .login-modal .modal-footer,
    .purchase-modal .modal-actions {
        flex-direction: column;
    }

    .payment-modal .modal-footer .btn,
    .login-modal .modal-footer .btn,
    .purchase-modal .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .pagination,
    .mcq-pagination {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 0.35rem;
        scroll-snap-type: x proximity;
    }

    .pagination button,
    .mcq-page-btn {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }
}
