/* ==========================================================================
   PassMRCS design system layer
   Loaded LAST. Unifies tokens, interaction states, accessibility and the
   student / exam surfaces on top of the existing stylesheets.
   ========================================================================== */

:root {
    /* Brand (unchanged): ink black + golden yellow */
    --primary: #FACC15;
    --primary-dark: #EAB308;
    --primary-ink: #0B0F19;

    /* Accessible text-on-light versions of the brand gold */
    --gold-text: #854D0E;          /* 7.6:1 on white */
    --gold-text-hover: #713F12;
    --gold-tint: #FEF9C3;
    --gold-tint-strong: #FEF08A;

    --ink: #0B0F19;
    --ink-2: #1E293B;
    --text: #0B0F19;
    --text-muted: #475569;         /* was #64748b; now 7:1 on white */
    --text-subtle: #64748B;
    --background: #F7F6F2;
    --surface: #FFFFFF;
    --surface-2: #F8FAFC;
    --border: #E5E2D9;
    --border-strong: #CBD5E1;

    --success: #15803D;
    --success-bg: #DCFCE7;
    --success-border: #22C55E;
    --error: #B91C1C;
    --danger: #DC2626;
    --error-bg: #FEE2E2;
    --error-border: #EF4444;
    --warning-bg: #FEF3C7;
    --warning-text: #92400E;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.10);
    --focus-ring: 0 0 0 3px #FFFFFF, 0 0 0 5px #0B0F19;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--background); }
img { max-width: 100%; }

/* ---------- Typography scale ---------- */
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); line-height: 1.2; letter-spacing: -0.015em; }
h2 { font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.5rem); line-height: 1.3; }
h3 { line-height: 1.35; }
.text-muted { color: var(--text-muted) !important; }

/* ---------- Focus & motion (accessibility) ---------- */
:where(a, button, input, select, textarea, summary, [role="button"], [tabindex]):focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Links & breadcrumbs: brand gold was 1.5:1 on cream; use readable gold ---------- */
.crumb-link, .breadcrumbs .crumb-link, a.crumb-link {
    color: var(--gold-text) !important;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    cursor: pointer;
    font-weight: 500;
}
.crumb-link:hover { color: var(--gold-text-hover) !important; }
.crumb-sep { color: var(--text-subtle); margin: 0 0.15rem; }
.breadcrumbs { font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }

/* ---------- Navbar ---------- */
.navbar { padding: 0.75rem clamp(1rem, 3vw, 2rem); box-shadow: var(--shadow-sm); gap: 1rem; min-height: 64px; }
.nav-brand { font-size: 1.25rem; gap: 0.5rem; min-width: 0; }
.brand-logo { height: 32px; width: auto; }
.nav-right { gap: 0.75rem; flex-wrap: nowrap; }

/* ---------- Buttons ---------- */
.btn {
    min-height: 42px;
    padding: 0.6rem 1.15rem;
    border-radius: 10px;
    font-size: 0.95rem;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn i, .btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: var(--ink); border: 1px solid var(--primary-dark); }
.btn-primary:hover { background: var(--primary-dark); color: var(--ink); transform: none; }
.btn-primary:active { background: #CA8A04; }
.btn-outline { background: var(--surface); border: 1px solid var(--border-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink); color: var(--ink); background: var(--surface-2); }
.btn-sm { min-height: 36px; padding: 0.45rem 0.85rem; font-size: 0.875rem; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-logout { border: 1px solid var(--border-strong); border-radius: 10px; min-height: 38px; }
.btn-logout:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- Cards, forms, tables ---------- */
.card { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.form-input, input.form-input, select.form-input, textarea.form-input {
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    min-height: 42px;
    font-size: 1rem;
    background: #fff;
    color: var(--ink);
}
.form-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.45); outline: none; }
.form-group label { font-weight: 600; color: var(--ink-2); }
input[type="radio"], input[type="checkbox"] { accent-color: var(--ink); width: 16px; height: 16px; }

/* Wide admin tables scroll inside their card instead of being clipped */
.card table, .admin-table, .data-table { width: 100%; }
.card:has(> table), .card:has(> .table-container), .table-container, .table-wrapper, .payments-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table th { white-space: nowrap; }

/* Admin tabs: active tab in ink with gold underline (gold text was unreadable on white) */
.tab-btn { color: var(--text-muted); font-weight: 600; }
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink) !important; border-bottom-color: var(--primary) !important; }
.tabs { overflow-x: auto; scrollbar-width: thin; }

