/* ── GANGETRÆNER — DESIGN-TOKENS + KOMPONENTER ─────────────────────────────
   Visuel identitet fra webversionen: mørk indigo baggrund, legende Baloo 2-
   display-font, og accentfarverne pink/gul/mint/rød. Appen kører i én mørk
   identitet (ingen tema-skifter), så farverne males eksplicit på :root. */

:root {
    --bg:            #1B1B3A;   /* mørk indigo baggrund */
    --surface:       #242456;   /* kort-overflade */
    --surface-2:     #2E2E68;   /* hævet kort / input */
    --surface-3:     #3A3A7A;   /* subtile kanter */

    --accent:        #FF5D8F;   /* pink — primær handling */
    --accent-ink:    #2A0A16;   /* tekst på pink */
    --yellow:        #FFC857;   /* i gang */
    --mint:          #3DDC97;   /* mestret / rigtigt */
    --red:           #FF6B5B;   /* forkert svar */

    --text:          #F3F1FF;   /* primær tekst */
    --text-dim:      #A8A6D0;   /* sekundær tekst */
    --text-faint:    #6E6CA0;   /* svag tekst / grå trappetrin */

    --radius:        22px;
    --radius-sm:     14px;
    --shadow:        0 10px 30px rgba(0,0,0,0.35);

    --ease:          cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: 'Baloo 2', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    /* Edge-to-edge: ryd status-/navigationsbjælker. */
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.app {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 20px 20px 28px;
}

/* ── Skærme (Navigation Compose-ækvivalent) ──────────────────────────────── */
.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; animation: screen-in 260ms var(--ease); }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Typografi ───────────────────────────────────────────────────────────── */
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: 0.2px; }
.app-title { font-size: 30px; }
.subtle { color: var(--text-dim); }

/* ── Knapper ─────────────────────────────────────────────────────────────── */
.btn {
    font-family: inherit;
    font-weight: 700;
    font-size: 18px;
    border: none;
    border-radius: var(--radius);
    padding: 16px 22px;
    cursor: pointer;
    transition: transform 120ms var(--ease), filter 120ms var(--ease);
    color: var(--text);
    background: var(--surface-2);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px rgba(255,93,143,0.35); }
.btn-lg { font-size: 22px; padding: 20px; width: 100%; }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }

.icon-btn {
    background: var(--surface-2); color: var(--text); border: none;
    width: 44px; height: 44px; border-radius: 50%; font-size: 20px;
    cursor: pointer; display: grid; place-items: center;
}
.icon-btn:active { transform: scale(0.94); }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar .spacer { flex: 1; }

/* ── HOME ────────────────────────────────────────────────────────────────── */
.best-card {
    background: linear-gradient(150deg, var(--surface-2), var(--surface));
    border-radius: var(--radius);
    padding: 26px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}
.best-number { font-size: 64px; font-weight: 800; line-height: 1; color: var(--yellow); }
.best-caption { color: var(--text-dim); margin-top: 6px; font-size: 15px; }

/* Trappen: 9 trin med stigende højde. */
.staircase-wrap { margin-bottom: 8px; }
.staircase-title { font-size: 15px; color: var(--text-dim); margin-bottom: 10px; }
.staircase {
    display: flex; align-items: flex-end; gap: 6px;
    height: 130px; padding: 8px 4px 0;
}
.stair-step {
    flex: 1; border-radius: 10px 10px 6px 6px;
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 6px; min-height: 22px;
    transition: height 400ms var(--ease), background 300ms var(--ease);
}
.stair-num { font-weight: 800; font-size: 14px; color: rgba(0,0,0,0.55); }
.stair-untried    { background: var(--surface-3); }
.stair-untried .stair-num { color: var(--text-faint); }
.stair-inprogress { background: var(--yellow); }
.stair-mastered   { background: var(--mint); }
.home-hint { color: var(--text-faint); font-size: 13px; margin: 6px 2px 0; text-align: center; }

.home-actions { margin-top: auto; padding-top: 22px; }
.reminder-status {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface); border-radius: var(--radius-sm);
    padding: 14px 16px; margin-top: 14px; color: var(--text-dim); font-size: 15px;
}

