/* BloxHelper — iPad-first dark theme baseline. */

:root {
    color-scheme: dark;

    /* Palette */
    --bg: #0F1B2D;
    --bg-elev: #1B3651;
    --bg-elev-2: #234a6e;
    --border: #2c5278;
    --text: #F5F0E8;
    --text-muted: #b8c5d6;
    --gold: #F4C152;
    --gold-strong: #ffd770;
    --red: #E53E3E;
    --green: #4ade80;
    --blue: #60a5fa;

    /* Type */
    --font-stack: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-size-base: 17px;
    --line-height-base: 1.5;

    /* Spacing & shape */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --tap-min: 44px;

    /* Safe areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: light) {
    :root[data-theme="auto"] {
        color-scheme: light;
        --bg: #F5F0E8;
        --bg-elev: #ffffff;
        --bg-elev-2: #f0e8d8;
        --border: #d4cab5;
        --text: #1a1a1a;
        --text-muted: #555;
    }
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-stack);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    min-height: 100vh;
    overscroll-behavior-y: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    padding-top: var(--safe-top);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    padding-bottom: var(--safe-bottom);
}

h1, h2, h3, h4 {
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1em; }

a {
    color: var(--gold);
    text-decoration: none;
}

a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

button {
    min-height: var(--tap-min);
    min-width: var(--tap-min);
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

button.primary {
    background: var(--gold);
    color: #1a1300;
    border-color: var(--gold-strong);
}

button.primary:active {
    background: var(--gold-strong);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input, select, textarea {
    min-height: var(--tap-min);
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    font: inherit;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: 3px solid var(--gold);
    outline-offset: 0;
    border-color: var(--gold);
}

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Boot / loading */

.boot-screen {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1.5rem;
    background: var(--bg);
}

.boot-mark {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--gold);
}

.loading-progress {
    width: 6rem;
    height: 6rem;
}

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

.loading-progress circle:first-child { stroke: var(--bg-elev); }
.loading-progress circle:last-child {
    stroke: var(--gold);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.1s ease-in-out;
}

.loading-progress-text {
    color: var(--text-muted);
    font-weight: 700;
}

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

/* Error UI */

#blazor-error-ui {
    background: var(--red);
    color: #fff;
    padding: 0.9rem 1.25rem;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.4);
    bottom: 0;
    left: 0;
    right: 0;
    position: fixed;
    display: none;
    z-index: 1000;
    align-items: center;
    gap: 0.75rem;
}

#blazor-error-ui .reload {
    color: #fff;
    text-decoration: underline;
    margin-left: auto;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
}

.blazor-error-boundary {
    background: var(--red);
    color: #fff;
    padding: 1rem;
    border-radius: var(--radius-md);
}

.blazor-error-boundary::after {
    content: "Something went wrong on this page.";
}

/* Validation */

.valid.modified:not([type=checkbox]) { outline: 2px solid var(--green); }
.invalid { outline: 2px solid var(--red); }
.validation-message { color: var(--red); font-weight: 700; }
