/* ===========================
   Life in the UK – STYLE.CSS
   =========================== */

/* ---------- Design Tokens (Dark = default) ---------- */
:root {
    /* Palette */
    --bg: #0f1115;
    --card: #151922;
    --muted: #9aa3b2;
    --text: #e9eef5;
    --accent: #4a76b2; /* Bright Sapphire Blue */
    --accent-2: #2c64a8; /* Deeper Sapphire */
    --ok: #2bb673;
    --warn: #f2b01e;
    --danger: #ff5a5a;
    --border: #242a36;

    /* UI tokens */
    --input-bg: #0e1219;
    --shadow: 0 6px 14px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(0, 0, 0, 0.18);
    --shadow-sm: 0 3px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.35);
    --ring-accent: 0 0 0 3px rgba(74, 118, 178, 0.35);
    --ring-ok: 0 0 0 3px rgba(43, 182, 115, 0.35);

    /* Motion */
    --tr-fast: 0.15s ease;
    --tr-med: 0.2s ease;
}

/* ---------- Light Theme Overrides ---------- */
:root[data-theme="light"] {
    --bg: #f7f8fb;
    --card: #ffffff;
    --muted: #5d6470;
    --text: #0e1420;
    --accent: #2f6bb8;
    --accent-2: #24589a;
    --ok: #1f9e63;
    --warn: #b9820f;
    --danger: #cf3e3e;
    --border: #e5e8ef;

    --input-bg: #ffffff;
    --shadow: 0 6px 14px rgba(17, 26, 48, 0.08), 0 1px 1px rgba(17, 26, 48, 0.06);
    --shadow-sm: 0 3px 8px rgba(17, 26, 48, 0.08);
    --shadow-lg: 0 18px 40px rgba(17, 26, 48, 0.12);
    --ring-accent: 0 0 0 3px rgba(47, 107, 184, 0.28);
    --ring-ok: 0 0 0 3px rgba(31, 158, 99, 0.28);
}

/* Reduce Motion Preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ---------- Base ---------- */
* {
    box-sizing: border-box;
}
html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font:
        16px/1.5 system-ui,
        -apple-system,
        Segoe UI,
        Roboto,
        Ubuntu,
        Cantarell,
        Noto Sans,
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a {
    color: inherit;
    text-decoration: none;
}
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: none;
    box-shadow: var(--ring-accent);
    border-radius: 10px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- Header ---------- */
.site-header {
    background: #0c0f14;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(180%) blur(6px);
}
:root[data-theme="light"] .site-header {
    background: #ffffff;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.brand {
    color: var(--text);
    font-weight: 700;
}
.brand:hover {
    opacity: 0.9;
}

.nav a {
    color: var(--muted);
    margin-left: 16px;
    position: relative;
    transition:
        color var(--tr-fast),
        transform var(--tr-fast);
}
.nav a:hover {
    color: var(--text);
    transform: translateY(-1px);
}
.nav a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 2px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--tr-med);
}
.nav a:hover::after {
    transform: scaleX(1);
}

/* Theme Toggle */
.theme-toggle {
    appearance: none;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 14px;
    cursor: pointer;
    margin-left: 12px;
    transition:
        transform var(--tr-fast),
        box-shadow var(--tr-fast),
        border-color var(--tr-fast);
}
.theme-toggle:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
}
.theme-toggle:active {
    transform: translateY(0);
}

/* ---------- Main ---------- */
.site-main {
    padding: 24px 0;
}

/* ---------- Hero ---------- */

:root {
    /* dark image by default (overridden in light) */
    --hero-image: url("/assets/hero-dark.webp");
    --hero-gradient: linear-gradient(
        180deg,
        rgba(15, 17, 21, 0) 0%,
        rgba(15, 17, 21, 0.75) 55%,
        rgba(15, 17, 21, 0.92) 100%
    );
}

