/* Koran: study glossary.
   Lapis and gold come from illuminated Quran manuscripts; the ۞ (rub el hizb)
   marks sections the way it marks divisions in the mushaf. */

:root,
[data-bs-theme="light"] {
    --k-paper: #f4f6f5;
    --k-surface: #ffffff;
    --k-ink: #16233b;
    --k-muted: #5b6577;
    --k-rule: #dde2e3;
    --k-lapis: #2a4d9b;
    --k-lapis-soft: #e6ecf8;
    --k-gold: #a87b1f;
    --k-mark: #fff1c2;
    --k-ok: #1f7a4d;
    --k-ok-soft: #e3f3ea;
    --k-bad: #b4372f;
    --k-bad-soft: #fbe9e7;

    --k-serif: "Literata", Georgia, serif;
    --k-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m4 10.5 4 4 8-9' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --k-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 5 10 10M15 5 5 15' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
    --k-sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
    --k-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M5 5h14v14H5z M12 2.1 21.9 12 12 21.9 2.1 12z M12 8.6a3.4 3.4 0 1 0 0 6.8a3.4 3.4 0 1 0 0-6.8z'/%3E%3C/svg%3E");

    --bs-body-bg: var(--k-paper);
    --bs-body-color: var(--k-ink);
    --bs-body-font-family: var(--k-sans);
    --bs-link-color-rgb: 42, 77, 155;
    --bs-focus-ring-color: rgba(42, 77, 155, .35);
}

[data-bs-theme="dark"] {
    --k-paper: #0f1726;
    --k-surface: #162036;
    --k-ink: #e7ebf2;
    --k-muted: #9aa5b8;
    --k-rule: #263250;
    --k-lapis: #93b0f0;
    --k-lapis-soft: #1d2b4b;
    --k-gold: #d8ad55;
    --k-mark: #5a4614;
    --k-ok: #5fc596;
    --k-ok-soft: #173a2e;
    --k-bad: #f0877e;
    --k-bad-soft: #43201f;

    --bs-body-bg: var(--k-paper);
    --bs-body-color: var(--k-ink);
    --bs-link-color-rgb: 147, 176, 240;
    --bs-focus-ring-color: rgba(147, 176, 240, .4);
}

html { scroll-padding-top: 9rem; }

@media (min-width: 992px) {
    html { scroll-padding-top: 7.5rem; }
}

body {
    background-color: var(--k-paper);
    color: var(--k-ink);
    font-size: 1rem;
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

main { flex: 1; }

:focus-visible {
    outline: 2px solid var(--k-lapis);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    z-index: 1100;
    top: .5rem;
    left: .5rem;
    padding: .5rem .75rem;
    background: var(--k-surface);
    border-radius: .375rem;
}

/* Eight-point star (rub el hizb), drawn as a mask so it takes the gold colour. */
.star {
    display: inline-block;
    width: .8em;
    height: .8em;
    flex: none;
    background-color: var(--k-gold);
    -webkit-mask: var(--k-star) center / contain no-repeat;
    mask: var(--k-star) center / contain no-repeat;
}

/* Header */

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

.site-header .container-fluid { min-height: 3.5rem; }

.brand {
    font-family: var(--k-serif);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--k-ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}

.brand-mark { width: 1.05rem; height: 1.05rem; }

.site-link {
    color: var(--k-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 1.05rem 0;
    border-bottom: 2px solid transparent;
}

.site-link.active { color: var(--k-ink); border-bottom-color: var(--k-lapis); }

/* Intro */

.intro { padding: 3rem 0 2rem; max-width: 46rem; }

.intro h1 {
    font-family: var(--k-serif);
    font-weight: 500;
    font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem);
    line-height: 1.08;
    letter-spacing: -.015em;
    font-variation-settings: "opsz" 72;
    margin-bottom: 1rem;
}

.lead-text {
    font-size: 1.125rem;
    color: var(--k-muted);
    max-width: 38rem;
    margin: 0;
}

/* Two-column layout */

.layout { display: block; padding-bottom: 4rem; }

@media (min-width: 992px) {
    .layout {
        display: grid;
        grid-template-columns: 15.5rem minmax(0, 1fr);
        gap: 3.5rem;
    }
}

.sidebar nav { position: sticky; top: 1.5rem; }

.sidebar-heading {
    font-size: .875rem;
    font-weight: 600;
    color: var(--k-muted);
    margin-bottom: .5rem;
}

.cat-list { list-style: none; padding: 0; margin: 0; }

.cat-link {
    display: grid;
    grid-template-columns: 1.1rem 1fr auto;
    align-items: baseline;
    gap: .5rem;
    padding: .45rem .6rem;
    margin-left: -.6rem;
    border-radius: .375rem;
    color: var(--k-muted);
    text-decoration: none;
    font-size: .925rem;
    line-height: 1.35;
}

.cat-link:hover { color: var(--k-ink); background: var(--k-lapis-soft); }

.cat-mark { width: .75rem; height: .75rem; align-self: center; opacity: 0; transition: opacity .2s ease; }

.cat-count { font-size: .8rem; font-variant-numeric: tabular-nums; }

.cat-link.active { color: var(--k-ink); font-weight: 600; }
.cat-link.active .cat-mark { opacity: 1; }

.cat-link.is-empty { opacity: .4; }

/* Toolbar: search, count, mobile chips */

.toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--k-paper);
    padding: .75rem 0 .5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--k-rule);
}

