/* ═══════════════════════════════════════════════════════════════
   Notebook (study-notebook.html)
   One place for mistakes, saved items (terms, lessons, quiz
   questions, marked exam questions) and personal lesson notes.
   Rendered by js/notebook-page.js. Uses the global design tokens
   from style.css so it follows the Day/Night theme automatically.
   ═══════════════════════════════════════════════════════════════ */

/* ── Hero ─────────────────────────────────────────────────────── */
.nb-hero {
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 26px;
    margin-bottom: 22px;
    border-radius: 24px;
    border: 1px solid var(--border-glass);
    background:
        radial-gradient(circle at 0% 0%, rgba(16, 185, 129, 0.16), transparent 42%),
        radial-gradient(circle at 100% 100%, rgba(139, 92, 246, 0.10), transparent 40%),
        var(--bg-glass);
    box-shadow: var(--shadow-glass);
    overflow: hidden;
}

.nb-hero__icon {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    background: rgba(16, 185, 129, 0.14);
    color: #059669;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    flex-shrink: 0;
}

.nb-hero__copy { flex: 1; min-width: 0; }

.nb-hero__title {
    font-family: var(--font-heading);
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.nb-hero__subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 60ch;
}

.nb-hero__stats {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.nb-stat {
    --nb-stat-accent: #10b981;
    appearance: none;
    border: 1px solid var(--border-glass);
    background: var(--bg-surface);
    border-radius: 16px;
    padding: 12px 16px;
    min-width: 108px;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font-family: inherit;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.nb-stat:hover,
.nb-stat:focus-visible {
    transform: translateY(-2px);
    border-color: var(--nb-stat-accent);
    box-shadow: 0 8px 22px rgba(2, 6, 23, 0.08);
    outline: none;
}

.nb-stat.is-active {
    border-color: var(--nb-stat-accent);
    box-shadow: inset 0 0 0 1px var(--nb-stat-accent);
}

.nb-stat__value {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    display: flex;
    align-items: center;
    gap: 9px;
}

.nb-stat__value::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--nb-stat-accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--nb-stat-accent) 18%, transparent);
    flex-shrink: 0;
}

