/* Site chrome on top of the MudBlazor theme (Styling/Theme.cs). Kept small on purpose:
   the theme carries the design tokens, this file only styles what MudBlazor cannot. */

html, body {
    margin: 0;
    font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
}

code, pre, .mono {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* The layouts stamp .theme-dark from the MudThemeProvider's mode — MudBlazor sets no class
   of its own — so anything defined here flips with the palette. */
:root, .theme-light {
    --link-colour: var(--mud-palette-primary);
    --code-bg: #F1EEF6;
    --code-border: #E4DFEC;
    --code-text: #3F3947;
}

.theme-dark {
    --link-colour: var(--mud-palette-primary-lighten);
    --code-bg: #302940;
    --code-border: #3F374F;
    --code-text: #CDB6E8;
}

/* Dark mode splits the accent: filled surfaces keep the primary with white text, while text
   and links take the lighter tint, which is the only one that clears AA on the dark canvas.
   Light mode uses the one colour for both. */
.mud-link.mud-primary-text {
    color: var(--link-colour);
}

/* The app bar sits flush against the content; the hairline does the separating. */
.app-bar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

/* The rail is dark in both themes, so its hairline is a light one either way. */
.nav-rail {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-brand {
    padding: 16px 18px 8px;
}

.nav-home {
    text-decoration: none;
}

.nav-wordmark {
    color: var(--mud-palette-drawer-text);
    letter-spacing: -0.02em;
}

/* Dark mode: the 1px border carries card separation, so shadows do nothing here. */
.theme-dark .mud-elevation-1,
.theme-dark .mud-paper {
    box-shadow: none;
}

.app-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: #605968;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0.6rem 1.25rem;
    background: #FFF4CE;
    color: #241B2E;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Inline code in rendered markdown. The class is put on by the editor's highlight style, so
   this is what makes `a value` read as one rather than as ordinary prose. */
code,
.cm-inline-code {
    color: var(--code-text);
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 0.87em;
}

/* An earlier step's output quoted in the text: coloured so it reads as a value, not prose. The
   link colour, because in dark mode it is the tint of the accent that clears AA. */
.output-reference {
    color: var(--link-colour);
    font-weight: 500;
}

/* The warning colour is too light to read as text, so it underlines the word instead. */
.output-reference.missing {
    color: var(--mud-palette-text-secondary);
    text-decoration: underline wavy var(--mud-palette-warning);
}

/* A read-only markdown field is a rendered document, not an input: no minimum height reserving
   space under a one-line purpose, and no padding pushing it out of line with the text around it. */
.md-editor.mud-input-control .mud-input-slot {
    min-height: 0;
}

/* The markdown field's formatting buttons: a quiet row above the text, separated by a hairline
   rather than a box, so the field still reads as one thing. */
.md-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    margin: -4px 0 6px -6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

/* The figures on the status page: a row of tiles, each edged in what its number means. */
.status-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.status-tile {
    border-left-width: 3px;
}

/* A verdict per pip: a test's recent runs. Narrow enough that twelve sit in a table cell. */
.verdict-strip {
    display: inline-flex;
    gap: 2px;
    align-items: center;
    vertical-align: middle;
}

.verdict-pip {
    width: 9px;
    height: 18px;
    border-radius: 2px;
}

/* A run's steps, the way GitHub draws contributions: a column per test, a square per step,
   columns top-aligned so the first steps line up. */
.verdict-grid {
    display: inline-flex;
    gap: 3px;
    align-items: flex-start;
    vertical-align: middle;
}

.verdict-grid-column {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.verdict-square {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* Field widths. A form reads better when a box is the size of the answer it wants, so only
   prose fields — a purpose, an instruction — take the full width; everything else is capped
   and falls back to full width on a narrow screen, where there is nothing to gain. */
.field-narrow {
    max-width: 220px;
}

.field-medium {
    max-width: 320px;
}

.field-wide {
    max-width: 480px;
}

@media (max-width: 600px) {
    .field-narrow,
    .field-medium,
    .field-wide {
        max-width: none;
    }
}

/* The run page: the tests listed down the side to jump between, beside the run itself. The list
   only earns its space on a wide screen; on a narrow one the page simply scrolls. */
.run-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.run-nav {
    display: none;
}

@media (min-width: 960px) {
    .run-layout:has(.run-nav) {
        grid-template-columns: 260px minmax(0, 1fr);
    }

    .run-nav {
        display: block;
        position: sticky;
        top: 80px;
        align-self: start;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        /* A status spinner's turning box pokes past the edge; the list only ever scrolls down. */
        overflow-x: hidden;
    }
}

/* In line with the item text, which sits clear of the bar. */
.run-nav-heading {
    padding: 0 0 8px 14px;
}

.run-nav-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.run-nav-status {
    flex: none;
    display: inline-flex;
}

/* ContentNavigation: a bar beside the list slides to the section scrolled to, as MudTabs'
   slider does between tabs. */
/* Going to a section glides there rather than jumping, on the pages that have the list. */
html:has(.content-navigation) {
    scroll-behavior: smooth;
}

.content-navigation-track {
    position: relative;
}

.content-navigation-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.content-navigation-indicator {
    position: absolute;
    left: 0;
    width: 3px;
    border-radius: 2px;
    background: var(--mud-palette-primary);
    transition: top .3s cubic-bezier(.64, .09, .08, 1), height .3s cubic-bezier(.64, .09, .08, 1);
}

.content-navigation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 0 6px 14px;
    border: 0;
    border-radius: 0 4px 4px 0;
    background: none;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: 0.84375rem;
    text-align: left;
    cursor: pointer;
}

.content-navigation-item:hover {
    background: var(--mud-palette-action-default-hover);
}

.content-navigation-item.current {
    color: var(--mud-palette-text-primary);
    font-weight: 600;
}

.content-navigation-item:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}

/* Name and value pairs — a run's details, a step's checks, inputs and outputs: names in one column,
   values in the next, so the values line up without a table's borders. */
.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    align-items: center;
    column-gap: 8px;
    row-gap: 2px;
    margin: 0;
    font-size: 0.875rem;
}

.facts dt {
    color: var(--mud-palette-text-secondary);
}

.facts dd {
    margin: 0;
    min-width: 0;
}

/* A value written in markdown is drawn by a read-only input, which brings an input's padding and
   the body text's size; in the list it takes the list's, so its row is no taller than the name. */
.facts dd .mud-input-slot,
.facts dd .cm-md-block {
    padding: 0;
}

.facts dd .mud-input,
.facts dd .cm-content {
    font-size: inherit;
    line-height: 1.6;
}

/* Clear of the app bar when the list scrolls a test into view. */
.run-test {
    scroll-margin-top: 80px;
}

/* The active step — waiting on a person, or being worked on by the engine — carries a bar down its
   left side in its status's colour, set by the step. */
.run-step {
    position: relative;
    overflow: hidden;
}

/* An accordion's header is clickable, so it greys on hover the way a clickable table row does. */
.mud-expand-panel-header:hover {
    background: var(--mud-palette-table-hover);
}

/* Square, because the steps sit inside their test's paper, and a rounded panel clips the bar. */
.run-test .mud-expansion-panels,
.run-test .run-step {
    border-radius: 0;
}

.run-step.active::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 3px;
    background: var(--run-step-accent);
}

/* In Progress spins inside its chip, sized to the text rather than the default spinner. */
.status-chip-spinner {
    width: 12px !important;
    height: 12px !important;
}

/* A status pill shrunk to a circle: the glyph in the colour's contrast text on the colour. */
.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.status-icon-glyph {
    font-size: 12px !important;
}

.status-icon-spinner {
    width: 10px !important;
    height: 10px !important;
}

/* A deactivated tag, still shown where it was used. Greyed, and dashed so it is not told apart
   by shade alone. */
.mud-chip.tag-deactivated {
    opacity: 0.6;
    border-style: dashed;
}

.tag-category-deactivated {
    border-style: dashed;
}

/* A step a reload has just changed, so the eye finds what changed. */
.step-changed {
    animation: step-changed 2s ease-out;
}

@keyframes step-changed {
    from { box-shadow: 0 0 0 2px var(--mud-palette-primary); }
    to { box-shadow: 0 0 0 2px transparent; }
}