.search { position: relative; max-width: 40rem; }

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    width: 1.1rem;
    height: 1.1rem;
    transform: translateY(-50%);
    color: var(--k-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 3.1rem;
    padding: 0 3rem 0 2.75rem;
    font: inherit;
    font-size: 1.05rem;
    color: var(--k-ink);
    background: var(--k-surface);
    border: 1px solid var(--k-rule);
    border-radius: .625rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.search-input::placeholder { color: var(--k-muted); opacity: .85; }

.search-input:focus {
    outline: none;
    border-color: var(--k-lapis);
    box-shadow: 0 0 0 3px var(--bs-focus-ring-color);
}

.search-key {
    position: absolute;
    right: .8rem;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--k-sans);
    font-size: .8rem;
    color: var(--k-muted);
    background: var(--k-paper);
    border: 1px solid var(--k-rule);
    border-radius: .3rem;
    padding: .05rem .45rem;
}

.search-input:focus ~ .search-key,
.search-input:not(:placeholder-shown) ~ .search-key { display: none !important; }

.result-count {
    font-size: .875rem;
    color: var(--k-muted);
    margin: .5rem 0 0;
    font-variant-numeric: tabular-nums;
}

.chips {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    margin: .6rem -1rem 0;
    padding: 0 1rem .25rem;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
    flex: none;
    font-size: .85rem;
    padding: .35rem .8rem;
    border-radius: 999px;
    border: 1px solid var(--k-rule);
    background: var(--k-surface);
    color: var(--k-ink);
    text-decoration: none;
    white-space: nowrap;
}

.chip.is-empty { display: none; }

/* Sections and entries */

.term-section { margin-bottom: 3.5rem; }

.section-title {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    font-family: var(--k-serif);
    font-weight: 500;
    font-size: clamp(1.4rem, 1.2rem + .8vw, 1.85rem);
    line-height: 1.2;
    margin: 0 0 .4rem;
}

.section-mark { width: .7em; height: .7em; align-self: center; }

.section-count {
    font-family: var(--k-sans);
    font-size: .875rem;
    font-weight: 500;
    color: var(--k-muted);
    font-variant-numeric: tabular-nums;
}

.section-note {
    color: var(--k-muted);
    max-width: 38rem;
    margin: 0 0 .5rem 1.3em;
}

.entries {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    column-gap: 2.5rem;
    margin: 1.25rem 0 0;
}

.entry {
    padding: 1rem 0 1.1rem;
    border-top: 1px solid var(--k-rule);
}

