/* Aurelius Quiz Master - Frontend Styles
   Primary: #2c51f7   Secondary: #353535
   Auto dark/light mode via prefers-color-scheme */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

/* ── Light mode ─────────────────────────────────────────── */
.aqm {
    --pri:        #2c51f7;
    --pri-dark:   #1a3dd4;
    --pri-light:  #eef1fe;
    --pri-mid:    #b8c5fc;
    --sec:        #353535;
    --bg:         #f5f6fa;
    --surface:    #ffffff;
    --surface2:   #f0f2f9;
    --border:     #e0e4ef;
    --text:       #1a1a2e;
    --text-muted: #6b7280;
    --success:    #15803d;
    --success-bg: #dcfce7;
    --danger:     #dc2626;
    --danger-bg:  #fee2e2;
    --radius:     12px;
    --shadow:     0 2px 12px rgba(44,81,247,.10);
    --shadow-lg:  0 6px 32px rgba(44,81,247,.16);

    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    border-radius: 16px;
    overflow: hidden;
}

/* ── Dark mode ──────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .aqm {
        --pri:        #6b87fa;
        --pri-dark:   #8fa3fb;
        --pri-light:  rgba(107,135,250,.15);
        --pri-mid:    rgba(107,135,250,.30);
        --sec:        #e8e8e8;
        --bg:         #111318;
        --surface:    #1c1f2a;
        --surface2:   #242837;
        --border:     #2e3347;
        --text:       #e8eaf0;
        --text-muted: #8b92a8;
        --success:    #4ade80;
        --success-bg: rgba(74,222,128,.12);
        --danger:     #f87171;
        --danger-bg:  rgba(248,113,113,.12);
        --shadow:     0 2px 12px rgba(0,0,0,.40);
        --shadow-lg:  0 6px 32px rgba(0,0,0,.50);
    }
}

.aqm *, .aqm *::before, .aqm *::after { box-sizing: border-box; }

/* ── Landing hero ───────────────────────────────────────── */
.aqm-landing { }

.aqm-hero {
    background: linear-gradient(140deg, var(--pri) 0%, var(--pri-dark) 100%);
    padding: 52px 36px 44px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.aqm-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 60% at 50% -10%, rgba(255,255,255,.18), transparent);
    pointer-events: none;
}

.aqm-hero-emblem {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border: 2px solid rgba(255,255,255,.5);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 17px;
    color: #fff;
    background: rgba(255,255,255,.15);
}

.aqm-hero h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(22px, 4vw, 32px);
    color: #fff;
    margin: 0 0 10px;
    line-height: 1.2;
}

.aqm-hero p {
    color: rgba(255,255,255,.80);
    font-size: 15px;
    margin: 0;
}

/* ── Quiz selection grid ────────────────────────────────── */
.aqm-quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 18px;
    padding: 32px;
}

.aqm-quiz-tile {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    display: grid;
    grid-template-columns: 52px 1fr;
    grid-template-rows: auto auto;
    column-gap: 14px;
    row-gap: 14px;
    box-shadow: var(--shadow);
    transition: border-color .18s, transform .18s, box-shadow .18s;
    cursor: default;
}
.aqm-quiz-tile:hover { border-color: var(--pri); transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.aqm-tile-icon {
    grid-row: 1 / 3;
    width: 52px;
    height: 52px;
    background: var(--pri);
    color: #fff;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 15px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aqm-tile-info { display: flex; flex-direction: column; gap: 5px; }
.aqm-tile-info h3 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
.aqm-tile-info p  { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.5; }

.aqm-badge {
    display: inline-block;
    background: var(--pri-light);
    color: var(--pri);
    font-size: 11.5px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--pri-mid);
    margin-top: 2px;
    width: fit-content;
}

.aqm-start-btn {
    grid-column: 2;
    background: var(--pri);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    transition: background .15s, transform .15s;
    text-align: center;
}
.aqm-start-btn:hover { background: var(--pri-dark); transform: translateY(-1px); }

/* ── Loading / empty ────────────────────────────────────── */
.aqm-loading {
    display: flex; align-items: center; justify-content: center;
    gap: 14px; padding: 60px; color: var(--text-muted); font-size: 15px;
}
.aqm-spinner {
    width: 26px; height: 26px;
    border: 3px solid var(--border);
    border-top-color: var(--pri);
    border-radius: 50%;
    animation: aqm-spin .7s linear infinite;
}
@keyframes aqm-spin { to { transform: rotate(360deg); } }

.aqm-empty-msg, .aqm-err {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Back button ────────────────────────────────────────── */
.aqm-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--pri);
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 16px 28px 0;
    transition: opacity .15s;
}
.aqm-back-btn:hover { opacity: .7; }

/* ── Viewer container ───────────────────────────────────── */
#aqm-viewer { background: var(--surface); }

/* ── Quiz wrap ──────────────────────────────────────────── */
.aqm-quiz { padding: 28px 32px; animation: aqm-in .3s ease; }
@keyframes aqm-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.aqm-quiz-top { margin-bottom: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }

.aqm-quiz-top h2 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(18px, 3vw, 26px);
    color: var(--text);
    margin: 0 0 8px;
}
.aqm-quiz-desc { color: var(--text-muted); font-size: 14px; margin: 0 0 16px; }

