/* ============================================================
   Decryptic Crossword — global theme & reset
   Mobile-first. Design tokens live here; components consume them.
   ============================================================ */

:root {
    /* Surfaces */
    --bg: #e9edf4;
    --surface: #ffffff;
    --keyboard-bg: #d6dbe6;
    --hairline: #d9dee8;

    /* Ink */
    --ink: #16202e;
    --ink-dim: #6b7686;
    --on-accent: #ffffff;

    /* Brand */
    --accent: #4f46e5;
    --accent-2: #0ea5a4;
    --danger: #d6453d;

    /* Grid */
    --grid-line: #1f2733;
    --grid-gap: 2px;
    --cell-bg: #ffffff;
    --block-bg: #1f2733;
    --cell-inword: #dfe7ff;
    --cell-selected: #ffe39a;
    /* Cells render on a light "paper" surface in both themes, so their
       text must not follow the global --ink (which flips light in dark mode). */
    --cell-ink: #16202e;
    --cell-num: #6b7686;

    /* Keyboard keys */
    --key-bg: #ffffff;
    --key-active: #c3cad8;
    --key-special: #b9c1d1;
    --key-shadow: rgba(0, 0, 0, .25);

    /* Radii & shadows */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .12);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .16);
    --shadow-grid: 0 4px 16px rgba(20, 30, 50, .14);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141b;
        --surface: #171e28;
        --keyboard-bg: #10161e;
        --hairline: #283242;

        --ink: #eef2f8;
        --ink-dim: #97a3b6;

        --accent: #7c75ff;
        --accent-2: #2dd4bf;

        --grid-line: #0a0e14;
        --cell-bg: #e9edf4;
        --block-bg: #060a0f;
        --cell-inword: #c3d0ff;
        --cell-selected: #f0c75a;
        /* Light paper cells -> keep dark cell text in dark mode too. */
        --cell-ink: #16202e;
        --cell-num: #5d6878;

        --key-bg: #222c3a;
        --key-active: #2f3b4d;
        --key-special: #2a3444;
        --key-shadow: rgba(0, 0, 0, .5);
    }

    /* Grid letters stay dark on the light cell faces for contrast. */
    .grid .cell { color: #16202e; }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overscroll-behavior: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.app-shell {
    height: 100dvh;
}

button { font-family: inherit; }

/* ── Blazor framework UI (kept from template) ──────────── */
#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;
    }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

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

        .loading-progress circle:last-child {
            stroke: var(--accent);
            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;
    color: var(--ink-dim);
}

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