/* ===========================================================================
   Nuna — design system
   A friendly, rounded, high-contrast learning UI inspired by Duolingo,
   themed for Greenland & climate: arctic blues, aurora green, snow whites.
   =========================================================================== */

:root {
    /* Brand palette */
    /* Greenland-inspired palette: glacial ice, deep ocean, aurora, flag red, midnight sun */
    --snow: #eef4f7;       /* cool snow background */
    --snow-2: #e2ecf1;
    --card: #ffffff;
    --ink: #0a2432;        /* polar-night navy, primary text */
    --ink-soft: #37566a;
    --muted: #6e8798;
    --line: #d7e4ec;

    --blue: #0e8fa8;       /* glacier teal (primary) */
    --blue-d: #0a6f86;
    --green: #17b890;      /* aurora green — correct / continue */
    --green-d: #0f9573;
    --green-soft: #cff3e6;
    --coral: #e11d48;      /* Greenland-flag red — wrong / hearts */
    --coral-d: #be123c;
    --coral-soft: #ffe0e6;
    --gold: #f2a33c;       /* midnight-sun gold — xp / streak */
    --gold-d: #d9861f;
    --purple: #7a6be8;     /* aurora violet accent */
    --teal: #159c9c;
    --ice: #d6eef3;        /* pale glacier tint for selections */
    --ice-line: #7fcbd9;

    --radius: 16px;
    --radius-lg: 24px;
    --shadow-card: 0 2px 0 var(--line);
    --sidebar-w: 256px;
    --topbar-h: 68px;

    --font: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--snow);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 3px solid rgba(28,176,246,.45); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Buttons — signature 3D "pressable" style with a darker bottom lip
   -------------------------------------------------------------------------- */
.btn {
    --b: var(--blue);
    --b-d: var(--blue-d);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font);
    font-weight: 800;
    font-size: 15px;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: #fff;
    background: var(--b);
    border: none;
    border-radius: var(--radius);
    padding: 14px 22px;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--b-d);
    transition: transform .06s ease, filter .15s ease, box-shadow .06s ease;
    user-select: none;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.03); text-decoration: none; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--b-d); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: 0 4px 0 var(--b-d); transform: none; }

.btn-success { --b: var(--green); --b-d: var(--green-d); }
.btn-danger  { --b: var(--coral); --b-d: var(--coral-d); }
.btn-gold    { --b: var(--gold);  --b-d: var(--gold-d); color: var(--ink); }

.btn-ghost {
    background: #fff;
    color: var(--blue);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    box-shadow: none;
}
.btn-ghost:hover { background: var(--snow-2); filter: none; }
.btn-ghost:active { transform: translateY(2px); border-bottom-width: 2px; }

.btn-lg { font-size: 17px; padding: 16px 28px; }
.btn-block { display: flex; width: 100%; }

/* --------------------------------------------------------------------------
   App shell — sidebar on desktop, bottom tab bar on mobile
   -------------------------------------------------------------------------- */
.app-shell { min-height: 100vh; display: flex; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    border-right: 2px solid var(--line);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fff;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 26px; font-weight: 900; color: var(--blue);
    padding: 6px 12px 18px;
    letter-spacing: -.02em;
}
.brand .brand-mark { font-size: 26px; }

.nav-item {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-weight: 800; font-size: 15px;
    color: var(--ink-soft);
    text-transform: uppercase; letter-spacing: .4px;
    border: 2px solid transparent;
    cursor: pointer;
}
.nav-item:hover { background: var(--snow-2); text-decoration: none; }
.nav-item .ico { font-size: 22px; width: 26px; text-align: center; }
.nav-item.active { background: var(--ice); border-color: var(--ice-line); color: var(--blue-d); }
.nav-item.logout { color: var(--muted); background: none; border: none; width: 100%; text-align: left; font-family: var(--font); }

