/* ==========================================================================
   BanoQabil Quiz — "answer sheet"
   Ink on exam-paper stock. The OMR bubble students know from board exams is
   the central interactive object; colour is reserved for meaning (time
   running out, right, wrong) rather than decoration.
   ========================================================================== */

:root {
    /* Ink & paper */
    --ink: #16211C;
    --ink-soft: #5A6B62;
    --ink-faint: #8A968F;
    --paper: #F5F7F3;
    --card: #FFFFFF;
    --rule: #DDE3DB;
    --rule-strong: #C3CCC4;

    /* Institution */
    --green: #14653F;
    --green-dark: #0E4A2E;
    --green-soft: #E3F0E8;

    /* Meaning only: the clock and the marking */
    --amber: #B3730E;
    --amber-soft: #FBF0DC;
    --red: #A83226;
    --red-soft: #FAE7E4;

    --radius: 6px;
    --radius-lg: 10px;

    --font-display: "Newsreader", Georgia, "Times New Roman", serif;
    --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

    /* Bootstrap hand-off */
    --bs-primary: #14653F;
    --bs-primary-rgb: 20, 101, 63;
    --bs-body-color: #16211C;
    --bs-body-bg: #F5F7F3;
    --bs-border-color: #DDE3DB;
    --bs-link-color: #14653F;
    --bs-link-hover-color: #0E4A2E;
    --bs-font-sans-serif: var(--font-sans);
}

/* --------------------------------------------------------------- base --- */

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

body {
    font-family: var(--font-sans);
    background-color: var(--paper);
    color: var(--ink);
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

main {
    flex: 1 0 auto;
}

h1, h2, h3, .display-4, .display-5 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
}

h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.005em;
}

a {
    color: var(--green);
    text-underline-offset: 0.2em;
}

a:hover {
    color: var(--green-dark);
}

.text-muted {
    color: var(--ink-soft) !important;
}

/* Data — timers, scores, IDs, counts. Tabular so digits never jitter. */
.mono, .tabular {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* Small uppercase label used for section eyebrows and table headers. */
.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

/* Keyboard focus stays visible everywhere — never removed, only styled. */
:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
    border-radius: 3px;
}

.btn:focus, .btn:active:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(20, 101, 63, 0.18);
    border-color: var(--green);
}

/* ------------------------------------------------------------- header --- */

.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--rule);
}

.site-header .navbar {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.brand {
    display: inline-flex;
    align-items: baseline;
    gap: 0.5rem;
    text-decoration: none;
}

.brand-mark {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.015em;
}

.brand-sub {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.site-nav .nav-link {
    font-size: 0.84rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--ink-soft);
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius);
}

.site-nav .nav-link:hover {
    color: var(--green);
    background: var(--green-soft);
}

.site-nav .nav-link.active {
    color: var(--green);
    font-weight: 600;
}

.who {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--ink-faint);
    padding: 0 0.6rem;
}

/* ------------------------------------------------------------- footer --- */

.site-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--rule);
    background: var(--card);
    font-size: 0.8rem;
    color: var(--ink-faint);
}

/* -------------------------------------------------------------- cards --- */

.card {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: none;
}

/* The scaffolded shadow utility reads as "default Bootstrap"; flatten it. */
.card.shadow-sm {
    box-shadow: 0 1px 2px rgba(22, 33, 28, 0.04);
}

.card-header, .card-footer {
    background: transparent;
    border-color: var(--rule);
    padding: 0.9rem 1.25rem;
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-family: var(--font-display);
    font-weight: 600;
}

