/* Self-hosted fonts (latin subset: covers French). Licenses: fonts/OFL-*.txt */
@font-face {
    font-family: 'Barlow';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url(../fonts/barlow-latin-500.woff2) format('woff2');
}

@font-face {
    font-family: 'Barlow';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url(../fonts/barlow-latin-600.woff2) format('woff2');
}

@font-face {
    font-family: 'Barlow';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url(../fonts/barlow-latin-700.woff2) format('woff2');
}

@font-face {
    font-family: 'Source Sans 3';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(../fonts/source-sans-3-latin-400.woff2) format('woff2');
}

@font-face {
    font-family: 'Source Sans 3';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url(../fonts/source-sans-3-latin-600.woff2) format('woff2');
}

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

html, body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
}

h1 {
    font-size: var(--fs-h1);
    letter-spacing: -0.01em;
}

h1:focus {
    outline: none;
}

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

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

:focus-visible {
    outline: 2px solid var(--color-primary-hover);
    outline-offset: 2px;
}

/* Initial loading: the tenant logo pulses inside the download progress ring (index.html). The sign-in status
   (Features/Authentication/AuthenticationStatus) reuses it with a spinning ring, so loading and sign-in look alike. */
.app-loading {
    position: absolute;
    inset: 30vh 0 auto 0;
    width: 6rem;
    height: 6rem;
    margin: 0 auto;
}

.app-loading.inline {
    position: relative;
    inset: auto;
    margin: 0;
}

.loading-progress {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

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

/* Real progress: --blazor-load-percentage is set by Blazor while the app downloads. 0.92 = 2 × r (46%). */
.loading-progress circle:last-child {
    stroke: var(--color-primary);
    stroke-linecap: round;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.92), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

/* No measurable progress (sign-in redirects): a quarter of the ring turns. */
.loading-progress.spinning circle:last-child {
    stroke-dasharray: calc(3.141 * 25% * 0.92), 500%;
    animation: loading-spin 1s linear infinite;
}

.loading-logo {
    position: absolute;
    inset: 22%;
    width: 56%;
    height: 56%;
    object-fit: contain;
    animation: loading-pulse 1.6s ease-in-out infinite;
}

@keyframes loading-pulse {
    0%, 100% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1); opacity: 1; }
}

@keyframes loading-spin {
    from { transform: rotate(-90deg); }
    to { transform: rotate(270deg); }
}

@media (prefers-reduced-motion: reduce) {
    .loading-logo {
        animation: none;
    }

    .loading-progress.spinning circle:last-child {
        animation-duration: 3s;
    }
}

/* Unhandled error */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding: 0.75rem 3rem 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    background: var(--color-accent-soft);
    color: var(--color-text);
    border-top: 1px solid var(--color-accent-border);
}

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

.blazor-error-boundary {
    padding: 1rem;
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
}

.blazor-error-boundary::after {
    content: "Une erreur est survenue.";
}

/* Page: mobile margins, limited width on the web portal */
.page {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--space-page);
}

/* Text for screen readers only */
.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;
}
