﻿/* Self-hosted Nunito (variable, weights 400–800) — keeps the app a
   self-contained static download with no Google Fonts render-path
   dependency. latin + latin-ext cover the Polish UI. */
@font-face {
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('../fonts/nunito-latin.woff2') format('woff2');
    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: 'Nunito';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('../fonts/nunito-latin-ext.woff2') format('woff2');
    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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Self-hosted Baloo 2 (variable, weights 400–800) — the display face for
   headings and the drill question. Same self-hosting rationale and the same
   latin / latin-ext split as Nunito, so Polish diacritics render from the
   second subset without a CDN round-trip. Baloo 2 replaced Fredoka because
   Fredoka ships no Polish glyphs at all (no ą ć ę ń ś ź ż in any subset,
   upstream included), so every heading fell back mid-word to a system face. */
@font-face {
    font-family: 'Baloo 2';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('../fonts/baloo2-latin.woff2') format('woff2');
    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: 'Baloo 2';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('../fonts/baloo2-latin-ext.woff2') format('woff2');
    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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

h1:focus {
    outline: none;
}

/* ── Page backdrops ───────────────────────────────────────────────────────
   Applied to MudMainContent from MainLayout's bound dark-mode flag, because
   MudBlazor emits colours but never a background image. Both variants stay
   faint: the card surfaces above them are opaque, so the answer field and the
   feedback strip are never read against a pattern. No background-attachment:
   fixed — it breaks the viewport on iOS Safari. */
.bg-day,
.bg-night {
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--mud-palette-background);
    background-repeat: no-repeat, no-repeat, repeat;
}

/* Warm daylight: two soft brand blobs plus a sparse dot grid. */
.bg-day {
    background-image:
        radial-gradient(at 14% 10%, rgba(var(--mud-palette-primary-rgb), 0.12) 0px, transparent 45%),
        radial-gradient(at 86% 88%, rgba(var(--mud-palette-secondary-rgb), 0.10) 0px, transparent 45%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cg fill='%231F2933' fill-opacity='0.06'%3E%3Ccircle cx='6' cy='6' r='2'/%3E%3Ccircle cx='26' cy='22' r='2'/%3E%3C/g%3E%3C/svg%3E");
}

/* Night sky: two cool glows plus a sparse star field. */
.bg-night {
    background-image:
        radial-gradient(at 12% 8%, rgba(var(--mud-palette-primary-rgb), 0.12) 0px, transparent 48%),
        radial-gradient(at 88% 84%, rgba(var(--mud-palette-secondary-rgb), 0.10) 0px, transparent 48%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90' viewBox='0 0 90 90'%3E%3Cg fill='%23F2F4FF' fill-opacity='0.06'%3E%3Ccircle cx='12' cy='18' r='1.4'/%3E%3Ccircle cx='58' cy='9' r='1'/%3E%3Ccircle cx='78' cy='52' r='1.4'/%3E%3Ccircle cx='34' cy='66' r='1'/%3E%3Ccircle cx='66' cy='80' r='1.2'/%3E%3C/g%3E%3C/svg%3E");
}

/* ── Buttons ──────────────────────────────────────────────────────────────
   Chunky primary buttons: a 4 px darker inset edge along the bottom reads as
   a pressable slab to a 10-year-old, and presses in on :active. The edge
   colour comes from the palette, so it follows the dark toggle. */
.btn-chunky {
    box-shadow: inset 0 -4px 0 var(--mud-palette-primary-darken);
    min-height: 56px;
}

    .btn-chunky:active {
        transform: translateY(2px);
        box-shadow: inset 0 -2px 0 var(--mud-palette-primary-darken);
    }

/* Every Mud button clears the 48 px minimum touch target. */
.mud-button-root {
    min-height: 48px;
}

/* ── Drill screen ─────────────────────────────────────────────────────────
   The question, the answer field and the feedback strip. Digits are tabular
   everywhere so the layout does not jitter as values change. */
.drill-question {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.drill-answer input {
    font-size: 2.5rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
    min-height: 64px;
}

/* Fixed height so revealing or clearing feedback never shifts the button
   below it — the drill rhythm depends on the target staying put. */
.feedback-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 64px;
    margin: 0.5rem 0;
    padding: 0 0.75rem;
    border-radius: var(--mud-default-borderradius);
    text-align: center;
    font-weight: 700;
}

.feedback-strip--ok {
    background-color: var(--mud-palette-success-lighten);
    color: var(--mud-palette-success);
    animation: feedback-in 120ms ease-out;
}

.feedback-strip--miss {
    background-color: var(--mud-palette-error-lighten);
    color: var(--mud-palette-error);
    animation: feedback-in 120ms ease-out, shake 150ms ease-in-out;
}

@keyframes feedback-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% {
        translate: 0;
    }

    25% {
        translate: -4px;
    }

    75% {
        translate: 4px;
    }
}

/* Colour, icon and text still carry the whole message without motion. */
@media (prefers-reduced-motion: reduce) {
    .feedback-strip--ok,
    .feedback-strip--miss {
        animation: none;
    }

    .btn-chunky:active {
        transform: none;
    }
}

/* The h1 above the card and the score both sit over a centred 520 px card, so
   they centre with it. .score keeps the H1 element (one per step, for
   FocusOnNavigate) while borrowing the H3 size from the type scale. */
.drill-title {
    text-align: center;
}

.score {
    font-size: var(--mud-typography-h3-size);
    font-variant-numeric: tabular-nums;
}

/* Actions row inside the card. Below Md the submit spans the card, where it is
   the thumb target and sits directly above the on-screen keyboard; from Md up it
   sizes to its label so a secondary action can share the row. */
.drill-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

@media (max-width: 959.98px) {
    .drill-actions .drill-submit {
        width: 100%;
    }
}

/* Test progress, as one dot per question. Decoration only — the row is
   aria-hidden and "Pytanie N z M" above it carries the same fact as text. */
.progress-pips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

    .progress-pips span {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        background-color: var(--mud-palette-lines-default);
    }

        .progress-pips span.is-done {
            background-color: var(--mud-palette-primary);
        }

/* ── Table picker ─────────────────────────────────────────────────────────
   Nine big tappable tiles instead of a dropdown. The fieldset is here for its
   group role and its legend-derived name, not for the browser's default frame,
   so the frame is stripped and the legend restyled as a field label. */
.table-picker {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

    .table-picker legend {
        padding: 0;
        font-family: var(--mud-typography-subtitle1-family);
        font-size: var(--mud-typography-subtitle1-size);
        font-weight: var(--mud-typography-subtitle1-weight);
        color: var(--mud-palette-text-primary);
    }

.table-tiles .mud-chip {
    min-width: 56px;
    min-height: 56px;
    font-family: 'Baloo 2', 'Nunito', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    border-width: 2px;
}

/* A picked table fills solid rather than taking MudBlazor's default selected
   tint (--mud-palette-primary-hover, a ~6% wash that a child does not read as
   "chosen" at arm's length). Same primary/primary-text pairing MudBlazor uses
   for a filled chip, so contrast holds in both palettes: 5.2:1 light,
   7.3:1 dark. The hover/focus/active variants are repeated because Mud's own
   rules for those states are more specific and would otherwise wash the fill
   back out on pointer-over. */
.table-tiles .mud-chip.mud-chip-selected,
.table-tiles .mud-chip.mud-chip-selected:hover:not(.mud-disabled),
.table-tiles .mud-chip.mud-chip-selected:focus-visible:not(.mud-disabled),
.table-tiles .mud-chip.mud-chip-selected:active:not(.mud-disabled) {
    background-color: var(--mud-palette-primary);
    border-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

/* ── Landing & hub ────────────────────────────────────────────────────────
   The three facts under the wordmark are decoration (aria-hidden); they set the
   subject of the app faster than the lead sentence does. */
.fact-tiles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

    .fact-tiles .fact-tile {
        padding: 0.75rem 1.25rem;
        border: 2px solid var(--mud-palette-lines-default);
        font-family: 'Baloo 2', 'Nunito', sans-serif;
        font-size: 1.5rem;
        font-variant-numeric: tabular-nums;
        color: var(--mud-palette-text-primary);
    }

.landing-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 360px;
}

/* Hub action cards: the whole tile is the link, so a thumb aimed anywhere in it
   routes. The inner span does the stacking rather than a MudBlazor internal
   class, so the layout does not depend on Mud's button markup. */
.hub-card {
    height: 100%;
    padding: 20px;
    white-space: normal;
}

    .hub-card .hub-card__body {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.35rem;
        width: 100%;
        text-align: center;
    }

    .hub-card .hub-card__label {
        font-family: 'Baloo 2', 'Nunito', sans-serif;
        font-size: 1.25rem;
    }

    .hub-card .hub-card__hint {
        font-size: 0.9rem;
        font-weight: 500;
        line-height: 1.35;
        opacity: 0.85;
    }

/* ── Auth cards ───────────────────────────────────────────────────────────
   A hairline instead of a drop shadow: the form should read as a panel on the
   page, not as something floating over it. */
.auth-card {
    border: 1px solid var(--mud-palette-lines-default);
}

/* Digits that line up column to column (history scores). */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* ── Forms ────────────────────────────────────────────────────────────────
   Blazor's template validation styles, moved onto the palette. */
.invalid {
    outline: 1px solid var(--mud-palette-error);
}

.validation-message {
    color: var(--mud-palette-error);
    font-weight: 700;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

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

/* ── WASM loader ──────────────────────────────────────────────────────────
   Painted before Blazor boots, so no --mud-palette-* variable exists yet and
   these colours are hard-coded on purpose. .boot-dark is set by the inline
   script in index.html so a dark-mode user never sees a cream flash. */
.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

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

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

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

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

html.boot-dark {
    background: #0F1224;
}

    html.boot-dark .loading-progress-text {
        color: #F2F4FF;
    }

/* ── Backend wake-up gate ─────────────────────────────────────────────────
   Shown by BackendGate while it waits for GET /api/ready, taking the screen over
   from the WASM loader above. Same constraint as that loader: MudThemeProvider
   has not run yet, so no --mud-palette-* variable exists and the colours are
   hard-coded to match it.

   The 0.4 s delay on the fade is the whole point of the animation. On a warm
   database /api/ready answers well inside that, so the usual case shows nothing
   at all instead of flashing "waking up" for one frame. */
.wakeup {
    position: absolute;
    inset: 20vh 1.5rem auto 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    /* Spelled out because MudBlazor's typography is not in play out here: without
       it the browser default (a serif) wins and the screen reads as a different
       app than the one loading behind it. */
    font-family: 'Nunito', system-ui, sans-serif;
    color: #1F2933;
    animation: wakeup-in 0.2s ease-in 0.4s both;
}

@keyframes wakeup-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.wakeup-spinner {
    width: 3.5rem;
    height: 3.5rem;
    border: 0.5rem solid #E5E0D3;
    border-top-color: #C2410C;
    border-radius: 50%;
    animation: wakeup-spin 1s linear infinite;
}

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

.wakeup-title {
    margin: 0;
    font-family: 'Baloo 2', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
}

.wakeup-hint {
    margin: 0;
    font-size: 1rem;
    opacity: 0.75;
}

/* Matches .btn-chunky's pressable slab, spelled out rather than reused: that
   rule leans on --mud-palette-primary-darken, which does not exist out here. */
.wakeup-retry {
    margin-top: 0.5rem;
    min-height: 48px;
    padding: 0 1.5rem;
    border: none;
    border-radius: 8px;
    background: #C2410C;
    color: #FFFBF0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}

    .wakeup-retry:active {
        transform: translateY(2px);
        box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
    }

html.boot-dark .wakeup {
    color: #F2F4FF;
}

html.boot-dark .wakeup-spinner {
    border-color: #2A2F45;
    border-top-color: #C2410C;
}

/* The delayed appearance is functional — it is what suppresses the flash — so it
   survives; only the decorative motion goes. The ring closes to a solid circle
   rather than freezing mid-spin, which would just look broken. */
@media (prefers-reduced-motion: reduce) {
    .wakeup {
        animation: wakeup-in 0.01s step-end 0.4s both;
    }

    .wakeup-spinner {
        animation: none;
        border-color: #C2410C;
        opacity: 0.5;
    }
}

/* ── Phones ───────────────────────────────────────────────────────────────
   Buy back horizontal room below 600 px; the drill card keeps its own
   breathing space via a tighter padding. */
@media (max-width: 599.98px) {
    .mud-container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .drill-card {
        padding: 20px !important;
    }

    /* Page-level primary calls to action span the column on phones. */
    .cta-full {
        width: 100%;
    }
}
