/* Base styles built on css/tokens.css. Component styles follow with the component kit (ADR 00014). */

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

html, body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-size-md);
    line-height: var(--line-height);
}

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

:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-focus-ring);
    outline-offset: var(--focus-ring-offset);
}

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

.skip-link {
    position: absolute;
    left: var(--space-4);
    top: -100px;
    padding: var(--space-2) var(--space-4);
    background: var(--color-accent-primary);
    color: var(--color-on-accent);
    border-radius: var(--radius-pill);
    z-index: 1000;
}

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

/* Shell */

.console-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.console-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-6);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    border-bottom-left-radius: var(--radius-elbow);
}

.console-brand {
    font-family: var(--font-mono);
    letter-spacing: var(--letter-spacing-readout);
    text-transform: uppercase;
    color: var(--color-accent-primary);
}

.console-main {
    flex: 1;
    padding: var(--space-6);
    /* Keep content clear of the fixed status bar. */
    padding-bottom: calc(var(--space-6) + var(--status-bar-height));
}

.console-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-panel);
    padding: var(--space-6);
}

.readout {
    font-family: var(--font-mono);
    letter-spacing: var(--letter-spacing-readout);
    color: var(--color-text-muted);
}

.pill-button {
    font: inherit;
    padding: var(--space-2) var(--space-6);
    border: none;
    border-radius: var(--radius-pill);
    background: var(--color-accent-primary);
    color: var(--color-on-accent);
    cursor: pointer;
}

/* Status bar (Components/Layout/StatusBar.razor). State is never color alone: icon shape + text. */

.status-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900; /* below #blazor-error-ui */
    height: var(--status-bar-height);
    display: flex;
    align-items: center;
    gap: var(--space-6);
    padding: 0 var(--space-6);
    overflow: hidden;
    white-space: nowrap;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border-strong);
    border-top-left-radius: var(--radius-elbow);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
}

.status-bar__item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.status-bar__label {
    color: var(--color-accent-primary);
    letter-spacing: var(--letter-spacing-readout);
    text-transform: uppercase;
}

.status-bar__readout {
    color: var(--color-text);
    letter-spacing: var(--letter-spacing-readout);
}

/* Build readout gives way first on narrow screens (full value stays in its title). */
.status-bar__item--build {
    min-width: 0;
}

.status-bar__item--build .status-bar__readout {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Narrow screens: labels become screen-reader only so the readouts fit on one line. */
@media (max-width: 40rem) {
    .status-bar {
        gap: var(--space-3);
        padding: 0 var(--space-3);
        border-top-left-radius: var(--radius-panel);
    }

    .status-bar__label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }
}

.status-pill {
    --status-color: var(--color-unknown);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0 var(--space-3);
    border: 1px solid var(--status-color);
    border-radius: var(--radius-pill);
    background: var(--color-surface-raised);
    color: var(--color-text);
    letter-spacing: var(--letter-spacing-readout);
    text-transform: uppercase;
}

.status-pill__icon {
    flex: none;
    fill: none;
    stroke: var(--status-color);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.status-pill--online {
    --status-color: var(--color-success);
}

.status-pill--degraded {
    --status-color: var(--color-warning);
}

.status-pill--offline {
    --status-color: var(--color-danger);
}

.status-pill--unknown {
    --status-color: var(--color-unknown);
}

/* Blazor unhandled-error bar (shown by the framework) */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: var(--space-3) var(--space-6);
    background: var(--color-surface-raised);
    color: var(--color-text);
    border-top: 2px solid var(--color-danger);
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    float: right;
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
}

/* Reconnect dialog (Components/Layout/ReconnectModal.razor) */

#components-reconnect-modal {
    background: var(--color-surface-raised);
    color: var(--color-text);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-panel);
    padding: var(--space-6);
}

#components-reconnect-modal::backdrop {
    background: rgb(0 0 0 / 0.6);
}

.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible {
    display: block;
}
