/*
 * Authoritative typography for interactive system pages.
 *
 * This file is intentionally loaded after page/module styles. Official forms,
 * print layouts, certificates, e-book content, source code, and email markup
 * retain their purpose-built typography through their own scoped styles.
 */
:root {
    --portal-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --portal-font-family-monospace: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --portal-font-page-title: 1.375rem;
    --portal-font-feature-title: 1.125rem;
    --portal-font-section-title: 0.9375rem;
    --portal-font-metric: 1.1875rem;
    --portal-font-body: 0.875rem;
    --portal-font-control: 0.8125rem;
    --portal-font-label: 0.75rem;
    --portal-font-meta: 0.6875rem;
    --portal-font-public-hero-title: clamp(2.5rem, 5vw, 4.5rem);
    --portal-font-public-section-title: clamp(1.875rem, 3.5vw, 3rem);
    --portal-font-public-callout-title: clamp(1.375rem, 2.5vw, 2.125rem);
    --portal-font-public-lead: clamp(1rem, 1.3vw, 1.125rem);
    --portal-line-height-title: 1.3;
    --portal-line-height-display: 1.08;
    --portal-line-height-body: 1.5;
    --portal-line-height-compact: 1.4;
    --portal-letter-spacing-display: -0.035em;
    --portal-font-weight-regular: 400;
    --portal-font-weight-medium: 500;
    --portal-font-weight-semibold: 600;
    --portal-font-weight-bold: 700;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--portal-font-family);
    font-size: var(--portal-font-body);
    font-weight: var(--portal-font-weight-regular);
    line-height: var(--portal-line-height-body);
}

body :where(button, input, select, textarea) {
    font-family: inherit;
}

body :where(code, kbd, pre, samp) {
    font-family: var(--portal-font-family-monospace);
}

/* Main application and legacy interactive shells. */
.portal-content,
.page-body,
.portal-public-page,
.portal-auth-page {
    font-family: var(--portal-font-family);
    font-size: var(--portal-font-body);
    line-height: var(--portal-line-height-body);
}

/* Page and section hierarchy. */
.portal-page-header h3,
.portal-type-page-title {
    font-size: var(--portal-font-page-title);
    font-weight: var(--portal-font-weight-semibold);
    line-height: var(--portal-line-height-title);
}

.portal-content :is(.card-header, .modal-header, .offcanvas-header) :is(h1, h2, h3, h4, h5, h6),
.portal-content :is(.modal-title, .offcanvas-title),
.portal-type-section-title {
    font-size: var(--portal-font-section-title);
    font-weight: var(--portal-font-weight-semibold);
    line-height: var(--portal-line-height-title);
}

.portal-content :is(.card-header, .modal-header, .offcanvas-header) p,
.portal-content :is(.card-header, .modal-header, .offcanvas-header) small {
    font-size: var(--portal-font-meta);
    line-height: var(--portal-line-height-compact);
}

.portal-type-feature-title {
    font-size: var(--portal-font-feature-title);
    font-weight: var(--portal-font-weight-semibold);
    line-height: var(--portal-line-height-title);
}

.portal-type-body {
    font-size: var(--portal-font-body);
    line-height: var(--portal-line-height-body);
}

/* Controls, navigation, and tabular data. */
.portal-content :is(.btn:not(.btn-lg), .dropdown-item, .form-control:not(.form-control-lg), .form-select:not(.form-select-lg), .input-group-text, .page-link),
.portal-public-page :is(.btn:not(.btn-lg), .dropdown-item, .form-control:not(.form-control-lg), .form-select:not(.form-select-lg), .input-group-text, .page-link),
.portal-auth-page :is(.btn:not(.btn-lg), .dropdown-item, .form-control:not(.form-control-lg), .form-select:not(.form-select-lg), .input-group-text, .page-link) {
    font-size: var(--portal-font-control);
    line-height: var(--portal-line-height-compact);
}

.portal-content :is(.btn-sm, .form-control-sm, .form-select-sm),
.portal-public-page :is(.btn-sm, .form-control-sm, .form-select-sm),
.portal-auth-page :is(.btn-sm, .form-control-sm, .form-select-sm) {
    font-size: var(--portal-font-label);
}

.portal-content :is(.btn-lg, .form-control-lg, .form-select-lg),
.portal-public-page :is(.btn-lg, .form-control-lg, .form-select-lg),
.portal-auth-page :is(.btn-lg, .form-control-lg, .form-select-lg) {
    font-size: var(--portal-font-body);
}

.portal-content :is(.form-label, .col-form-label, legend, .nav-link, .portal-module-tabs__link),
.portal-public-page :is(.form-label, .col-form-label, legend, .nav-link),
.portal-auth-page :is(.form-label, .col-form-label, legend, .nav-link) {
    font-size: var(--portal-font-label);
    line-height: var(--portal-line-height-compact);
}

