/* ============================================================
   TJKT Quest — Komponen UI
   Tombol, form, kartu, alert, navigasi, modal, chip, dsb.
   ============================================================ */

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;              /* target sentuh */
  padding: var(--space-2) var(--space-5);
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--color-primary);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .btn-primary { color: #0B1518; }
.btn-primary:hover { background: var(--color-primary-strong); box-shadow: var(--shadow-md); }

.btn-accent {
  background: var(--color-accent);
  color: #3B2F14;
}
.btn-accent:hover { filter: brightness(1.05); }

.btn-outline {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }

.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover { background: var(--color-surface-2); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

.btn-sm { min-height: 36px; padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.field label { font-weight: 700; font-size: var(--text-sm); }
.field .hint { font-size: var(--text-xs); color: var(--color-text-muted); }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  color: var(--color-text);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font: inherit;
  transition: border-color var(--transition);
}
.textarea { min-height: 120px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Kartu ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}
.card-hover { transition: transform var(--transition), box-shadow var(--transition); }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-link { color: inherit; display: block; }
.card-link:hover { text-decoration: none; }

/* ---------- Chip & badge ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}
.chip-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.chip-accent { background: var(--color-accent-soft); color: var(--color-warning); }
.chip-danger { background: rgb(220 38 38 / 0.12); color: var(--color-danger); }
.chip-success { background: rgb(22 163 74 / 0.12); color: var(--color-success); }

/* ---------- Alert / flash ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid transparent;
}
.alert-success { background: rgb(22 163 74 / 0.12); color: var(--color-success); }
.alert-error { background: rgb(220 38 38 / 0.10); color: var(--color-danger); }
.alert-info { background: rgb(2 132 199 / 0.10); color: var(--color-info); }
.alert .icon { margin-top: 2px; }

/* ---------- Navigasi atas ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
  display: flex;
  align-items: center;
}
.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 700; color: var(--color-text); }
.brand img { width: 32px; height: 32px; }
.brand:hover { text-decoration: none; }

.topnav { display: none; gap: var(--space-2); }
.topnav a {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-weight: 700; font-size: var(--text-sm);
}
.topnav a:hover { background: var(--color-surface-2); color: var(--color-text); text-decoration: none; }
.topnav a[aria-current="page"] { background: var(--color-primary-soft); color: var(--color-primary); }

@media (min-width: 768px) {
  .topnav { display: flex; }
  .bottom-nav { display: none; }
}

/* ---------- Navigasi bawah (mobile-first) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  min-height: 44px;
  color: var(--color-text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
}
.bottom-nav a[aria-current="page"] { color: var(--color-primary); }
main.with-bottom-nav { padding-bottom: calc(var(--bottom-nav-height) + var(--space-5)); }

/* ---------- Menu pengguna (dropdown) ---------- */
.user-menu { position: relative; }
.user-menu .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  display: none;
}
.user-menu.open .menu { display: block; }
.user-menu .menu a, .user-menu .menu button {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0; background: none;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-sm);
  cursor: pointer;
  text-align: left;
}
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--color-surface-2); text-decoration: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.5);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  width: 100%;
  max-height: 85dvh;
  overflow: auto;
  padding: var(--space-5);
  animation: modal-in 160ms ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- Status kosong ---------- */
.empty {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--color-text-muted);
}
.empty img, .empty .icon-lg { margin-inline: auto; margin-bottom: var(--space-3); width: 120px; height: auto; }

