/* ===========================================
   REEL FEED — halaman post sebagai timeline vertikal
   Struktur: post.hbs → .reel-feed > .reel-item (× banyak) + .reel-sentinel
   =========================================== */

.reel-feed {
  display: block;
  width: 100%;
  position: relative;   /* top diatur reel-feed.js (<1px) untuk membuang sisa pecahan piksel saat koreksi scroll */
}

.reel-item {
  position: relative;
}

/* Jarak antar post (tanpa garis pemisah) */
/* Pakai "~" (bukan "+"): di antara post bisa ada elemen tersembunyi (.reel-queue, penanda scroll),
   jadi post tidak selalu bersebelahan langsung. */
.reel-item ~ .reel-item {
  margin-top: 29px !important;
  padding-top: 0 !important;
}

/* Baris aksi ala Instagram: Subscribe / Purchase Sellfy di kiri, Share di kanan (posisi Save) */
.reel-item .sm-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px auto 0 !important;
  padding: 0 20px !important;
  box-sizing: border-box;
  width: 100%;
}
@media (min-width: 768px) {
  .reel-item .sm-actions { padding: 0 !important; }
}
.sm-actions-left { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 11px 0 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.sm-btn[hidden] { display: none !important; }
.sm-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  margin-left: auto;
}
.reel-item .gh-content { padding-bottom: 0; }

/* Judul & tag tetap ada untuk SEO/aksesibilitas, tapi tidak terlihat */
.reel-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* Sama seperti aturan lama di post.hbs: elemen setelah elemen pertama diberi ruang kiri-kanan */
.reel-item .gh-content > * + * {
  padding: 0 20px 0 20px;
}

/* Daftar antrean URL related tidak pernah tampil */
.reel-queue,
.reel-queue[hidden] {
  display: none !important;
}

/* Penanda dasar feed + indikator "memuat" */
.reel-sentinel {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 72px;
  padding: 24px 0 40px;
}

.reel-sentinel.is-done {
  display: none;
}

/* Penanda tidak sedang memuat → hanya 1px (tidak menambah area kosong di akhir post); tinggi penuh hanya saat memuat */
.reel-sentinel:not(.is-loading) {
  min-height: 0;
  height: 1px;
  padding: 0;
  overflow: hidden;
}

.reel-dots {
  display: inline-flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .2s;
}

.reel-sentinel.is-loading .reel-dots {
  opacity: 1;
}

.reel-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #bbb;
  animation: reel-dot 1s infinite ease-in-out;
}

.reel-dots i:nth-child(2) { animation-delay: .15s; }
.reel-dots i:nth-child(3) { animation-delay: .3s; }

@keyframes reel-dot {
  0%, 80%, 100% { transform: scale(.6); opacity: .5; }
  40%           { transform: scale(1);  opacity: 1;  }
}