/* ── Progress bar ───────────────────────────────────────── */
.aqm-progress { display: flex; align-items: center; gap: 14px; }
.aqm-progress-bar { flex: 1; height: 7px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.aqm-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pri) 0%, var(--pri-dark) 100%);
    border-radius: 999px;
    transition: width .4s cubic-bezier(.4,0,.2,1);
}
.aqm-progress-text { font-size: 12.5px; font-weight: 600; color: var(--text-muted); white-space: nowrap; min-width: 48px; text-align: right; }

/* ── Questions ──────────────────────────────────────────── */
.aqm-question { display: none; animation: aqm-in .22s ease; }
.aqm-question.active { display: block; }

.aqm-q-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--pri);
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.aqm-q-text {
    font-family: 'Playfair Display', serif;
    font-size: clamp(16px, 2.5vw, 20px);
    color: var(--text);
    line-height: 1.5;
    margin: 0 0 22px;
}

/* ── Options ────────────────────────────────────────────── */
.aqm-options { display: flex; flex-direction: column; gap: 11px; margin-bottom: 26px; }

.aqm-option {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 17px;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .12s;
    user-select: none;
}
.aqm-option input { display: none; }
.aqm-option:hover { border-color: var(--pri); background: var(--pri-light); transform: translateX(3px); }

.aqm-opt-letter {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all .15s;
}
.aqm-opt-text { font-size: 15px; color: var(--text); line-height: 1.4; }

.aqm-option.selected                  { border-color: var(--pri); background: var(--pri-light); }
.aqm-option.selected .aqm-opt-letter  { background: var(--pri); border-color: var(--pri); color: #fff; }
.aqm-option.correct                   { border-color: var(--success); background: var(--success-bg); }
.aqm-option.correct .aqm-opt-letter   { background: var(--success); border-color: var(--success); color: #fff; }
.aqm-option.incorrect                 { border-color: var(--danger); background: var(--danger-bg); }
.aqm-option.incorrect .aqm-opt-letter { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ── Nav ────────────────────────────────────────────────── */
.aqm-q-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aqm-btn-prev, .aqm-btn-next, .aqm-btn-submit {
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--text);
    padding: 10px 22px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all .15s;
}
.aqm-btn-prev:hover:not(:disabled),
.aqm-btn-next:hover:not(:disabled) { border-color: var(--pri); color: var(--pri); }
.aqm-btn-prev:disabled,
.aqm-btn-next:disabled,
.aqm-btn-submit:disabled { opacity: .35; cursor: not-allowed; }

.aqm-btn-submit:not(:disabled) {
    background: var(--pri);
    border-color: var(--pri);
    color: #fff;
}
.aqm-btn-submit:not(:disabled):hover {
    background: var(--pri-dark);
    border-color: var(--pri-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(44,81,247,.30);
}

/* ── Results ────────────────────────────────────────────── */
.aqm-results { padding: 28px 32px; animation: aqm-in .35s ease; }

.aqm-results-inner { text-align: center; }

.aqm-score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--pri);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    box-shadow: 0 6px 24px rgba(44,81,247,.35);
}
.aqm-score-num   { font-family: 'Playfair Display', serif; font-size: 36px; font-weight: 700; color: #fff; line-height: 1; }
.aqm-score-denom { font-size: 14px; color: rgba(255,255,255,.75); margin-top: 2px; }

.aqm-score-pct { font-size: 28px; font-weight: 700; color: var(--pri); margin: 0 0 6px; }
.aqm-score-msg { color: var(--text-muted); font-size: 15px; max-width: 420px; margin: 0 auto 28px; line-height: 1.6; }

.aqm-breakdown { text-align: left; margin-bottom: 24px; }

.aqm-bd-item {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 17px;
    margin-bottom: 10px;
}
.aqm-bd-item.right  { border-left: 4px solid var(--success); }
.aqm-bd-item.wrong  { border-left: 4px solid var(--danger); }

.aqm-bd-q { font-size: 14px; font-weight: 600; color: var(--text); margin: 0 0 8px; }

.aqm-bd-tag {
    display: inline-block;
    font-size: 12.5px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
    margin-right: 8px;
    margin-top: 2px;
}
.aqm-bd-tag.green { background: var(--success-bg); color: var(--success); }
.aqm-bd-tag.red   { background: var(--danger-bg);  color: var(--danger); }

.aqm-retake-btn {
    background: transparent;
    border: 2px solid var(--pri);
    color: var(--pri);
    padding: 11px 28px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14.5px;
    cursor: pointer;
    transition: all .15s;
    margin-top: 8px;
}
.aqm-retake-btn:hover {
    background: var(--pri);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(44,81,247,.28);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 580px) {
    .aqm-hero        { padding: 34px 20px 28px; }
    .aqm-quiz-grid   { padding: 20px 16px; grid-template-columns: 1fr; gap: 12px; }
    .aqm-quiz        { padding: 20px 18px; }
    .aqm-results     { padding: 20px 18px; }
    .aqm-quiz-tile   { grid-template-columns: 44px 1fr; }
    .aqm-tile-icon   { width: 44px; height: 44px; font-size: 13px; }
}
