/* =========================================================
   BASE.CSS — dipakai bersama oleh index.html, koding.html & kuis.html
   Isinya: token desain (warna, huruf, radius), reset, dan elemen umum
   (tombol, isian, jendela dialog, konfeti). Style khusus tiap halaman
   ada di index.css / koding.css / kuis.css.

   TAMPILAN (v8): antarmuka gelap berwarna; aksen cerah ala sintaks kode.
   Satu tema untuk SEMUA siswa (Tosca), supaya warna tidak menjadi variabel
   lain selama penelitian.

   Pembagian warna (tetap, supaya warna tidak mengaburkan makna):
     --accent  aksi utama & penanda aktif (Tosca)
     --ok      berhasil
     --help    bantuan (Bantuan 1 / Bantuan 2)
     --err     salah / error
   ========================================================= */

:root {
  /* Huruf: keluarga IBM Plex (teknis, terbaca di layar kecil) */
  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-brand: 'IBM Plex Sans Condensed', 'IBM Plex Sans', system-ui, sans-serif;
  --font-code: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  /* Permukaan gelap (biru-hitam, bukan hitam polos) */
  --bg-page: #17191e;
  --bg-panel: #1f2227;
  --bg-editor: #181a1f;   /* isian & area cekung (bukan editor kode) */
  --bg-raised: #292d34;
  --line: #343941;
  --line-strong: #444a54;
  --text: #e6e8eb;
  --muted: #9aa1ab;

  /* Warna makna (tetap: tidak dipakai untuk hal lain) */
  --accent: #6cb4f2;        --accent-strong: #9ccbf7;  --accent-soft: rgba(108,180,242,.15);
  --accent-2: #a9b4c8;      --accent-2-soft: rgba(169,180,200,.16);
  --ok: #6fbf73;            --ok-soft: rgba(111,191,115,.15);
  --help: #d9a13b;          --help-fill: #d9a13b;      --help-soft: rgba(217,161,59,.16);
  --err: #e5655f;           --err-soft: rgba(229,101,95,.15);
  --on-ok: #0c1d0d;  --on-help: #2a1d03;  --on-accent: #07121f;  --on-err: #2a0a07;

  /* Permukaan kode: editor & Console (lebih gelap dari halaman) */
  --code-bg: #1e1e1e;  --code-bg-2: #252526;  --code-line: #3a3d41;
  --code-text: #d4d4d4;  --code-muted: #858585;
  --run: #6cb4f2;  --on-run: #07121f;

  --syn-keyword: #569cd6; --syn-fn: #dcdcaa; --syn-var: #9cdcfe;
  --syn-num: #b5cea8;     --syn-str: #ce9178; --syn-comment: #6a9955;
  --block-bg: #2b4a73;    --block-border: #3d6aa6;

  --radius-s: 6px; --radius-m: 10px; --radius-l: 14px;
  --shadow-float: 0 8px 22px rgba(0,0,0,0.45);
  --shadow-deep: 0 24px 60px rgba(0,0,0,0.6);
}

/* Nama variabel lama dipetakan ke token baru (kode JS & CSS lama tetap jalan) */
:root {
  --paper: var(--bg-panel); --paper-2: var(--bg-raised); --paper-line: var(--line);
  --ink: var(--text); --ink-soft: var(--muted);
  --console-bg: var(--code-bg); --console-bg-2: var(--code-bg-2);
  --console-text: var(--code-text); --console-line: var(--line);
  --mint: var(--ok); --mint-dim: var(--ok);
  --amber: var(--help-fill); --rose: var(--err); --copper: var(--accent);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
/* Scrollbar gelap & tipis, serasi dengan tema */
* { scrollbar-width: thin; scrollbar-color: #3a5063 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a5063; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #4d6a82; background-clip: content-box; }

::selection { background: rgba(108,180,242,0.28); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* Logo (segi enam seperti mur) */
.bk-logo { display: block; flex-shrink: 0; color: var(--accent); }

/* ---------- Tombol umum ---------- */
.btn {
  font-family: var(--font-ui); font-weight: 600; font-size: 14px; line-height: 1.2;
  border: 1px solid transparent; border-radius: 8px; padding: 11px 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:not(:disabled):hover { background: var(--accent-strong); }
.btn--ghost { background: var(--bg-panel); color: var(--text); border-color: var(--line-strong); }
.btn--ghost:not(:disabled):hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn--amber { background: var(--help-soft); color: var(--help); border-color: var(--help-fill); }
.btn--amber:not(:disabled):hover { background: var(--help-fill); color: var(--on-help); }

/* ---------- Isian teks umum ---------- */
.field-input, .bk-student-input, .ix-input {
  width: 100%; padding: 11px 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--bg-panel); color: var(--text);
  font-size: 15px; font-family: var(--font-ui);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-input::placeholder, .bk-student-input::placeholder, .ix-input::placeholder { color: var(--muted); opacity: 0.75; }
.field-input:focus, .bk-student-input:focus, .ix-input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Jendela dialog umum ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10,11,14,0.55);
  backdrop-filter: blur(2px);
  z-index: 50; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay--show { display: flex; }
.modal-card {
  background: var(--bg-panel); color: var(--text); border-radius: var(--radius-l);
  border: 1px solid var(--line);
  padding: 28px 28px 24px; max-width: 440px; width: 100%; text-align: left;
  box-shadow: var(--shadow-deep);
  animation: bk-modal-in 0.22s ease-out;
}
@keyframes bk-modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-emoji { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.modal-emoji svg { width: 24px; height: 24px; }
.modal-card h2 { font-family: var(--font-brand); font-weight: 700; margin: 0 0 6px; font-size: 24px; line-height: 1.2; }
.modal-lead { font-size: 14.5px; line-height: 1.6; color: var(--muted); margin: 0 0 12px; }
.modal-lead b { color: var(--text); font-weight: 600; }
.modal-body ul { font-size: 14.5px; line-height: 1.7; padding-left: 20px; margin: 0 0 20px; color: var(--text); }
.modal-body li::marker { color: var(--accent); }
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.bk-student-input + .modal-actions { margin-top: 22px; }
.modal-actions .btn { width: 100%; }

/* ---------- Konfeti (satu kali, saat semua tahap selesai) ---------- */
.bk-confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.bk-confetti i {
  position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; opacity: 0;
  animation: bk-fall var(--d, 1.8s) ease-in var(--delay, 0s) forwards;
}
@keyframes bk-fall {
  0% { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(105vh) translateX(var(--dx, 0px)) rotate(var(--rot, 540deg)); }
}