/* Card that names a destination (the teacher dashboard tiles). */
.tile {
    display: block;
    height: 100%;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.tile:hover {
    color: inherit;
    border-color: var(--green);
    transform: translateY(-2px);
}

.tile:hover .tile-go {
    color: var(--green);
}

.tile-go {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
}

/* ------------------------------------------------------------ buttons --- */

.btn {
    font-weight: 500;
    border-radius: var(--radius);
    padding: 0.5rem 1.1rem;
}

.btn-lg {
    padding: 0.7rem 1.6rem;
    font-size: 1rem;
}

.btn-primary {
    --bs-btn-bg: var(--green);
    --bs-btn-border-color: var(--green);
    --bs-btn-hover-bg: var(--green-dark);
    --bs-btn-hover-border-color: var(--green-dark);
    --bs-btn-active-bg: var(--green-dark);
    --bs-btn-active-border-color: var(--green-dark);
    /* Disabled reads as "not yet", not as a washed-out green. */
    --bs-btn-disabled-bg: #E7EBE6;
    --bs-btn-disabled-border-color: #E7EBE6;
    --bs-btn-disabled-color: #7C8880;
    --bs-btn-disabled-opacity: 1;
}

.btn-success {
    --bs-btn-bg: var(--green);
    --bs-btn-border-color: var(--green);
    --bs-btn-hover-bg: var(--green-dark);
    --bs-btn-hover-border-color: var(--green-dark);
}

.btn-outline-primary, .btn-outline-secondary {
    --bs-btn-color: var(--ink);
    --bs-btn-border-color: var(--rule-strong);
    --bs-btn-hover-bg: var(--green-soft);
    --bs-btn-hover-color: var(--green-dark);
    --bs-btn-hover-border-color: var(--green);
    --bs-btn-active-bg: var(--green-soft);
    --bs-btn-active-color: var(--green-dark);
    --bs-btn-active-border-color: var(--green);
}

.btn-outline-danger {
    --bs-btn-color: var(--red);
    --bs-btn-border-color: var(--red);
    --bs-btn-hover-bg: var(--red);
    --bs-btn-hover-border-color: var(--red);
}

/* --------------------------------------------------------------- form --- */

.form-label {
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    border-color: var(--rule-strong);
    border-radius: var(--radius);
    padding: 0.55rem 0.75rem;
    color: var(--ink);
    background-color: var(--card);
}

.form-control::placeholder {
    color: var(--ink-faint);
}

.form-text {
    color: var(--ink-faint);
    font-size: 0.8rem;
}

/* ------------------------------------------------------------- badges --- */

.badge {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0.34em 0.6em;
    border-radius: 3px;
}

.badge.bg-success { background: var(--green) !important; }
.badge.bg-secondary { background: var(--ink-faint) !important; }
.badge.bg-danger { background: var(--red) !important; }

.tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0.24em 0.55em;
    border-radius: 3px;
    border: 1px solid var(--rule-strong);
    color: var(--ink-soft);
    background: var(--paper);
}

.tag-open {
    border-color: var(--green);
    color: var(--green);
    background: var(--green-soft);
}

.tag-off {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-soft);
}

/* ------------------------------------------------------- row actions --- */
/* Table row controls: one line, one weight. Each action is its own POST
   form, so this is a flex row rather than a .btn-group (whose radius rules
   only reach direct .btn children). */

.row-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.row-actions .btn {
    padding: 0.28rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Destructive, but quiet until the pointer is on it — a red block on every
   row trains people to ignore it, which is the opposite of what it needs. */
.row-actions .btn-delete {
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
}

.row-actions .btn-delete:hover,
.row-actions .btn-delete:focus-visible {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}

/* ------------------------------------------------------------- tables --- */

.table {
    --bs-table-color: var(--ink);
    --bs-table-border-color: var(--rule);
    margin-bottom: 0;
}

.table > thead th {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-faint);
    border-bottom: 1px solid var(--rule-strong);
    padding: 0.7rem 0.75rem;
    white-space: nowrap;
}

.table > tbody td {
    padding: 0.7rem 0.75rem;
    vertical-align: middle;
    border-color: var(--rule);
}

.table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: var(--green-soft);
}

/* ======================================================== THE BUBBLE ==== */
/* The OMR answer bubble: hollow until chosen, shaded solid once it is.     */