/* Payments table: keep Approve / Reject reachable without sideways scrolling */
.payments-table th, .payments-table td { padding: 0.75rem 0.6rem; vertical-align: middle; }
.payments-table .col-actions { position: sticky; right: 0; background: #fff; box-shadow: -8px 0 12px -10px rgba(15, 23, 42, 0.25); }
.payments-table thead .col-actions { background: inherit; }
.pay-actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }

/* ---------- Badges & toasts ---------- */
.badge { border-radius: 999px; }
.toast-container { z-index: 4000; }

/* ---------- Empty states & notices ---------- */
.empty-state { text-align: center; padding: 2.5rem 1.5rem; color: var(--text-muted); }
.empty-state > i, .empty-state > svg { width: 40px; height: 40px; color: var(--text-subtle); margin-bottom: 0.75rem; }
.empty-state h3 { color: var(--ink); margin-bottom: 0.35rem; font-size: 1.1rem; }
.notice-card { display: flex; gap: 1.25rem; align-items: flex-start; padding: 1.75rem; }
.notice-card h2 { margin-bottom: 0.4rem; }
.notice-icon { flex-shrink: 0; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--error-bg); color: var(--error); }
.notice-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }
.notice-inline { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; border-radius: 10px; background: var(--warning-bg); color: var(--warning-text); font-weight: 500; margin-bottom: 1.25rem; flex-wrap: wrap; }
.notice-inline a { color: var(--warning-text); font-weight: 700; }
.notice-inline i, .notice-inline svg { width: 18px; height: 18px; }

/* ==========================================================================
   Student dashboard
   ========================================================================== */
.dash-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.dash-eyebrow { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-text); margin-bottom: 0.25rem; }
.sub-pill { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.85rem; border-radius: 999px; background: var(--success-bg); color: var(--success); font-weight: 600; font-size: 0.85rem; }
.sub-pill.is-warning { background: var(--warning-bg); color: var(--warning-text); }
.sub-pill i, .sub-pill svg { width: 16px; height: 16px; }

.stat-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.15rem; box-shadow: var(--shadow-sm); }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--ink); line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 0.95rem; font-weight: 600; color: var(--text-subtle); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.section-title { font-size: 1.1rem; margin-bottom: 1rem; color: var(--ink); }