/* ── PRACTICE ────────────────────────────────────────────────────────────── */
.practice-hud { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.hud-timer {
    font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums;
    background: var(--surface); border-radius: var(--radius-sm); padding: 6px 18px;
}
.hud-timer.urgent { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.hud-streak { font-size: 24px; font-weight: 800; color: var(--yellow); min-width: 60px; text-align: right; }
.hud-streak.hot { color: var(--red); }

.practice-card {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 22px; background: var(--surface); border-radius: var(--radius);
    padding: 24px; margin: 8px 0 14px; box-shadow: var(--shadow);
}
.practice-problem { font-size: 68px; font-weight: 800; letter-spacing: 1px; }
.practice-problem .op { color: var(--accent); margin: 0 10px; }
.practice-input {
    font-family: inherit; font-weight: 800; font-size: 52px; text-align: center;
    width: 100%; max-width: 220px; color: var(--text);
    background: var(--surface-2); border: 3px solid transparent; border-radius: var(--radius-sm);
    padding: 10px 8px; outline: none; caret-color: var(--accent);
}
.practice-input:focus { border-color: var(--accent); }
.practice-card.flash-correct { animation: flash-correct 450ms var(--ease); }
.practice-card.flash-wrong   { animation: flash-wrong 450ms var(--ease); }
@keyframes flash-correct { 0% { box-shadow: 0 0 0 0 rgba(61,220,151,0.0); } 30% { box-shadow: 0 0 0 4px var(--mint); } 100% { box-shadow: var(--shadow); } }
@keyframes flash-wrong   { 0% { box-shadow: 0 0 0 0 rgba(255,107,91,0.0); } 30% { box-shadow: 0 0 0 4px var(--red); } 100% { box-shadow: var(--shadow); }
                           20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
.practice-feedback { min-height: 26px; text-align: center; font-weight: 700; font-size: 18px; color: var(--text-dim); }
.practice-feedback.ok  { color: var(--mint); }
.practice-feedback.err { color: var(--red); }

/* ── SUMMARY ─────────────────────────────────────────────────────────────── */
.summary-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 20px; }
.summary-headline { font-size: 30px; }
.record-badge {
    background: var(--yellow); color: #2A2100; font-weight: 800; font-size: 16px;
    padding: 8px 18px; border-radius: 999px;
}
.summary-stats { display: flex; gap: 14px; width: 100%; }
.stat-box { flex: 1; background: var(--surface); border-radius: var(--radius-sm); padding: 18px 10px; }
.stat-num { font-size: 40px; font-weight: 800; line-height: 1; }
.stat-num.correct { color: var(--mint); }
.stat-num.wrong { color: var(--red); }
.stat-num.streak { color: var(--yellow); }
.stat-label { color: var(--text-dim); font-size: 13px; margin-top: 6px; }
.summary-actions { width: 100%; }

/* ── SETTINGS ────────────────────────────────────────────────────────────── */
.settings-list { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.setting-row {
    background: var(--surface); border-radius: var(--radius-sm); padding: 16px 18px;
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.setting-label { font-weight: 700; font-size: 17px; }
.setting-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.reminder-note { color: var(--text-faint); font-size: 13px; padding: 0 4px; }

/* Toggle-switch */
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0; cursor: pointer; background: var(--surface-3);
    border-radius: 999px; transition: background 200ms var(--ease);
}
.slider::before {
    content: ''; position: absolute; height: 24px; width: 24px; left: 4px; top: 4px;
    background: #fff; border-radius: 50%; transition: transform 200ms var(--ease);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* Native tidsvælger (Android viser sin egen Material-urskive). */
.time-input {
    font-family: inherit; font-weight: 700; font-size: 18px;
    background: var(--surface-2); color: var(--text);
    border: 2px solid var(--surface-3); border-radius: 12px; padding: 8px 12px;
    color-scheme: dark;
}

.danger-link { color: var(--red); }

/* ── Snackbar ────────────────────────────────────────────────────────────── */
#snackbar {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    background: #111133; color: var(--text); padding: 14px 20px; border-radius: 14px;
    font-size: 15px; max-width: 90vw; box-shadow: var(--shadow);
    transition: opacity 220ms var(--ease), transform 220ms var(--ease); z-index: 50;
    text-align: center;
}
#snackbar.visible { opacity: 1; transform: translate(-50%, 0); }

/* ── Splash ──────────────────────────────────────────────────────────────── */
#splash {
    position: fixed; inset: 0; background: var(--bg); z-index: 100;
    display: grid; place-items: center; transition: opacity 400ms ease;
}
#splash.hidden { opacity: 0; pointer-events: none; }
#splash .splash-icon { width: 132px; height: 132px; }

/* ── Niveau + XP (home) ────────────────────────────────────────────────────── */
.level-card {
    background: var(--surface); border-radius: var(--radius-sm);
    padding: 14px 16px; margin-bottom: 18px;
}
.level-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.level-badge {
    font-weight: 800; font-size: 15px; color: var(--accent-ink);
    background: var(--accent); padding: 4px 12px; border-radius: 999px;
}
.level-xp { color: var(--text-dim); font-weight: 700; font-size: 14px; }
.xp-bar { height: 12px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.xp-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--yellow), var(--mint));
    border-radius: 999px; transition: width 500ms var(--ease);
}
.xp-next { color: var(--text-faint); font-size: 12px; margin-top: 6px; text-align: right; }

