/* Müzâkere — ilahiyat ders çalışma uygulaması */
:root {
  --ink: #16233f;
  --ink-soft: #5a6478;
  --paper: #f3f5f8;
  --surface: #ffffff;
  --line: #dde2ea;
  --line-strong: #c3cad6;
  --cobalt: #1d4f91;
  --cobalt-soft: #e6eef9;
  --correct: #127c74;
  --correct-soft: #e2f4f1;
  --wrong: #b8392b;
  --wrong-soft: #fbe9e6;
  --warn: #9a6a00;
  --warn-soft: #fff4d9;
  --focus: #1d4f91;

  --t-cobalt: #1d4f91;
  --t-turquoise: #127c74;
  --t-coral: #b8392b;
  --t-emerald: #2f6b3a;
  --t-saffron: #a2650a;
  --t-plum: #6b3a73;

  --serif: "Source Serif 4", "Amiri", Georgia, serif;
  --sans: "IBM Plex Sans", "Amiri", system-ui, -apple-system, "Segoe UI", sans-serif;
  --arabic: "Amiri", "Geeza Pro", "Noto Naskh Arabic", serif;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7ebf3;
    --ink-soft: #a3adc0;
    --paper: #0f1626;
    --surface: #172036;
    --line: #273250;
    --line-strong: #36446a;
    --cobalt: #8cb4f0;
    --cobalt-soft: #1c2c4c;
    --correct: #5ccfc2;
    --correct-soft: #11332f;
    --wrong: #f08a7c;
    --wrong-soft: #3a1c19;
    --warn: #f2c35b;
    --warn-soft: #382c10;
    --focus: #8cb4f0;
    --t-cobalt: #2c5fa6;
    --t-turquoise: #17857c;
    --t-coral: #a63a2d;
    --t-emerald: #356f40;
    --t-saffron: #94600f;
    --t-plum: #6f4277;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e7ebf3;
  --ink-soft: #a3adc0;
  --paper: #0f1626;
  --surface: #172036;
  --line: #273250;
  --line-strong: #36446a;
  --cobalt: #8cb4f0;
  --cobalt-soft: #1c2c4c;
  --correct: #5ccfc2;
  --correct-soft: #11332f;
  --wrong: #f08a7c;
  --wrong-soft: #3a1c19;
  --warn: #f2c35b;
  --warn-soft: #382c10;
  --focus: #8cb4f0;
  --t-cobalt: #2c5fa6;
  --t-turquoise: #17857c;
  --t-coral: #a63a2d;
  --t-emerald: #356f40;
  --t-saffron: #94600f;
  --t-plum: #6f4277;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}
a { color: var(--cobalt); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.ar {
  font-family: var(--arabic);
  font-size: 1.32em;
  line-height: 1.6;
  font-weight: 400;
  unicode-bidi: isolate;
}
.ar--block { display: block; text-align: right; margin: .15em 0 .25em; }
.opt .ar--block { text-align: left; text-align: start; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.wrap--narrow { max-width: 760px; }

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0;
}
.brand {
  display: inline-flex; align-items: baseline; gap: 10px;
  text-decoration: none; color: var(--ink);
  font-family: var(--serif); font-weight: 600; font-size: 1.2rem;
}
.brand .ar { font-size: 1.35rem; color: var(--cobalt); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Home ---------- */
.home-intro { padding: 28px 0 8px; max-width: 60ch; }
.home-intro h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.12; margin: 0 0 12px;
  letter-spacing: -0.01em;
}
.home-intro p { margin: 0; color: var(--ink-soft); font-size: 1.05rem; }

.tiles {
  list-style: none; margin: 28px 0 48px; padding: 0;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 220px; padding: 20px 22px; border-radius: var(--r-lg);
  color: #fff; text-decoration: none; overflow: hidden;
  background-color: var(--tile);
  isolation: isolate;
}
.tile::before { /* İznik-like eight-pointed star lattice */
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .16;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23fff' stroke-width='1.2'%3E%3Crect x='14' y='14' width='28' height='28'/%3E%3Crect x='14' y='14' width='28' height='28' transform='rotate(45 28 28)'/%3E%3Ccircle cx='28' cy='28' r='5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 56px 56px;
}
.tile:hover .tile__arabic { transform: translateY(-2px); }
.tile__arabic {
  font-family: var(--arabic); font-size: clamp(2.6rem, 7vw, 3.4rem); line-height: 1.25;
  direction: rtl; text-align: right; margin: 0 0 12px; transition: transform .2s ease;
}
.tile__title { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; margin: 0 0 4px; }
.tile__meta { margin: 0; font-size: .92rem; opacity: .88; }
.tile__bar { margin-top: 14px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); overflow: hidden; }
.tile__bar span { display: block; height: 100%; background: #fff; width: 0; }

.t-cobalt { --tile: var(--t-cobalt); }
.t-turquoise { --tile: var(--t-turquoise); }
.t-coral { --tile: var(--t-coral); }
.t-emerald { --tile: var(--t-emerald); }
.t-saffron { --tile: var(--t-saffron); }
.t-plum { --tile: var(--t-plum); }

.footnote { color: var(--ink-soft); font-size: .88rem; padding: 0 0 32px; max-width: 70ch; }

/* ---------- Course page ---------- */
.course-head { padding: 12px 0 20px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.course-head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.7rem, 4.5vw, 2.4rem); line-height: 1.15; margin: 0; }
.course-head .ar { font-size: clamp(2rem, 6vw, 2.8rem); color: color-mix(in srgb, var(--tile) 70%, var(--ink)); line-height: 1.2; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink-soft); font-size: .95rem; padding: 6px 0; }
.back:hover { color: var(--ink); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 1rem; font-weight: 600; margin: 0 0 12px; }