.entry dt {
    font-family: var(--k-serif);
    font-weight: 600;
    font-size: 1.15rem;
    line-height: 1.3;
    margin-bottom: .3rem;
}

.entry dd {
    color: var(--k-muted);
    margin: 0;
    max-width: 34rem;
}

mark {
    padding: 0 .1em;
    border-radius: .2em;
    background: var(--k-mark);
    color: inherit;
}

/* Empty state */

.empty { padding: 2rem 0 4rem; max-width: 34rem; }

.empty-title {
    font-family: var(--k-serif);
    font-size: 1.35rem;
    font-weight: 500;
    margin-bottom: .4rem;
    overflow-wrap: anywhere;
}

.empty-text { color: var(--k-muted); margin-bottom: 1.25rem; }

.btn-clear {
    font: inherit;
    font-weight: 500;
    color: var(--k-surface);
    background: var(--k-lapis);
    border: 0;
    border-radius: .5rem;
    padding: .55rem 1.1rem;
}

[data-bs-theme="dark"] .btn-clear { color: var(--k-paper); }

/* Footer */

.site-footer {
    border-top: 1px solid var(--k-rule);
    padding: 1.25rem 0;
    font-size: .875rem;
    color: var(--k-muted);
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto !important; }
    *, *::before, *::after { transition: none !important; }
}

/* Header nav */

.site-nav { display: flex; gap: 1.5rem; }

/* Themes page: quiz cards */

.theme-section { margin-bottom: 3.5rem; }

.quiz-grid {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
    gap: 1rem;
}

@media (min-width: 768px) {
    .quiz-grid { grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 1.25rem; }
}

.quiz-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    aspect-ratio: 4 / 3.4;
    padding: .9rem 1rem;
    overflow: hidden;
    border: 1px solid var(--k-rule);
    border-radius: .875rem;
    background:
        radial-gradient(120% 90% at 100% 100%, var(--k-lapis-soft) 0%, transparent 70%),
        var(--k-surface);
    color: var(--k-ink);
    text-decoration: none;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.quiz-card:hover {
    color: var(--k-ink);
    border-color: var(--k-lapis);
    transform: translateY(-3px);
    box-shadow: 0 10px 24px -12px rgba(22, 35, 59, .35);
}

.quiz-card:hover .quiz-book { transform: rotate(-4deg) scale(1.04); }

/* Book illustration in the background */
.quiz-book {
    position: absolute;
    top: 10%;
    right: -10%;
    width: 72%;
    height: 50%;
    transition: transform .3s ease;
}

.book-cover { fill: var(--k-lapis); opacity: .22; }
.book-page { fill: var(--k-surface); stroke: var(--k-gold); stroke-width: 1.6; }
.book-line { fill: none; stroke: var(--k-gold); stroke-width: 1.4; stroke-linecap: round; opacity: .55; }

/* Large quiz number */
.quiz-number {
    position: absolute;
    top: .35rem;
    left: .9rem;
    font-family: var(--k-serif);
    font-weight: 600;
    font-size: clamp(2.75rem, 2.3rem + 1.5vw, 3.5rem);
    line-height: 1;
    font-variation-settings: "opsz" 72;
    font-variant-numeric: lining-nums;
    color: var(--k-lapis);
}

.quiz-meta { position: relative; display: flex; flex-direction: column; gap: .1rem; }

