/*
 * Hearthstead base layer (Roadmap/49 D2): a light modern reset and the
 * element defaults every page shares. Loaded right after css/tokens.css and
 * before the legacy stylesheets, so old page bodies keep their own rules;
 * everything here reads the tokens and follows the active theme.
 */

/* ---------- Safe areas (need viewport-fit=cover in the viewport meta) ---------- */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    accent-color: var(--accent);
    background: var(--bg);
    hanging-punctuation: first last;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

[hidden] {
    display: none !important;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    margin: 0;
    line-height: 1.25;
    text-wrap: balance;
}

p {
    margin: 0;
    text-wrap: pretty;
}

code, kbd, samp, pre {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: 1px 5px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: var(--radius-sm);
    background: var(--raised);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    line-height: var(--lh-xs);
    text-align: center;
}

/* Links written as plain prose; classed links style themselves. */
a:not([class]) {
    color: var(--accent-text);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
a:not([class]):hover {
    text-decoration-thickness: 2px;
}

/* ---------- Focus ---------- */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}
:focus:not(:focus-visible) {
    outline: none;
}

/* ---------- Selection ---------- */
::selection {
    background: color-mix(in srgb, var(--accent) 32%, transparent);
    color: var(--text);
}

/* ---------- Scrollbars: quiet, themed ---------- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar) transparent;
}
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
*::-webkit-scrollbar-track {
    background: transparent;
}
*::-webkit-scrollbar-thumb {
    background: var(--scrollbar);
    border: 2px solid transparent;
    border-radius: var(--radius-full);
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover);
    background-clip: padding-box;
}
*::-webkit-scrollbar-corner {
    background: transparent;
}

/* ---------- Phones: 16 px body; inputs never below 16 px (no focus zoom) ---------- */
@media (max-width: 767px) {
    body {
        font-size: var(--fs-base);
        line-height: var(--lh-base);
    }
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
    select,
    textarea {
        font-size: 16px;
    }
}

/* ---------- Screen-reader-only text ---------- */
.sr-only,
.hs-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Motion off when asked ---------- */
@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;
    }
}