:root[data-theme="light"] {
    /* light image + lighter gradient */
    --hero-image: url("/assets/hero-light.webp");
    --hero-gradient: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.65) 55%,
        rgba(255, 255, 255, 0.88) 100%
    );
}

.hero {
    margin-bottom: 24px;
}
.hero h1 {
    margin: 0 0 8px;
    font-size: clamp(24px, 3vw, 36px);
}
.hero p {
    color: var(--muted);
    max-width: 70ch;
}

.hero-with-bg {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0;
    overflow: hidden;
    margin-top: 12px;

    /* one background rule that adapts by variables */
    background:
        var(--hero-gradient),
        var(--hero-image) center/cover no-repeat;

    min-height: 360px;
    display: flex;
    align-items: flex-end;
    box-shadow: var(--shadow);
}

.hero-with-bg .hero-inner {
    padding: 28px;
}
.hero-with-bg h1 {
    margin: 0 0 8px;
    font-size: clamp(26px, 3.6vw, 40px);
}
.hero-with-bg p {
    color: var(--text);
    max-width: 70ch;
    margin: 0 0 12px;
}

.hero-cta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 8px 0 6px;
}
.cta-btn {
    display: inline-block;
    padding: 12px 18px;
    border-radius: 999px;
    background: var(--ok);
    color: #fff;
    font-weight: 700;
    transition:
        transform var(--tr-fast),
        box-shadow var(--tr-fast),
        filter var(--tr-fast);
    box-shadow: var(--shadow-sm);
}
.cta-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    filter: brightness(1.02);
}
.cta-btn:active {
    transform: translateY(0);
}
.sub-hint {
    color: var(--muted);
    font-size: 14px;
}
.trust-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
    display: grid;
    gap: 6px;
    color: var(--text);
}
.trust-list li {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin: 24px 0;
    box-shadow: var(--shadow-sm);
}
.card h2 {
    margin: 0 0 12px;
}

/* ---------- Launcher (Group dropdown) ---------- */
.launcher label {
    display: block;
    margin-bottom: 8px;
}
.launcher-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Theme-aware select */
.launcher select,
.test-controls select {
    padding: 10px 36px 10px 12px; /* ⬅️ more right-side padding */
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    transition:
        border-color var(--tr-fast),
        box-shadow var(--tr-fast),
        transform var(--tr-fast);
    appearance: none;

    /* custom arrow */
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
        linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position:
        calc(100% - 16px) center,
        calc(100% - 11px) center;
    background-size:
        6px 6px,
        6px 6px;
    background-repeat: no-repeat;
}

.launcher select:hover,
.test-controls select:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
.launcher select:active,
.test-controls select:active {
    transform: translateY(0);
}
.launcher select:focus,
.test-controls select:focus {
    box-shadow: var(--ring-accent);
}

.launcher button {
    padding: 10px 16px;
    border-radius: 10px;
    border: 0;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition:
        transform var(--tr-fast),
        background var(--tr-fast),
        box-shadow var(--tr-fast);
    box-shadow: var(--shadow-sm);
}
.launcher button:hover {
    background: var(--accent-2);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.launcher button:active {
    transform: translateY(0);
}
.hint {
    color: var(--muted);
    margin-top: 8px;
}

/* ---------- Feature grid ---------- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.info-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    transition:
        transform var(--tr-fast),
        box-shadow var(--tr-fast);
}
.info-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.info-card h3 {
    margin: 0 0 8px;
}

/* ---------- Test Header / Progress ---------- */
.test-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.group-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--muted);
    margin: 0;
}
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid var(--border);
    color: var(--muted);
}

/* ---------- Question ---------- */
.loading {
    color: var(--muted);
    padding: 8px;
}
.q-item {
    border-top: 1px solid var(--border);
    padding: 16px 0;
}
.q-index {
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 6px;
}
.q-stem {
    margin: 0 0 10px;
}
.meta {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.options {
    display: grid;
    gap: 8px;
    margin: 8px 0;
}
.option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    cursor: pointer;
    transition:
        transform var(--tr-fast),
        box-shadow var(--tr-fast),
        border-color var(--tr-fast);
}
.option:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    border-color: var(--accent);
}
.option:active {
    transform: translateY(0);
}
.option input {
    margin-top: 3px;
}
.option.correct {
    outline: 2px solid var(--ok);
}
.option.incorrect {
    outline: 2px solid var(--danger);
}

