/*
    Base layer (after tokens.css, before mud-overrides.css and the component CSS):
    font, document defaults, focus, utilities (.t-*), form conventions and the pre-Blazor screens.
    No colour values here: only var(--token).
*/

/* ---------- Font: Archivo, self-hosted (never from a third party) ---------- */
@font-face {
    font-family: "Archivo";
    src: url("../fonts/archivo-variable.woff2") format("woff2-variations"), url("../fonts/archivo-variable.woff2") format("woff2");
    font-weight: 400 800;
    font-stretch: 62% 125%;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Archivo";
    src: url("../fonts/archivo-variable-ext.woff2") format("woff2-variations"), url("../fonts/archivo-variable-ext.woff2") format("woff2");
    font-weight: 400 800;
    font-stretch: 62% 125%;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Metric-matched local fallback, so text does not jump when Archivo arrives (font-display: swap). */
@font-face {
    font-family: "Archivo Fallback";
    src: local("Segoe UI"), local("Arial");
    size-adjust: 104%;
    ascent-override: 84%;
    descent-override: 20%;
    line-gap-override: 0%;
}

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

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

html, body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    font-weight: var(--fw-regular);
    font-stretch: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4 {
    margin: 0;
    color: var(--ink);
}

a {
    color: var(--petrol);
}

/* No italic file is shipped: never let the browser synthesise one. */
em, i, cite, address {
    font-style: normal;
}

/* One focus style everywhere: 2px ring in the focus token. Never removed. */
:focus-visible {
    outline: var(--focus-width) solid var(--focus);
    outline-offset: var(--focus-offset);
}

[hidden] {
    display: none !important; /* the attribute must win over any display rule */
}

/* ---------- Skip link ---------- */
.skip-link {
    position: fixed;
    left: var(--space-3);
    top: var(--space-3);
    z-index: var(--z-skip);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--r-control);
    background: var(--petrol);
    color: var(--on-petrol);
    font-weight: var(--fw-medium);
    text-decoration: none;
    transform: translateY(-200%);
}

    .skip-link:focus-visible,
    .skip-link:focus {
        transform: none;
    }

/* ---------- Type utilities (pages never write font-stretch / font-variation-settings themselves) ---------- */
.t-hull {
    font-size: var(--fs-hull);
    font-weight: var(--fw-hull);
    font-stretch: var(--wdth-hull);
    letter-spacing: 0.005em;
    line-height: 1.05;
}

.t-title {
    font-size: var(--fs-title);
    font-weight: var(--fw-title);
    font-stretch: var(--wdth-title);
    letter-spacing: -0.005em;
    line-height: var(--lh-tight);
}

.t-brand {
    font-size: var(--fs-brand);
    font-weight: 750;
    font-stretch: var(--wdth-brand);
    letter-spacing: 0.01em;
}

.t-boat {
    font-weight: var(--fw-semibold);
    font-stretch: var(--wdth-boat);
}

