/* Reset, element defaults, focus and forced-colors rules (visual direction › Where things live). Tokens only. */

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

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

body {
    margin: 0;
    min-height: 100vh;
    background: var(--surface-chrome);
    color: var(--text-primary);
}

h1,
h2,
h3,
p {
    margin: 0;
}

/* Links in running text are underlined, so color isn't the only signal (visual direction › Accessibility). */
a {
    color: var(--text-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

button,
input,
textarea,
select {
    font: inherit;
    color: inherit;
}

/* Visible keyboard focus everywhere. Never remove it. */
:focus-visible {
    outline: var(--focus-ring) solid var(--stroke-focus);
    outline-offset: 2px;
}

/* Inputs (visual direction › Inputs), set by the field components. A global class, because Blazor's input
   components render the element itself. */
.input {
    inline-size: 100%;
    min-height: var(--control-height);
    padding: 0 var(--space-3);
    background: var(--layer-content);
    border: var(--stroke-thickness) solid var(--stroke-control);
    border-radius: var(--radius-control);
}

textarea.input {
    min-height: var(--textarea-min-height);
    padding-block: var(--space-2);
    resize: vertical;
}

/* Chromium pads a select's text by another space-1, so take it off ours to line up with text fields. */
select.input {
    padding-inline-start: calc(var(--space-3) - var(--space-1));
}

/* Dates and times keep the browser's natural width rather than filling the form column. */
.input.input-date {
    inline-size: auto;
    align-self: flex-start;
}

.input::placeholder {
    color: var(--text-placeholder);
}

/* A 2px ring with no layout shift: the border plus a 1px outline. Never box-shadow (contrast themes drop it). */
.input:focus-visible {
    border-color: var(--stroke-focus);
    outline: 1px solid var(--stroke-focus);
    outline-offset: 0;
}

.input[aria-invalid="true"]:not(:focus-visible) {
    border-color: var(--danger-text);
}

.input:disabled {
    background: var(--fill-subtle);
    border-color: var(--stroke-subtle);
    color: var(--text-disabled);
    cursor: not-allowed;
}

/* Checkboxes and radios (visual direction › Selection controls): native controls in the accent, with the label as
   part of the target. */
.check-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--control-height);
    cursor: pointer;
}

.check-input {
    flex: none;
    inline-size: var(--icon-size);
    block-size: var(--icon-size);
    margin: 0;
    accent-color: var(--accent-fill);
    cursor: inherit;
}

.check-label:has(.check-input:disabled) {
    color: var(--text-disabled);
    cursor: not-allowed;
}

.check-input[aria-invalid="true"]:not(:focus-visible) {
    outline: 1px solid var(--danger-text);
    outline-offset: 1px;
}

/* Buttons (visual direction › Buttons). Global, because Button, IconButton and the Menu trigger all render them. */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-height);
    padding: 0 var(--space-3);
    border: var(--stroke-thickness) solid transparent;
    border-radius: var(--radius-control);
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-out);
}

.button:disabled {
    background: var(--fill-subtle);
    color: var(--text-disabled);
    border-color: transparent;
    cursor: not-allowed;
}

.button-primary {
    background: var(--accent-fill);
    color: var(--text-on-accent);
}

.button-primary:hover:not(:disabled) {
    background: var(--accent-fill-hover);
}

.button-primary:active:not(:disabled) {
    background: var(--accent-fill-pressed);
}

.button-secondary {
    background: var(--layer-content);
    color: var(--text-primary);
    border-color: var(--stroke-subtle);
}

.button-secondary:hover:not(:disabled),
.button-subtle:hover:not(:disabled) {
    background: var(--fill-subtle);
}

.button-secondary:active:not(:disabled),
.button-subtle:active:not(:disabled) {
    background: var(--fill-subtle-pressed);
}

.button-subtle {
    background: transparent;
    color: var(--text-primary);
}

.button-danger {
    background: var(--danger-fill);
    color: var(--text-on-danger);
}

@media (forced-colors: active) {
    .button {
        border-color: ButtonText;
    }
}

/* Icon-only: 32x32 (IconButton, icon-only Menu). */
.button-icon {
    inline-size: var(--control-height);
    padding: 0;
}

/* Brand (BrandMark, BrandLockup). Global, not scoped: the host serves a fixed copy of the lockup on the start-up screen
   (wwwroot/brands/{brand}/lockup.html), which can't carry scoped-CSS attributes (P3 review F1). */
.brand-lockup {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: var(--text-primary);
}

.brand-mark {
    flex: none;
    display: block;
}

.brand-mark-bar {
    fill: var(--logo-accent);
}

/* Brand logos are the one place forced colours may be turned off (visual direction › Accessibility), so the bar keeps
   the brand colour. The ink is set to the forced text colour itself: with forcing off, currentColor would be the app
   theme's TextPrimary, which vanishes when the contrast theme and the app theme differ (P3 review F5). */
@media (forced-colors: active) {
    .brand-mark {
        forced-color-adjust: none;
        color: CanvasText;
    }
}

.muted {
    color: var(--text-secondary);
}

.prose {
    max-inline-size: 80ch;
}

.visually-hidden {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    padding: var(--space-2) var(--space-4);
    background: var(--danger-subtle);
    color: var(--danger-text);
}

#blazor-error-ui .dismiss {
    float: right;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
}

@media (forced-colors: active) {
    :focus-visible {
        outline-color: Highlight;
    }
}