.expl {
    background: rgba(74, 118, 178, 0.15);
    border-left: 4px solid var(--accent);
    padding: 12px 16px;
    border-radius: 10px;
    margin-top: 14px;
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
    box-shadow: var(--shadow-sm);
}
.judge {
    border-color: var(--border);
}

/* ---------- Buttons ---------- */
.nav-btn {
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    padding: 10px 18px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition:
        background var(--tr-med),
        transform var(--tr-fast),
        box-shadow var(--tr-fast),
        filter var(--tr-fast);
    box-shadow: var(--shadow-sm);
}
.nav-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    filter: brightness(1.02);
}
.nav-btn:active {
    transform: translateY(0);
}
.nav-btn.prev {
    background: var(--accent-2);
}
.nav-btn.next {
    background: var(--ok);
}
.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
    transform: none;
    box-shadow: none;
}

.actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
}
.actions.centered {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.action-btn {
    font-size: 18px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition:
        transform var(--tr-fast),
        background var(--tr-med),
        box-shadow var(--tr-fast),
        filter var(--tr-fast);
    box-shadow: var(--shadow-sm);
}
.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    filter: brightness(1.03);
}
.action-btn:active {
    transform: translateY(0);
}
.action-btn.primary {
    background: var(--accent);
    color: #fff;
}
.action-btn.finish {
    background: var(--ok);
    color: #fff;
}
.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    filter: none;
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 20px 0;
    margin-top: 40px;
    background: #0c0f14;
}
:root[data-theme="light"] .site-footer {
    background: #ffffff;
}
.footer-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.footer-links a {
    color: var(--muted);
    margin-right: 12px;
}
.footer-links a:hover {
    color: var(--text);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .header-inner {
        height: 56px;
    }
    .nav a {
        margin-left: 10px;
    }
    .cta-btn {
        width: 100%;
        text-align: center;
    }
}

/* ---------- Utility ---------- */
.hidden {
    display: none !important;
}

/* Nav Dropdown */
.nav-item {
    position: relative;
    display: inline-block;
}

.nav-item > a {
    cursor: pointer;
}

.nav-item.has-dropdown .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    padding: 8px 0;
    z-index: 1000;
}

.nav-item.has-dropdown .dropdown a {
    display: block;
    padding: 8px 14px;
    color: var(--text);
    transition:
        background var(--tr-fast),
        color var(--tr-fast);
    white-space: nowrap;
}

.nav-item.has-dropdown .dropdown a:hover {
    background: var(--accent);
    color: #fff;
}

.nav-item.has-dropdown:hover .dropdown {
    display: flex;
}

/* Light mode adjustments */
:root[data-theme="light"] .nav-item.has-dropdown .dropdown {
    background: #fff;
    border-color: var(--border);
}

.nav-item.has-dropdown .dropdown {
    max-height: 400px;
    overflow-y: auto;
}

/* Floating Theme Toggle (bottom-right) */
.theme-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9999;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    display: grid;
    place-items: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        filter 0.15s ease,
        border-color 0.15s ease;
}

.theme-fab:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
    filter: brightness(1.03);
}

.theme-fab:active {
    transform: translateY(0);
}

.theme-fab:focus-visible {
    outline: none;
    box-shadow: var(--shadow-lg), var(--ring-accent);
}

/* Optional: move away from cookie banners on small screens */
@media (max-width: 480px) {
    .theme-fab {
        right: 14px;
        bottom: 14px;
    }
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 14px;
}
.tab {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        border-color 0.15s ease,
        background 0.15s ease;
}
.tab:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    border-color: var(--accent);
}
.tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Finder controls */
.finder-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 10px 0 6px;
}
.finder-left {
    flex: 1 1 280px;
}
.finder-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}
.input:focus {
    outline: none;
    box-shadow: var(--ring-accent);
}

