/* Nhật ký mèo - giao diện các KHỐI trong bài viết (ảnh, lưới ảnh, nhúng, callout, nút, CTA, cột, các bước, hỏi đáp, trích dẫn nổi bật, bảng, mục lục…).
   MỘT nguồn cho cả 3 nơi: trang công khai loomiie.com (.j-body), app (.tf-journal, import ở src/index.css) và xem trước trong trang quản trị.
   HTML do supabase/functions/_shared/journalBlocks.ts dựng. Dùng :is(.j-body, .tf-journal) (KHÔNG dùng :where) để quy tắc của khối thắng quy tắc chữ
   chung của từng nơi (VD `.tf-journal a` tô màu link sẽ làm chữ trên nút trùng màu nền). Thêm khối mới → thêm class ở đây. Không dùng biến CSS của riêng nơi nào. */
:is(.j-body, .tf-journal) { --jb-ink: #18181b; --jb-soft: #52525b; --jb-line: #e4e4e7; --jb-bg: #f4f4f2; --jb-primary: #ff5a4e; --jb-pink: #ff3d81; --jb-violet: #6d5dfc; }
:is(.j-body, .tf-journal) > * { max-width: 100%; }
:is(.j-body, .tf-journal) h2, :is(.j-body, .tf-journal) h3, :is(.j-body, .tf-journal) h4 { scroll-margin-top: 84px; }
:is(.j-body, .tf-journal) h4 { margin: 1.3em 0 0.4em; font-size: 1.02em; font-weight: 800; color: var(--jb-ink); }
:is(.j-body, .tf-journal) mark { background: #fff1c2; color: inherit; padding: 0 0.15em; border-radius: 4px; }
:is(.j-body, .tf-journal) pre { margin: 0 0 1em; padding: 16px 18px; border-radius: 16px; background: #18181b; color: #f4f4f5; overflow-x: auto; font: 0.86em/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
:is(.j-body, .tf-journal) pre code { background: none; padding: 0; color: inherit; font: inherit; }

/* Danh sách tick */
:is(.j-body, .tf-journal) ul.jb-tasks { list-style: none; padding-left: 0; }
.jb-tasks > li { display: flex; gap: 10px; align-items: flex-start; }
.jb-tasks > li > div { min-width: 0; flex: 1; }
.jb-tasks > li > div > p { margin: 0; }
.jb-check { flex: none; width: 20px; height: 20px; margin-top: 0.22em; border-radius: 7px; border: 2px solid #c4c4c8; }
.jb-done > .jb-check { border-color: transparent; background: #16a34a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3.2 3.2L15 7' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat; }
.jb-done > div { color: var(--jb-soft); }

/* Ảnh + lưới ảnh */
.jb-img { margin: 1.4em auto; text-align: center; }
.jb-img img { display: block; width: 100%; height: auto; border-radius: 18px; background: var(--jb-bg); }
.jb-img figcaption { margin-top: 8px; font-size: 0.86em; color: var(--jb-soft); }
.jb-img.jb-normal { max-width: 620px; }
.jb-gallery { display: grid; gap: 10px; margin: 1.4em 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.jb-gallery img { display: block; width: 100%; height: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; background: var(--jb-bg); }

/* Khung nhúng */
.jb-embed { position: relative; margin: 1.4em 0; border-radius: 18px; overflow: hidden; background: #18181b; aspect-ratio: 16 / 9; }
.jb-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.jb-embed-tall { aspect-ratio: 9 / 16; max-width: 340px; margin-left: auto; margin-right: auto; }
.jb-embed-audio { aspect-ratio: auto; height: 152px; background: transparent; }
.jb-embed-board { aspect-ratio: 4 / 3; background: var(--jb-bg); }

/* Callout */
.jb-callout { display: flex; gap: 12px; margin: 1.2em 0; padding: 14px 16px; border-radius: 18px; background: #eef2ff; }
.jb-callout > div { min-width: 0; flex: 1; }
.jb-callout > div > :last-child { margin-bottom: 0; }
.jb-callout > div > :first-child { margin-top: 0; }
.jb-emoji { flex: none; font-size: 1.25em; line-height: 1.4; }
.jb-callout.jb-tip { background: #dcfce7; }
.jb-callout.jb-warn { background: #fef3c7; }
.jb-callout.jb-note { background: var(--jb-bg); }

/* Đóng mở + hỏi đáp */
.jb-toggle, .jb-faq-item { margin: 0.7em 0; border-radius: 16px; background: var(--jb-bg); }
.jb-faq { margin: 1.2em 0; }
.jb-toggle > summary, .jb-faq-item > summary { cursor: pointer; list-style: none; padding: 13px 44px 13px 16px; font-weight: 700; color: var(--jb-ink); position: relative; }
.jb-toggle > summary::-webkit-details-marker, .jb-faq-item > summary::-webkit-details-marker { display: none; }
.jb-toggle > summary::after, .jb-faq-item > summary::after { content: ''; position: absolute; right: 18px; top: 50%; width: 9px; height: 9px; margin-top: -7px; border-right: 2.2px solid var(--jb-soft); border-bottom: 2.2px solid var(--jb-soft); transform: rotate(45deg); transition: transform 0.2s; }
.jb-toggle[open] > summary::after, .jb-faq-item[open] > summary::after { transform: rotate(-135deg); margin-top: -2px; }
.jb-toggle > div, .jb-faq-item > div { padding: 0 16px 14px; }
.jb-toggle > div > :last-child, .jb-faq-item > div > :last-child { margin-bottom: 0; }
.jb-toggle > summary:focus-visible, .jb-faq-item > summary:focus-visible { outline: 3px solid rgba(255, 90, 78, 0.45); outline-offset: 2px; border-radius: 16px; }

/* Nút + hộp kêu gọi hành động */
:is(.j-body, .tf-journal) a.jb-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 26px; border-radius: 999px; background: linear-gradient(135deg, #ff6a3d, #ff3d81); color: #fff; font-weight: 800; text-decoration: none; box-shadow: 0 10px 24px rgba(255, 61, 129, 0.26); transition: transform 0.15s, box-shadow 0.15s; }
:is(.j-body, .tf-journal) a.jb-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(255, 61, 129, 0.34); }
.jb-btn-row { margin: 1.3em 0; }
.jb-btn-row.jb-center { text-align: center; }
.jb-cta { margin: 1.8em 0; padding: 26px 24px; border-radius: 24px; text-align: center; background: linear-gradient(135deg, #fff1ec, #ffe6f0 60%, #efeaff); }
:is(.j-body, .tf-journal) .jb-cta h3 { margin: 0 0 6px; font-size: 1.35em; line-height: 1.25; font-weight: 800; letter-spacing: -0.01em; color: var(--jb-ink); }
.jb-cta p { margin: 0 auto 16px; max-width: 46ch; color: var(--jb-soft); }

/* Chia cột: điện thoại xếp dọc */
.jb-cols { display: grid; gap: 20px; margin: 1.3em 0; grid-template-columns: minmax(0, 1fr); align-items: center; }
.jb-col { min-width: 0; }
.jb-col > :first-child { margin-top: 0; }
.jb-col > :last-child { margin-bottom: 0; }

/* Các bước */
:is(.j-body, .tf-journal) ol.jb-steps { list-style: none; padding: 0; margin: 1.4em 0; counter-reset: jb-step; }
.jb-steps > li { position: relative; margin: 0; padding: 0 0 22px 56px; counter-increment: jb-step; }
.jb-steps > li::before { content: counter(jb-step); position: absolute; left: 0; top: 0; width: 38px; height: 38px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #6d5dfc, #b150f5); }
.jb-steps > li::after { content: ''; position: absolute; left: 18px; top: 44px; bottom: 4px; width: 2px; border-radius: 2px; background: var(--jb-line); }
.jb-steps > li:last-child { padding-bottom: 0; }
.jb-steps > li:last-child::after { display: none; }
.jb-step-title { padding-top: 5px; font-weight: 800; font-size: 1.08em; color: var(--jb-ink); }
.jb-step-body > :first-child { margin-top: 6px; }
.jb-step-body > :last-child { margin-bottom: 0; }

/* Trích dẫn nổi bật */
.jb-pull { margin: 1.8em 0; padding: 0 0 0 20px; border-left: 5px solid var(--jb-violet); }
:is(.j-body, .tf-journal) .jb-pull blockquote { margin: 0; padding: 0; border: 0; background: none; border-radius: 0; font-size: 1.4em; line-height: 1.35; font-weight: 800; letter-spacing: -0.015em; color: var(--jb-ink); }
.jb-pull figcaption { margin-top: 10px; font-size: 0.9em; font-weight: 600; color: var(--jb-soft); }

/* Bảng: cuộn ngang trong khung riêng, không làm vỡ trang */
.jb-table { margin: 1.3em 0; overflow-x: auto; border-radius: 16px; border: 1px solid var(--jb-line); }
.jb-table table { width: 100%; border-collapse: collapse; font-size: 0.94em; }
.jb-table th, .jb-table td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--jb-line); min-width: 110px; }
.jb-table th { background: var(--jb-bg); font-weight: 800; color: var(--jb-ink); }
.jb-table tr:last-child > td { border-bottom: 0; }
.jb-table td > p, .jb-table th > p { margin: 0; }

/* Mục lục + khoảng cách */
.jb-toc { margin: 1.2em 0 1.6em; padding: 16px 18px; border-radius: 18px; background: var(--jb-bg); }
.jb-toc-title { font-size: 0.78em; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--jb-soft); }
:is(.j-body, .tf-journal) .jb-toc ol { list-style: none; margin: 8px 0 0; padding: 0; }
.jb-toc li { margin: 0; padding: 4px 0; }
.jb-toc li.jb-toc-2 { padding-left: 16px; }
:is(.j-body, .tf-journal) .jb-toc a { color: var(--jb-ink); font-weight: 600; text-decoration: none; }
:is(.j-body, .tf-journal) .jb-toc a:hover { color: var(--jb-primary); text-decoration: underline; }
.jb-spacer.jb-space-s { height: 12px; }
.jb-spacer.jb-space-m { height: 32px; }
.jb-spacer.jb-space-l { height: 64px; }

@media (min-width: 640px) {
  .jb-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
  .jb-gallery.jb-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .jb-gallery.jb-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  :is(.j-body, .tf-journal) a.jb-btn, .jb-toggle > summary::after, .jb-faq-item > summary::after { transition: none; }
}
