/* =========================================================================================
   public/assets/css/style.css
   -----------------------------------------------------------------------------------------
   THE SITE'S ENTIRE STYLESHEET — one file, loaded by every page via app/layout.php's
   page_header(). Organized top-to-bottom as:
     1. CSS custom properties (design tokens) that DON'T change per-admin (spacing, fonts,
        shadows, borders) — the 4 THEME COLOR variables (--color-primary etc.) are instead
        injected inline per-page by app/layout.php, straight from the site_settings table,
        so an admin's color choice takes effect with zero changes to this file.
     2. Reset / base element styles.
     3. Layout primitives (.container, grids).
     4. Reusable components (buttons, cards, forms, alerts, badges, tables).
     5. Page-specific styles, grouped by the page(s) that use them.
     6. Responsive breakpoints (mobile-first: base styles ARE the mobile styles; larger
        screens get MORE layout via min-width media queries) — requirement #10.

   REQUIREMENT #10 ("responsive and modern... mobile and desktop, all modern browsers"):
   this file uses only widely-supported modern CSS (custom properties, Flexbox, Grid,
   clamp()) with no vendor-prefix hacks needed in any current-generation browser.
   ========================================================================================= */


/* ============================== 1. DESIGN TOKENS ============================== */
:root {
    /* --color-primary / --color-secondary / --color-accent / --color-bg are injected
       inline by app/layout.php from the site_settings table — NOT redefined here, so
       an admin's saved color choice always wins. Fallbacks exist only in case some
       future page forgets to include that inline <style> block. */
    --color-primary:   #0b3d78;
    --color-secondary: #0f6bb8;
    --color-accent:    #50c0f0;
    --color-bg:        #f4f6fa;

    /* Neutral grays used for text/borders/surfaces — these don't need to be
       admin-configurable, so they live here as ordinary fixed tokens. */
    --color-text:        #1c2530;
    --color-text-muted:  #5b6672;
    --color-border:      #dde3ea;
    --color-surface:     #ffffff;
    --color-success-bg:  #e6f7ec;
    --color-success-fg:  #1c7a3c;
    --color-error-bg:    #fdeaea;
    --color-error-fg:    #b3261e;
    --color-info-bg:     #e8f2fb;
    --color-info-fg:     #14548c;
    /* Added for the account-controls update (pending-approval badges/alerts, and any
       future "needs attention but isn't an error" state) — kept as its own semantic
       pair rather than reusing --color-error-* so "awaiting action" never reads as
       visually identical to "something is wrong". */
    --color-warning-bg:  #fff3cd;
    --color-warning-fg:  #8a6100;

    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-card: 0 1px 3px rgba(20, 30, 45, 0.08), 0 1px 2px rgba(20, 30, 45, 0.06);
    --shadow-card-hover: 0 6px 16px rgba(20, 30, 45, 0.12);
    --max-width: 1120px;
    --spacing-unit: 1rem;
}

/* The "Compact" layout density option (public/admin/settings.php) simply shrinks the
   base font size and spacing unit — every component below is built from `rem` units
   and var(--spacing-unit), so this one change cascades through the whole site. */
body.layout-compact {
    --spacing-unit: 0.7rem;
    font-size: 15px;
}
body.layout-comfortable {
    font-size: 16px;
}


/* ============================== 2. RESET / BASE ============================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3 { line-height: 1.25; color: var(--color-primary); margin-top: 0; }
h1 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem); }
h2 { font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.5rem); }
h3 { font-size: 1.1rem; }

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

img { max-width: 100%; height: auto; display: block; }

code { background: #eef1f5; padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.9em; }

table { border-collapse: collapse; width: 100%; }


/* ============================== 3. LAYOUT PRIMITIVES ============================== */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-unit);
}

.site-main { flex: 1 0 auto; padding: calc(var(--spacing-unit) * 2) 0; }

.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-unit);
    margin: var(--spacing-unit) 0;
}
@media (min-width: 640px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
    .card-grid { grid-template-columns: repeat(3, 1fr); }
}


/* ============================== 4. REUSABLE COMPONENTS ============================== */