.sidebar .spacer { flex: 1; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-wrap { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: 24px 20px 120px; }

/* Top stats bar */
.statbar {
    display: flex; align-items: center; justify-content: flex-end; gap: 18px;
    max-width: 920px; margin: 0 auto; width: 100%;
    padding: 16px 20px 0;
}
.stat {
    display: inline-flex; align-items: center; gap: 7px;
    font-weight: 900; font-size: 17px;
}
.stat .ico { font-size: 20px; }
.stat.streak { color: var(--gold-d); }
.stat.hearts { color: var(--coral); }
.stat.xp { color: var(--blue-d); }

/* Bottom tab bar (mobile) */
.tabbar { display: none; }

/* --------------------------------------------------------------------------
   Landing page
   -------------------------------------------------------------------------- */
.landing {
    min-height: 100vh;
    background: radial-gradient(1200px 600px at 50% -10%, #d4edf3 0%, var(--snow) 55%);
    display: flex; flex-direction: column;
}
.landing-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 28px; max-width: 1100px; margin: 0 auto; width: 100%;
}
.landing-hero {
    flex: 1; display: flex; align-items: center; gap: 40px;
    max-width: 1100px; margin: 0 auto; width: 100%; padding: 20px 28px 60px;
    flex-wrap: wrap; justify-content: center;
}
.landing-hero .copy { flex: 1 1 360px; max-width: 520px; }
.landing-hero h1 { font-size: clamp(34px, 5vw, 54px); margin: 0 0 16px; }
.landing-hero p.sub { font-size: 19px; color: var(--ink-soft); font-weight: 600; margin: 0 0 28px; line-height: 1.5; }
.landing-hero .art { flex: 1 1 320px; display: flex; justify-content: center; }
.hero-cta { display: flex; flex-direction: column; gap: 14px; max-width: 340px; }

.feature-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px; max-width: 1100px; margin: 0 auto 60px; width: 100%; padding: 0 28px;
}
.feature {
    background: #fff; border: 2px solid var(--line); border-bottom-width: 4px;
    border-radius: var(--radius-lg); padding: 22px;
}
.feature .fi { font-size: 34px; }
.feature h3 { margin: 10px 0 6px; font-size: 19px; }
.feature p { margin: 0; color: var(--ink-soft); font-weight: 600; font-size: 15px; }

/* --------------------------------------------------------------------------
   Learn path
   -------------------------------------------------------------------------- */
.unit-header {
    border-radius: var(--radius-lg);
    padding: 20px 24px; color: #fff; margin: 34px 0 10px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
.unit-header .uh-left { display: flex; flex-direction: column; gap: 4px; }
.unit-header .u-kicker { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; opacity: .85; }
.unit-header h2 { margin: 0; font-size: 23px; color: #fff; }
.unit-header .u-sub { font-weight: 700; opacity: .9; font-size: 14px; }
.unit-header .u-emoji { font-size: 40px; }

.path { display: flex; flex-direction: column; align-items: center; gap: 34px; padding: 22px 0 16px; }

.node-row { display: flex; justify-content: center; width: 100%; }
.node-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; transform: translateX(var(--dx, 0px)); }
.lesson-node {
    position: relative;
    width: 76px; height: 68px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
    color: #fff;
    background: var(--node-color, var(--blue));
    box-shadow: 0 6px 0 var(--node-shadow, var(--blue-d));
    transition: transform .08s ease;
}
.lesson-node:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--node-shadow, var(--blue-d)); }
.lesson-node.locked {
    background: #e5eef4; color: #b9cdda; box-shadow: 0 6px 0 #d2e0ea; cursor: not-allowed;
}
.lesson-node.completed { background: var(--gold); box-shadow: 0 6px 0 var(--gold-d); color: #fff; }
.lesson-node.current::after {
    content: "START";
    position: absolute; top: -34px; left: 50%; transform: translateX(-50%);
    background: #fff; color: var(--node-color, var(--blue));
    font-size: 11px; font-weight: 900; letter-spacing: .6px;
    padding: 5px 10px; border-radius: 10px; white-space: nowrap;
    box-shadow: 0 2px 0 var(--line); border: 2px solid var(--line);
    animation: bob 1.1s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateX(-50%) translateY(0);} 50% { transform: translateX(-50%) translateY(-5px);} }

.lesson-label { font-size: 12px; font-weight: 800; color: var(--muted); margin-top: 2px; text-align: center; max-width: 120px; }

