/* Frontend publik (Panduan §3) — dark theme, sticky header, grid kartu, 16:9 */
:root {
  --bg: #0b0d10;
  --bg-2: #12151a;
  --bg-3: #191d24;
  --border: #262b33;
  --text: #e8ebf0;
  --dim: #8b93a1;
  --accent: #FA479D;
  --accent-2: #ff65bb;   /* versi lebih terang dari #FA479D — dipakai state hover */
  --radius: 10px;
}

* { box-sizing: border-box; }

/*
 * attribute `hidden` harus SELALU menang atas stylesheet buatan kita.
 * Browser menyembunyikan elemen ber-`hidden` lewat aturan bawaan
 * `[hidden] { display:none }`, tapi stylesheet author selalu mengalahkan
 * stylesheet bawaan (menang kalahnya soal origin, bukan spesifisitas).
 * Tanpa baris ini, kelas dengan rule `display` (mis. `.modal { display:flex }`)
 * akan tetap tampil walau attribute `hidden` sudah dipasang.
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; }
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
.dim { color: var(--dim); }

/* ---------------- header sticky ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 13, 16, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
}
/* logo adalah gambar mahkota (logo.png) — rasio asli 165x144 */
.logo img {
  height: 48px;
  width: auto;
  display: block;
}

/* ---------------- search ---------------- */
.search {
  flex: 1;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.search input {
  flex: 1;
  min-width: 0;
  padding: 9px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.95rem;
}
.search input:focus { outline: none; border-color: var(--accent); }
.search input::placeholder { color: var(--dim); }

.search button {
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-weight: 600;
}
.search button:hover { background: var(--accent-2); }

/* ---------------- kategori ---------------- */
.cats {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px 10px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.cats::-webkit-scrollbar { height: 4px; }
.cats::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.cat {
  flex: 0 0 auto;
  padding: 6px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--dim);
  font-size: 0.85rem;
  white-space: nowrap;
}
.cat:hover { color: var(--text); border-color: var(--dim); }
.cat.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------------- konten ---------------- */
.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  color: var(--dim);
}
.perpage { display: flex; align-items: center; gap: 6px; }
.perpage select {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
}

/* ---------------- grid kartu ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.card {
  display: block;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  /* card adalah <a href="/video/:id"> — jangan ada gaya link bawaan */
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card:hover { transform: translateY(-3px); border-color: #3a4150; }

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;      /* thumbnail 16:9 sesuai panduan */
  background: #000;
  overflow: hidden;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb .noimg {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 2rem;
}

.badge {                       /* badge durasi */
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, .82);
  color: #fff;
  border-radius: 4px;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-sub {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--dim);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tag {
  padding: 1px 7px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* ---------------- kosong ---------------- */
.empty {
  text-align: center;
  padding: 70px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty p { margin: 6px 0; }

/* ---------------- pagination ---------------- */
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 28px;
}
.pager button {
  min-width: 36px;
  padding: 7px 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.88rem;
}
.pager button:hover:not(:disabled):not(.on) { border-color: var(--dim); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.pager .gap { color: var(--dim); padding: 0 3px; }

/* ---------------- footer ---------------- */
.foot {
  border-top: 1px solid var(--border);
  padding: 22px 16px;
  text-align: center;
  color: var(--dim);
  font-size: 0.82rem;
}

/* ---------------- halaman detail /video/:id ----------------
   Perbaikan.md §2: tanpa modal, tanpa popup, tanpa tab baru. */
.back {
  display: inline-block;
  margin-bottom: 16px;
  padding: 8px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
}
.back:hover { background: var(--bg-2); border-color: #3a4150; }

.thumbbox {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}
.thumbbox img { width: 100%; height: 100%; object-fit: cover; }
.thumbbox .noimg {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: var(--dim);
}

.detail-meta { max-width: 760px; }
.detail-meta h1 { margin: 0 0 10px; font-size: 1.25rem; line-height: 1.4; }

.detail-error {
  padding: 44px 16px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.detail-error .back { margin-top: 16px; }

/* §10 — pemutar berdiri sendiri di halaman /video/:id, tanpa modal */
.player-wrap {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}
.player-wrap video,
.player-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}
.player-wrap .no-media {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 20px;
  background: repeating-linear-gradient(45deg, #0c0c11, #0c0c11 14px, #101018 14px, #101018 28px);
}
.no-media-title {
  margin: 0 !important;
  color: #e0a92c;
  font-size: .95rem !important;
  font-weight: 600;
}
.no-media-sub {
  margin: 0 !important;
  color: var(--dim);
  font-size: .82rem !important;
}

.detail-meta h1 { margin: 0 0 8px; font-size: 1.15rem; line-height: 1.4; }
.detail-meta p { margin: 0 0 12px; line-height: 1.6; font-size: .92rem; }

.d-facts {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.d-facts li {
  padding: 4px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .8rem;
  color: var(--dim);
}

.btn-primary {
  display: inline-block;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
}
.btn-primary:hover { background: var(--accent-2); }

/* ---------------- saran tonton (Penambahanterakhir.md) ----------------
   Ditempatkan setelah seluruh konten utama, SELALU sebelum footer.
   .grid sudah responsif (auto-fill), jadi mobile ikut menyesuaikan. */
.related {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.related-title {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 700;
}
.related-more {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}
.related-more .btn-primary { padding: 9px 28px; }

/* ---------------- mobile ---------------- */
@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .logo { justify-content: center; }   /* header mobile: logo ditengahkan */
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card-title { font-size: .85rem; }
  .meta { flex-direction: column; align-items: flex-start; gap: 8px; }
  .related { margin-top: 26px; padding-top: 18px; }
  .related-title { font-size: 1rem; margin-bottom: 12px; }
  .related-more .btn-primary { width: 100%; }
}
