/* Kad Kilat Sejarah - Gaya Moden & Ceria */
:root {
  --primary: #f59e0b;
  --primary-hover: #d97706;
  --primary-light: #fef3c7;
  --primary-dark: #b45309;
  --accent: #4f46e5;
  --accent-light: #e0e7ff;
  --accent-hover: #4338ca;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --bg-gradient: linear-gradient(135deg, #fffbeb 0%, #fef3c7 40%, #e0e7ff 100%);
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 35px -8px rgba(99, 102, 241, 0.18), 0 10px 15px -3px rgba(0, 0, 0, 0.07);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* Header */
.app-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid #fde68a;
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge {
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.35);
}

.app-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #1e1b4b;
  letter-spacing: -0.02em;
}

.app-subtitle {
  font-size: 0.825rem;
  color: #6366f1;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-top-reset {
  background: #ffffff;
  color: #4f46e5;
  border: 1.5px solid #c7d2fe;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-top-reset:hover {
  background: #eff6ff;
  border-color: #818cf8;
  color: #3730a3;
  transform: translateY(-1px);
}

.stats-pill {
  background: #ffffff;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: var(--shadow-sm);
}

/* Hero Section */
.hero-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 1rem;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.8);
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 1.5rem;
  align-items: center;
}

.hero-text h2 {
  font-size: 1.65rem;
  font-weight: 800;
  color: #1e1b4b;
  margin-bottom: 0.5rem;
  line-height: 1.25;
}

.hero-text p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.hero-badge-tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.hero-image-wrap {
  width: 100%;
  height: 130px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Progress Bar */
.progress-container {
  margin-top: 1.5rem;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.progress-extra {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.shuffle-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-weight: 600;
}

.btn-text-reset {
  background: none;
  border: none;
  color: #4f46e5;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.btn-text-reset:hover {
  background: #eef2ff;
  text-decoration: underline;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #f1f5f9;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ec4899);
  width: 10%;
  transition: width 0.35s ease;
  border-radius: 9999px;
}

/* Flashcard Styles */
.flashcard-area {
  margin-top: 1.5rem;
  perspective: 1200px;
}

.flashcard {
  width: 100%;
  min-height: 330px;
  position: relative;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}

/* Card Front */
.card-front {
  background: linear-gradient(145deg, #ffffff 0%, #fffdfa 100%);
  border: 2px solid #fde68a;
}

.card-front .tag {
  background: #fef3c7;
  color: #b45309;
}

/* Card Back */
.card-back {
  background: linear-gradient(145deg, #eef2ff 0%, #ffffff 100%);
  border: 2px solid #c7d2fe;
  transform: rotateY(180deg);
}

.card-back .tag {
  background: #e0e7ff;
  color: #4338ca;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flip-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.card-body {
  margin: 1.5rem 0;
}

.card-question {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.4;
}

.card-answer {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e1b4b;
  line-height: 1.45;
  margin-bottom: 0.75rem;
}

.card-explanation {
  font-size: 0.95rem;
  color: #334155;
  background: #ffffff;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  line-height: 1.5;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px dashed var(--border);
  padding-top: 1rem;
}

.chapter-badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
}

.click-instruction {
  font-size: 0.8rem;
  color: #d97706;
  font-weight: 700;
}

/* Action Controls (Buttons) */
.action-controls {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.self-eval-prompt {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #334155;
}

.button-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.85rem 1.4rem;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 3px solid #3b82f6;
  outline-offset: 2px;
}

.btn-flip {
  background: #ffffff;
  color: #1e293b;
  border: 2px solid #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.btn-flip:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.btn-know {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  flex: 1;
  min-width: 160px;
}

.btn-know:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-dont-know {
  background: #f43f5e;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
  flex: 1;
  min-width: 160px;
}

.btn-dont-know:hover {
  background: #e11d48;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(244, 63, 94, 0.4);
}

.btn-nav {
  background: transparent;
  color: #64748b;
  border: 1px solid #cbd5e1;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

.btn-nav:hover {
  background: #ffffff;
  color: #0f172a;
}

.btn-reset-secondary {
  background: #ffffff;
  color: #4f46e5;
  border: 1px solid #c7d2fe;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  box-shadow: var(--shadow-sm);
}

.btn-reset-secondary:hover {
  background: #eff6ff;
  border-color: #818cf8;
}

/* Secondary Navigation row */
.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Result Screen */
.result-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 3px solid #fde68a;
  animation: fadeIn 0.4s ease-out;
}

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

.result-emoji {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.result-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: #1e1b4b;
  margin-bottom: 0.25rem;
}

.result-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.score-badge-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fef3c7, #fed7aa);
  border: 4px solid #f59e0b;
  margin: 0 auto 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.25);
}

.score-number {
  font-size: 2.75rem;
  font-weight: 900;
  color: #b45309;
  line-height: 1;
}

.score-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #92400e;
  text-transform: uppercase;
}

.result-details {
  background: #f8fafc;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  max-width: 500px;
  margin: 0 auto 1.5rem;
  text-align: left;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.95rem;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: #64748b;
  font-weight: 600;
}

.detail-val {
  font-weight: 700;
  color: #1e293b;
}

.detail-val.good {
  color: var(--success);
}

.detail-val.bad {
  color: var(--danger);
}

.result-feedback {
  font-size: 1.05rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 1.75rem;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.btn-restart {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
  font-size: 1.05rem;
  padding: 0.95rem 2rem;
}

.btn-restart:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.45);
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  color: #64748b;
}

/* Accessibility */
.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;
}

/* Responsive */
@media (max-width: 640px) {
  .hero-card {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 1.25rem;
  }
  .hero-image-wrap {
    height: 110px;
    margin: 0 auto;
    max-width: 260px;
  }
  .flashcard {
    min-height: 350px;
  }
  .card-face {
    padding: 1.25rem;
  }
  .card-question {
    font-size: 1.15rem;
  }
  .card-answer {
    font-size: 1rem;
  }
  .button-group {
    flex-direction: column;
  }
  .btn {
    width: 100%;
  }
  .header-actions {
    gap: 0.4rem;
  }
  .btn-top-reset {
    padding: 0.35rem 0.6rem;
    font-size: 0.775rem;
  }
  .nav-row {
    justify-content: center;
  }
}