/* ---------- Lencana bintang ---------- */
.star-count {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-weight: 700; color: var(--color-accent);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-5) 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ---------- Tabel sederhana ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 1px solid var(--color-border); }
.table th { color: var(--color-text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; }

/* ============================================================
   HERO beranda
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--color-border);
  background:
    radial-gradient(1100px 480px at 88% -12%, var(--color-primary-soft), transparent 62%),
    radial-gradient(900px 420px at -8% 112%, var(--color-accent-soft), transparent 58%),
    var(--color-bg);
}
.hero-net {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--color-primary);
  opacity: 0.07;
  pointer-events: none;
}
.hero-inner {
  position: relative;
  display: grid;
  gap: var(--space-7);
  padding-block: var(--space-7) var(--space-8);
  align-items: center;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .hero-inner { grid-template-columns: 1.05fr 0.95fr; gap: var(--space-8); }
}

.hero-copy { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-4); }
.hero-copy h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  max-width: 15ch;
}
.text-gradient {
  background: linear-gradient(92deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead { font-size: var(--text-lg); color: var(--color-text-muted); max-width: 34rem; }

.hero-checks { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.hero-checks li { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; font-size: var(--text-sm); }
.hero-checks .icon {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  padding: 4px;
  width: 1.4rem;
  height: 1.4rem;
}

.hero-cta { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-2); }
.btn-lg { min-height: 52px; padding: var(--space-3) var(--space-6); font-size: var(--text-md); }

.hero-guru { font-size: var(--text-sm); color: var(--color-text-muted); }

/* --- Visual: kartu "jendela browser" + kartu melayang --- */
.hero-visual { position: relative; max-width: 440px; width: 100%; margin-inline: auto; }
.hero-window {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  text-align: center;
}
.hero-window-bar { display: flex; gap: 6px; justify-content: flex-start; padding: 2px 4px 12px; }
.hero-window-bar span { width: 10px; height: 10px; border-radius: 50%; }
.hero-window-bar span:nth-child(1) { background: #F87171; }
.hero-window-bar span:nth-child(2) { background: #FBBF24; }
.hero-window-bar span:nth-child(3) { background: #34D399; }
.hero-window img { width: 70%; height: auto; margin-inline: auto; }
.hero-window .caption { font-size: var(--text-sm); color: var(--color-text-muted); padding-top: var(--space-2); padding-bottom: var(--space-2); }

.float-card {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  padding: 6px var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  animation: floaty 4.5s ease-in-out infinite alternate;
}
.fc-star { top: -12px; left: 2%; color: var(--color-warning); animation-duration: 4s; }
.fc-task { bottom: 96px; right: -3%; color: var(--color-success); animation-duration: 5.2s; animation-delay: 0.7s; }
.fc-class { bottom: -14px; left: 6%; color: var(--color-primary); animation-duration: 4.6s; animation-delay: 0.3s; }
@keyframes floaty {
  from { transform: translateY(-5px); }
  to { transform: translateY(7px); }
}

/* ============================================================
   KELAS & MODUL (Tahap 2)
   ============================================================ */

/* ---------- Kartu kelas & kode ---------- */
.class-card {
  border-top: none;
  gap: var(--space-1);
  padding: 0;
  overflow: hidden;
}
.class-cover {
  width: 100%;
  height: 112px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--color-border);
}
.class-card-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.class-code {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.18em;
  background: var(--color-surface-2);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
  color: var(--color-text);
}
.class-code-lg {
  font-size: var(--text-xl);
  padding: var(--space-1) var(--space-3);
  cursor: copy;
}
.join-card { border-left: 5px solid var(--color-accent); }
.join-input { min-width: 160px; }

/* ---------- Form ---------- */
.breadcrumb { margin: 0; font-size: var(--text-sm); }
.breadcrumb a { color: var(--color-text-muted); display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb a:hover { color: var(--color-primary); }

.color-pick { display: inline-flex; cursor: pointer; }
.color-pick input { position: absolute; opacity: 0; pointer-events: none; }
.color-pick span {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  border: 3px solid transparent;
  outline: 2px solid transparent;
  transition: transform var(--transition), outline-color var(--transition);
}
.color-pick input:checked + span { outline-color: var(--color-text); transform: scale(1.1); }
.color-pick input:focus-visible + span { outline-color: var(--color-primary); }

.danger-zone { border-left: 4px solid var(--color-danger); }

/* ---------- Hero kelas ---------- */
.class-hero {
  border-left: 6px solid var(--class-color, var(--color-primary));
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.class-hero-body { padding: var(--space-5); }
.cp-box { border-left: 4px solid var(--color-accent); }

/* ---------- Peta perjalanan belajar ---------- */
.peta-modul {
  list-style: none;
  margin: 0; padding: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.peta-modul::before {
  content: '';
  position: absolute;
  left: 23px; top: 16px; bottom: 16px;
  width: 3px;
  background: var(--color-border);
  border-radius: var(--radius-full);
}
.peta-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--transition), transform var(--transition), opacity var(--transition);
}
.peta-item.is-locked { opacity: 0.75; background: var(--color-surface-2); }
.peta-node {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--class-color, var(--color-primary));
  color: #fff;
  font-weight: 700;
  font-size: var(--text-sm);
  z-index: 1;
}
.is-locked .peta-node { background: var(--color-text-muted); }
.peta-body { flex: 1; min-width: 0; }
.modul-link { color: inherit; }
.modul-link:hover { color: var(--color-primary); }
.peta-actions { margin-top: var(--space-2); }
.peta-side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}
.peta-handle {
  cursor: grab;
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  touch-action: none;
}
.peta-handle:focus-visible { outline: 2px solid var(--color-primary); }
.peta-handle:active { cursor: grabbing; }
.peta-item.dragging { opacity: 0.45; transform: scale(0.99); }
.peta-item.drag-over { box-shadow: 0 0 0 3px var(--color-primary-soft); border-color: var(--color-primary); }

/* ---------- Daftar TP ---------- */
.tp-row { flex-wrap: nowrap; }
.tp-row .input { flex: 1 1 auto; width: auto; min-width: 0; }
.tp-remove { flex: 0 0 auto; }
.tp-list {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.tp-list li { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-sm); }
.tp-num {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 700;
  font-size: var(--text-xs);
}

@media (prefers-reduced-motion: reduce) {
  .peta-item, .color-pick span { transition: none; }
}