/* ---- Cards ---- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: calc(var(--spacing-unit) * 1.4);
    margin-bottom: var(--spacing-unit);
}
a.admin-nav-card, a.domain-card { text-decoration: none; color: inherit; display: block; transition: box-shadow 0.15s ease, transform 0.15s ease; }
a.admin-nav-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    font: inherit;
    font-weight: 600;
    padding: 0.6em 1.3em;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-secondary { background: #fff; color: var(--color-primary); border-color: var(--color-primary); }
.btn-danger { background: var(--color-error-fg); color: #fff; }
.btn-lg { padding: 0.8em 1.8em; font-size: 1.05rem; }
.btn-small { padding: 0.35em 0.8em; font-size: 0.85rem; }
.btn-block { display: block; width: 100%; }
.btn-nav-signup { background: var(--color-accent); color: #06283f; padding: 0.4em 1em; border-radius: var(--radius-sm); }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.form-hint-inline { font-weight: 400; color: var(--color-text-muted); font-size: 0.85em; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="file"], input[type="color"], select, textarea {
    width: 100%;
    padding: 0.55em 0.7em;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
    color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}
input[type="color"] { padding: 0.15em; height: 2.6em; width: 3.2em; flex: none; }
textarea { resize: vertical; font-family: var(--font-family); }
.form-row { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .form-row { grid-template-columns: 1fr 1fr; } }
.form-row-block { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1rem; }
.form-group-inline { display: flex; align-items: center; gap: 0.6rem; }
.form-group-inline input { width: 6rem; }
.form-hint { color: var(--color-text-muted); font-size: 0.9rem; }
.form-section-title { border-top: 1px solid var(--color-border); padding-top: 1rem; margin-top: 1.5rem; }
.form-section-note { color: var(--color-text-muted); font-size: 0.9rem; margin-top: -0.5rem; }
.checkbox-option, .radio-option { display: flex; align-items: flex-start; gap: 0.6rem; font-weight: 400; cursor: pointer; padding: 0.4rem 0; }
.checkbox-option input, .radio-option input { width: auto; margin-top: 0.2rem; flex: none; }
.checkbox-option-group { display: flex; flex-direction: column; }
.radio-row { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 1rem; }
.color-input-row { display: flex; gap: 0.5rem; align-items: center; }
.color-input-row input[type="text"] { flex: 1; }
.inline-form { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0.15rem 0; }
.inline-form-row { display: flex; gap: 0.6rem; align-items: center; }
.inline-form-input { width: auto; padding: 0.3em 0.5em; }
.flex-grow { flex: 1; }
.alert-list { margin: 0; padding-left: 1.2rem; }

/* ---- Alerts / flash messages ---- */
.alert { padding: 0.8em 1.1em; border-radius: var(--radius-sm); margin: 1rem 0; }
.alert-success { background: var(--color-success-bg); color: var(--color-success-fg); }
.alert-error   { background: var(--color-error-bg);   color: var(--color-error-fg); }
.alert-info    { background: var(--color-info-bg);    color: var(--color-info-fg); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-fg); }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.2em 0.6em;
    border-radius: 999px;
    background: #eef1f5;
    color: var(--color-text-muted);
}
.badge-admin { background: var(--color-primary); color: #fff; }
.badge-corrected { background: #fff3cd; color: #8a6100; }
.badge-kind { background: var(--color-info-bg); color: var(--color-info-fg); }
.badge-pending { background: var(--color-warning-bg); color: var(--color-warning-fg); }
.status-correct { background: var(--color-success-bg); color: var(--color-success-fg); }
.status-incorrect { background: var(--color-error-bg); color: var(--color-error-fg); }
.status-skipped { background: #f0f0f0; color: var(--color-text-muted); }
.utc-offset-tag { font-size: 0.85em; font-weight: 400; color: var(--color-text-muted); white-space: nowrap; }

/* ---- Data tables ---- */
.table-scroll { overflow-x: auto; margin-bottom: 1rem; } /* horizontal scroll on narrow screens, never the whole page */
.data-table { min-width: 640px; }
.data-table th, .data-table td { text-align: left; padding: 0.6em 0.8em; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.data-table th { background: #f7f9fc; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); }
.admin-row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.question-preview-cell { max-width: 320px; }
.ua-cell { max-width: 260px; overflow-wrap: anywhere; font-size: 0.85rem; color: var(--color-text-muted); }
.temp-password { font-size: 1.1rem; padding: 0.15em 0.5em; }


/* ============================== 5. PAGE-SPECIFIC STYLES ============================== */

/* ---- Top navigation (all pages) ---- */
.site-header { background: var(--color-primary); color: #fff; }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; padding: 0.8rem var(--spacing-unit); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-badge { background: var(--color-accent); color: #06283f; font-weight: 800; padding: 0.25em 0.55em; border-radius: 6px; }
.nav-toggle-checkbox { display: none; }
.nav-toggle-label { display: none; color: #fff; font-size: 1.6rem; cursor: pointer; line-height: 1; }
.site-nav { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.site-nav a { color: #dce7f5; font-weight: 500; }
.site-nav a.active, .site-nav a:hover { color: #fff; }
.site-nav a.nav-logout { color: #f6c6c0; }

/* Mobile nav: collapse into a hamburger-triggered stack using ONLY the checkbox hack
   (no JavaScript at all) — see app/layout.php's comment on #nav-toggle. */
@media (max-width: 720px) {
    .nav-toggle-label { display: block; }
    .site-nav {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 0;
        background: var(--color-primary);
    }
    .site-nav a { display: block; width: 100%; padding: 0.6rem 0; border-top: 1px solid rgba(255,255,255,0.15); }
    .nav-toggle-checkbox:checked ~ .site-nav { display: flex; }
}

/* ---- Footer (all pages) ---- */
.site-footer { background: #0a1f38; color: #b9c6d6; padding: 1.2rem 0; margin-top: 2rem; font-size: 0.85rem; }
.site-footer-note { margin: 0.2rem 0 0; opacity: 0.75; }

/* ---- Landing page (public/index.php) ---- */
.hero { text-align: center; padding: 2rem 0 1rem; }
.hero-tagline { font-size: 1.15rem; color: var(--color-text-muted); max-width: 640px; margin: 0.5rem auto; }
.hero-stats { color: var(--color-text-muted); }
.hero-actions { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.2rem; }
.domain-overview { margin-top: 2rem; }
.domain-card-number { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; color: var(--color-secondary); letter-spacing: 0.05em; }
.feature-highlights { margin-top: 2rem; }

/* ---- Auth pages (login/signup/forgot/force-change) ---- */
.auth-page { display: flex; justify-content: center; padding: 1rem 0; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card-wide { max-width: 720px; }
.auth-subtitle { color: var(--color-text-muted); margin-top: -0.5rem; }
.auth-links { text-align: center; margin-top: 1rem; font-size: 0.9rem; }
.auth-links-sep { margin: 0 0.4rem; color: var(--color-border); }
.security-question-row { align-items: end; }

/* ---- Dashboard (public/dashboard.php) ---- */
.page-subtitle { color: var(--color-text-muted); }
.dashboard-form-card { max-width: 760px; }
.domain-picker { display: grid; grid-template-columns: 1fr; gap: 0.6rem; margin-bottom: 1rem; }
@media (min-width: 640px) { .domain-picker { grid-template-columns: 1fr 1fr; } }
.domain-option {
    display: flex; gap: 0.6rem; align-items: flex-start; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); padding: 0.7rem; cursor: pointer;
}
.domain-option:has(input:checked) { border-color: var(--color-secondary); background: var(--color-info-bg); }
.domain-option input { margin-top: 0.25rem; }
.domain-option-body { display: flex; flex-direction: column; }
.domain-option-count { font-size: 0.85rem; color: var(--color-text-muted); }
/* v2.4: "Specific Topics" is the 3rd, mutually-exclusive choice in the same radio
   group as "All Domains Combined" and each individual domain — a dashed border (vs.
   the other options' solid one) is the one visual cue that this option behaves
   differently (it reveals the topic checklist below instead of just narrowing by
   domain), while :has(input:checked) above still gives it the same "selected" look
   as any other radio once chosen. */
.domain-option-topics { border-style: dashed; }

/* ---- Topic filter picker (v2.2 feature; v2.4: now shown only for the "Specific
   Topics" exam-domain choice, see .topic-picker-wrapper below; public/dashboard.php) ----
   A search box + Select All/Clear All row above a scrollable checkbox grid — with
   71 topics to choose from, an unfiltered flat list would be unusable, so
   initTopicFilter() in app.js hides/shows .topic-option rows as the visitor types
   and toggles only the currently-VISIBLE checkboxes on Select All/Clear All. */
.topic-picker-wrapper {
    border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    background: var(--color-info-bg); padding: 0.8rem 1rem; margin-bottom: 1.2rem;
}
.topic-picker-wrapper[hidden] { display: none; }
.topic-picker-controls { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 0.7rem; }
.topic-picker-controls input[type="search"] { flex: 1 1 220px; }
.topic-picker-count { font-size: 0.85rem; color: var(--color-text-muted); margin-left: auto; }
.topic-picker-list {
    display: grid; grid-template-columns: 1fr; gap: 0.1rem 1rem; max-height: 320px;
    overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem; margin-bottom: 0.4rem;
}
@media (min-width: 640px) { .topic-picker-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .topic-picker-list { grid-template-columns: 1fr 1fr 1fr; } }
.topic-option { display: flex; align-items: baseline; gap: 0.4rem; padding: 0.25rem 0; font-size: 0.92rem; }
.topic-option input { margin-top: 0.15rem; flex: none; }
.topic-option-count { font-size: 0.78rem; color: var(--color-text-muted); }
.topic-option[hidden] { display: none; }
.topic-picker-empty-notice { display: none; color: var(--color-text-muted); font-size: 0.9rem; padding: 0.4rem 0; }

/* ---- Admin: Topic catalog management (public/admin/topics.php, v2.2) ---- */
/* Visually-hidden but still screen-reader-accessible label, for the "Add a New Topic"
   input above, which is self-explanatory from its placeholder + the card's own heading. */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
/* Both override the narrow 6rem default .form-group-inline/.inline-form-input width —
   a topic NAME needs much more room than the numeric inputs those defaults were sized for. */
.topic-name-input { width: 100%; max-width: 26rem; }
.topic-rename-input { width: 14rem; max-width: 100%; }

/* ---- Exam runner (public/exam.php) ---- */
.exam-progress-bar { height: 8px; background: var(--color-border); border-radius: 999px; overflow: hidden; margin-bottom: 0.6rem; }
.exam-progress-fill { height: 100%; background: var(--color-accent); transition: width 0.3s ease; }
.exam-meta-row { display: flex; flex-wrap: wrap; gap: 1rem; color: var(--color-text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.exam-timer-value { font-weight: 700; color: var(--color-primary); }
.question-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.question-instruction { color: var(--color-primary); }
.question-body :is(p) { margin: 0 0 0.9rem; }
.question-body table.mdtable { margin: 0.8rem 0; }
.question-body table.mdtable th, .question-body table.mdtable td { border: 1px solid var(--color-border); padding: 0.45em 0.7em; }
.question-exhibit { margin: 1rem 0; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; }
.option-row { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.5rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); margin-bottom: 0.5rem; cursor: pointer; }
.option-row input { margin-top: 0.2rem; flex: none; }
.yesno-grid th, .yesno-grid td { border: 1px solid var(--color-border); padding: 0.5em 0.7em; }
.yesno-cell { text-align: center; width: 4rem; }
.blank-row { max-width: 480px; }
.dragdrop-item-bank { border: 1px dashed var(--color-border); border-radius: var(--radius-sm); padding: 0.8rem; margin-bottom: 1rem; }
.drag-item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.drag-chip { background: var(--color-info-bg); color: var(--color-info-fg); border: 1px solid var(--color-secondary); border-radius: 999px; padding: 0.3em 0.9em; cursor: grab; user-select: none; }
.drag-chip.drag-chip-placed { opacity: 0.4; }
.drop-target-row.drag-over select { outline: 2px dashed var(--color-accent); }
.exam-form-actions { display: flex; gap: 1rem; margin-top: 1.2rem; flex-wrap: wrap; }
.reveal-banner { font-size: 1.1rem; font-weight: 700; }
.review-row.review-correct { border-color: var(--color-success-fg); background: var(--color-success-bg); }
.review-row.review-wrong { border-color: var(--color-error-fg); background: var(--color-error-bg); }
.review-table td.review-correct { background: var(--color-success-bg); }
.review-table td.review-wrong { background: var(--color-error-bg); }
.review-table th, .review-table td { border: 1px solid var(--color-border); padding: 0.5em 0.7em; }
.review-tag { font-size: 0.75rem; font-weight: 700; margin-left: 0.5rem; color: var(--color-text-muted); }
.review-tag-correct { color: var(--color-success-fg); }
.explanation-block { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--color-border); }
.question-note { font-style: italic; color: var(--color-text-muted); margin-top: 0.6rem; }

/* ---- Results / History ---- */
.results-summary-card { text-align: center; max-width: 560px; margin-left: auto; margin-right: auto; }
.results-score { margin: 1rem 0; }
.results-score-number { font-size: 3rem; font-weight: 800; }
.score-pass .results-score-number { color: var(--color-success-fg); }
.score-fail .results-score-number { color: var(--color-error-fg); }
.results-score-detail { color: var(--color-text-muted); }
.results-meta { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; text-align: left; max-width: 360px; margin: 1rem auto; }
.results-meta dt { font-weight: 600; color: var(--color-text-muted); }
.results-meta dd { margin: 0; }
.results-actions { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.review-item summary { cursor: pointer; display: flex; align-items: center; gap: 0.7rem; list-style: none; }
.review-item summary::-webkit-details-marker { display: none; }
.review-item-number { font-weight: 700; color: var(--color-primary); }
.review-item-snippet { color: var(--color-text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-item-body { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--color-border); }
.review-toolbar { display: flex; justify-content: flex-end; gap: 0.6rem; flex-wrap: wrap; margin: 0 0 0.8rem; }
.history-stats-grid, .admin-stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat-card { text-align: center; }
.stat-number { font-size: 2rem; font-weight: 800; color: var(--color-primary); }
.stat-label { color: var(--color-text-muted); font-size: 0.9rem; }
.empty-state { text-align: center; padding: 2.5rem 1rem; }

/* ---- Profile ---- */
.profile-grid { align-items: start; }
.profile-security-card { grid-column: 1 / -1; }
/* Account Limits summary (public/profile.php) — a plain, calm read-only list; it
   only ever appears when an admin actually set a limit, so it never competes for
   attention with a user's own editable account cards. */
.limits-summary-card { grid-column: 1 / -1; }
.limits-summary-list { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.limits-summary-list li { margin-bottom: 0.3rem; }

/* ---- Admin panel ---- */
.admin-nav-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.admin-search-form, .admin-filter-form { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0; }
.admin-search-form input, .admin-filter-form select, .admin-filter-form input { width: auto; min-width: 160px; }
.admin-toolbar { margin: 1rem 0; }
.theme-color-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .theme-color-grid { grid-template-columns: repeat(2, 1fr); } }

/* Users screen's Accounts / Deleted tabs (public/admin/users.php) — plain link
   tabs, no JS: the "active" class is applied server-side from ?view=. */
.admin-view-tabs { display: flex; gap: 0.4rem; margin: 1rem 0; border-bottom: 1px solid var(--color-border); }
.admin-view-tabs a {
    padding: 0.5em 1em; color: var(--color-text-muted); font-weight: 600;
    border-bottom: 2px solid transparent;
}
.admin-view-tabs a.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.admin-view-tabs a:hover { text-decoration: none; color: var(--color-primary); }

/* Access & Limits editor (public/admin/user_edit.php) — the expiration date field
   and the domain checklist each visually dim when their controlling toggle isn't
   engaged, using the SAME CSS-only technique as the domain-picker's :has()
   selector above (public/dashboard.php) and the kind-picker's :checked ~ sibling
   selector below — no JavaScript needed for either. */
.expiry-field-group:not(:has(#account_expires_enabled:checked)) .expiry-datetime {
    opacity: 0.45;
}
.domain-access-card:not(:has(#domain_mode_restricted:checked)) .domain-checklist {
    opacity: 0.45;
}
.domain-checklist {
    display: grid; grid-template-columns: 1fr; gap: 0.2rem;
    margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--color-border);
}
@media (min-width: 640px) { .domain-checklist { grid-template-columns: 1fr 1fr; } }

/* Question authoring form: CSS-only show/hide of the kind-specific field sections,
   driven purely by which radio button is checked — zero JavaScript needed. See
   app/exam_engine.php::render_question_editor_fields() for the matching markup. */
.kind-picker { display: flex; flex-wrap: wrap; gap: 1rem; }
.kind-picker-option { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; cursor: pointer; }
.kind-section { display: none; }
#kind_standard:checked ~ .kind-fields .kind-section-standard,
#kind_hotspot_yesno:checked ~ .kind-fields .kind-section-hotspot_yesno,
#kind_hotspot_dropdown:checked ~ .kind-fields .kind-section-hotspot_dropdown,
#kind_dragdrop:checked ~ .kind-fields .kind-section-dragdrop {
    display: block;
}
.option-edit-row, .statement-edit-row, .target-edit-row { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.5rem; }
.option-edit-letter { font-weight: 700; width: 1.4rem; }
.blank-edit-block { background: #fafbfd; }

/* ---- Analytics charts (server-rendered SVG, no JS charting library) ---- */
.bar-chart { width: 100%; height: auto; margin-top: 0.5rem; }
.chart-gridline { stroke: var(--color-border); stroke-width: 1; }
.chart-axis-label { font-size: 10px; fill: var(--color-text-muted); }
.chart-value-label { font-size: 11px; font-weight: 700; fill: var(--color-text); }
.chart-category-label { font-size: 10px; fill: var(--color-text-muted); }

/* ---- Maintenance page ---- */
.maintenance-page { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.maintenance-card { text-align: center; max-width: 480px; }
.maintenance-icon { font-size: 3rem; }
.maintenance-admin-note { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 1.5rem; }


/* ======================================================================================
   v2 / v2.1: HOMEPAGE SLIDER (public/index.php, public/admin/slider.php / slider_edit.php)
   -------------------------------------------------------------------------------------
   JavaScript-driven (public/assets/js/app.js's "HOMEPAGE SLIDER ENGINE" — see that
   file and public/index.php for WHY this is no longer a pure-CSS scroll-snap strip):
   every slide is rendered up front, absolutely stacked on top of each other inside
   .page-slider-viewport, and the script toggles ONE slide's .is-active class at a
   time. Which CSS below actually MOVES a slide depends on the site-wide transition
   preset an admin chose (public/admin/slider.php's "Slider Display Settings" panel),
   applied as a class on the outer .page-slider element:
     .slider-transition-slide  -> slides sit side-by-side via a translateX() built
                                   from the --slide-offset custom property app.js sets
                                   on every slide (offset 0 = on screen).
     .slider-transition-fade   -> slides stay in place; only opacity crossfades.
     .slider-transition-zoom   -> same crossfade as "fade", plus a gentle scale().
   Without JavaScript, only the server-rendered .is-active FIRST slide is genuinely
   interactive — see public/index.php's <noscript> block for the graceful fallback
   that still keeps every OTHER slide's content readable (stacked, non-rotating).
   ==================================================================================== */
.page-slider {
    position: relative; margin: 0 0 2rem; border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow-card);
}
/* v2.1 "extend page slider width to cover full page" — breaks the slider out of its
   normal container width to span the full browser viewport edge-to-edge, using the
   standard "negative margin relative to 50vw" full-bleed technique. Applied only
   when public/admin/settings.php's slider_full_width setting is on (see
   public/index.php's $sliderClasses). */
.page-slider-full-width {
    width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
    border-radius: 0; /* a full-bleed edge-to-edge slider looks wrong with rounded corners */
}
.page-slider-viewport {
    position: relative; overflow: hidden;
    /* clamp(floor, admin's chosen height, ceiling): the admin's --slider-height
       custom property (set inline by public/index.php only when one is configured)
       can never collapse the slider to nothing nor blow past the full viewport
       height, no matter what value ends up here — see is_valid_css_length(). The
       built-in RESPONSIVE default (no admin override) is the 3 breakpoint heights
       below, matching this project's existing mobile-first convention. */
    min-height: clamp(180px, var(--slider-height, 260px), 100vh);
}
@media (min-width: 640px) { .page-slider-viewport { min-height: clamp(180px, var(--slider-height, 360px), 100vh); } }
@media (min-width: 960px) { .page-slider-viewport { min-height: clamp(180px, var(--slider-height, 440px), 100vh); } }

.slider-slide {
    position: absolute; inset: 0; display: flex; align-items: flex-end;
    overflow: hidden; color: #fff;
    pointer-events: none; /* re-enabled only for whichever slide is .is-active, below */
}
.slider-slide.is-active { pointer-events: auto; z-index: 2; }

/* ---- Transition preset: SLIDE (the default) — slides sit side-by-side, positioned
   entirely by app.js's --slide-offset custom property (0 = the active slide;
   -1/+1 = one slide left/right of it, and so on). Always visible/opaque; being
   pushed outside the 0% position is what hides an inactive slide, and
   .page-slider-viewport's overflow:hidden clips it once it's off-canvas. ---- */
.slider-transition-slide .slider-slide {
    opacity: 1; visibility: visible;
    transform: translateX(calc(var(--slide-offset, 0) * 100%));
    transition: transform 0.6s ease;
}

/* ---- Transition preset: FADE — every slide stays in the same place; only opacity
   changes. ---- */
.slider-transition-fade .slider-slide {
    opacity: 0; visibility: hidden; transform: none;
    transition: opacity 0.6s ease, visibility 0.6s;
}
.slider-transition-fade .slider-slide.is-active { opacity: 1; visibility: visible; }

/* ---- Transition preset: ZOOM — same crossfade as "fade", plus the incoming slide
   gently scales up from slightly smaller rather than snapping straight to full size. ---- */
.slider-transition-zoom .slider-slide {
    opacity: 0; visibility: hidden; transform: scale(0.96);
    transition: opacity 0.6s ease, transform 0.6s ease, visibility 0.6s;
}
.slider-transition-zoom .slider-slide.is-active { opacity: 1; visibility: visible; transform: scale(1); }

/* A visitor who has asked their OS/browser to minimize motion gets an instant swap
   between slides instead of an animated one — app.js separately also turns their
   AUTOPLAY off entirely (see initHomepageSlider()), so combined, a slide only ever
   changes for this visitor when they deliberately click an arrow/dot. */
@media (prefers-reduced-motion: reduce) {
    .slider-slide { transition: none !important; }
}

.slider-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slider-scrim {
    position: absolute; inset: 0;
    background: linear-gradient(0deg, rgba(10, 15, 25, 0.78) 0%, rgba(10, 15, 25, 0.25) 55%, rgba(10, 15, 25, 0.05) 100%);
}
.slider-gradient-1 { background: linear-gradient(135deg, var(--color-primary), var(--color-secondary)); }
.slider-gradient-2 { background: linear-gradient(135deg, var(--color-secondary), var(--color-accent)); }
.slider-gradient-3 { background: linear-gradient(135deg, var(--color-primary), var(--color-accent)); }
.slider-caption {
    position: relative; z-index: 1; padding: 1.5rem; max-width: 640px;
}
.slider-caption h2 { color: #fff; margin-bottom: 0.4rem; font-size: 1.5rem; }
@media (min-width: 640px) { .slider-caption h2 { font-size: 2rem; } }
.slider-caption p { margin: 0 0 1rem; color: rgba(255, 255, 255, 0.92); font-size: 1rem; }
.slider-video-frame {
    position: absolute; inset: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center; background: #0a0f19;
}
.slider-video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---- Arrow navigation (v2.1) — plain <button>s, entirely driven by app.js. ---- */
.slider-arrow {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
    width: 2.4rem; height: 2.4rem; border-radius: 50%; border: none;
    background: rgba(10, 15, 25, 0.45); color: #fff; font-size: 1.4rem; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.slider-arrow:hover { background: rgba(10, 15, 25, 0.7); }
.slider-arrow-prev { left: 0.8rem; }
.slider-arrow-next { right: 0.8rem; }

.slider-dots {
    position: relative; z-index: 3;
    display: flex; justify-content: center; gap: 0.5rem;
    padding: 0.8rem 0; /* sits UNDER the absolutely-positioned slide stack, not overlapping it */
}
.slider-dot {
    width: 0.6rem; height: 0.6rem; border-radius: 50%; padding: 0;
    background: var(--color-border); border: 1px solid var(--color-border); cursor: pointer;
}
.slider-dot:hover { background: var(--color-accent); border-color: var(--color-accent); }
.slider-dot.is-active { background: var(--color-secondary); border-color: var(--color-secondary); }

.slider-admin-thumb {
    width: 4rem; height: 2.5rem; object-fit: cover; border-radius: var(--radius-sm);
    border: 1px solid var(--color-border); display: block; margin-top: 0.4rem;
}

/* ---- Practice / Exam mode chooser (public/index.php, logged-in visitors only) ---- */
.mode-choice-section { text-align: center; margin-bottom: 2rem; }
.mode-choice-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 1rem; text-align: left; }
@media (min-width: 640px) { .mode-choice-grid { grid-template-columns: 1fr 1fr; } }
.mode-choice-card {
    display: block; background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 1.5rem;
    color: var(--color-text); transition: box-shadow 0.15s ease, transform 0.15s ease;
    border-top: 4px solid var(--color-secondary);
}
.mode-choice-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); text-decoration: none; }
.mode-choice-card h3 { margin-bottom: 0.4rem; }
.mode-choice-card p { color: var(--color-text-muted); margin: 0; }
.mode-choice-exam { border-top-color: var(--color-primary); }

/* ---- Slide editor: media-type picker (public/admin/slider_edit.php) ----
   CSS-only show/hide of the field group matching whichever radio is checked — the
   same :has() technique used elsewhere in this file (domain-picker, expiry toggle). */
.media-type-picker { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 1rem; }
.media-type-option {
    display: flex; align-items: center; gap: 0.4rem; font-weight: 600; cursor: pointer;
    border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 0.5em 1em;
}
.media-type-option:has(input:checked) { border-color: var(--color-secondary); background: var(--color-info-bg); }
.media-field-group { display: none; }
/* .media-editor wraps BOTH the radio picker and the field groups (see
   slider_edit.php) — :has() only matches within its own descendants, so the checked
   radio and the field group it reveals must share this common ancestor. */
.media-editor:has(#media_type_text:checked) .media-field-text,
.media-editor:has(#media_type_image:checked) .media-field-image,
.media-editor:has(#media_type_youtube:checked) .media-field-youtube,
.media-editor:has(#media_type_video:checked) .media-field-video {
    display: block;
}
.form-group-cta { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .form-group-cta { grid-template-columns: 1fr 1fr; } }

/* ---- Ready-made theme presets (public/admin/settings.php) ---- */
.theme-preset-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 1rem; }
@media (min-width: 640px) { .theme-preset-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .theme-preset-grid { grid-template-columns: repeat(3, 1fr); } }
.theme-preset-card {
    border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.theme-preset-active { border-color: var(--color-success-fg); background: var(--color-success-bg); }
.theme-preset-swatches { display: flex; gap: 0.3rem; }
.theme-preset-swatch {
    width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.15);
    display: inline-block;
}
.theme-preset-card h3 { margin: 0; font-size: 1.05rem; }
.theme-preset-card .form-hint { flex: 1; margin: 0; }

/* ---- Slider display settings (v2.1, public/admin/slider.php): the custom-width
   field visually dims while "Full Width" is checked, since it would have no effect
   in that state — same CSS-only :has() dimming technique as the account-expiry
   toggle and the domain-access-mode picker elsewhere in this file. ---- */
.slider-width-card:has(#slider_full_width:checked) .slider-custom-width-field {
    opacity: 0.45;
}
.slider-admin-thumb[src] { background: #0a0f19; } /* a <video> thumb with no poster frame yet still reads as intentional, not broken */


/* ============================== 6. PRINT ============================== */
@page {
    /* A sane, consistent margin regardless of the printer/PDF-writer's own default
       (some default to unusually large margins, which only shrinks the already-
       limited printable width further and makes long content wrap/overflow sooner). */
    margin: 1.2cm;
}
@media print {
    .site-header, .site-footer, .btn, form, .review-toolbar { display: none !important; }

    /* Force every question's review panel to show on the printed/PDF page regardless
       of its on-screen expanded/collapsed <details> state, and hide the now-pointless
       disclosure triangle. The "Save All Questions as PDF" button (app.js) also
       expands every item via the "open" attribute before calling window.print(), but
       these rules make a plain Ctrl/Cmd+P come out complete too. */
    .review-item-body { display: block !important; }
    .review-item summary::marker, .review-item summary::-webkit-details-marker { display: none !important; }

    /* The collapsed-view preview snippet (the first ~110 characters + "…") is a
       screen-only affordance for finding a question before expanding it — once
       printed, the FULL question text is always shown right below it in
       .question-body, so also showing the truncated "…" preview just looks like
       content got cut off. Hide it; nothing is lost, the complete text follows. */
    .review-item-snippet { display: none !important; }

    /* This stylesheet caps on-screen reading width at --max-width (1120px) for
       comfortable line lengths — print has no such reason to stay narrow, and a
       width wider than the physical printable page is exactly what sliced long
       lines of text, wide tables, and exhibit images off the right edge of the
       page. Use the full printable width instead. */
    .container, .site-main, main { max-width: 100% !important; width: 100% !important; padding: 0 !important; }

    /* THE KEY FIX for long questions: do NOT force the whole question (which can
       easily run taller than one printed page once its scenario text, exhibit
       image, answer options, and explanation are all expanded) to avoid splitting
       across a page break — a block that is itself taller than a page can't honor
       that anyway, and print engines tend to respond by clipping the overflow
       rather than simply continuing it onto the next page, which is exactly how
       content gets lost. So the question AS A WHOLE is free to flow across as many
       pages as it genuinely needs — instead, only the SMALLER, genuinely atomic
       pieces inside it are kept from splitting at an awkward spot: the exhibit
       image, one table row, one answer option. Ordinary body text (the scenario
       paragraph, the explanation paragraph) is deliberately NOT given this same
       "don't split me" treatment — a single question's scenario or explanation is
       often one long paragraph, and forcing an entire long paragraph to avoid
       breaking just pushes the WHOLE thing onto a fresh page, leaving whatever
       space remained on the page before it blank. Ordinary paragraphs are instead
       left free to break between their own lines exactly like in any printed
       document or Word doc — which is what actually "fits proportionally": each
       page fills up with as much of the question as fits, and the rest continues
       on the next page, with nothing cut or lost either way. The orphans/widows
       rule below still stops a single stranded line of that text from ending up
       alone at the very top or bottom of a page. */
    .review-item { break-inside: auto; margin-bottom: 1rem; }
    .question-exhibit, .question-exhibit img { break-inside: avoid; }
    .option-row { break-inside: avoid; }
    table.mdtable, table.review-table, table.yesno-grid { width: 100% !important; break-inside: auto; }
    table.mdtable tr, table.review-table tr, table.yesno-grid tr { break-inside: avoid; }
    h3 { break-after: avoid; } /* keep a heading (e.g. "Explanation") glued to what follows it */
    p, li { orphans: 3; widows: 3; } /* never strand a single line alone at the top/bottom of a page */

    /* Status badges (Correct/Incorrect/Skipped) rely on background color for meaning;
       browsers drop background colors from print output unless told not to. */
    .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; color-adjust: exact; }

    /* Keep the score summary (percentage, Question Source, Mode, Started/Completed)
       on a page of its own — "Question-by-Question Review" and every question
       always start fresh at the top of page 2 rather than the first question
       getting crammed onto whatever space is left under the summary. */
    .results-summary-card { break-after: page; page-break-after: always; }
}
