/* ==========================================================================
   HomeRP base stylesheet (#78)
   ==========================================================================

   Loaded after the vendored Bootstrap and before the design-system layers.
   Its job is narrow: normalise the document, set the type system from the
   tokens, and style the two pieces of chrome Blazor itself owns (the boot
   loader and the unhandled-error bar). Page and component patterns live in
   ui.css (#80), data display in datadisplay.css (#81) and forms in forms.css
   (#82); the anonymous shell in anonymous.css (#83).

   Rule: no colour, radius or spacing literal in this file — only tokens.
   ========================================================================== */

/* --- document ------------------------------------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: var(--fs-root);
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-md);
    line-height: var(--leading);
    color: var(--ink);
    background-color: var(--bg);
}

/* --- typography ---------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-3);
    color: var(--heading);
    font-weight: var(--heading-weight);
    letter-spacing: var(--heading-tracking);
    line-height: 1.25;
}

/* The display face is Fraunces, and only for headings and figures — never body,
   labels, table cells, badges or inputs (#104). h4–h6 stay in the body face: they
   are used as small section labels, not as display type. */
h1, h2, h3 {
    font-family: var(--font-display);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4, h5, h6 { font-size: var(--fs-md); }

p {
    margin: 0 0 var(--space-4);
}

small {
    font-size: var(--fs-sm);
}

strong, b {
    font-weight: var(--fw-semibold);
    color: var(--heading);
}

code, kbd, samp {
    font-family: var(--font-mono);
    /* was .92em — 13.8px against the 15px body, i.e. under the 14px floor (#104) */
    font-size: var(--fs-sm);
    color: var(--accent);
    background: var(--accent-soft);
    padding: .1rem .35rem;
    border-radius: var(--r-sm);
}

pre code {
    display: block;
    padding: var(--space-3);
    overflow-x: auto;
    background: var(--accent-soft);
}

/* --- links --------------------------------------------------------------- */
a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* --- focus --------------------------------------------------------------- */
/* One visible focus treatment, keyboard-only, for every interactive element. */
:focus-visible {
    outline: var(--focus-width) solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

h1:focus {
    outline: none;
}

/* --- selection ----------------------------------------------------------- */
::selection {
    background: var(--accent-soft);
    color: var(--heading);
}

/* --- form validation (Blazor InputBase) ---------------------------------- */
/* InputText/ValidationMessage are given these classes by EditContext. */
.validation-message {
    color: var(--danger);
    font-size: var(--fs-sm);
    margin-top: var(--space-1);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--pos);
}

.invalid {
    outline: 1px solid var(--danger);
}

/* --- Blazor boot loader -------------------------------------------------- */
.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--line);
        stroke-width: .6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--accent);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
            transition: stroke-dasharray .05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: var(--fw-semibold);
    color: var(--muted);
    inset: calc(20vh + 3.25rem) 0 auto .2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

/* --- Blazor unhandled-error bar ------------------------------------------ */
#blazor-error-ui {
    color-scheme: light only;
    background: var(--warn-bg);
    color: var(--ink);
    bottom: 0;
    box-shadow: var(--elev-2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: var(--space-3) var(--space-5);
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: var(--space-3);
        top: var(--space-2);
    }

/* --- skip link (#84) ----------------------------------------------------- */
/* Off-screen until focused, then pinned to the top-left so a keyboard user can
   jump straight past the navigation to the page content. */
.skip-link {
    position: absolute;
    left: var(--space-2);
    top: -4rem;
    z-index: 2000;
    padding: .5rem .8rem;
    /* The tap-target floor (#110): it is the first focusable element, and at 38.5px the
       measurement in docs/ui-design/qa.py flagged it. */
    display: inline-flex;
    align-items: center;
    min-height: var(--ctl-h);
    border-radius: var(--r-ctl);
    background: var(--accent);
    color: var(--on-accent);
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    text-decoration: none;
    transition: top .15s ease;
}

    .skip-link:focus {
        top: var(--space-2);
        color: var(--on-accent);
        text-decoration: none;
    }

/* --- motion preferences -------------------------------------------------- */
/* Essential animation (the boot spinner, the sidebar drawer) is reduced to an
   imperceptible duration rather than removed, so nothing depends on a
   transition having completed. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