.qbank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1.25rem; }
.qbank-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.25rem 1.25rem 1.1rem; display: flex; flex-direction: column; gap: 0.75rem;
    cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .15s ease, box-shadow .15s ease;
    min-width: 0;
}
.qbank-card:hover { border-color: var(--ink); box-shadow: var(--shadow); }
.qbank-card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.qbank-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--gold-tint); color: var(--gold-text); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.qbank-icon i, .qbank-icon svg { width: 22px; height: 22px; }
.qbank-icon img { width: 100%; height: 100%; object-fit: contain; }
.qbank-card.is-osce .qbank-icon { background: var(--ink); color: var(--primary); }
.qbank-tag { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); padding: 0.2rem 0.55rem; border-radius: 999px; white-space: nowrap; }
.qbank-title { font-size: 1.1rem; font-weight: 700; color: var(--ink); margin: 0; overflow-wrap: anywhere; }
.qbank-sub { font-size: 0.9rem; color: var(--text-muted); margin: 0; }
.qbank-progress { display: flex; flex-direction: column; gap: 0.4rem; }
.qbank-bar { height: 8px; border-radius: 999px; background: #EEF0F3; overflow: hidden; display: flex; }
.qbank-bar .bar-correct { background: #16A34A; }
.qbank-bar .bar-wrong { background: #EF4444; }
.qbank-progress-meta { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.qbank-cta { margin-top: auto; display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.qbank-cta i, .qbank-cta svg { width: 16px; height: 16px; transition: transform .15s ease; }
.qbank-card:hover .qbank-cta svg { transform: translateX(3px); }

/* Folder rows (topics) */
.passmed-row { cursor: pointer; min-height: 56px; }
.passmed-row:focus-visible { box-shadow: var(--focus-ring); }
.pm-stats { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; min-width: 80px; }
.pm-count { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.quiz-setup-heading { margin: 1.5rem 0 0.25rem; font-size: 1.05rem; text-align: center; }
.quiz-setup-sub { text-align: center; font-size: 0.9rem; margin: 0; }
.single-page-quiz-setup { border-radius: var(--radius) !important; }

/* ==========================================================================
   Exam interface
   ========================================================================== */
.quiz-navbar { position: sticky; top: 0; }
.quiz-mode-pill { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; padding: 0.25rem 0.6rem; border-radius: 999px; background: var(--gold-tint); color: var(--gold-text); margin-left: 0.25rem; white-space: nowrap; }
.quiz-timer-pill {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.8rem; border-radius: 999px;
    border: 1px solid var(--border-strong); background: var(--surface); font-weight: 700; font-variant-numeric: tabular-nums;
    min-width: 92px; justify-content: center; color: var(--ink);
}
.quiz-timer-pill i, .quiz-timer-pill svg { width: 16px; height: 16px; color: var(--text-muted); }
.quiz-progress-track { height: 4px; background: #E9E7E1; position: sticky; top: 64px; z-index: 90; }
.quiz-progress-fill { height: 100%; background: var(--ink); transition: width .25s ease; }

.quiz-main { padding-top: 1.5rem; padding-bottom: 6rem; }
.quiz-shell { max-width: 820px; margin: 0 auto; }
.quiz-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.85rem; gap: 1rem; }
.quiz-counter { color: var(--text-muted); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.quiz-counter strong { color: var(--ink); }
.btn-flag {
    width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface);
    color: var(--text-muted); display: inline-grid; place-items: center; cursor: pointer;
}
.btn-flag:hover { border-color: #D97706; color: #B45309; }
.btn-flag.active { border-color: #D97706; color: #B45309 !important; background: #FFFBEB; }
.btn-flag i, .btn-flag svg { width: 18px; height: 18px; }

.quiz-card { padding: clamp(1.1rem, 3vw, 1.75rem); margin-bottom: 1rem; }
.quiz-card .question-text { font-size: 1.075rem; font-weight: 500; line-height: 1.7; margin-bottom: 1.25rem; color: var(--ink); overflow-wrap: anywhere; }
.quiz-card .question-text img { height: auto; border-radius: 8px; margin: 0.75rem 0; }
.options-list { display: flex; flex-direction: column; gap: 0.6rem; }
.option-btn {
    min-height: 52px; padding: 0.8rem 1rem; border: 1px solid var(--border-strong); border-radius: 12px;
    background: var(--surface); color: var(--ink); align-items: center; gap: 0.85rem; font-size: 1rem; line-height: 1.5;
    transition: border-color .12s ease, background-color .12s ease;
}
.option-btn .opt-letter {
    width: 30px; height: 30px; min-width: 30px; border-radius: 50%; display: inline-grid; place-items: center;
    border: 1px solid var(--border-strong); color: var(--ink-2); font-size: 0.85rem; font-weight: 700; background: var(--surface-2);
}
.option-btn .opt-text { flex: 1; overflow-wrap: anywhere; }
.option-btn:hover:not(:disabled) { border-color: var(--ink); background: var(--surface-2); }
.option-btn.selected { border: 2px solid var(--ink); background: var(--gold-tint); padding: calc(0.8rem - 1px) calc(1rem - 1px); }
.option-btn.selected .opt-letter { background: var(--ink); color: var(--primary); border-color: var(--ink); }
.option-btn.correct { border: 2px solid var(--success-border) !important; background: var(--success-bg) !important; color: #14532D !important; padding: calc(0.8rem - 1px) calc(1rem - 1px); }
.option-btn.correct .opt-letter { background: #16A34A; color: #fff; border-color: #16A34A; }
.option-btn.incorrect { border: 2px solid var(--error-border) !important; background: var(--error-bg) !important; color: #7F1D1D !important; padding: calc(0.8rem - 1px) calc(1rem - 1px); }
.option-btn.incorrect .opt-letter { background: #DC2626; color: #fff; border-color: #DC2626; }
.option-btn:disabled:not(.correct):not(.incorrect) { color: var(--text-muted); opacity: 1; }
.option-btn:disabled { cursor: default; }
.quiz-hint { margin: 1rem 0 0; font-size: 0.85rem; color: var(--text-muted); }

.explanation-box { margin-top: 0; border-left: 4px solid var(--primary); background: #FFFDF5; animation: none; }
.explanation-box h3 { display: flex; align-items: center; gap: 0.5rem; font-size: 1.05rem; margin-bottom: 0.75rem; }
.explanation-box h3 svg { width: 20px; height: 20px; color: var(--gold-text); }
.explanation-box .prose { line-height: 1.75; color: var(--ink-2); overflow-wrap: anywhere; }
.explanation-box .prose img { height: auto; }

.quiz-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.quiz-footer #next-btn-top.hidden { display: block !important; visibility: hidden; } /* reserve space: no layout shift */
.quiz-footer .btn { min-width: 130px; }

/* Progress rings: the SVG uses rotate(-90 cx cy); a CSS transform-origin on top of
   that shifted the coloured arc off the circle. Reset it so the arc sits on the ring. */
.progress-ring circle, .progress-ring-svg circle { transform-origin: 0 0 !important; transform-box: view-box; }

/* Buttons placed on the dark summary footer */
.btn-on-dark { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.4); }
.btn-on-dark:hover { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: #fff; }

/* Quiz summary */
.quiz-summary-table { width: 100%; }
.quiz-summary-table td, .quiz-summary-table th { vertical-align: middle; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    #main-content { padding: 1.25rem 1rem; }
    .stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
    .stat-tile { padding: 0.75rem; }
    .stat-value { font-size: 1.25rem; }
    .stat-label { font-size: 0.75rem; }
    .quiz-progress-track { top: 60px; }
    .quiz-footer {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; margin: 0;
        background: rgba(255, 255, 255, 0.97); border-top: 1px solid var(--border);
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
        box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
    }
    .quiz-footer .btn { flex: 1; min-width: 0; min-height: 48px; }
    .quiz-footer #next-btn-top { flex: 1.4; display: flex; }
    .quiz-footer #next-btn-top .btn { width: 100%; }
    .quiz-navbar .nav-right .btn-outline { display: none; } /* End block lives in the bottom bar */
    .notice-card { flex-direction: column; }
}
@media (hover: none) { .kbd-hint { display: none; } }
@media (max-width: 600px) { .col-stem { display: none; } }
@media (max-width: 480px) {
    .navbar { min-height: 56px; padding: 0.6rem 0.85rem; }
    .nav-brand { font-size: 1.05rem; }
    .brand-logo { height: 28px; }
    .quiz-mode-pill { display: none; }
    .quiz-progress-track { top: 56px; }
    .option-btn { padding: 0.7rem 0.8rem; gap: 0.65rem; font-size: 0.975rem; }
    .option-btn.selected, .option-btn.correct, .option-btn.incorrect { padding: calc(0.7rem - 1px) calc(0.8rem - 1px); }
    .quiz-card .question-text { font-size: 1rem; }
    .stat-strip { gap: 0.5rem; }
    .stat-value { font-size: 1.1rem; }
    .dash-header h1 { font-size: 1.4rem; }
    .single-page-quiz-setup > div:first-child { grid-template-columns: 1fr !important; }
}

/* ==========================================================================
   Landing header: seven links + three buttons wrapped and overlapped the logo
   at common laptop widths. Keep links on one line and drop secondary links
   progressively instead of wrapping.
   ========================================================================== */
.landing-navbar { gap: 1.25rem; }
.landing-nav-links { gap: 1.25rem; align-items: center; min-width: 0; }
.landing-nav-link, .landing-nav-actions .btn { white-space: nowrap; }
@media (max-width: 1480px) {
    .landing-nav-links a[href="#preview"],
    .landing-nav-links a[href="#payment"] { display: none; }
}
@media (max-width: 1240px) {
    .landing-nav-links a[href="#features"],
    .landing-nav-links a[href="#faq"] { display: none; }
}
@media (max-width: 1024px) {
    .landing-nav-links { display: none; }
}