.option-btn {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
    padding: 0.85rem 1rem;
    background: var(--card);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    color: var(--ink);
    font-size: 1rem;
    line-height: 1.45;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}

.option-btn:hover {
    border-color: var(--green);
    background: var(--green-soft);
}

.bubble {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid var(--rule-strong);
    background: var(--card);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-soft);
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.option-btn:hover .bubble {
    border-color: var(--green);
}

/* Shaded in, like pencil on an answer sheet. */
.option-btn.is-selected {
    border-color: var(--green);
    background: var(--green-soft);
}

.option-btn.is-selected .bubble {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.option-text {
    flex: 1 1 auto;
}

/* Bubbles in the answer review, where they carry the marking. */
.bubble-sm {
    width: 1.65rem;
    height: 1.65rem;
    font-size: 0.72rem;
    border-width: 2px;
}

.bubble-correct {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.bubble-wrong {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

/* ==================================================== THE EXAM SHEET ==== */

.sheet-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
}

.sheet-bar {
    background: var(--card);
    border-bottom: 1px solid var(--rule);
    padding-bottom: 0.8rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sheet-bar-inner {
    padding: 0.75rem 1.25rem 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.sheet-progress {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
}

/* The clock. Large, monospaced, and the only thing on the page that
   changes colour — so a colour change always means "time is short". */
.sheet-clock {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1;
    color: var(--ink);
    transition: color 0.2s ease;
}

.sheet-clock.is-warning { color: var(--amber); }
.sheet-clock.is-critical { color: var(--red); }

/* Depletion rule: a hairline that drains left as the seconds go. */
.sheet-rule {
    margin-top: 0.7rem;
    padding: 0 1.25rem;
}

/* The measure is capped only on the standalone exam page. Reused inside a
   card (the practice quiz) the bar must span the card, not float within it. */
.sheet-page .sheet-bar-inner,
.sheet-page .sheet-rule {
    max-width: 46rem;
    margin-left: auto;
    margin-right: auto;
}

.sheet-rule-track {
    height: 3px;
    background: var(--rule);
    border-radius: 2px;
    overflow: hidden;
}

.sheet-rule-fill {
    height: 100%;
    width: 100%;
    background: var(--green);
    border-radius: 2px;
    transition: width 1s linear, background-color 0.2s ease;
}

.sheet-rule-fill.is-warning { background: var(--amber); }
.sheet-rule-fill.is-critical { background: var(--red); }

/* Centred vertically so the question sits at eye level rather than pinned
   under the clock with a void beneath it. */
.sheet-body {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 46rem;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.25rem 1rem;
}

.sheet-question {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: -0.01em;
    margin-bottom: 1.6rem;
}

.sheet-options {
    display: grid;
    gap: 0.6rem;
}

.sheet-foot {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, var(--paper) 62%, rgba(245, 247, 243, 0));
    padding: 1rem 1.25rem 1.25rem;
}

.sheet-foot-inner {
    max-width: 46rem;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.sheet-note {
    font-size: 0.78rem;
    color: var(--ink-faint);
    margin: 0;
}

/* Cross-fade as one question replaces the next. */
.sheet-swap {
    animation: sheet-in 0.22s ease-out;
}

@keyframes sheet-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 575.98px) {
    .sheet-question { font-size: 1.2rem; }
    .sheet-clock { font-size: 1.5rem; }
    .sheet-body { padding-top: 1.4rem; }
    .sheet-foot-inner { flex-direction: column-reverse; align-items: stretch; }
    .sheet-foot .btn { width: 100%; }
    .sheet-note { text-align: center; }
}

/* ------------------------------------------------------------- result --- */

.scorecard {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.score-figure {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 4rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--ink);
}

.score-figure .of {
    color: var(--ink-faint);
    font-weight: 500;
}

.verdict {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 0.4rem 1rem;
    border-radius: 3px;
}

.verdict-pass {
    background: var(--green-soft);
    color: var(--green-dark);
    border: 1px solid var(--green);
}

.verdict-fail {
    background: var(--red-soft);
    color: var(--red);
    border: 1px solid var(--red);
}

/* ---------------------------------------------------------- accordion --- */

.accordion {
    --bs-accordion-border-color: var(--rule);
    --bs-accordion-btn-focus-box-shadow: 0 0 0 3px rgba(20, 101, 63, 0.18);
    --bs-accordion-active-bg: var(--green-soft);
    --bs-accordion-active-color: var(--green-dark);
    --bs-accordion-btn-bg: var(--card);
    --bs-accordion-border-radius: var(--radius-lg);
}

.accordion-button {
    font-size: 0.94rem;
    padding: 0.85rem 1.1rem;
}

.accordion-button .q-no {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--ink-faint);
    margin-right: 0.6rem;
}

.review-option {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.15rem;
    border-bottom: 1px solid var(--rule);
    font-size: 0.94rem;
}

.review-option:last-child {
    border-bottom: 0;
}

.review-mark {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-faint);
    white-space: nowrap;
}

.review-mark-correct { color: var(--green); }
.review-mark-wrong { color: var(--red); }

/* -------------------------------------------------------------- alerts -- */

.alert {
    border-radius: var(--radius);
    border-width: 1px;
    font-size: 0.92rem;
}

.alert-success {
    background: var(--green-soft);
    border-color: var(--green);
    color: var(--green-dark);
}

.alert-warning {
    background: var(--amber-soft);
    border-color: var(--amber);
    color: #6E470A;
}

.alert-info {
    background: var(--card);
    border-color: var(--rule-strong);
    color: var(--ink);
}

.alert-danger {
    background: var(--red-soft);
    border-color: var(--red);
    color: var(--red);
}

/* --------------------------------------------------------------- misc --- */

.page-head {
    margin-bottom: 1.5rem;
}

.page-head h1, .page-head h2 {
    font-size: 1.75rem;
    margin: 0.15rem 0 0;
}

.auth-shell {
    max-width: 26rem;
    margin: 3rem auto;
}

.rule-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.rule-list li {
    display: flex;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--rule);
    font-size: 0.94rem;
}

