/* ============================================================
   SafeRide — Global Stylesheet
   Digunakan oleh: index.html, kuis.html, hasil.html, leaderboard.html
   ============================================================ */

/* ===== IMPORT FONT ===== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ===== CSS VARIABLES ===== */
:root {
  --green:   #16a34a;
  --green2:  #22c55e;
  --greenL:  #dcfce7;
  --teal:    #0891b2;
  --yellow:  #eab308;
  --yellowL: #fef9c3;
  --orange:  #f97316;
  --red:     #ef4444;
  --redL:    #fee2e2;
  --blue:    #3b82f6;
  --blueL:   #dbeafe;
  --purple:  #8b5cf6;
  --purpleL: #ede9fe;
  --dark:    #0f172a;
  --dark2:   #1e293b;
  --dark3:   #334155;
  --muted:   #64748b;
  --border:  #e2e8f0;
  --white:   #ffffff;
  --bg:      #f8fafc;
  --bg2:     #f1f5f9;

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 4px rgba(0,0,0,.06);
  --shadow-md: 0 4px 24px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.1);

  --font: 'Nunito', sans-serif;
}

/* ===== BASE ===== */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--font); }
img { max-width: 100%; }

/* ===== TOPBAR (shared) ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 60px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 200;
  box-shadow: var(--shadow-sm);
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px;
}
.topbar-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--dark2), var(--dark3));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.topbar-name {
  font-weight: 900; font-size: 1rem; color: var(--dark);
}
.topbar-sub {
  font-size: .72rem; color: var(--muted);
}
.back-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .9rem; color: var(--dark);
  transition: all .2s; text-decoration: none;
}
.back-btn:hover { background: var(--border); }

/* ===== PROGRESS BAR (shared) ===== */
.progress-wrap {
  position: fixed; top: 60px; left: 0; right: 0;
  height: 4px; background: var(--border); z-index: 199;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green2));
  transition: width .5s ease;
}

/* ===== PAGE WRAPPER ===== */
.page-wrap {
  padding-top: 80px;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-bottom: 48px;
}
.page-inner {
  width: 100%;
  max-width: 680px;
  padding: 20px;
}

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.card-sm { padding: 20px; border-radius: var(--radius-lg); }
.card-dark {
  background: var(--dark2);
  border-color: var(--dark3);
  color: var(--white);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; border: none; border-radius: var(--radius-md);
  padding: 14px 24px; cursor: pointer;
  font-family: var(--font); font-size: .95rem; font-weight: 800;
  transition: all .25s; text-decoration: none;
}
.btn-full { width: 100%; }
.btn-primary {
  background: linear-gradient(135deg, var(--green), var(--green2));
  color: var(--white);
  box-shadow: 0 6px 20px rgba(22,163,74,.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(22,163,74,.45); }
.btn-dark {
  background: var(--dark);
  color: var(--white);
}
.btn-dark:hover { background: var(--dark2); transform: translateY(-1px); }
.btn-outline {
  background: var(--bg);
  color: var(--dark);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--dark); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { color: var(--dark); border-color: var(--dark3); }

/* ===== BADGES / PILLS ===== */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: var(--radius-full);
  font-size: .72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .6px;
}
.tag-green { background: var(--greenL); color: var(--green); }
.tag-yellow { background: var(--yellowL); color: #92400e; }
.tag-blue { background: var(--blueL); color: var(--blue); }
.tag-red { background: var(--redL); color: var(--red); }
.tag-purple { background: var(--purpleL); color: var(--purple); }
.tag-dark { background: var(--dark2); color: rgba(255,255,255,.7); }

/* ===== DIVIDER ===== */
.divider {
  height: 1px; background: var(--border); margin: 20px 0;
}

/* ===== STAT BOXES ===== */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
}
.stat-box-num {
  font-size: 1.6rem; font-weight: 900; line-height: 1;
}
.stat-box-label {
  font-size: .7rem; color: var(--muted); margin-top: 5px; font-weight: 700;
}

/* ===== SCORE BIG ===== */
.score-big {
  font-size: 4rem; font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, var(--green), var(--yellow));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.score-label {
  font-size: .78rem; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px; margin-top: 4px;
}

/* ===== XP BAR ===== */
.xp-wrap {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px;
}
.xp-meta {
  display: flex; justify-content: space-between;
  font-size: .75rem; font-weight: 700; color: var(--muted); margin-bottom: 8px;
}
.xp-track {
  height: 10px; border-radius: var(--radius-full);
  background: var(--border); overflow: hidden;
}
.xp-fill {
  height: 100%; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--green), var(--green2));
  width: 0%; transition: width 1.2s cubic-bezier(.34,1.56,.64,1);
}

/* ===== BADGE CARD ===== */
.badge-card {
  background: linear-gradient(135deg, #fef9c3, #fde68a);
  border: 2px solid #fcd34d;
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}
.badge-icon-big { font-size: 3rem; margin-bottom: 8px; }
.badge-name { font-weight: 900; font-size: 1.05rem; color: #78350f; }
.badge-desc { font-size: .8rem; color: #92400e; margin-top: 4px; }

/* ===== LEADERBOARD ROW ===== */
.lb-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .2s;
  gap: 4px;
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: var(--greenL); }
.lb-row.top1 { background: linear-gradient(90deg, #fef9c3, var(--white)); }
.lb-row.top2 { background: linear-gradient(90deg, #f1f5f9, var(--white)); }
.lb-row.top3 { background: linear-gradient(90deg, #fff7ed, var(--white)); }
.lb-row.me   { background: linear-gradient(90deg, var(--greenL), var(--white)); }

.lb-rank { font-size: 1.1rem; font-weight: 900; text-align: center; }
.lb-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green2));
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 900; color: white; flex-shrink: 0;
}
.lb-info { display: flex; align-items: center; gap: 10px; }
.lb-name { font-weight: 800; font-size: .92rem; }
.lb-modul { font-size: .72rem; color: var(--muted); }
.lb-right { text-align: right; }
.lb-score { font-weight: 900; color: var(--green); font-size: .95rem; }
.lb-time { font-size: .7rem; color: var(--muted); margin-top: 2px; }

/* ===== ANIMASI ===== */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  0%   { transform: scale(.8); opacity: 0; }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.anim-fade-down { animation: fadeDown .5s ease both; }
.anim-fade-up   { animation: fadeUp .5s ease both; }
.anim-pop       { animation: popIn .4s cubic-bezier(.34,1.56,.64,1) both; }

.reveal {
  opacity: 0; transform: translateY(20px);
  transition: opacity .55s ease, transform .55s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .card { padding: 20px; border-radius: var(--radius-lg); }
  .stat-row { grid-template-columns: repeat(3,1fr); gap: 8px; }
  .stat-box-num { font-size: 1.3rem; }
  .score-big { font-size: 3rem; }
  .page-inner { padding: 14px; }
  .lb-row { padding: 12px 14px; }
}