.t-figure {
    font-size: var(--fs-figure);
    font-weight: var(--fw-bold);
    font-stretch: var(--wdth-figure);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.t-num {
    font-variant-numeric: tabular-nums;
    font-stretch: var(--wdth-num);
}

.t-muted {
    color: var(--ink-2);
}

.t-meta {
    color: var(--ink-3);
    font-size: var(--fs-caption);
}

.t-strong {
    font-weight: var(--fw-semibold);
}

.t-right {
    text-align: right;
}

.t-nowrap {
    white-space: nowrap;
}

.visually-hidden {
    position: absolute !important; /* must never be overridden by a component layout rule */
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Quiet text link (used in tables, lists, breadcrumbs) */
.link {
    color: var(--petrol);
    font-weight: var(--fw-medium);
    text-decoration: none;
    border-radius: 3px;
}

    .link:hover {
        text-decoration: underline;
    }

/* The same quiet link, as a button (an action in a row: "Downloaden", "Archiveren"). */
.link-button {
    appearance: none;
    background: none;
    border: 0;
    padding: 2px 4px;
    margin: 0;
    font: inherit;
    font-weight: var(--fw-medium);
    color: var(--petrol);
    cursor: pointer;
    border-radius: 3px;
}

    .link-button:hover:not(:disabled) {
        text-decoration: underline;
    }

    .link-button:disabled {
        color: var(--ink-3);
        cursor: default;
    }

/* ---------- Layout helpers ---------- */
.stack {
    display: grid;
    gap: var(--space-5);
    align-content: start;
}

.cols {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: 10px;
}

    .toolbar .toolbar-end {
        margin-left: auto;
        color: var(--ink-3);
        font-size: var(--fs-small);
    }

@media (max-width: 959.98px) {
    .cols {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Form conventions (see the vocabulary in the task-17c report) ---------- */
.form {
    display: grid;
    gap: var(--space-5);
    max-width: 760px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4) var(--space-5);
    align-items: start;
}

/* Plausibility hint under a number field (DecimalField WarnAbove): the warning tone, a live region that takes no height while empty. */
.field-hint {
    margin: 0;
    color: var(--warn);
    font-size: var(--fs-caption);
    font-weight: var(--fw-medium);
}

    .field-hint.is-shown {
        margin-top: 4px;
        animation: field-hint-in 160ms ease-out;
    }

@keyframes field-hint-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .field-hint.is-shown {
        animation: none;
    }
}

    .form-grid > .span-2 {
        grid-column: 1 / -1;
    }

.form-section-title {
    font-size: var(--fs-panel);
    font-weight: 650;
    margin: 0 0 var(--space-1);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: flex-end;
    padding-top: var(--space-4);
    border-top: 1px solid var(--line);
}

    .form-actions.is-sticky {
        position: sticky;
        bottom: 0;
        z-index: var(--z-sticky);
        background: var(--surface);
        padding: var(--space-3) var(--panel-x);
        margin: 0 calc(-1 * var(--panel-x)) calc(-1 * var(--panel-y));
        border-radius: 0 0 var(--r-panel) var(--r-panel);
    }

@media (max-width: 599.98px) {
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .form-actions {
        flex-direction: column-reverse;
    }

        .form-actions > * {
            width: 100%;
        }
}

/* ---------- Pre-Blazor screens (loading ring, boot failure, startup error) ---------- */
.loading-progress {
    position: absolute;
    display: block;
    width: 5rem;
    height: 5rem;
    inset: 22vh 0 auto 0;
    margin: 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--line);
        stroke-width: 0.4rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--petrol);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    color: var(--ink-2);
    inset: calc(22vh + 5.75rem) 0 auto 0;
}

    .loading-progress-text::after {
        content: var(--blazor-load-percentage-text, "Laden");
    }

/* The boot-failure box (index.html script) and the StartupError component share this look. */
.boot-box {
    max-width: 40rem;
    margin: 12vh auto 0;
    padding: var(--space-5) var(--space-6);
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-left: 4px solid var(--bad);
    border-radius: var(--r-panel);
    font-family: var(--font);
    line-height: var(--lh-body);
}

    .boot-box h1 {
        margin: 0 0 var(--space-3);
        font-size: 20px;
        font-weight: var(--fw-title);
        font-stretch: var(--wdth-title);
    }

    .boot-box p {
        margin: 0 0 var(--space-3);
    }

    .boot-box pre {
        white-space: pre-wrap;
        word-break: break-word;
        font-size: var(--fs-caption);
        color: var(--ink-2);
        background: var(--sunken);
        padding: var(--space-3);
        border-radius: var(--r-control);
    }

    .boot-box summary {
        cursor: pointer;
        color: var(--petrol);
        font-weight: var(--fw-medium);
    }

    .boot-box.is-slow {
        margin-top: 42vh;
        border-left-color: var(--warn);
    }

    .boot-box button {
        height: var(--control-height);
        padding: 0 14px;
        border-radius: var(--r-control);
        border: 1px solid var(--line-strong);
        background: var(--surface);
        font-weight: var(--fw-medium);
        cursor: pointer;
    }