/* --------------------------------------------------------------------------
   Lesson player
   -------------------------------------------------------------------------- */
.lesson-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--snow); }
.lesson-top {
    display: flex; align-items: center; gap: 16px;
    max-width: 760px; margin: 0 auto; width: 100%; padding: 18px 20px;
}
.quit-btn { background: none; border: none; font-size: 26px; color: var(--muted); cursor: pointer; line-height: 1; }
.progress-track { flex: 1; height: 16px; background: var(--line); border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 10px; transition: width .35s ease; }
.hearts-mini { color: var(--coral); font-weight: 900; display: inline-flex; align-items: center; gap: 4px; font-size: 18px; }
.sound-toggle {
    background: none; border: none; cursor: pointer; font-size: 20px;
    line-height: 1; padding: 4px; border-radius: 10px; opacity: .85;
}
.sound-toggle:hover { opacity: 1; background: var(--snow-2); }

.lesson-body { flex: 1; max-width: 760px; margin: 0 auto; width: 100%; padding: 12px 20px 160px; }
.review-flag {
    display: inline-block; background: #fff4e0; color: var(--gold-d);
    border: 2px solid #ffe0b0; border-radius: 999px; padding: 6px 14px;
    font-weight: 800; font-size: 13px; margin-bottom: 14px;
}
.prompt-kicker { font-size: 14px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.question-title { font-size: 26px; margin: 0 0 22px; }

.choice-list { display: flex; flex-direction: column; gap: 12px; }
.choice {
    display: flex; align-items: center; gap: 14px;
    background: #fff; border: 2px solid var(--line); border-bottom-width: 4px;
    border-radius: var(--radius); padding: 16px 18px;
    font-weight: 700; font-size: 17px; cursor: pointer; text-align: left;
    transition: background .1s ease, border-color .1s ease;
    color: var(--ink);
}
.choice:hover { background: var(--snow-2); }
.choice.selected { background: var(--ice); border-color: var(--ice-line); color: var(--blue-d); }
.choice.correct { background: var(--green-soft); border-color: var(--green); color: var(--green-d); }
.choice.wrong { background: var(--coral-soft); border-color: var(--coral); color: var(--coral-d); }
.choice .key {
    width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--line);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 900; color: var(--muted);
}

/* image / emoji grid */
.img-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.img-card {
    background: #fff; border: 2px solid var(--line); border-bottom-width: 4px;
    border-radius: var(--radius); padding: 22px 14px 14px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    font-weight: 800; font-size: 16px; color: var(--ink);
    transition: background .1s, border-color .1s;
}
.img-card:hover { background: var(--snow-2); }
.img-card .emoji { font-size: 54px; line-height: 1; }
.img-card.selected { background: var(--ice); border-color: var(--ice-line); }
.img-card.correct { background: var(--green-soft); border-color: var(--green); }
.img-card.wrong { background: var(--coral-soft); border-color: var(--coral); }

/* true / false */
.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* fill blank — word bank */
.blank-sentence { font-size: 22px; font-weight: 800; line-height: 1.7; margin-bottom: 26px; }
.blank-slot {
    display: inline-block; min-width: 110px; border-bottom: 3px dashed var(--muted);
    text-align: center; color: var(--blue-d); padding: 0 6px;
}
.word-bank { display: flex; flex-wrap: wrap; gap: 12px; }
.word {
    background: #fff; border: 2px solid var(--line); border-bottom-width: 4px;
    border-radius: 12px; padding: 12px 18px; font-weight: 800; font-size: 17px;
    cursor: pointer; color: var(--ink);
}
.word:hover { background: var(--snow-2); }
.word.selected { background: var(--ice); border-color: var(--ice-line); color: var(--blue-d); }
.word.correct { background: var(--green-soft); border-color: var(--green); color: var(--green-d); }
.word.wrong { background: var(--coral-soft); border-color: var(--coral); color: var(--coral-d); }