.select {
    padding: 10px 36px 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    appearance: none;
    transition:
        border-color 0.2s,
        box-shadow 0.2s,
        transform 0.15s;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
        linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position:
        right 16px center,
        right 11px center;
    background-size:
        6px 6px,
        6px 6px;
    background-repeat: no-repeat;
}
.select:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
.select:focus {
    outline: none;
    box-shadow: var(--ring-accent);
}

/* Centres grid + cards */
.centers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 10px;
}
.center-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow-sm);
    transition:
        transform 0.15s,
        box-shadow 0.15s,
        border-color 0.15s;
}
.center-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}
.center-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}
.center-head h3 {
    margin: 0;
    font-size: 18px;
}
.center-addr {
    margin: 6px 0 8px;
    color: var(--muted);
}
.center-meta {
    margin-bottom: 10px;
}
.center-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.center-actions .action-btn {
    padding: 10px 14px;
    font-size: 16px;
}

.faq-grid {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.faq-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    transition:
        transform 0.15s,
        box-shadow 0.15s;
}

.faq-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

.faq-item h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.faq-item p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

/* Contact form layout */
.contact-form .form-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, 1fr);
}
.contact-form .form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.contact-form label {
    color: var(--muted);
    font-size: 14px;
}
.contact-form .form-span-2 {
    grid-column: 1 / -1;
}

@media (max-width: 720px) {
    .contact-form .form-grid {
        grid-template-columns: 1fr;
    }
    .contact-form .form-span-2 {
        grid-column: 1 / 1;
    }
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
}

.brand-logo {
    height: 28px; /* tweak size as needed */
    width: auto;
    display: block;
}

/* Submit on right */
.actions-inline {
    display: flex;
    align-items: center;
    margin-top: 12px;
    gap: 12px;
}
.actions-inline .actions-spacer {
    flex: 1;
}

/* Finish centered below */
.finish-bar {
    display: flex;
    justify-content: center;
    margin: 20px 0 6px;
}

/* Right-aligned submit */
.actions-inline {
    display: flex;
    align-items: center;
    margin-top: 12px;
    gap: 12px;
}
.actions-inline .actions-spacer {
    flex: 1;
}

/* Finish centered below the card */
.finish-wrapper {
    display: flex;
    justify-content: center;
    margin: 24px 0 12px;
}

/* ========== TIMER ========== */
.timer-container {
    text-align: center;
    margin: 10px 0 18px;
}

.timer-label {
    font-weight: 600;
    font-size: 18px;
    color: var(--text);
    margin-bottom: 6px;
}

.timer-bar {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 10px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
    margin: 0 auto;
}

.timer-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 1s linear;
}

/* ========== QUESTION GRID (1–24) ========== */
.question-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 8px;
    margin: 20px 0 10px;
    justify-items: center;
}

.q-number {
    width: 38px;
    height: 38px;
    line-height: 38px;
    border-radius: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    text-align: center;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition:
        transform 0.1s ease,
        background 0.25s ease,
        border-color 0.25s ease;
}

.q-number:hover {
    transform: scale(1.05);
    border-color: var(--accent);
}

/* state colours */
.q-number.correct {
    background: var(--ok);
    color: #fff;
    border-color: var(--ok);
}

