/*
 * Base layer + shared components (FR-UX-001).
 * Feature-specific CSS lives in wwwroot/css/<feature>.css and is included per page.
 * Everything here consumes tokens.css — no literal colours.
 */

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

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

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4 {
    line-height: var(--leading-tight);
    margin: 0 0 var(--space-3);
    font-weight: 650;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

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

a {
    color: var(--color-accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

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

/* NFR-ACC-001: focus must always be visible, on every interactive element. */
:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
    border-radius: var(--radius-sm);
}

code, pre { font-family: var(--font-mono); font-size: var(--text-sm); }

/* --- Layout --------------------------------------------------------------- */

.layout-container {
    width: 100%;
    max-width: var(--layout-max);
    margin-inline: auto;
    padding-inline: var(--space-4);
}

.site-main {
    flex: 1;
    padding-block: var(--space-6);
}

.site-header {
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-surface);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 3.5rem;
}

.site-header__brand {
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--color-text);
    text-decoration: none;
}

.site-footer {
    border-top: 1px solid var(--color-border);
    background-color: var(--color-bg-subtle);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    padding-block: var(--space-5);
}

/* NFR-ACC-001: keyboard users get a skip link before the nav. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: var(--space-2) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    z-index: 100;
}

.skip-link:focus {
    left: var(--space-4);
    top: var(--space-2);
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    /* NFR-ACC-002: 44px min target — the Assembly phase is used at a workbench. */
    min-height: 2.75rem;
    padding: var(--space-2) var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font: inherit;
    font-weight: 550;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.btn--primary {
    background-color: var(--color-accent);
    color: var(--color-text-inverse);
}

.btn--primary:hover {
    background-color: var(--color-accent-hover);
    color: var(--color-text-inverse);
}

.btn--secondary {
    background-color: var(--color-surface);
    border-color: var(--color-border-strong);
    color: var(--color-text);
}

.btn--secondary:hover { background-color: var(--color-bg-subtle); }

.btn[disabled],
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
}

/* --- Cards ---------------------------------------------------------------- */

.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}

.card__title { margin-bottom: var(--space-2); }

.card__meta {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.card-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
}

/* --- Status cues ---------------------------------------------------------- */
/* NFR-ACC-001: colour is never the only cue — each badge pairs colour with an icon
   glyph and a text label supplied in the markup. */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 600;
}

.badge--success { background: var(--color-success-subtle); color: var(--color-success); }
.badge--warning { background: var(--color-warning-subtle); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-subtle);  color: var(--color-danger); }
.badge--neutral { background: var(--color-bg-subtle);      color: var(--color-text-muted); }

/* --- Utilities ------------------------------------------------------------ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.stack > * + * { margin-top: var(--space-4); }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: var(--text-sm); }

/* --- Header navigation ---------------------------------------------------- */
/* Account chrome (FR-AUTH-006, AU-005). Marked up as a list so a screen reader
   announces how many destinations there are; the bullets are removed, the
   semantics are not. */

.site-nav {
    margin-inline-start: auto;
}

.site-nav__list {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav__link {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 550;
    /* NFR-ACC-002: the same 44px target the buttons use, so the header is usable
       on a phone at a workbench. */
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
}

.site-nav__link:hover,
.site-nav__link:focus-visible {
    color: var(--color-text);
    text-decoration: underline;
}

/* Sign-out has to be a form button, and it has to look like its neighbours. */
.site-nav__link--button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-weight: 550;
    cursor: pointer;
}

/* AD-SYS-003 maintenance banner. Full-bleed and above the header so it cannot be mistaken for
   page content, and legible without perceiving its colour — the message itself carries the
   meaning (NFR-ACC-001). */
.maintenance-banner {
    margin: 0;
    padding: var(--space-3) var(--space-4);
    background: var(--color-warning-subtle);
    border-bottom: 2px solid var(--color-warning);
    color: var(--color-text);
    text-align: center;
    font-weight: 600;
}

/* Two-factor enrolment QR (FR-AUTH-005). The SVG is drawn server-side and sized here rather than
   with width/height attributes, so it scales with the reader's zoom instead of fighting it. The
   white plate is not decoration — a QR scanned off a dark-theme page fails without it. */
.auth__qr {
    display: inline-block;
    padding: var(--space-3);
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.auth__qr svg {
    display: block;
    inline-size: min(14rem, 60vw);
    block-size: auto;
}

.auth__shared-key code {
    font-size: var(--text-lg);
    letter-spacing: 0.08em;
}
