/* Class Quiz: shared colours, type and controls. */

:root {
  --ink: #160c22;
  --ink-2: #241433;
  --ink-3: #31204a;
  --cream: #f6f1e7;
  --muted: #b7adc6;
  --gold: #f0c14d;
  --gold-ink: #2a1c00;
  --line: rgba(246, 241, 231, 0.14);
  --line-strong: rgba(246, 241, 231, 0.3);
  --good: #3dce7a;
  --good-soft: rgba(61, 206, 122, 0.18);
  --bad: #ff6b81;
  --bad-soft: rgba(255, 107, 129, 0.16);
  --a1: #e5482c;
  --a2: #0b8a7f;
  --a3: #f2b134;
  --a4: #6a4bdc;
  --radius: 16px;
  --font: "Avenir Next", "Segoe UI", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  --arabic: "Geeza Pro", "Noto Naskh Arabic", "Segoe UI", "Tahoma", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  line-height: 1.4;
  color: var(--cream);
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(240, 193, 77, 0.16), transparent 55%),
    radial-gradient(700px 480px at 100% 110%, rgba(19, 104, 206, 0.2), transparent 50%),
    var(--ink);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* Mixed English and Arabic: each line picks its own direction from its first strong letter. */
.bidi { unicode-bidi: plaintext; text-align: start; }
:lang(ar), .bidi:dir(rtl) { font-family: var(--arabic), var(--font); }

h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }
a { color: var(--gold); }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--ink-3);
  color: var(--cream);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--cream); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn.primary:hover:not(:disabled) { background: #f6cf6a; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad-soft); color: #ffd0d6; border-color: rgba(255, 107, 129, 0.45); }
.btn.big { min-height: 56px; padding: 14px 28px; font-size: 1.15rem; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 0.9rem; }
.btn.icon { padding: 0; width: 44px; }

.field { display: grid; gap: 6px; font-weight: 700; font-size: 0.95rem; }
.field input, .field textarea, .field select, input.plain, textarea.plain {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(10, 5, 18, 0.55);
  font-weight: 500;
}
.field input:focus, .field textarea:focus, input.plain:focus, textarea.plain:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(240, 193, 77, 0.25); }
.field .hint { font-weight: 500; color: var(--muted); font-size: 0.88rem; }

.kicker { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8rem; font-weight: 800; color: var(--gold); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.logo { width: 30px; height: 30px; flex: none; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 14px);
  background: #fff8ea;
  color: var(--gold-ink);
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  max-width: min(92vw, 560px);
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: #ffe1e5; color: #4a0010; }

body.offline::before {
  content: "Reconnecting…";
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #3a2410;
  color: var(--gold);
  border: 1px solid rgba(240, 193, 77, 0.45);
  padding: 6px 14px;
  border-radius: 999px;
  z-index: 60;
  font-size: 0.95rem;
  font-weight: 700;
}

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