.quiz-name {
    font-weight: 600;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quiz-count { font-size: .8rem; color: var(--k-muted); font-variant-numeric: tabular-nums; }

/* Quiz page */

.quiz-page { max-width: 44rem; padding: 1.5rem 0 4rem; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-left: -.25rem;
    color: var(--k-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: .925rem;
}

.back-link svg { width: 1.1rem; height: 1.1rem; }
.back-link:hover { color: var(--k-ink); }

.quiz-intro { padding: 1.25rem 0 1.75rem; }

.quiz-intro h1 {
    font-family: var(--k-serif);
    font-weight: 500;
    font-size: clamp(1.9rem, 1.5rem + 1.8vw, 2.75rem);
    line-height: 1.1;
    letter-spacing: -.015em;
    font-variation-settings: "opsz" 72;
    margin-bottom: .6rem;
}

.quiz-progress { margin-bottom: 1rem; }

.quiz-step {
    font-size: .875rem;
    font-weight: 500;
    color: var(--k-muted);
    margin: 0 0 .5rem;
    font-variant-numeric: tabular-nums;
}

.progress-track { height: 4px; border-radius: 999px; background: var(--k-rule); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--k-gold); border-radius: inherit; transition: width .35s ease; }

.quiz-card-panel {
    background: var(--k-surface);
    border: 1px solid var(--k-rule);
    border-radius: .875rem;
    padding: 1.5rem 1.25rem;
}

@media (min-width: 576px) {
    .quiz-card-panel { padding: 2rem; }
}

.slide.is-entering { animation: slide-in .3s ease both; }

@keyframes slide-in {
    from { opacity: 0; transform: translateX(1.25rem); }
    to { opacity: 1; transform: none; }
}

.question-text {
    font-family: var(--k-serif);
    font-weight: 500;
    font-size: clamp(1.3rem, 1.15rem + .6vw, 1.6rem);
    line-height: 1.3;
    margin-bottom: .35rem;
}

/* Question text is rich HTML from the editor (paragraphs, lists, images, tables). */
.question-text > :last-child { margin-bottom: 0; }
.question-text p { margin-bottom: .5em; }
.question-text :is(h1, h2, h3, h4, h5, h6) { font-size: 1em; font-weight: 600; }
.question-text img { max-width: 100%; height: auto; }
.question-text table { width: 100%; font-size: 1rem; margin-bottom: .5em; }
.question-text :is(td, th) { border: 1px solid var(--bs-border-color); padding: .25rem .5rem; }

.question-hint { font-size: .875rem; color: var(--k-muted); margin-bottom: 1.25rem; }

.answers { display: grid; gap: .6rem; }

/* Parts of a MULTIANSWER question: smaller sub-questions under the main question text. */
.parts { padding-left: 1.5rem; margin: 1.25rem 0 0; }
/* Every slide answers through .part elements; only MULTIANSWER parts sit in a numbered .parts list. */
.parts > .part + .part { margin-top: 1.5rem; }
.parts > .part { padding-top: 1.25rem; border-top: 1px solid var(--k-rule); }
.parts > .part::marker { color: var(--k-muted); font-family: var(--k-serif); font-size: 1.1rem; }
.parts > .part .part-text { font-size: 1.1rem; }
.part-feedback { font-size: .875rem; color: var(--k-muted); margin: .6rem 0 0; }

.answer {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: .8rem;
    padding: .8rem 1rem;
    border: 1px solid var(--k-rule);
    border-radius: .625rem;
    background: var(--k-paper);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.answer input { position: absolute; opacity: 0; pointer-events: none; }

.answer-key {
    display: grid;
    place-items: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: .4rem;
    border: 1px solid var(--k-rule);
    background: var(--k-surface);
    font-size: .85rem;
    font-weight: 600;
    color: var(--k-muted);
}

input[type="radio"] + .answer-key { border-radius: 50%; }

.answer:hover { border-color: var(--k-lapis); }

.answer:has(input:focus-visible) { outline: 2px solid var(--k-lapis); outline-offset: 2px; }

.answer:has(input:checked) { border-color: var(--k-lapis); background: var(--k-lapis-soft); }
.answer:has(input:checked) .answer-key { background: var(--k-lapis); border-color: var(--k-lapis); color: var(--k-surface); }

.answer:has(input:disabled) { cursor: default; }
.answer:has(input:disabled):not(.is-correct):not(.is-wrong) { opacity: .6; }

.answer-state { width: 1.1rem; height: 1.1rem; }

.answer.is-correct { border-color: var(--k-ok); background: var(--k-ok-soft); }
.answer.is-correct .answer-key { background: var(--k-ok); border-color: var(--k-ok); color: var(--k-surface); }
.answer.is-correct .answer-state { background: var(--k-ok); -webkit-mask: var(--k-tick) center / contain no-repeat; mask: var(--k-tick) center / contain no-repeat; }

.answer.is-wrong { border-color: var(--k-bad); background: var(--k-bad-soft); }
.answer.is-wrong .answer-key { background: var(--k-bad); border-color: var(--k-bad); color: var(--k-surface); }
.answer.is-wrong .answer-state { background: var(--k-bad); -webkit-mask: var(--k-cross) center / contain no-repeat; mask: var(--k-cross) center / contain no-repeat; }

.written-input {
    width: 100%;
    padding: .75rem 1rem;
    font: inherit;
    font-size: 1.05rem;
    color: var(--k-ink);
    background: var(--k-paper);
    border: 1px solid var(--k-rule);
    border-radius: .625rem;
    resize: vertical;
}

.written-input:focus { outline: none; border-color: var(--k-lapis); box-shadow: 0 0 0 3px var(--bs-focus-ring-color); }
.written-input.is-correct { border-color: var(--k-ok); background: var(--k-ok-soft); }
.written-input.is-wrong { border-color: var(--k-bad); background: var(--k-bad-soft); }

.feedback {
    margin-top: 1.25rem;
    padding: .8rem 1rem;
    border-left: 3px solid var(--k-rule);
    border-radius: 0 .5rem .5rem 0;
    background: var(--k-paper);
}

.feedback[data-state="correct"] { border-left-color: var(--k-ok); }
.feedback[data-state="wrong"] { border-left-color: var(--k-bad); }
.feedback[data-state="neutral"] { border-left-color: var(--k-gold); }

.feedback-title { font-weight: 600; margin: 0; }
.feedback-text { color: var(--k-muted); margin: .2rem 0 0; white-space: pre-line; }
.feedback-text:empty { display: none; }

.quiz-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }

.btn-quiz {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 8rem;
    min-height: 2.9rem;
    padding: .6rem 1.4rem;
    font: inherit;
    font-weight: 600;
    color: var(--k-surface);
    background: var(--k-lapis);
    border: 1px solid var(--k-lapis);
    border-radius: .625rem;
    text-decoration: none;
    transition: opacity .15s ease, transform .15s ease;
}

.btn-quiz:hover { color: var(--k-surface); opacity: .92; }
.btn-quiz:active { transform: translateY(1px); }
.btn-quiz:disabled { opacity: .4; cursor: not-allowed; }

.btn-quiz-quiet { color: var(--k-ink); background: transparent; border-color: var(--k-rule); }
.btn-quiz-quiet:hover { color: var(--k-ink); border-color: var(--k-lapis); }

[data-bs-theme="dark"] .btn-quiz:not(.btn-quiz-quiet) { color: var(--k-paper); }

@media (max-width: 575.98px) {
    .quiz-actions .btn-quiz { flex: 1; }
}

.quiz-summary { text-align: center; padding-top: 2.5rem; padding-bottom: 2.5rem; }
.quiz-summary:focus { outline: none; }
.quiz-summary .quiz-actions { justify-content: center; }

.summary-mark { width: 2.25rem; height: 2.25rem; margin-bottom: .75rem; }

.summary-title {
    font-family: var(--k-serif);
    font-weight: 500;
    font-size: 1.85rem;
    margin-bottom: .25rem;
}

.summary-score { font-size: 1.15rem; font-weight: 600; color: var(--k-lapis); margin-bottom: .35rem; }
.summary-text { color: var(--k-muted); margin: 0 auto; max-width: 28rem; }

@media (prefers-reduced-motion: reduce) {
    .slide.is-entering { animation: none; }
    .quiz-card:hover, .quiz-card:hover .quiz-book { transform: none; }
}
