/* ==========================================================================
   Crusty Quiz – basisstijlen
   ========================================================================== */

/* Cascade layers: een latere laag wint altijd, ongeacht specificiteit.
   base       – tokens, reset en basiscomponenten (dit bestand)
   components – admin.css en game.css
   utilities  – hulpregels die altijd moeten winnen (zoals [hidden]) */
@layer base, components, utilities;

@layer base {
    :root {
        color-scheme: light dark;

        /* Merk */
        --brand: #46178f;
        --brand-strong: #35106d;
        --brand-contrast: #ffffff;

        /* Antwoordkleuren (Kahoot-achtig: kleur + vorm per optie) */
        --answer-1: #e21b3c; /* ▲ */
        --answer-2: #1368ce; /* ◆ */
        --answer-3: #d89e00; /* ● */
        --answer-4: #26890c; /* ■ */
        --answer-5: #0aa3a3; /* ⬟ */
        --answer-6: #864cbf; /* ★ */

        --success: #26890c;
        --danger: #e21b3c;

        /* Neutraal */
        --bg: #f3f1f7;
        --surface: #ffffff;
        --surface-2: #f7f6fa;
        --text: #1d1a24;
        --text-muted: #6b6578;
        --border: #e2deea;

        --radius: 12px;
        --radius-lg: 20px;
        --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(0 0 0 / .06);
        --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
    }

    @media (prefers-color-scheme: dark) {
        :root {
            --bg: #14111a;
            --surface: #1f1b27;
            --surface-2: #28232f;
            --text: #f1eef6;
            --text-muted: #a49cb3;
            --border: #36303f;
            --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .3);
        }
    }

    /* Reset ---------------------------------------------------------------- */
    *, *::before, *::after { box-sizing: border-box; }
    * { margin: 0; }
    html { -webkit-text-size-adjust: 100%; }
    body {
        min-height: 100dvh;
        font-family: var(--font);
        font-size: 1rem;
        line-height: 1.5;
        color: var(--text);
        background: var(--bg);
    }
    img, video, svg { display: block; max-width: 100%; }
    input, button, textarea, select { font: inherit; color: inherit; }
    a { color: var(--brand); }
    code { font-family: var(--font-mono); font-size: .9em; }

    /* Layout --------------------------------------------------------------- */
    .center-screen {
        min-height: 100dvh;
        display: grid;
        grid-template-columns: minmax(0, 1fr); /* kaarten nooit breder dan het scherm */
        place-items: center;
        padding: 16px;
    }
    .stack { display: flex; flex-direction: column; gap: 16px; }
    .muted { color: var(--text-muted); }

    /* Spelerspagina's: paars merkvlak */
    .page-player, .page-login {
        background: var(--brand);
        background-image: radial-gradient(circle at 20% 10%, rgb(255 255 255 / .12), transparent 40%),
                          radial-gradient(circle at 90% 90%, rgb(0 0 0 / .2), transparent 45%);
    }

    /* Card ----------------------------------------------------------------- */
    .card {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow);
        padding: 24px;
    }
    .card--narrow { width: min(100%, 400px); }
    .card__title { font-size: 1.375rem; line-height: 1.25; }
    .card + .card { margin-top: 16px; }

    /* Formulieren ---------------------------------------------------------- */
    .field { display: flex; flex-direction: column; gap: 6px; }
    .field__label { font-weight: 600; font-size: .9rem; }
    .field__input {
        width: 100%;
        padding: 12px 14px;
        background: var(--surface-2);
        border: 2px solid var(--border);
        border-radius: var(--radius);
        outline: none;
        transition: border-color .15s;
    }
    .field__input:focus-visible { border-color: var(--brand); }
    .field__input--code {
        text-align: center;
        text-transform: uppercase;
        font-size: 2rem;
        font-weight: 800;
        letter-spacing: .35em;
        padding-left: calc(14px + .35em); /* compenseer letter-spacing */
    }

    /* Knoppen -------------------------------------------------------------- */
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 10px 18px;
        border: 0;
        border-radius: var(--radius);
        font-weight: 700;
        text-decoration: none;
        cursor: pointer;
        transition: transform .08s, background-color .15s, box-shadow .15s;
    }
    .btn:active { transform: translateY(1px); }
    .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 2px; }
    .btn--primary {
        background: var(--brand);
        color: var(--brand-contrast);
        box-shadow: 0 4px 0 var(--brand-strong);
    }
    .btn--primary:hover { background: color-mix(in srgb, var(--brand) 88%, white); }
    .btn--ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
    .btn--ghost:hover { background: var(--surface-2); }
    .btn--block { width: 100%; }
    .btn--lg { padding: 14px 22px; font-size: 1.125rem; }
    .btn--sm { padding: 6px 12px; font-size: .875rem; }

    /* Meldingen ------------------------------------------------------------ */
    .flashes {
        position: fixed;
        inset: 16px 16px auto;
        display: grid;
        gap: 8px;
        justify-items: center;
        z-index: 10;
    }
    .flash {
        padding: 10px 16px;
        border-radius: var(--radius);
        background: var(--surface);
        border-left: 4px solid var(--brand);
        box-shadow: var(--shadow);
        font-weight: 600;
    }
    .flash--error { border-left-color: var(--danger); }
    .flash--success { border-left-color: var(--success); }
    .admin-main .flash { margin-bottom: 16px; }

    /* Beheer --------------------------------------------------------------- */
    .admin-header {
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }
    .admin-header__inner {
        max-width: 1100px;
        margin: 0 auto;
        padding: 12px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 24px;
    }
    .brand {
        display: flex;
        align-items: center;
        gap: 10px;
        font-weight: 900;
        font-size: 1.1rem;
        letter-spacing: -.01em;
        color: var(--text);
        text-decoration: none;
    }
    .brand__mark { width: 40px; height: auto; }

    /* Logo boven kaarten op de paarse pagina's (start, inloggen) */
    .page-logo { display: block; width: min(240px, 60vw); height: auto; margin: 0 auto 8px; }
    .center-screen--logo { align-content: center; gap: 16px; }
    .admin-main {
        max-width: 1100px;
        margin: 0 auto;
        padding: 24px 16px 48px;
    }
    .page-title { font-size: 1.75rem; margin-bottom: 20px; }

    .stat-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 16px;
        margin-bottom: 16px;
    }
    .stat {
        display: flex;
        flex-direction: column;
        padding: 16px 20px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
    }
    .stat__value { font-size: 2rem; font-weight: 800; line-height: 1.1; }
    .stat__label { color: var(--text-muted); font-size: .9rem; }


    .debug {
        white-space: pre-wrap;
        font-family: var(--font-mono);
        font-size: .8rem;
        background: var(--surface-2);
        padding: 12px;
        border-radius: var(--radius);
        overflow-x: auto;
    }
}

@layer utilities {
    /* "hidden" wint zo ook van componenten met een eigen display (grid/flex) */
    [hidden] { display: none; }
}