@media (max-width: 599.98px) {
    .boot-box {
        margin-left: var(--space-4);
        margin-right: var(--space-4);
    }
}

#blazor-error-ui {
    background: var(--warn-soft);
    color: var(--ink);
    border-top: 1px solid var(--line-strong);
    bottom: 0;
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: var(--z-snackbar);
}

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

.blazor-error-boundary {
    background: var(--bad-soft);
    color: var(--ink);
    border: 1px solid var(--bad);
    border-radius: var(--r-control);
    padding: var(--space-3) var(--space-4);
}

    .blazor-error-boundary::after {
        content: "Er is een fout opgetreden.";
    }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important; /* overrides MudBlazor's own animations too */
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* A form that takes focus programmatically when it opens is not a visible keyboard stop itself. */
.form:focus {
    outline: none;
}

/* ---------- Relations and sales area ---------- */
.row-link {
    color: var(--ink);
    font-weight: var(--fw-medium);
    text-decoration: none;
    border-radius: 3px;
}

    .row-link:hover {
        text-decoration: underline;
    }

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    align-items: end;
}

    .filter-row > * {
        flex: 1 1 220px;
        min-width: 0;
    }

.relation-picker {
    display: grid;
    gap: 2px;
    justify-items: start;
}

    .relation-picker > :first-child {
        width: 100%;
    }

.bookkeeping {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
    align-items: center;
}

.line-form {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: var(--space-3);
    align-items: start;
}

@media (max-width: 599.98px) {
    .line-form {
        grid-template-columns: minmax(0, 1fr);
    }
}

.stack-sm {
    display: grid;
    gap: var(--space-3);
}

.form-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.aid {
    color: var(--ink-2);
    font-size: var(--fs-small);
}

.progress {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 0;
    list-style: none;
    margin: 0 0 var(--space-5);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    background: var(--surface);
    overflow: hidden;
}

    .progress > li {
        padding: var(--space-3) var(--space-4);
        border-left: 1px solid var(--line);
        display: grid;
        gap: 2px;
        min-width: 0;
    }

        .progress > li:first-child {
            border-left: 0;
        }

        .progress > li .step-name {
            font-weight: var(--fw-semibold);
        }

        .progress > li .step-when {
            color: var(--ink-3);
            font-size: var(--fs-small);
        }

        .progress > li.is-done .step-name {
            color: var(--ok);
        }

        .progress > li.is-next {
            background: var(--petrol-soft);
        }

@media (max-width: 599.98px) {
    .progress {
        grid-auto-flow: row;
    }

        .progress > li {
            border-left: 0;
            border-top: 1px solid var(--line);
        }

            .progress > li:first-child {
                border-top: 0;
            }
}

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

    .plain-list > li {
        padding: var(--space-3) var(--panel-x);
        border-top: 1px solid var(--line);
    }

        .plain-list > li:first-child {
            border-top: 0;
        }

.notice-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.invoice-block + .invoice-block {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--line);
}

.form-problem:focus {
    outline: none;
}

@media (max-width: 599.98px) {
    /* the stock list should not start below the fold on a phone */
    .filter-fields {
        gap: var(--space-2);
    }
}

/* The validation summary opens with a short height transition instead of pushing the form down in one jump. */
.form-problem-region {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows var(--dur-base, 180ms) var(--ease, ease-out);
}

    .form-problem-region.is-open {
        grid-template-rows: 1fr;
    }

.form-problem-inner {
    min-height: 0;
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .form-problem-region {
        transition: none;
    }
}

/* The dossier tabs have two cards that need more room than the generic two-column grid gives at tablet widths. */
@media (max-width: 1279.98px) {
    .cols.is-roomy {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Reports ---------- */
.report-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: 10px;
}

.report-link {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--r-pill);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink-2);
    text-decoration: none;
    white-space: nowrap;
}

    .report-link:hover {
        background: var(--sunken);
    }

    .report-link[aria-current="page"] {
        background: var(--ink);
        border-color: var(--ink);
        color: var(--surface);
        font-weight: var(--fw-medium);
    }