.q-number.incorrect {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.q-number.active {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ========== NAVIGATION BUTTONS (Prev/Next) ========== */
.nav-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.nav-btn {
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    padding: 10px 18px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.1s ease;
}

.nav-btn:hover {
    transform: scale(1.04);
}

.nav-btn.prev {
    background: var(--accent-2);
}

.nav-btn.next {
    background: var(--ok);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== FINISH WRAPPER ========== */
.finish-wrapper {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

/* ========== SUMMARY PAGE: DETAILED REVIEW ========== */
.summary-review {
    margin-top: 20px;
}

.review-item {
    border-top: 1px solid var(--border);
    padding: 14px 0;
}

.review-item h4 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.review-item .your-answer {
    margin: 4px 0;
    color: var(--muted);
}

.review-item .correct {
    color: var(--ok);
    font-weight: 600;
}

.review-item .incorrect {
    color: var(--danger);
    font-weight: 600;
}

.review-item .expl {
    margin-top: 6px;
    background: rgba(74, 118, 178, 0.15);
    border-left: 4px solid var(--accent);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
}

/* Test banner inside the section */
.test-banner {
    background: rgba(74, 118, 178, 0.14); /* subtle accent tint */
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    margin: -4px 0 14px;
    font-weight: 700;
    text-align: center;
}

/* Inline judge badge next to "Question N" */
.judge-inline {
    vertical-align: middle;
}

/* Explanation panel spacing (already styled via .expl) */
#explain_panel {
    margin-top: 14px;
}

/* ===== Right-side Drawer ===== */
@media (max-width: 900px) {
    .nav {
        display: none;
    } /* hide desktop nav on mobile/tablet */
    .menu-fab {
        display: inline-grid;
    } /* show hamburger */
}

/* Hamburger (header right) */
.menu-fab {
    display: none;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    font-size: 18px;
    cursor: pointer;
    transition:
        transform var(--tr-fast),
        box-shadow var(--tr-fast),
        border-color var(--tr-fast);
}
.menu-fab:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

/* Backdrop */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    z-index: 9997;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--tr-med);
}
.drawer-backdrop[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
}

/* Drawer panel */
.side-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(360px, 82vw);
    background: var(--card);
    color: var(--text);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 9998;
    transform: translateX(100%);
    transition: transform var(--tr-med);
    display: grid;
    grid-template-rows: auto 1fr;
}
.side-drawer[data-open="true"] {
    transform: translateX(0);
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.drawer-head h2 {
    margin: 0;
    font-size: 16px;
    color: var(--muted);
}
.drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    cursor: pointer;
    transition:
        transform var(--tr-fast),
        box-shadow var(--tr-fast),
        border-color var(--tr-fast);
}
.drawer-close:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    border-color: var(--accent);
}

.drawer-content {
    padding: 10px;
    overflow: auto;
}
.drawer-content a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text);
    border: 1px solid transparent;
    transition:
        background var(--tr-fast),
        border-color var(--tr-fast),
        transform var(--tr-fast);
}
.drawer-content a:hover {
    background: var(--input-bg);
    border-color: var(--border);
    transform: translateY(-1px);
}

/* Collapsible Tests group */
.drawer-group {
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 12px;
    margin: 8px 0;
    overflow: hidden;
}
.drawer-group > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px;
    font-weight: 600;
    color: var(--text);
}
.drawer-group > summary::-webkit-details-marker {
    display: none;
}
.drawer-list {
    padding: 6px;
    max-height: 280px;
    overflow: auto;
}
.drawer-list a {
    padding: 8px 10px;
}
/* Drawer hamburger visibility */
.menu-fab {
    display: inline-grid; /* default: visible */
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none; /* prevents flex shrink/disappear */
    margin-left: 12px;
    z-index: 1001; /* above header bits */
}

/* Hide on desktop/tablet */
@media (min-width: 901px) {
    .menu-fab {
        display: none;
    }
}

/* ----- Mobile tweaks for test page ----- */
@media (max-width: 640px) {
    /* Make question boxes smaller and tighter */
    .question-grid {
        grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
        gap: 6px;
        margin: 14px 0 8px;
    }

    .q-number {
        width: 30px;
        height: 30px;
        line-height: 30px;
        font-size: 13px;
        border-radius: 10px;
    }

    /* Reduce top margin / padding for the test card */
    .card {
        padding-top: 12px;
        margin-top: 10px;
    }

    /* Optional: slightly smaller timer + banner */
    .timer-label {
        font-size: 16px;
    }

    .test-banner {
        font-size: 15px;
        padding: 8px 12px;
    }
}

