/* Precision Codex Base Layer — Safe Layout, Focus, Select Normalization, Reduced Motion */

html,
body {
    overflow-x: clip;
    width: 100%;
    font-family: var(--font-body);
    color: var(--color-ink);
    background-color: var(--color-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scrollbar-color: var(--app-scrollbar-thumb) var(--app-scrollbar-track);
    scrollbar-width: thin;
}

h1,
h2,
h3,
h4,
h5,
h6,
.page-heading,
.card-title {
    font-family: var(--font-heading);
    letter-spacing: -0.015em;
    font-weight: 700;
    color: var(--color-ink);
    text-wrap: balance;
    overflow-wrap: break-word;
    min-width: 0;
}

p {
    text-wrap: pretty;
}

/* Instant keyboard focus ring across all interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="tab"]:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* Eliminate double downward arrows on custom-styled native <select> elements */
select.form-select,
.form-select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-repeat: no-repeat !important;
}

select.form-select::-ms-expand,
.form-select::-ms-expand {
    display: none;
}

@supports selector(select::picker-icon) {
    select.form-select::picker-icon,
    .form-select::picker-icon {
        display: none !important;
    }
}

/* Themed text selection, caret, and tabular numerals */
input,
textarea,
[contenteditable="true"] {
    caret-color: var(--color-accent);
}

::selection {
    background-color: var(--color-selection-bg);
    color: var(--color-ink);
}

.table td,
.font-mono,
.lms-stat-grid,
.badge,
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Scrollbar Chrome */
@supports not (scrollbar-color: auto) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-track {
        background: var(--app-scrollbar-track);
    }

    ::-webkit-scrollbar-thumb {
        background: var(--app-scrollbar-thumb);
        border-radius: var(--radius-pill);
    }

    ::-webkit-scrollbar-thumb:hover {
        background: var(--app-scrollbar-thumb-hover);
    }
}

/* Disabled controls carry full three-channel semantics */
button:disabled,
[aria-disabled="true"],
.btn:disabled,
.btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Reduced motion global fallback */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
