/*
 * #app-brand is the only visible logo for the whole session. It never remounts
 * with Angular and never changes size (Portal Open flicker — logo must stay static).
 * The Ultima topbar keeps an invisible spacer of the same box for the click target.
 *
 * Loaded from index.html <head> (not Angular styles) so first paint has no FOUC.
 * Canvas colour is fixed here — never restored from localStorage (KB Collector model).
 *
 * Boot: coloured splash logo + spinner. #app-brand (white wordmark) stays hidden while
 * boot is up; white on the light canvas was invisible.
 *
 * Tokens (BBWT3Variables.scss): text-primary #1F1F1F, text-secondary #4C4C4C,
 * surface-canvas #F5F5F5, surface-card #FFFFFF.
 */
:root {
    --app-brand-w: 178px;
    --app-brand-h: 26px;
    --app-brand-bar-h: 52px;
    --app-brand-pad-x: 20px;
    /* Ultima hamburger sits left of the logo; pad so brand clears the button. */
    --app-menu-toggle-space: 40px;
    --app-shell-bg: #F5F5F5; /* token surface-canvas — fixed, never scripted */
    --app-boot-text: #1F1F1F; /* token text-primary */
    --app-boot-text-secondary: #4C4C4C; /* token text-secondary */
}

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--app-shell-bg);
}

#app-brand {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2147483001;
    height: var(--app-brand-bar-h);
    padding: 0 var(--app-brand-pad-x);
    display: flex;
    align-items: center;
    pointer-events: none; /* topbar link underneath remains clickable once shell paints */
}

:root:has(.topbar .topbar-menu-toggle) #app-brand {
    left: var(--app-menu-toggle-space);
}

/* display:flex above would otherwise ignore the hidden attribute */
#app-brand[hidden] {
    display: none !important;
}

/* While boot is up, hide the white wordmark; splash uses .boot-logo instead. */
:root:has(#app-boot:not(.is-done)) #app-brand {
    visibility: hidden;
}

#app-brand img {
    display: block;
    width: var(--app-brand-w);
    height: var(--app-brand-h);
    max-width: var(--app-brand-w);
    max-height: var(--app-brand-h);
    object-fit: contain;
    object-position: left center;
}

#app-boot {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    background: var(--app-shell-bg);
    color: var(--app-boot-text-secondary);
    font-family: "DM Sans", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
    transition: opacity 120ms ease;
    pointer-events: none;
}

#app-boot.is-done {
    opacity: 0;
}

#app-boot .boot-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 0 16px;
    text-align: center;
    background: var(--app-shell-bg);
}

#app-boot .boot-logo {
    display: block;
    width: 228px;
    max-width: 100%;
    height: auto;
}

#app-boot .boot-loading[hidden],
#app-boot .boot-error:empty {
    display: none;
}

#app-boot .boot-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;
}

/* The error state takes clicks (the overlay ignores them while loading). */
#app-boot.has-error {
    pointer-events: auto;
}

#app-boot .boot-error {
    max-width: 30rem;
    color: var(--app-boot-text);
}

#app-boot .boot-error-title {
    margin: 0 0 8px;
    font-size: 1.43rem; /* 20px */
    font-weight: 700;
    line-height: 1.25;
    color: var(--app-boot-text);
}

#app-boot .boot-error-text {
    margin: 0 0 24px;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--app-boot-text-secondary);
}

#app-boot .boot-error-button {
    min-height: 36px;
    padding: 0 16px;
    border: 1px solid var(--app-boot-text-secondary);
    border-radius: 8px;
    background: #FFFFFF; /* token surface-card */
    color: var(--app-boot-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

#app-boot .boot-error-button:hover {
    background: #F5F5F5; /* token surface-muted */
}

#app-boot .boot-error-button:focus-visible {
    outline: 2px solid var(--app-boot-text);
    outline-offset: 2px;
}

/* Block box: an inline <span> ignores width/height and paints only its border, as a thin vertical line. */
#app-boot .boot-spinner {
    display: block;
    box-sizing: border-box;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: boot-spin 0.9s linear infinite;
}

@keyframes boot-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    #app-boot {
        transition: none;
    }

    #app-boot .boot-spinner {
        animation: none;
        border-right-color: currentColor;
        opacity: 0.45;
    }
}