.portal-content .table:not(:where(
    .registrar-document *,
    .registrar-report-card *,
    .registrar-official-front *,
    .registrar-legacy-card *,
    .registrar-certificate *,
    .permanent-record-sheet *,
    .scheduler-print-document *,
    .library-reader-page *
)) {
    font-size: var(--portal-font-control);
    line-height: var(--portal-line-height-compact);
}

.portal-content .table > :not(caption) > * > th:not(:where(
    .registrar-document *,
    .registrar-report-card *,
    .registrar-official-front *,
    .registrar-legacy-card *,
    .registrar-certificate *,
    .permanent-record-sheet *,
    .scheduler-print-document *,
    .library-reader-page *
)) {
    font-size: var(--portal-font-label);
    font-weight: var(--portal-font-weight-semibold);
    line-height: var(--portal-line-height-compact);
}

.portal-content .table > :not(caption) > * > td:not(:where(
    .registrar-document *,
    .registrar-report-card *,
    .registrar-official-front *,
    .registrar-legacy-card *,
    .registrar-certificate *,
    .permanent-record-sheet *,
    .scheduler-print-document *,
    .library-reader-page *
)) {
    font-size: var(--portal-font-control);
    line-height: var(--portal-line-height-compact);
}

/* Supporting and status text. */
.portal-content :is(small, .small, .form-text, .invalid-feedback, .valid-feedback, .text-muted, .badge, .workflow-status):not(:where(
    .registrar-document *,
    .registrar-report-card *,
    .registrar-official-front *,
    .registrar-legacy-card *,
    .registrar-certificate *,
    .permanent-record-sheet *,
    .scheduler-print-document *,
    .library-reader-page *
)),
.portal-public-page :is(small, .small, .form-text, .invalid-feedback, .valid-feedback, .text-muted, .badge),
.portal-auth-page :is(small, .small, .form-text, .invalid-feedback, .valid-feedback, .text-muted, .badge),
.portal-type-meta {
    font-size: var(--portal-font-meta);
    line-height: var(--portal-line-height-compact);
}

.portal-content :is(.alert, .toast-body, .workflow-alert),
.portal-public-page :is(.alert, .toast-body),
.portal-auth-page :is(.alert, .toast-body) {
    font-size: var(--portal-font-control);
    line-height: var(--portal-line-height-body);
}

/* Reusable metric hierarchy used across school modules. */
.portal-content :is(
    .workflow-metrics,
    .student-metrics,
    .registrar-metrics,
    .registrar-inline-metrics,
    .scheduler-dashboard-metrics,
    .scheduler-metric,
    .sh-metric,
    .incident-stat,
    .library-metric,
    .library-inline-metrics,
    .creator-diagnostics-metric,
    .biotime-stat-grid,
    .biotime-report-readiness__metrics,
    .sf2-stat-grid
) strong,
.portal-type-metric {
    font-size: var(--portal-font-metric);
    font-weight: var(--portal-font-weight-bold);
    line-height: 1.1;
}

/* Header, sidebar, notifications, and messaging chrome. */
.page-wrapper .page-header,
.page-wrapper .sidebar-wrapper,
.page-wrapper .profile-dropdown,
.xclnt-notification-panel,
.xclnt-message-panel {
    font-family: var(--portal-font-family);
}

.page-wrapper .sidebar-wrapper :is(.sidebar-link, .sidebar-submenu a),
.page-wrapper .page-header :is(.dropdown-item, .profile-media span),
.xclnt-notification-panel :is(a, button),
.xclnt-message-panel :is(a, button) {
    font-size: var(--portal-font-control);
    line-height: var(--portal-line-height-compact);
}

.page-wrapper .sidebar-wrapper .sidebar-main-title h6,
.page-wrapper .page-header .profile-media p,
.xclnt-notification-panel :is(small, time),
.xclnt-message-panel :is(small, time) {
    font-size: var(--portal-font-meta);
    line-height: var(--portal-line-height-compact);
}

/* Public and authentication pages follow the same scale without portal chrome. */
.portal-public-page:not(.portal-landing-page) h1,
.portal-auth-page h1 {
    font-size: var(--portal-font-page-title);
    font-weight: var(--portal-font-weight-semibold);
    line-height: var(--portal-line-height-title);
}

.portal-public-page:not(.portal-landing-page) :is(h2, h3),
.portal-auth-page :is(h2, h3) {
    font-size: var(--portal-font-feature-title);
    font-weight: var(--portal-font-weight-semibold);
    line-height: var(--portal-line-height-title);
}

.portal-public-page:not(.portal-landing-page) :is(h4, h5, h6),
.portal-auth-page :is(h4, h5, h6) {
    font-size: var(--portal-font-section-title);
    font-weight: var(--portal-font-weight-semibold);
    line-height: var(--portal-line-height-title);
}

@media (max-width: 575.98px) {
    :root {
        --portal-font-page-title: 1.25rem;
        --portal-font-feature-title: 1.0625rem;
        --portal-font-public-hero-title: clamp(2.125rem, 10vw, 3.25rem);
        --portal-font-public-section-title: clamp(1.75rem, 8vw, 2.5rem);
        --portal-font-public-callout-title: 1.375rem;
    }
}