.rule-list li:last-child {
    border-bottom: 0;
}

.rule-list .rule-key {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--green);
    flex: 0 0 4.5rem;
}

/* ------------------------------------------------- landing: the cover --- */
/* The anonymous landing page reads like the cover of a question paper:
   who set it, what it is, and the rules — stated before anyone signs up. */

.paper-cover {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: 3.5rem 2.5rem;
    margin: 3rem 0;
}

.cover-title {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 7vw, 3.6rem);
    font-weight: 600;
    line-height: 1.02;
    letter-spacing: -0.03em;
    margin: 0.4rem 0 0;
}

.cover-sub {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 3.5vw, 1.8rem);
    font-weight: 400;
    font-style: italic;
    color: var(--ink-soft);
    margin: 0 0 2rem;
}

/* The exam's terms, set like a specification block on a paper. */
.spec {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 0;
    margin: 0;
    border-top: 1px solid var(--rule-strong);
}

.spec > div {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--rule);
}

.spec dt {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 0.3rem;
}

.spec dd {
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1;
    color: var(--green);
    margin: 0;
}

/* Units ride close to the figure and stay quieter than it. */
.spec dd .unit {
    font-size: 0.62em;
    font-weight: 500;
    opacity: 0.65;
    margin-left: 0.06em;
}

@media (max-width: 575.98px) {
    .paper-cover { padding: 2rem 1.4rem; }
    .spec > div { padding: 0.75rem 0; }
    .spec dd { font-size: 1.35rem; }
}

/* ------------------------------------------------ teacher: batch rows --- */

.batch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.batch-row.is-open {
    border-color: var(--green);
    background: var(--green-soft);
}

.batch-row:last-of-type {
    margin-bottom: 0;
}

.batch-note {
    font-size: 0.84rem;
    color: var(--ink-soft);
    margin-top: 0.2rem;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