.units { list-style: none; padding: 0; margin: 0; }
.unit {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 4px; border-top: 1px solid var(--line); cursor: pointer;
}
.unit:first-child { border-top: 0; }
.unit input { width: 20px; height: 20px; accent-color: var(--tile); margin: 0; }
.unit__name { font-weight: 500; }
.unit__no { color: var(--ink-soft); font-variant-numeric: tabular-nums; margin-right: 6px; }
.unit__count { color: var(--ink-soft); font-size: .88rem; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.unit__stat { display: block; font-size: .8rem; }
.unit-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }

.field { margin: 0 0 16px; }
.field:last-child { margin-bottom: 0; }
.field__label { display: block; font-weight: 600; font-size: .95rem; margin: 0 0 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer;
  font-size: .95rem; background: var(--surface); user-select: none;
}
.seg input:checked + label { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.seg input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg input:disabled + label { opacity: .45; cursor: not-allowed; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--cobalt); }
.check small { display: block; color: var(--ink-soft); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 40px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; font-size: 1rem;
}
.btn:hover { border-color: var(--ink-soft); }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--primary:hover { filter: brightness(1.12); }
.btn--small { min-height: 36px; padding: 6px 12px; font-size: .9rem; font-weight: 500; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.hint { color: var(--ink-soft); font-size: .9rem; margin: 8px 0 0; }

/* ---------- Quiz ---------- */
.quiz { padding-bottom: 120px; }
.quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 10px; }
.quiz-top__pos { font-variant-numeric: tabular-nums; font-weight: 600; }
.quiz-top__score { display: flex; gap: 12px; font-size: .9rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.quiz-top__score b { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot--ok { background: var(--correct); }
.dot--two { background: var(--warn); }
.dot--no { background: var(--wrong); }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 22px; }
.progress span { display: block; height: 100%; background: var(--tile, var(--cobalt)); width: 0; transition: width .25s ease; }

.q-unit { color: var(--ink-soft); font-size: .88rem; margin: 0 0 8px; }
.q-stem {
  font-family: var(--serif); font-size: clamp(1.12rem, 2.6vw, 1.3rem); line-height: 1.6;
  margin: 0 0 20px; font-weight: 500; white-space: pre-line;
}
.q-stem .ar { font-size: 1.4em; }

.options { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.opt {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px;
  width: 100%; text-align: left; padding: 12px 14px; min-height: 56px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
  cursor: pointer; font-family: var(--serif); font-size: 1.05rem; line-height: 1.45;
  transition: border-color .12s ease, background-color .12s ease;
}
.opt:hover:not(:disabled) { border-color: var(--ink-soft); }
.opt__key {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 50%; border: 1.5px solid var(--line-strong); font-family: var(--sans); font-weight: 600; font-size: .9rem;
}
.opt__mark { display: inline-flex; width: 22px; }
.opt__mark:empty { width: 0; }
.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; }
.in-quiz .course-head { display: none; }
@media (max-width: 640px) {
  .opt { grid-template-columns: 30px 1fr auto; gap: 10px; padding: 11px 12px; font-size: 1rem; }
  .opt__key { width: 28px; height: 28px; }
}
.opt:disabled { cursor: default; }
.opt.is-wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.opt.is-wrong .opt__key { border-color: var(--wrong); background: var(--wrong); color: #fff; }
.opt.is-wrong .opt__mark { color: var(--wrong); }
.opt.is-correct { border-color: var(--correct); background: var(--correct-soft); }
.opt.is-correct .opt__key { border-color: var(--correct); background: var(--correct); color: #fff; }
.opt.is-correct .opt__mark { color: var(--correct); }
.opt.is-dim { opacity: .6; }

.feedback {
  margin-top: 18px; padding: 14px 16px; border-radius: var(--r-md); border-left: 4px solid;
}
.feedback p { margin: 0; }
.feedback p + p { margin-top: 8px; }
.feedback__title { font-weight: 600; }
.feedback__expl { font-family: var(--serif); line-height: 1.6; }
.feedback__src { color: var(--ink-soft); font-size: .85rem; }
.feedback--retry { border-color: var(--warn); background: var(--warn-soft); }
.feedback--ok { border-color: var(--correct); background: var(--correct-soft); }
.feedback--no { border-color: var(--wrong); background: var(--wrong-soft); }

.quiz-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
}
.quiz-nav .wrap { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.quiz-nav .btn--primary { flex: 0 1 260px; }
.kbd-hint { color: var(--ink-soft); font-size: .82rem; }
@media (max-width: 640px) { .kbd-hint { display: none; } .quiz-nav .btn--primary { flex: 1 1 auto; } }

/* ---------- Results ---------- */
.result-head { padding: 12px 0 20px; }
.result-head h1 { font-family: var(--serif); font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 6px; }
.result-head p { margin: 0; color: var(--ink-soft); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; }
.stat b { display: block; font-size: 1.8rem; font-family: var(--serif); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .88rem; color: var(--ink-soft); }
.stat--ok b { color: var(--correct); }
.stat--two b { color: var(--warn); }
.stat--no b { color: var(--wrong); }
@media (max-width: 420px) { .stat { padding: 10px; } .stat b { font-size: 1.45rem; } }

.review { list-style: none; padding: 0; margin: 0; }
.review li { padding: 14px 0; border-top: 1px solid var(--line); }
.review li:first-child { border-top: 0; }
.review__q { font-family: var(--serif); margin: 0 0 6px; line-height: 1.55; }
.review__a { margin: 0; font-size: .95rem; }
.review__a b { color: var(--correct); }
.review__x { margin: 4px 0 0; font-size: .9rem; color: var(--ink-soft); }
.tag { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 999px; margin-right: 6px; font-weight: 600; }
.tag--two { background: var(--warn-soft); color: var(--warn); }
.tag--no { background: var(--wrong-soft); color: var(--wrong); }

.empty { padding: 40px 0; text-align: center; color: var(--ink-soft); }

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