/* ── Pædagogisk forklaring (practice) ──────────────────────────────────────── */
.is-hidden { display: none !important; }
/* `[hidden]` slår ikke igennem alene, fordi .explain-panel sætter display:flex —
   attribut-selektoren her har højere specificitet og skjuler panelet korrekt. */
.explain-panel[hidden] { display: none; }
.explain-panel {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 18px; text-align: center; background: var(--surface); border-radius: var(--radius);
    padding: 28px 24px; margin: 8px 0 14px; box-shadow: var(--shadow);
    animation: screen-in 260ms var(--ease);
}
.explain-emoji { font-size: 44px; }
.explain-eq { font-size: 40px; font-weight: 800; color: var(--mint); }
.explain-strategy {
    font-size: 19px; font-weight: 600; color: var(--text); line-height: 1.4;
    max-width: 340px;
}
.explain-panel .btn { width: 100%; max-width: 320px; margin-top: 6px; }

/* ── Summary: XP + nye titler ──────────────────────────────────────────────── */
.summary-xp {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.summary-xp-badge {
    background: var(--yellow); color: #2A2100; font-weight: 800; font-size: 20px;
    padding: 6px 18px; border-radius: 999px;
}
.summary-xp-total { color: var(--text-dim); font-size: 14px; font-weight: 600; }

.summary-titles { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.title-badge-new {
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(120deg, var(--surface-2), var(--surface));
    border: 2px solid var(--mint); border-radius: var(--radius-sm);
    padding: 12px 16px; opacity: 0; transform: scale(0.8);
    animation: badge-pop 500ms var(--ease) forwards;
}
@keyframes badge-pop {
    0%   { opacity: 0; transform: scale(0.8) translateY(6px); }
    60%  { opacity: 1; transform: scale(1.06); }
    100% { opacity: 1; transform: scale(1); }
}
.title-badge-new .tb-icon { font-size: 30px; }
.tb-text { display: flex; flex-direction: column; text-align: left; font-weight: 800; font-size: 17px; }
.tb-label { color: var(--mint); font-size: 12px; font-weight: 700; }

/* ── Mine titler-skærm ─────────────────────────────────────────────────────── */
.titles-grid { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-bottom: 8px; }
.title-card {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface); border-radius: var(--radius-sm); padding: 14px 16px;
}
.title-card.locked { opacity: 0.55; }
.title-card.unlocked { border: 2px solid var(--mint); }
.tc-icon { font-size: 30px; width: 40px; text-align: center; flex: none; }
.tc-body { display: flex; flex-direction: column; gap: 2px; }
.tc-name { font-weight: 800; font-size: 17px; }
.tc-req { color: var(--text-dim); font-size: 13px; }
.title-card.unlocked .tc-req { color: var(--mint); }
