/* ============================================================
   HTML5 Interactive Quiz — Stylesheet
   Palet warna: biru tua, biru muda, putih, aksen oranye
   ============================================================ */

:root {
  /* Palet warna utama */
  --navy-900: #0b2545;
  --navy-800: #123163;
  --blue-500: #2f6fed;
  --blue-300: #7fb0ff;
  --blue-100: #eaf2ff;
  --orange-500: #ff7a29;
  --orange-400: #ff9a54;
  --white: #ffffff;
  --green-500: #2fb872;
  --red-500: #e64b4b;

  /* Tema terang (default) */
  --bg-page: linear-gradient(160deg, var(--navy-900) 0%, var(--navy-800) 42%, var(--blue-500) 100%);
  --surface: var(--white);
  --surface-alt: var(--blue-100);
  --text-main: #10213f;
  --text-muted: #55698e;
  --border-soft: #d9e4fb;
  --shadow-card: 0 20px 45px rgba(11, 37, 69, 0.25);

  --font-display: "Segoe UI", "Poppins", "Trebuchet MS", sans-serif;
  --font-body: "Segoe UI", "Inter", Arial, sans-serif;
  --font-mono: "Consolas", "SFMono-Regular", Menlo, monospace;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

body.dark {
  --surface: #101c34;
  --surface-alt: #16274a;
  --text-main: #eef3ff;
  --text-muted: #9fb2d9;
  --border-soft: #24365f;
  --shadow-card: 0 20px 45px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  transition: background 0.4s ease, color 0.3s ease;
}

button {
  font-family: inherit;
}

/* ---------- Layout dasar layar ---------- */

#app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.screen {
  display: none;
  width: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeSlideIn 0.45s ease both;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Kontrol mengambang (suara, tema, fullscreen) ---------- */

.floating-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 40;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
  backdrop-filter: blur(6px);
}

.icon-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.25);
}

.icon-btn:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--orange-400);
  outline-offset: 2px;
}

/* ============================================================
   SCREEN: START
   ============================================================ */

.start-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 40px clamp(20px, 5vw, 48px);
  max-width: 460px;
  width: 100%;
  text-align: center;
  color: var(--text-main);
}

.start-visual {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

/* Ilustrasi jendela browser berisi kode HTML — elemen ciri khas halaman ini */
.browser-mock {
  width: 100%;
  max-width: 320px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  box-shadow: 0 12px 24px rgba(11, 37, 69, 0.15);
}

.browser-bar {
  background: var(--navy-900);
  padding: 8px 12px;
  display: flex;
  gap: 6px;
}

.browser-bar .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot-red { background: #ff6159; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }

.browser-body {
  background: #0f1c33;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: left;
  line-height: 1.55;
}

.browser-body p {
  margin: 0;
  white-space: pre;
}

.browser-body .indent { padding-left: 14px; }
.browser-body .indent-2 { padding-left: 28px; }
.browser-body .tag { color: var(--orange-400); }
.browser-body .txt { color: var(--blue-300); }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--blue-500);
  font-weight: 700;
  margin: 0 0 6px;
}

.title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 0 0 6px;
  color: var(--navy-900);
  font-weight: 800;
}

body.dark .title { color: var(--white); }

.title-sm { font-size: clamp(1.3rem, 3vw, 1.6rem); }

.subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 0.98rem;
}

#form-start {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  margin-bottom: 16px;
}

#form-start label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"] {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-soft);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text-main);
  transition: border-color 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--blue-500);
}

.field-error {
  color: var(--red-500);
  font-size: 0.82rem;
  margin: 2px 0 0;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 13px 26px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--orange-500);
  color: var(--white);
  box-shadow: 0 10px 20px rgba(255, 122, 41, 0.35);
}

.btn-primary:hover { background: var(--orange-400); }

.btn-secondary {
  background: var(--surface-alt);
  color: var(--navy-900);
  border: 1.5px solid var(--border-soft);
}

body.dark .btn-secondary { color: var(--white); }

.btn-block { width: 100%; }

.btn-link {
  background: none;
  border: none;
  color: var(--blue-500);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.9rem;
  margin-top: 6px;
}

.btn-link-light {
  color: var(--white);
}

.last-result-note {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ============================================================
   SCREEN: QUIZ
   ============================================================ */

#screen-quiz {
  max-width: 640px;
}

.quiz-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.progress-wrap {
  flex: 1;
  color: var(--white);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.progress-track {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 10%;
  background: var(--orange-500);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.timer-ring {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.timer-ring svg { transform: rotate(-90deg); }

.timer-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 6;
}

.timer-arc {
  fill: none;
  stroke: var(--orange-500);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 176;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

#timer-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
  font-size: 0.95rem;
}

.quiz-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px clamp(18px, 4vw, 36px);
  width: 100%;
  animation: fadeSlideIn 0.35s ease both;
}

.question-text {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.6vw, 1.4rem);
  color: var(--navy-900);
  margin: 0 0 20px;
  line-height: 1.4;
}

