/*
 * Base — global reset layered on top of preflight.
 *
 * Loaded after preflight.css and tokens.css. Sets body colors, antialiasing,
 * typography defaults, and custom scrollbar.
 */

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

html.dark {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--color-foreground);
    background-color: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Default heading styles (preflight resets, we restore semantics) */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    color: var(--color-foreground);
    line-height: var(--leading-tight);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

a {
    color: inherit;
    text-decoration: none;
}

/* ─── Default focus-visible ring ───────────────────── */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-ring);
    border-radius: inherit;
}

/* ─── Selection ───────────────────────────────────── */
::selection {
    background-color: color-mix(in oklch, var(--color-primary) 20%, transparent);
    color: var(--color-foreground);
}

/* ─── Scrollbar ────────────────────────────────────── */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--color-muted-foreground);
    background-clip: padding-box;
}

/* ─── Form element defaults ───────────────────────── */
input, textarea, select, button {
    font: inherit;
    color: inherit;
}

input::placeholder,
textarea::placeholder {
    color: var(--color-muted-foreground);
    opacity: 1;
}

/* ─── Disabled state convention ───────────────────── */
:where([disabled], [aria-disabled="true"]) {
    cursor: not-allowed;
    opacity: 0.6;
}

/* ─── Image defaults ──────────────────────────────── */
img, svg, video, canvas {
    display: block;
    max-width: 100%;
}

/* ─── Reduced motion ──────────────────────────────── */
@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;
    }
}

/* ─── Print defaults ──────────────────────────────── */
@media print {
    body {
        color: #000;
        background: #fff;
    }
}