/* ----- Mobile reposition for test banner ----- */
@media (max-width: 640px) {
    /* Make the parent card use flex for easy reordering */
    .card {
        display: flex;
        flex-direction: column;
    }

    /* Move banner after the timer visually */
    .test-banner {
        order: 2; /* after timer (timer is first) */
        margin-top: 8px;
        margin-bottom: 8px;
        font-size: 15px;
        padding: 8px 12px;
        border-radius: 10px;
        text-align: center;
    }

    /* Keep timer and grid close together */
    .timer-container {
        order: 1;
    }
    #q_grid {
        order: 3;
    }
}

/* ===== Test Picker (modal) ===== */
.test-picker-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    z-index: 9997;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--tr-med);
}
.test-picker-backdrop[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
}

.test-picker {
    position: fixed;
    z-index: 9998;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: min(720px, 92vw);
    max-height: min(80vh, 720px);
    inset: 50% auto auto 50%;
    transform: translate(-50%, -52%) scale(0.98);
    display: grid;
    grid-template-rows: auto 1fr auto;
    opacity: 0;
    pointer-events: none;
    transition:
        transform var(--tr-med),
        opacity var(--tr-med);
}
.test-picker[data-open="true"] {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.tp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.tp-head h2 {
    margin: 0;
    font-size: 16px;
    color: var(--muted);
}

.tp-close {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    cursor: pointer;
    transition:
        transform var(--tr-fast),
        box-shadow var(--tr-fast),
        border-color var(--tr-fast);
}
.tp-close:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    border-color: var(--accent);
}

.tp-body {
    padding: 12px 14px;
    overflow: auto;
}
.tp-foot {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}

.tp-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(6, 1fr);
}

/* Number tiles */
.tp-item {
    display: grid;
    place-items: center;
    height: 50px;
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 700;
    transition:
        transform var(--tr-fast),
        box-shadow var(--tr-fast),
        border-color var(--tr-fast),
        background var(--tr-fast);
}
.tp-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--accent);
    background: var(--input-bg);
}

/* Responsive: mobile becomes full-screen, comfy tiles */
@media (max-width: 640px) {
    .test-picker {
        width: 100vw;
        height: 100vh;
        inset: 0;
        border-radius: 0;
        transform: none;
        opacity: 0;
        pointer-events: none;
    }
    .test-picker[data-open="true"] {
        opacity: 1;
        pointer-events: auto;
    }
    .tp-body {
        padding: 12px;
    }
    .tp-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    .tp-item {
        height: 44px;
        border-radius: 10px;
    }
    .tp-head,
    .tp-foot {
        padding: 10px 12px;
    }
}

/* Tablet */
@media (min-width: 641px) and (max-width: 900px) {
    .tp-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ==== Fix test picker on mobile: slide from right, full screen ==== */
@media (max-width: 640px) {
  .test-picker {
    position: fixed;
    left: 0; right: 0; top: 0; bottom: 0;      /* full screen */
    width: 100vw; height: 100vh;
    inset: 0;                                   /* overrides desktop inset */
    border-radius: 0;
    transform: translateX(100%);                /* start off-screen RIGHT */
    opacity: 1;                                 /* we animate transform only */
    pointer-events: auto;
    transition: transform var(--tr-med);
    /* ensure we don't inherit desktop transform/scale */
  }
  .test-picker[data-open="true"] {
    transform: translateX(0);                   /* slide in from right */
  }

  /* Backdrop stays the same; just make sure it’s clickable */
  .test-picker-backdrop[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
  }

  /* Tighter paddings for mobile */
  .tp-head, .tp-foot { padding: 10px 12px; }
  .tp-body { padding: 12px; }
  .tp-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .tp-item { height: 44px; border-radius: 10px; }
}
