/* ============================================================
   BASE: reset, element defaults, focus, utilities
   Replaces Bootstrap. Only what this app actually needs.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html {
    color-scheme: dark;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-md);
    line-height: var(--leading-body);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    /* Backstop: a single mis-sized child must not drag the page into
       horizontal scroll on narrow screens. */
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-3);
    font-family: var(--font-display);
    line-height: var(--leading-snug);
    color: var(--color-text-strong);
    text-wrap: balance;
}

p { margin: 0 0 var(--space-4); text-wrap: pretty; }
ul, ol { margin: 0 0 var(--space-4); padding-left: 1.25rem; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; vertical-align: middle; }
code { font-family: var(--font-mono); font-size: 0.9em; color: var(--color-accent-soft); }
small { font-size: var(--text-xs); }

table { border-collapse: collapse; }
th { text-align: left; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
    margin: 0;
}
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
label { display: inline-block; }

::selection { background: var(--color-accent); color: var(--color-text-on-accent); }

/* Blazor's FocusOnNavigate focuses the page <h1> on every navigation for
   screen readers. Suppress the box that creates; it is not a real focus state. */
h1:focus, main:focus { outline: none; }

/* Keyboard focus. Mouse and touch users never see it. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 3px;
}

/* ---- Accessibility helpers ---- */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: var(--space-2);
    left: var(--space-2);
    z-index: var(--z-error);
    padding: var(--space-2) var(--space-4);
    background: var(--color-accent);
    color: var(--color-text-on-accent);
    border-radius: var(--radius-sm);
    font-weight: 600;
    transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---- Layout primitives ---- */
.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--gutter);
}
.field-row { display: flex; gap: var(--space-4); }
.field-row > * { flex: 1; min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---- Text utilities ---- */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-subtle { color: var(--color-text-subtle); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger-text); }
.inline-icon { vertical-align: -1px; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.break-all { word-break: break-all; }
.list-plain { list-style: none; padding: 0; margin: 0; }

/* ---- Spacing utilities (token scale only) ---- */
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

/* ---- Blazor framework states ---- */
.validation-message,
.validation-errors { color: var(--color-danger-text); font-size: var(--text-sm); }
.validation-errors { list-style: none; padding: 0; margin: 0; }
.form-input.invalid { border-color: var(--color-danger); }

#blazor-error-ui {
    background: var(--ink-600);
    color: var(--color-text-strong);
    bottom: 0;
    box-shadow: var(--shadow-up);
    display: none;
    padding: var(--space-3) var(--space-5);
    position: fixed;
    width: 100%;
    z-index: var(--z-error);
}
#blazor-error-ui .reload { text-decoration: underline; margin-left: var(--space-2); }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: var(--space-3); top: var(--space-2); }

/* ---- Motion ---- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