.nb-stat__label {
    margin-top: 5px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.nb-stat--mistakes { --nb-stat-accent: #f43f5e; }
.nb-stat--saved    { --nb-stat-accent: #f59e0b; }
.nb-stat--notes    { --nb-stat-accent: #10b981; }

/* ── Tabs ─────────────────────────────────────────────────────── */
.nb-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    margin-bottom: 20px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.nb-tabs::-webkit-scrollbar { display: none; }

.nb-tab {
    --nb-tab-accent: #10b981;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 9px 16px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nb-tab i { font-size: 1.1rem; color: var(--nb-tab-accent); }
.nb-tab:hover { color: var(--text-primary); }
.nb-tab:focus-visible { outline: 2px solid var(--nb-tab-accent); outline-offset: 1px; }

.nb-tab.is-active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: 0 4px 14px rgba(2, 6, 23, 0.08);
}

.nb-tab__count {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--border-glass);
    color: var(--text-secondary);
    min-width: 22px;
    text-align: center;
}

.nb-tab.is-active .nb-tab__count {
    background: color-mix(in srgb, var(--nb-tab-accent) 16%, transparent);
    color: var(--nb-tab-accent);
}

.nb-tab--mistakes { --nb-tab-accent: #f43f5e; }
.nb-tab--saved    { --nb-tab-accent: #f59e0b; }
.nb-tab--notes    { --nb-tab-accent: #10b981; }

/* Panels are <section>s — neutralise the landing-page section spacing from style.css. */
.nb-panel { padding: 0; margin: 0; }

/* The page toggles sections with the hidden attribute; keep it authoritative. */
.nb-panel[hidden],
.nb-empty[hidden],
.nb-review-bar[hidden],
.nb-practice-btn[hidden],
.nb-hidden { display: none !important; }

/* ── Toolbar + chips ──────────────────────────────────────────── */
.nb-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.nb-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.nb-chip {
    appearance: none;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 0.83rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.nb-chip:hover { color: var(--text-primary); border-color: rgba(16, 185, 129, 0.35); }

.nb-chip.is-active {
    background: rgba(16, 185, 129, 0.14);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.35);
}

.nb-chip__count { font-size: 0.72rem; opacity: 0.8; }

.nb-toolbar__right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.nb-toolbar__stat { font-size: 0.83rem; color: var(--text-muted); }
.nb-toolbar .btn { padding: 0.6rem 1.1rem; font-size: 0.9rem; }

/* ── Mistake cards ────────────────────────────────────────────── */
.nb-list { display: flex; flex-direction: column; gap: 12px; }

.nb-card {
    border: 1px solid var(--border-glass);
    background: var(--bg-surface);
    border-radius: 18px;
    padding: 18px 20px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nb-card:hover {
    border-color: rgba(16, 185, 129, 0.25);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.05);
}

.nb-card__top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.nb-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 7px;
    padding: 3px 8px;
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
}

.nb-badge--pastpaper { background: rgba(139, 92, 246, 0.12); color: #7c3aed; }
.nb-badge--geoquiz   { background: rgba(16, 185, 129, 0.12); color: #059669; }
.nb-badge--mapdrill  { background: rgba(6, 182, 212, 0.12);  color: #0891b2; }
.nb-badge--academy   { background: rgba(245, 158, 11, 0.14); color: #d97706; }
.nb-badge--term      { background: rgba(16, 185, 129, 0.12); color: #059669; }
.nb-badge--lesson    { background: rgba(245, 158, 11, 0.14); color: #d97706; }
.nb-badge--question  { background: rgba(139, 92, 246, 0.12); color: #7c3aed; }
.nb-badge--exam      { background: rgba(244, 63, 94, 0.12);  color: #e11d48; }
.nb-badge--missed    { background: rgba(244, 63, 94, 0.12);  color: #e11d48; }

.nb-card__img {
    display: block;
    max-width: 200px;
    max-height: 130px;
    border-radius: 10px;
    margin: 0 0 10px;
    border: 1px solid var(--border-glass);
}

.nb-card__q {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.55;
    font-size: 0.98rem;
}

.nb-answers {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.86rem;
}

.nb-answer {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.nb-answer i { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
.nb-answer--wrong, .nb-answer--wrong i { color: #e11d48; }
.nb-answer--right, .nb-answer--right i { color: #059669; }
.nb-answer strong { font-weight: 600; color: inherit; }

.nb-card__actions {
    margin-top: 14px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nb-card__actions .btn {
    padding: 0.5rem 0.95rem;
    font-size: 0.85rem;
    border-radius: 10px;
}

.btn.nb-btn-soft { background: rgba(16, 185, 129, 0.10); color: #059669; }
.btn.nb-btn-soft:hover { background: rgba(16, 185, 129, 0.18); }

/* ── Saved grid ───────────────────────────────────────────────── */
.nb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.nb-scard {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border-glass);
    background: var(--bg-surface);
    border-radius: 18px;
    padding: 16px 18px;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.nb-scard:hover {
    transform: translateY(-2px);
    border-color: rgba(16, 185, 129, 0.28);
    box-shadow: 0 10px 26px rgba(2, 6, 23, 0.06);
}

.nb-scard__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 34px;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.nb-scard__title {
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
    font-size: 0.95rem;
}

.nb-scard__title a { color: inherit; text-decoration: none; }
.nb-scard__title a:hover { color: #059669; }

.nb-scard__sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nb-scard__img {
    width: 100%;
    max-height: 150px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
}

.nb-scard__foot {
    margin-top: auto;
    padding-top: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.nb-scard__open {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    color: #059669;
    text-decoration: none;
    font-size: 0.82rem;
}

.nb-scard__open:hover { text-decoration: underline; }

.nb-scard__remove,
.nb-icon-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.05rem;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.nb-scard__remove { position: absolute; top: 12px; right: 12px; }
.nb-scard__remove:hover, .nb-icon-btn--danger:hover { color: #e11d48; background: rgba(244, 63, 94, 0.10); }
.nb-icon-btn:hover { background: var(--border-glass); color: var(--text-primary); }

/* ── Exam review bar ──────────────────────────────────────────── */
.nb-review-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 18px;
    margin-bottom: 16px;
    border-radius: 18px;
    border: 1px solid rgba(244, 63, 94, 0.22);
    background: linear-gradient(120deg, rgba(244, 63, 94, 0.10), rgba(244, 63, 94, 0.03));
}

.nb-review-bar__icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(244, 63, 94, 0.14);
    color: #e11d48;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.nb-review-bar__copy { flex: 1; min-width: 200px; }
.nb-review-bar__title { font-weight: 700; color: var(--text-primary); font-size: 0.95rem; }
.nb-review-bar__desc { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.nb-review-bar__papers { display: flex; gap: 8px; flex-wrap: wrap; }

.nb-paper-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.83rem;
    font-weight: 600;
    background: var(--bg-surface);
    border: 1px solid rgba(244, 63, 94, 0.25);
    color: var(--text-primary);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.nb-paper-btn:hover { border-color: #e11d48; transform: translateY(-1px); }
.nb-paper-btn i { color: #e11d48; }

.nb-paper-btn__count {
    background: rgba(244, 63, 94, 0.12);
    color: #e11d48;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.74rem;
}

/* ── Notes ────────────────────────────────────────────────────── */
.nb-note {
    border: 1px solid var(--border-glass);
    background: var(--bg-surface);
    border-radius: 18px;
    padding: 18px 20px;
}

.nb-note__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.nb-note__icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.nb-note__titles { flex: 1; min-width: 0; }
.nb-note__title { font-weight: 700; color: var(--text-primary); line-height: 1.35; }
.nb-note__title a { color: inherit; text-decoration: none; }
.nb-note__title a:hover { color: #059669; }
.nb-note__meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.nb-note__actions { display: flex; gap: 4px; flex-shrink: 0; }

.nb-note__body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.92rem;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nb-note.is-expanded .nb-note__body {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}

.nb-note__more {
    margin-top: 6px;
    background: none;
    border: none;
    color: #059669;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.nb-note__editor textarea {
    width: 100%;
    min-height: 150px;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-primary);
    padding: 12px 14px;
    font-family: var(--font-body);
    font-size: 0.92rem;
    line-height: 1.55;
}

.nb-note__editor textarea:focus {
    outline: none;
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.14);
}

.nb-note__editor-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 10px;
}

.nb-note__editor-actions .btn { padding: 0.5rem 0.95rem; font-size: 0.85rem; border-radius: 10px; }

/* ── Empty states ─────────────────────────────────────────────── */
.nb-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    border: 1px dashed var(--border-glass);
    border-radius: 20px;
}

.nb-empty__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.nb-empty h3 { margin: 0 0 6px; color: var(--text-primary); font-family: var(--font-heading); }
.nb-empty p { margin: 0 auto; max-width: 48ch; line-height: 1.55; }
.nb-empty .btn { margin-top: 18px; }

/* ── Practice runner ──────────────────────────────────────────── */
.nb-practice__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.nb-practice__head h2 {
    margin: 0;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.2px;
}

.nb-practice { max-width: 760px; margin: 0 auto; padding: 26px; }

.nb-practice__progress {
    height: 6px;
    border-radius: 999px;
    background: var(--border-glass);
    overflow: hidden;
    margin-bottom: 14px;
}

.nb-practice__progress span {
    display: block;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.nb-practice__count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.nb-practice__q {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.55;
    margin-bottom: 18px;
}

.nb-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    border: 1.5px solid var(--border-glass);
    background: var(--bg-surface);
    color: var(--text-primary);
    border-radius: 14px;
    padding: 13px 16px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.nb-option:hover:not(:disabled) { border-color: rgba(16, 185, 129, 0.5); }
.nb-option:disabled { cursor: default; opacity: 0.9; }
.nb-option.is-correct { border-color: #059669; background: rgba(16, 185, 129, 0.12); }
.nb-option.is-wrong   { border-color: #e11d48; background: rgba(244, 63, 94, 0.10); }

.nb-option__letter {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.nb-practice__next { margin-top: 14px; text-align: right; }
.nb-practice__done { text-align: center; padding: 30px 10px; }
.nb-practice__done i { font-size: 3rem; color: #059669; }
.nb-practice__done h2 { margin: 12px 0 6px; color: var(--text-primary); }
.nb-practice__done p { color: var(--text-secondary); margin-bottom: 20px; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
    .nb-hero { flex-wrap: wrap; }
    .nb-hero__stats { width: 100%; }
    .nb-stat { flex: 1; min-width: 0; }
}

@media (max-width: 640px) {
    .nb-hero { padding: 20px; gap: 14px; }
    .nb-hero__icon { width: 48px; height: 48px; font-size: 1.6rem; border-radius: 14px; }
    .nb-hero__title { font-size: 1.3rem; }
    .nb-hero__subtitle { font-size: 0.88rem; }
    .nb-hero__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .nb-stat { padding: 10px 10px; min-width: 0; }
    .nb-stat__value { font-size: 1.25rem; }
    .nb-stat__label { white-space: normal; font-size: 0.66rem; line-height: 1.25; overflow-wrap: anywhere; }
    .nb-tabs { display: flex; width: 100%; }
    .nb-tab { flex: 1; justify-content: center; padding: 8px 8px; gap: 6px; font-size: 0.83rem; }
    .nb-tab i { font-size: 1rem; }
    .nb-tab__count { padding: 1px 6px; min-width: 18px; font-size: 0.68rem; }
    .nb-toolbar__right { width: 100%; margin-left: 0; justify-content: space-between; }
    .nb-card, .nb-note { padding: 16px; }
    .nb-practice { padding: 18px; }
    .nb-review-bar__papers { width: 100%; }
}

@media (max-width: 420px) {
    /* The hero tiles already show the counts; keep the three tabs on one row. */
    .nb-tab__count { display: none; }
    .nb-stat { padding: 10px 8px; }
    .nb-stat__label { text-transform: none; letter-spacing: 0; font-size: 0.72rem; overflow-wrap: normal; }
}