/* match pairs */
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.match-col { display: flex; flex-direction: column; gap: 12px; }
.match-item {
    background: #fff; border: 2px solid var(--line); border-bottom-width: 4px;
    border-radius: 12px; padding: 14px 16px; font-weight: 700; font-size: 16px;
    cursor: pointer; color: var(--ink); text-align: left;
}
.match-item:hover { background: var(--snow-2); }
.match-item.selected { background: var(--ice); border-color: var(--ice-line); color: var(--blue-d); }
.match-item.done { background: var(--green-soft); border-color: var(--green); color: var(--green-d); opacity: .7; cursor: default; }
.match-item.bad { background: var(--coral-soft); border-color: var(--coral); }

/* feedback footer */
.feedback-bar {
    position: fixed; left: 0; right: 0; bottom: 0;
    padding: 18px 20px 26px;
    border-top: 2px solid var(--line);
    background: #fff;
    animation: slideUp .2s ease;
}
.feedback-bar.good { background: #e8ffd6; border-top-color: var(--green); }
.feedback-bar.bad { background: #ffeaea; border-top-color: var(--coral); }
.feedback-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.feedback-msg { display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 18px; }
.feedback-bar.good .feedback-msg { color: var(--green-d); }
.feedback-bar.bad .feedback-msg { color: var(--coral-d); }
.feedback-msg .fb-emoji { font-size: 30px; }
.feedback-fact { font-weight: 700; font-size: 14px; color: var(--ink-soft); margin-top: 2px; }
@keyframes slideUp { from { transform: translateY(100%);} to { transform: translateY(0);} }

.check-dock {
    position: fixed; left: 0; right: 0; bottom: 0; padding: 18px 20px 26px;
    border-top: 2px solid var(--line); background: #fff;
}
.check-inner { max-width: 760px; margin: 0 auto; display: flex; justify-content: flex-end; }

/* lesson complete screen */
.complete-screen { text-align: center; padding: 40px 20px; max-width: 520px; margin: 0 auto; }
.complete-screen h1 { font-size: 34px; margin: 18px 0 8px; color: var(--gold-d); }
.reward-row { display: flex; gap: 16px; justify-content: center; margin: 26px 0; flex-wrap: wrap; }
.reward {
    border-radius: var(--radius); padding: 14px 18px; min-width: 120px;
    border: 3px solid; font-weight: 900;
}
.reward .r-label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.reward .r-value { font-size: 26px; }
.reward.xp { border-color: var(--gold); color: var(--gold-d); background: #fff9e3; }
.reward.acc { border-color: var(--green); color: var(--green-d); background: #f0ffe3; }
.reward.streak { border-color: var(--coral); color: var(--coral-d); background: #fff0f0; }

/* --------------------------------------------------------------------------
   Auth pages
   -------------------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: radial-gradient(1000px 500px at 50% -10%, #d4edf3 0%, var(--snow) 55%); }
.auth-card {
    background: #fff; border: 2px solid var(--line); border-radius: var(--radius-lg);
    padding: 34px; width: 100%; max-width: 420px; box-shadow: 0 10px 40px rgba(15,42,63,.08);
}
.auth-card .brand { justify-content: center; padding: 0 0 10px; }
.auth-card h1 { text-align: center; font-size: 26px; margin: 0 0 6px; }
.auth-card .auth-sub { text-align: center; color: var(--muted); font-weight: 700; margin: 0 0 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 800; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.input {
    width: 100%; padding: 14px 16px; font-size: 16px; font-family: var(--font); font-weight: 600;
    border: 2px solid var(--line); border-radius: 12px; background: var(--snow); color: var(--ink);
}
.input:focus { border-color: var(--blue); background: #fff; outline: none; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); font-weight: 700; font-size: 14px; }
.val-error, .text-danger { color: var(--coral-d); font-weight: 700; font-size: 13px; }
.alert-danger { background: var(--coral-soft); color: var(--coral-d); border-radius: 12px; padding: 10px 14px; font-weight: 700; margin-bottom: 14px; }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */
.page-title { font-size: 30px; margin: 6px 0 4px; }
.page-sub { color: var(--ink-soft); font-weight: 600; margin: 0 0 20px; }

.card {
    background: #fff; border: 2px solid var(--line); border-bottom-width: 4px;
    border-radius: var(--radius-lg); padding: 22px;
}
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; }
.badge-tile { text-align: center; padding: 18px; border-radius: var(--radius); border: 2px solid var(--line); }
.badge-tile .bt-ico { font-size: 34px; }
.badge-tile .bt-val { font-size: 28px; font-weight: 900; }
.badge-tile .bt-label { font-size: 13px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff3cd; color: #664d03; padding: 12px 20px; z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,.1); font-weight: 700;
}
#blazor-error-ui .reload, #blazor-error-ui .dismiss { color: #664d03; margin-left: 10px; cursor: pointer; }

/* --------------------------------------------------------------------------
   Responsive — collapse sidebar into a bottom tab bar on phones
   -------------------------------------------------------------------------- */
@media (max-width: 820px) {
    /* --- Sidebar becomes a bottom tab bar --- */
    .sidebar {
        position: fixed; bottom: 0; left: 0; right: 0; top: auto;
        width: 100%; height: auto; flex-direction: row; justify-content: space-between;
        align-items: stretch;
        border-right: none; border-top: 2px solid var(--line);
        padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
        gap: 2px; z-index: 50;
        box-shadow: 0 -2px 12px rgba(10,36,50,.06);
    }
    .sidebar .brand, .sidebar .spacer { display: none; }
    .sidebar > form { flex: 1 1 0; min-width: 0; display: flex; }
    .nav-item {
        flex: 1 1 0; min-width: 0;
        flex-direction: column; gap: 3px; padding: 7px 1px;
        font-size: 9px; letter-spacing: 0; text-align: center;
        border: none; border-radius: 12px;
    }
    .nav-item .ico { font-size: 21px; width: auto; }
    .nav-item .label {
        display: block; overflow: hidden; text-overflow: ellipsis;
        white-space: nowrap; max-width: 100%;
    }
    .nav-item.active { background: none; border-color: transparent; color: var(--blue-d); }
    .nav-item.active .ico { transform: translateY(-1px); }
    .nav-item.logout { width: 100%; align-items: center; justify-content: center; }

    /* --- Content spacing: leave room for the bottom bar --- */
    .app-main { padding-bottom: 0; }
    .content-wrap { padding: 8px 16px 110px; }

    /* --- Sticky stats bar at the top --- */
    .statbar {
        position: sticky; top: 0; z-index: 20;
        background: var(--snow); justify-content: center; gap: 18px;
        padding: 12px 16px; margin-bottom: 4px;
    }

    /* --- Headings: a touch tighter on small screens --- */
    .page-title { font-size: 24px; }
    .page-sub { font-size: 15px; }
    .unit-header { padding: 16px 18px; margin: 24px 0 8px; }
    .unit-header h2 { font-size: 20px; }
    .unit-header .u-emoji { font-size: 32px; }

    /* --- Learn path: gentler zigzag so nodes never clip --- */
    .node-slot { transform: translateX(calc(var(--dx, 0px) * 0.5)); }
    .path { gap: 30px; }

    /* --- Lesson player: full-width, thumb-friendly actions --- */
    .lesson-top { padding: 14px 16px; gap: 12px; }
    .lesson-body { padding: 10px 16px 150px; }
    .question-title { font-size: 22px; }
    .img-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .img-card .emoji { font-size: 44px; }
    .match-cols { gap: 10px; }
    .match-item { padding: 12px 12px; font-size: 15px; }

    .check-dock { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
    .check-inner { justify-content: stretch; }
    .check-dock .btn { width: 100%; }

    .feedback-bar { padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); }
    .feedback-inner { flex-direction: column; align-items: stretch; gap: 12px; }
    .feedback-bar .btn { width: 100%; }

    /* --- Landing / auth --- */
    .landing-nav { padding: 14px 18px; }
    .landing-hero { padding: 12px 18px 40px; gap: 20px; }
    .landing-hero .art .nuna-mascot { width: min(220px, 56vw); height: auto; }
    .hero-cta { max-width: 100%; }
    .feature-row { padding: 0 18px; margin-bottom: 40px; }
    .auth-card { padding: 26px 20px; }
    .complete-screen { padding: 28px 16px; }
}
