/*
 * Scholix base layer — styles for themes/base/* views.
 *
 * Base views render a page or section that the active theme does not provide
 * itself (instead of borrowing another theme's markup). They must look
 * acceptable inside ANY theme, so this file:
 *   - uses only the platform tokens every theme emits (shared/design-tokens):
 *     --primary-color, --text-color, --border-color, --cta-*, fonts, …
 *   - prefixes every class with "sx-" and depends on no CSS framework or icon font
 *   - wraps selectors in :where() (zero specificity) so a theme's own element
 *     styles (headings, links, buttons) still apply and can restyle base output.
 */

:where(.sx-page) {
    --sx-gap: 1.5rem;
    --sx-radius: var(--border-radius, 8px);
    --sx-surface: var(--surface-color, #fff);
    --sx-soft: var(--surface-muted-color, #f5f7fa);
    --sx-border: var(--border-color, #e3e7ee);
    --sx-text: var(--text-color, #1f2937);
    --sx-muted: var(--text-muted-color, #6b7280);
    --sx-primary: var(--primary-color, #1d4ed8);
    --sx-on-primary: var(--primary-contrast-color, #fff);
    --sx-primary-soft: var(--primary-soft-color, #e8efff);
    padding-block: clamp(2rem, 5vw, 4rem);
    color: var(--sx-text);
}

:where(.sx-page *, .sx-page *::before, .sx-page *::after) { box-sizing: border-box; }
:where(.sx-page img) { max-width: 100%; height: auto; display: block; }

:where(.sx-container) { width: min(1200px, 100%); margin-inline: auto; padding-inline: 16px; }
:where(.sx-stack) > * + * { margin-top: var(--sx-gap); }
:where(.sx-list) { list-style: none; margin: 0; padding: 0; }

/* Headings */
:where(.sx-head) { text-align: center; max-width: 760px; margin: 0 auto 2rem; }
:where(.sx-head h2, .sx-title) { font-family: var(--header-font-family, inherit); margin: 0 0 .5rem; line-height: 1.25; }
:where(.sx-eyebrow) { display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--sx-primary); margin-bottom: .5rem; }
:where(.sx-lead) { color: var(--sx-muted); font-size: 1.05rem; margin: 0; }
:where(.sx-section-title) { font-family: var(--header-font-family, inherit); font-size: 1.25rem; margin: 0 0 1rem; }

/* Tabs and filter pills */
:where(.sx-tabs, .sx-pills) { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: 0 0 1.5rem; padding: 0; list-style: none; }
:where(.sx-tab, .sx-pill) {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .5rem 1rem; border: 1px solid var(--sx-border); border-radius: 999px;
    color: var(--sx-text); background: var(--sx-surface); text-decoration: none; font-weight: 600; font-size: .9rem;
}
:where(.sx-tab:hover, .sx-pill:hover) { border-color: var(--sx-primary); color: var(--sx-primary); }
:where(.sx-tab.is-active, .sx-pill.is-active) { background: var(--sx-primary); border-color: var(--sx-primary); color: var(--sx-on-primary); }

/* Grids */
:where(.sx-grid) { display: grid; gap: var(--sx-gap); grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
:where(.sx-grid--wide) { grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); }
:where(.sx-grid--narrow) { grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }

/* Cards */
:where(.sx-card) {
    display: flex; flex-direction: column; height: 100%;
    background: var(--sx-surface); border: 1px solid var(--sx-border); border-radius: var(--sx-radius); overflow: hidden;
}
:where(.sx-card__media) { position: relative; aspect-ratio: 16 / 10; background: var(--sx-soft); }
:where(.sx-card__media img) { width: 100%; height: 100%; object-fit: cover; }
:where(.sx-card__media .sx-badge) { position: absolute; top: .75rem; left: .75rem; }
:where(.sx-card__body) { display: flex; flex-direction: column; gap: .5rem; padding: 1.1rem 1.25rem 1.25rem; flex: 1; }
:where(.sx-card__title) { font-family: var(--header-font-family, inherit); font-size: 1.1rem; line-height: 1.35; margin: 0; }
:where(.sx-card__title a) { color: inherit; text-decoration: none; }
:where(.sx-card__title a:hover) { color: var(--sx-primary); }
:where(.sx-card__text) { color: var(--sx-muted); margin: 0; }
:where(.sx-card__actions) { margin-top: auto; padding-top: .5rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
:where(.sx-card__actions--center) { justify-content: center; }

/* Meta rows and badges */
:where(.sx-meta) { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: 0; padding: 0; list-style: none; color: var(--sx-muted); font-size: .9rem; }
:where(.sx-badge) {
    display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700;
    background: var(--sx-primary-soft); color: var(--sx-primary);
}
:where(.sx-badge--success) { background: #e7f6ec; color: #17663a; }
:where(.sx-badge--warning) { background: #fff4e0; color: #8a5300; }
:where(.sx-badge--danger) { background: #fdecec; color: #a12727; }
:where(.sx-badge--muted) { background: var(--sx-soft); color: var(--sx-muted); }

/* Buttons and links */
:where(.sx-btn) {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .65rem 1.25rem; border: 1px solid transparent; border-radius: var(--sx-radius);
    background: var(--cta-bg-color, var(--sx-primary)); color: var(--cta-text-color, var(--sx-on-primary));
    font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2;
}
:where(.sx-btn:hover) { background: var(--cta-hover-bg-color, var(--sx-primary)); color: var(--cta-hover-text-color, var(--sx-on-primary)); }
:where(.sx-btn--ghost) { background: transparent; color: var(--sx-primary); border-color: currentColor; }
:where(.sx-btn--ghost:hover) { background: var(--sx-primary); color: var(--sx-on-primary); }
:where(.sx-btn--block) { width: 100%; }
:where(.sx-link) { color: var(--sx-primary); font-weight: 600; text-decoration: none; }
:where(.sx-link:hover) { text-decoration: underline; }

/* Detail layout: main column + aside */
:where(.sx-layout) { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 992px) {
    :where(.sx-layout) { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
}
:where(.sx-panel) { background: var(--sx-surface); border: 1px solid var(--sx-border); border-radius: var(--sx-radius); padding: 1.25rem 1.5rem; }
:where(.sx-panel--soft) { background: var(--sx-soft); }
:where(.sx-panel + .sx-panel) { margin-top: 1.25rem; }
:where(.sx-hero-media) { border-radius: var(--sx-radius); overflow: hidden; margin-bottom: 1.5rem; }
:where(.sx-hero-media img) { width: 100%; max-height: 460px; object-fit: cover; }

/* Definition list (label / value rows) */
:where(.sx-dl) { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
:where(.sx-dl > div) { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--sx-border); }
:where(.sx-dl > div:last-child) { border-bottom: 0; }
:where(.sx-dl dt) { color: var(--sx-muted); font-weight: 500; }
:where(.sx-dl dd) { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* Rich text */
:where(.sx-prose) { line-height: 1.7; overflow-wrap: anywhere; }
:where(.sx-prose img) { border-radius: var(--sx-radius); }
:where(.sx-prose table) { width: 100%; border-collapse: collapse; }
:where(.sx-prose td, .sx-prose th) { border: 1px solid var(--sx-border); padding: .5rem; }

/* Tags */
:where(.sx-tags) { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }

/* Horizontal scroll gallery (no JS) */
:where(.sx-gallery) { display: grid; grid-auto-flow: column; grid-auto-columns: min(85%, 520px); gap: 1rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .5rem; }
:where(.sx-gallery figure) { margin: 0; scroll-snap-align: start; }
:where(.sx-gallery img) { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--sx-radius); }
:where(.sx-gallery figcaption) { font-size: .9rem; color: var(--sx-muted); padding-top: .4rem; }

/* Tables */
:where(.sx-table-wrap) { overflow-x: auto; border: 1px solid var(--sx-border); border-radius: var(--sx-radius); }
:where(.sx-table) { width: 100%; border-collapse: collapse; background: var(--sx-surface); }
:where(.sx-table th, .sx-table td) { padding: .75rem 1rem; border-bottom: 1px solid var(--sx-border); text-align: left; vertical-align: top; }
:where(.sx-table thead th) { background: var(--sx-soft); font-weight: 700; white-space: nowrap; }
:where(.sx-table tbody tr:last-child td) { border-bottom: 0; }

/* Forms */
:where(.sx-form) { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) {
    :where(.sx-form--2col) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    :where(.sx-form--2col .sx-field--full, .sx-form--2col .sx-form__actions, .sx-form--2col .sx-alert) { grid-column: 1 / -1; }
}
:where(.sx-field) { display: flex; flex-direction: column; gap: .35rem; }
:where(.sx-field label) { font-weight: 600; font-size: .9rem; }
:where(.sx-field input, .sx-field select, .sx-field textarea) {
    width: 100%; padding: .65rem .8rem; border: 1px solid var(--sx-border); border-radius: var(--sx-radius);
    background: var(--sx-surface); color: var(--sx-text); font: inherit;
}
:where(.sx-field input:focus, .sx-field select:focus, .sx-field textarea:focus) { outline: 2px solid var(--sx-primary); outline-offset: 1px; border-color: var(--sx-primary); }
:where(.sx-field__error) { color: #a12727; font-size: .85rem; }
:where(.sx-field__hint) { color: var(--sx-muted); font-size: .85rem; }
:where(.sx-required) { color: #a12727; }
:where(.sx-check) { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
:where(.sx-check input) { width: auto; margin-top: .25rem; }

/* Alerts and empty state */
:where(.sx-alert) { padding: .85rem 1rem; border-radius: var(--sx-radius); border: 1px solid var(--sx-border); background: var(--sx-soft); margin-bottom: 1rem; }
:where(.sx-alert--success) { background: #e7f6ec; border-color: #b9e3c7; color: #17663a; }
:where(.sx-alert--error) { background: #fdecec; border-color: #f3c2c2; color: #a12727; }
:where(.sx-empty) { text-align: center; padding: 3rem 1rem; border: 1px dashed var(--sx-border); border-radius: var(--sx-radius); color: var(--sx-muted); }
:where(.sx-empty h3) { color: var(--sx-text); margin: 0 0 .5rem; }

/* Pagination */
:where(.sx-pagination) { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; margin: 2rem 0 0; padding: 0; list-style: none; }
:where(.sx-pagination a, .sx-pagination span) {
    display: inline-flex; min-width: 2.4rem; height: 2.4rem; align-items: center; justify-content: center; padding: 0 .6rem;
    border: 1px solid var(--sx-border); border-radius: var(--sx-radius); color: var(--sx-text); text-decoration: none; background: var(--sx-surface);
}
:where(.sx-pagination a:hover) { border-color: var(--sx-primary); color: var(--sx-primary); }
:where(.sx-pagination [aria-current="page"]) { background: var(--sx-primary); border-color: var(--sx-primary); color: var(--sx-on-primary); }
:where(.sx-pagination .is-disabled) { opacity: .45; }

/* Steps (numbered process) */
:where(.sx-steps) { counter-reset: sx-step; display: grid; gap: 1rem; margin: 0; padding: 0; list-style: none; }
:where(.sx-steps > li) { counter-increment: sx-step; position: relative; padding: 1rem 1rem 1rem 3.5rem; border: 1px solid var(--sx-border); border-radius: var(--sx-radius); background: var(--sx-surface); }
:where(.sx-steps > li)::before {
    content: counter(sx-step); position: absolute; left: 1rem; top: 1rem; width: 1.8rem; height: 1.8rem; border-radius: 50%;
    display: grid; place-items: center; background: var(--sx-primary); color: var(--sx-on-primary); font-weight: 700; font-size: .85rem;
}

/* Sub-navigation (e.g. admission pages) */
:where(.sx-subnav) { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 2rem; padding: 0; list-style: none; }
:where(.sx-subnav a) { display: block; padding: .5rem .9rem; border-radius: var(--sx-radius); border: 1px solid var(--sx-border); color: var(--sx-text); text-decoration: none; font-weight: 600; font-size: .9rem; }
:where(.sx-subnav a[aria-current="page"]) { background: var(--sx-primary); border-color: var(--sx-primary); color: var(--sx-on-primary); }

/* Person / logo tiles */
:where(.sx-avatar) { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: var(--sx-soft); }
:where(.sx-logo) { max-height: 64px; width: auto; object-fit: contain; }

/* Notice ticker */
:where(.sx-ticker) { position: relative; display: flex; align-items: center; gap: 1rem; padding: .5rem 3rem .5rem 16px; background: var(--sx-primary, var(--primary-color)); color: var(--sx-on-primary, #fff); overflow: hidden; font-size: .9rem; }
:where(.sx-ticker__label) { font-weight: 700; white-space: nowrap; }
:where(.sx-ticker__track) { display: flex; gap: 2.5rem; overflow-x: auto; scrollbar-width: none; margin: 0; padding: 0; list-style: none; white-space: nowrap; }
:where(.sx-ticker a) { color: inherit; }
:where(.sx-ticker .sx-dialog__close) { top: 50%; transform: translateY(-50%); width: 1.75rem; height: 1.75rem; font-size: 1rem; }

/* Splash dialog */
:where(.sx-dialog) { border: 0; padding: 0; border-radius: var(--border-radius, 8px); width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; color: var(--text-color, #1f2937); background: var(--surface-color, #fff); }
:where(.sx-dialog)::backdrop { background: rgb(0 0 0 / .55); }
:where(.sx-dialog__media img) { width: 100%; max-height: 320px; object-fit: cover; display: block; }
:where(.sx-dialog__body) { padding: 1.5rem; display: grid; gap: .75rem; }
:where(.sx-dialog__close) { position: absolute; top: .5rem; right: .5rem; width: 2.25rem; height: 2.25rem; border: 0; border-radius: 50%; background: rgb(0 0 0 / .55); color: #fff; font-size: 1.25rem; line-height: 1; cursor: pointer; }

:where(.sx-visually-hidden) { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Inner-page banner (themes/base/custom/inner-page-banner) */
:where(.sx-banner) { position: relative; overflow: hidden; padding: clamp(2.5rem, 7vw, 5rem) 0; background: var(--primary-color, #1d4ed8); color: var(--primary-contrast-color, #fff); }
:where(.sx-banner__image) { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .35; }
:where(.sx-banner .sx-container) { position: relative; }
:where(.sx-banner__title) { margin: 0; font-family: var(--header-font-family, inherit); font-size: clamp(1.75rem, 4vw, 2.75rem); color: inherit; }

/* ── UI kit fallbacks (themes/base/ui/*) ───────────────────────────────── */
:where(.sx-ui-page) { padding-block: 3rem 4.5rem; }
:where(.sx-ui-section) { padding-block: 4rem; }
:where(.sx-accordion) { max-width: 860px; margin-inline: auto; display: grid; gap: .75rem; }
:where(.sx-accordion__item) { background: var(--sx-surface); border: 1px solid var(--sx-border); border-radius: var(--sx-radius); overflow: hidden; }
:where(.sx-accordion__title) { cursor: pointer; list-style: none; font-weight: 700; padding: 1rem 3rem 1rem 1.25rem; position: relative; color: var(--sx-text); }
:where(.sx-accordion__title)::-webkit-details-marker { display: none; }
:where(.sx-accordion__title)::after { content: "+"; position: absolute; right: 1.25rem; top: 50%; transform: translateY(-50%); color: var(--sx-primary); font-weight: 800; font-size: 1.2rem; }
:where(.sx-accordion__item[open] > .sx-accordion__title)::after { content: "\2212"; }
:where(.sx-accordion__item[open] > .sx-accordion__title) { color: var(--sx-primary); }
:where(.sx-accordion__body) { border-top: 1px solid var(--sx-border); color: var(--sx-muted); padding: 1rem 1.25rem 1.25rem; }

/* ── UI kit layout helpers, shared by every theme (no colours: the theme kits style the components) ── */
.ui-group + .ui-group { margin-top: 2.5rem; }
.ui-group__title { margin: 0 0 1.25rem; text-align: center; }
.ui-actions { margin-top: 2.5rem; text-align: center; }