@media (max-width: 959.98px) and (pointer: coarse), (max-width: 599.98px) {
    .report-link {
        height: 44px;
        padding: 0 16px;
    }
}

/* ---------- Settings ---------- */
.settings-section {
    display: grid;
    gap: 2px;
    color: var(--ink);
    text-decoration: none;
    border-radius: 3px;
}

    .settings-section:hover .t-strong {
        text-decoration: underline;
    }

.settings-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-3);
    align-items: start;
}

@media (max-width: 599.98px) {
    .settings-add {
        grid-template-columns: minmax(0, 1fr);
    }
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
}

.settings-textarea textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--fs-small);
}

/* Text Stapelloop always adds to a document and the user cannot edit (shown as a quote, not as an input). */
.settings-fixed-text {
    margin: 0;
    padding: var(--space-3);
    background: var(--sunken);
    border-left: 3px solid var(--line-strong);
    border-radius: var(--r-tag);
    color: var(--ink);
    overflow-wrap: anywhere;
}


/* ---------- Trial (bar under the top bar) and blocked company (notice instead of the app) ---------- */
/* The bar is a full-width band directly under the sticky top bar; the notice inside keeps the Notice look (tokens, both themes). */
.trial-bar {
    padding: var(--space-3) var(--gutter) 0;
    max-width: var(--content-max);
}

    .trial-bar .notice {
        margin-bottom: 0;
    }

.trial-bar-requested {
    color: var(--ink-2);
}

/* The demo company's bar, directly under the trial bar: the same band, so on a small screen it moves the page no more than the trial bar does. */
.demo-bar {
    padding: var(--space-3) var(--gutter) 0;
    max-width: var(--content-max);
}

    .demo-bar .notice {
        margin-bottom: 0;
    }

/* The progress of a fill of sample data: one live region; empty (and so without height) while nothing runs. */
.sample-progress {
    overflow-wrap: anywhere;
}

.sample-progress-trouble {
    color: var(--ink-2);
}

/* A small action (a quiet link-button in a bar or a row, a dialog button) that still offers a 44 px touch target. */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

.link-button.touch-target {
    padding: 0 var(--space-2);
}

/* Same composition as the shell's "Geen toegang" message, which is scoped to AppShell. */
.blocked-notice {
    max-width: 34rem;
    margin: 12vh auto 0;
    padding: 0 var(--space-4);
}

.blocked-notice-brand {
    margin: 0 0 var(--space-4);
}

.blocked-notice-title {
    font-size: 20px;
    font-weight: var(--fw-title);
    font-stretch: var(--wdth-title);
    margin: 0 0 var(--space-2);
}

.blocked-notice p:not(.blocked-notice-brand) {
    margin: 0 0 var(--space-4);
    color: var(--ink-2);
}

/* The offer of sample data above the empty stock list of a trial: the primary action first, as the spec lists it; on a phone the buttons stack at full width. */
.sample-offer {
    margin-bottom: var(--space-4);
}

.sample-offer-title {
    font-size: var(--fs-panel);
    font-weight: 650;
    margin: 0;
}

.sample-offer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

@media (max-width: 599.98px) {
    .sample-offer-actions {
        flex-direction: column;
    }

        .sample-offer-actions > * {
            width: 100%;
        }
}

/* The sentence about the minute and the photos under a trial's progress line: standing help, outside the live region. */
.sample-progress-aid {
    margin: var(--space-1) 0 0;
    color: var(--ink-2);
}

/* The one-time notice after the platform wiped a trial's sample data: the same band as the other bars. */
.sample-wipe-notice {
    padding: var(--space-3) var(--gutter) 0;
    max-width: var(--content-max);
}

    .sample-wipe-notice .notice {
        margin-bottom: 0;
    }

/* Lists and buttons of the sample data dialogs and settings. */
.sample-dialog-list {
    margin: 0 0 var(--space-3);
    padding-left: var(--space-5);
}

.sample-settings-actions {
    justify-content: flex-start;
}