/* Ruang untuk bar navigasi bawah di mobile */
@media (max-width: 767px) {
  .reel-feed {
    padding-bottom: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reel-dots i { animation: none; opacity: 1; }
}

/* Jaring pengaman tampilan: dua baris dots berurutan tidak pernah tampil bersamaan */
.igslide-dots + .igslide-dots,
.igslide-outer + .igslide-dots + .igslide-dots {
  display: none !important;
}

/* Urutan post mengikuti grid/home: sembunyikan related dari server sampai JS menggantinya */
.reel-grid-order .reel-feed > .reel-item ~ .reel-item { display: none; }

/* Scroll ke atas memuat post sebelumnya: posisi dijaga lewat reel-feed.js, bukan oleh browser */
.reel-feed,
.reel-feed * { overflow-anchor: none; }
/* margin -1px: penanda ini tidak menambah tinggi halaman, jadi saat dilepas (semua post sebelumnya termuat) isi tidak naik 1px */
.reel-sentinel-top { height: 1px; margin-bottom: -1px; }

/* Post paling akhir: tanpa tinggi tambahan (sebelumnya min-height 100vh → ada area kosong di bawah post terakhir) */
.reel-feed.is-ended > .reel-item:last-of-type { min-height: 0; }

/* Tanggal upload di bawah deskripsi (seperti Instagram) */
.reel-item .sm-date {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: #737373;
}

/* Jarak ala Instagram: gambar → titik → ikon → deskripsi → tanggal rapat. !important karena aturan umum .gh-content
   memberi margin atas 24px / 6vmin pada setiap elemen di dalam kartu. */
.reel-item .gh-content > .igslide-dots { margin-top: 10px !important; }
.reel-item .gh-content > .sm-actions { margin: 10px auto 0 !important; }
.reel-item .gh-content > .gh-content-preview { margin-top: 2px !important; }
.reel-item .gh-content > .sm-date { margin-top: 0 !important; }
/* deskripsi terbuka ("less"): tanpa jarak bawah paragraf, supaya tanggal langsung di bawah teks */
.reel-item .gh-content-preview:not(.collapsed) .preview-text p:last-child { margin-bottom: 0 !important; }
.reel-item .gh-content-preview .preview-text p:first-child { margin-top: 0; }

/* Isi tombol aksi: ikon + label + harga */
.sm-btn { gap: 4px; }
.sm-btn .sm-ico { flex: none; width: 24px; height: 24px; }
.sm-btn .sm-per { font-weight: 500; }
.sm-btn .sm-price:empty { display: none; }
.sm-btn .sm-lbl:only-child { margin: 0; }

/* Pop-up checkout Sellfy (bottom sheet di HP, kartu 480px di desktop) — sama seperti Teesful */
.sellfy-sheet { position: fixed; inset: 0; z-index: 4000001; }
.sellfy-sheet[hidden] { display: none; }
.sellfy-sheet__overlay { position: absolute; inset: 0; background: rgba(8,8,10,.6); opacity: 0; transition: opacity .25s ease; }
.sellfy-sheet:not(.is-open) .sellfy-sheet__overlay { pointer-events: none; }
.sellfy-sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0; height: 90dvh;
  display: flex; flex-direction: column; background: #fff;
  border-radius: 16px 16px 0 0; overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.sellfy-sheet.is-open .sellfy-sheet__overlay { opacity: 1; }
.sellfy-sheet.is-open .sellfy-sheet__panel { transform: translateY(0); }
.sellfy-sheet__bar { display: flex; align-items: center; justify-content: flex-end; min-height: 56px; box-sizing: border-box; padding: 8px 15px 8px 16px; border-bottom: 1px solid rgba(16,16,20,.08); }
.sellfy-sheet__close { position: relative; flex: none; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: rgba(0,0,0,.5); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sellfy-sheet__close::after { content: ""; position: absolute; inset: -7px; }
.sellfy-sheet__close:hover { background: rgba(0,0,0,.06); }
.sellfy-sheet__frame { flex: 1; width: 100%; border: 0; opacity: 0; transition: opacity .2s; }
.sellfy-sheet.is-loaded .sellfy-sheet__frame { opacity: 1; }
html:has(.sellfy-sheet.is-open) body { overflow: hidden; }
@media (min-width: 769px) {
  .sellfy-sheet__panel { max-width: 480px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .sellfy-sheet__overlay, .sellfy-sheet__panel { transition: none; }
}

/* Baris aksi seragam: ikon & teks sama tipis */
.sm-actions svg,
.sm-actions svg * { stroke-width: 1.5; }
.sm-btn .sm-per,
.sm-btn .sm-per b,
.sm-btn .sm-price,
.sm-btn .sm-lbl { font-weight: 500; }

.sm-save.is-saved svg path { fill: currentColor; }

/* Template "Demo": tombol Visit Demo di tengah bawah post */
.reel-item .sm-demo-wrap {
  display: flex;
  justify-content: center;
  margin: 22px auto 4px !important;
}
.reel-item .sm-demo-btn {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 10px 20px;
  border-radius: 999px;
  background: #fff;
  color: #111 !important;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none !important;
  transition: background .15s ease, transform .15s ease;
}
.reel-item .sm-demo-btn:hover { background: #f2f2f2; }
.reel-item .sm-demo-btn:active { transform: scale(.97); }

/* Tombol di dalam gambar: tengah horizontal, 30% dari bawah gambar; hanya tombolnya yang bisa diklik */
.reel-item .sm-demo-wrap.in-stage {
  position: absolute;
  left: 0;
  right: 0;
  top: auto;
  bottom: 10%;   /* titik tengah tombol 10% dari bawah gambar */
  transform: translateY(50%);
  margin: 0 !important;
  z-index: 13;
  pointer-events: none;
}
.reel-item .sm-demo-wrap.in-stage .sm-demo-btn { pointer-events: auto; }

/* Garis penutup di bawah file terakhir (sejajar dengan garis antar file) */
.reel-item .kg-file-card:not(:has(~ .kg-file-card)) {
  margin-bottom: 2px !important;
}
.reel-item .kg-file-card:not(:has(~ .kg-file-card)) a.kg-file-card-container {
  border-bottom: 1px solid rgba(124, 139, 154, .25) !important;
  padding-bottom: 17px !important;
}

/* Jarak tanggal → garis file pertama sama dengan jarak file terakhir → teks kecil (27px) */
.reel-item .gh-content > :not(.kg-file-card) + .kg-file-card { margin-top: 27px !important; }

/* ===== Teks kecil di bawah file + pop up (paragraf "Note: ..." di post) ===== */
/* Teks kecil di bawah file (gaya tanggal upload) */
.reel-item .gh-content > .sm-file-note {
  display: block;
  margin: 25px 0 0 !important;
  font-size: 13px;
  line-height: 1.4;
  color: #737373;
  font-weight: 400;
}
.sm-file-note a { color: inherit; text-decoration: none; cursor: pointer; }

/* Pop up (dibuka saat tautan di teks kecil diklik) */
.sm-note-pop {
  position: fixed; top: 0; left: 0; right: 0; bottom: var(--pm-nav-h, 0px); z-index: 20000;   /* blur tidak menutupi bar navigasi, sama dengan menu */
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 14px 14px; box-sizing: border-box;
  background: rgba(0,0,0,.1);
  -webkit-backdrop-filter: blur(1.5px); backdrop-filter: blur(1.5px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .2s ease, visibility 0s linear .2s;
}
.sm-note-pop.open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .2s ease; }
.sm-note-pop__card {
  position: relative; width: min(100%, 340px); max-height: calc(100dvh - var(--pm-nav-h, 0px) - 40px); overflow: hidden;
  display: flex; flex-direction: column;   /* judul + X tetap, hanya isi yang discroll */
  box-sizing: border-box;
  background: #fff; border-radius: 16px; padding: 0;
  box-shadow: 0 12px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);   /* sama dengan kartu menu */
  transform: translateY(14px); transition: transform .28s cubic-bezier(.32,.72,0,1);
}
.sm-note-pop.open .sm-note-pop__card { transform: translateY(0); }
.sm-note-pop__card.is-loading { height: calc(100dvh - var(--pm-nav-h, 0px) - 40px); }   /* menunggu isi: sudah setinggi penuh */
@media (prefers-reduced-motion: reduce) { .sm-note-pop, .sm-note-pop__card { transition: none; } }
.sm-note-pop__head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px 0; margin-bottom: 6px; }
.sm-note-pop__title { flex: none; margin: 0; padding: 0; font-size: 18px; font-weight: 700; color: #15171a; }
.sm-note-pop__x { position: static; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: rgba(0,0,0,.5); font-size: inherit; line-height: normal; cursor: pointer; border-radius: 6px; }
.sm-note-pop__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 20px 22px; font-size: 14px; line-height: 1.6; color: #333; }
.sm-note-pop__body > *:first-child { margin-top: 0; }
.sm-note-pop__body h2, .sm-note-pop__body h3 { font-size: 15px; margin: 18px 0 6px; color: #111; }
.sm-note-pop__body p, .sm-note-pop__body ul, .sm-note-pop__body ol { margin: 0 0 10px; }
.sm-note-pop__body ul, .sm-note-pop__body ol { padding-left: 20px; }
.sm-note-pop__body img { max-width: 100%; height: auto; }

/* ── Kode QR "Scan on mobile" (desktop saja) ── */
.sm-qr { display: none; }
@media (min-width: 900px) {
  body.post-template .sm-qr {   /* hanya di halaman post, tidak di grid */
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    position: fixed; right: 20px; bottom: 84px; z-index: 900;   /* di atas footer, tidak menimpa */
  }
  .sm-qr__label { font-size: 1.3rem; font-weight: 600; color: #000; }
  .sm-qr__code { background: #fff; padding: 8px; border-radius: 8px; }
  .sm-qr__code img { display: block; width: 90px; height: 90px; }
}

/* ── Desktop: teks di bawah gambar sejajar dengan gambar ──
   Lebar kolom = lebar gambar (--stage-w dari igslide.js), tapi tidak kurang dari 500px,
   supaya teks di bawah gambar/video story yang ramping tetap nyaman dibaca. */
@media (min-width: 768px) {
  .reel-item .gh-content { --col-min: 500px; }
  .reel-item .gh-content > .sm-actions,
  .reel-item .gh-content > .gh-content-preview,
  .reel-item .gh-content > .sm-date,
  .reel-item .gh-content > .kg-file-card,
  .reel-item .gh-content > .sm-file-note {
    box-sizing: border-box;
    width: 100%;
    max-width: max(var(--stage-w, 0px), var(--col-min)) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 0 !important;    /* padding 20px bawaan (untuk HP) dihapus di desktop */
    padding-right: 0 !important;
  }

  /* Ikon save rata dengan tepi kanan gambar (ruang kosong di dalam SVG dikompensasi) */
  .reel-item .sm-actions .sm-save { margin-right: -10px; }

  /* Ikon download: kotak ikon dipersempit dari 80px ke 24px (seukuran ikonnya),
     jadi ikon dan garisnya berakhir tepat di tepi gambar */
  .reel-item .kg-file-card .kg-file-card-icon {
    width: 24px !important;
    min-width: 24px !important;
  }
}