body.dark .question-text { color: var(--white); }

.options-list {
  display: grid;
  gap: 12px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-soft);
  background: var(--surface-alt);
  color: var(--text-main);
  font-size: 0.98rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, background 0.2s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--blue-500);
  transform: translateX(2px);
}

.option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy-900);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
}

.option-btn.correct {
  background: rgba(47, 184, 114, 0.15);
  border-color: var(--green-500);
}

.option-btn.correct .option-letter { background: var(--green-500); }

.option-btn.wrong {
  background: rgba(230, 75, 75, 0.12);
  border-color: var(--red-500);
}

.option-btn.wrong .option-letter { background: var(--red-500); }

.option-btn:disabled { cursor: default; }

.feedback-message {
  font-weight: 700;
  margin: 16px 0 4px;
}

.feedback-message.is-correct { color: var(--green-500); }
.feedback-message.is-wrong { color: var(--red-500); }

.explanation-text {
  background: var(--surface-alt);
  border-left: 4px solid var(--blue-500);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 6px 0 18px;
}

#btn-next { margin-top: 4px; }

/* ============================================================
   SCREEN: RESULT
   ============================================================ */

#screen-result { position: relative; }

.result-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 36px clamp(18px, 5vw, 44px);
  max-width: 560px;
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 2;
}

.grade-badge {
  width: 84px;
  height: 84px;
  margin: 8px auto 12px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--orange-500), var(--orange-400));
  color: var(--white);
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px rgba(255, 122, 41, 0.4);
}

.motivation {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 26px;
}

.result-stat {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--navy-900);
}

body.dark .stat-value { color: var(--white); }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

/* ============================================================
   SCREEN: REVIEW / PEMBAHASAN
   ============================================================ */

.review-wrap {
  max-width: 640px;
  width: 100%;
}

.review-wrap .title { color: var(--white); text-align: center; }

.review-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 20px 0;
}

.review-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  border-left: 6px solid var(--green-500);
}

.review-item.is-wrong { border-left-color: var(--red-500); }

.review-question {
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--navy-900);
}

body.dark .review-question { color: var(--white); }

.review-line {
  margin: 3px 0;
  font-size: 0.92rem;
}

.review-status {
  font-weight: 700;
}

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

.review-explanation {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

#btn-back-result { display: block; margin: 0 auto; }

/* ============================================================
   SCREEN: LECTURER PANEL
   ============================================================ */

.lecturer-wrap {
  max-width: 640px;
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px clamp(18px, 4vw, 40px);
}

.lecturer-settings {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 18px 0 26px;
}

.switch-row, .select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.94rem;
}

.select-row select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-main);
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--orange-500);
}

.lecturer-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.section-heading {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--navy-900);
  margin: 0 0 12px;
}

body.dark .section-heading { color: var(--white); }

.lecturer-question-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.lecturer-question-item {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
}

.lecturer-question-item strong { color: var(--green-500); }

#btn-lecturer-exit { display: block; margin: 20px auto 0; }

/* ============================================================
   SCREEN: PRESENTATION MODE
   ============================================================ */

.presentation-wrap {
  max-width: 900px;
  width: 100%;
  text-align: center;
  color: var(--white);
}

.presentation-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  font-weight: 700;
}

.presentation-question {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4.5vw, 2.6rem);
  margin-bottom: 32px;
  line-height: 1.35;
}

.presentation-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 30px;
}

.presentation-option {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-md);
  color: var(--white);
  font-size: clamp(1rem, 2vw, 1.3rem);
  padding: 22px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.presentation-option:hover { background: rgba(255, 255, 255, 0.2); }

.presentation-option.reveal-correct {
  background: rgba(47, 184, 114, 0.35);
  border-color: var(--green-500);
}

.presentation-controls {
  display: flex;
  justify-content: center;
  gap: 14px;
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 16, 33, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.modal-box h2 {
  margin-top: 0;
  color: var(--navy-900);
  font-family: var(--font-display);
}

body.dark .modal-box h2 { color: var(--white); }

.modal-box p { color: var(--text-muted); font-size: 0.9rem; }

#form-lecturer-code {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy-900);
  color: var(--white);
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
  z-index: 60;
  animation: toastPop 0.3s ease both;
}

@keyframes toastPop {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 560px) {
  .result-grid { grid-template-columns: 1fr; }
  .presentation-options { grid-template-columns: 1fr; }
  .quiz-topbar { flex-direction: row; }
  #app { padding: 20px 12px; }
}

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

/* ============================================================
   PRINT (Cetak Hasil)
   ============================================================ */

@media print {
  .floating-controls,
  .result-actions,
  #confetti-canvas { display: none !important; }

  body { background: var(--white); }

  .result-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
