/* ==========================================================================
   Komponen reusable: header, footer, kartu, badge, accordion, tab, toast, modal, dll.
   ========================================================================== */

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 100; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid transparent; transition: border-color .3s, box-shadow .3s; }
.site-header.is-scrolled { border-bottom-color: var(--border); box-shadow: 0 8px 24px -18px rgba(84, 43, 58, .35); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--text); }
.brand:hover { text-decoration: none; }
.monogram { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--burgundy); color: #F6E9D3; font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; letter-spacing: .02em; box-shadow: inset 0 0 0 1.5px var(--gold), 0 0 0 3px var(--bg), 0 0 0 4px var(--border-strong); flex: none; }
.brand-text { display: grid; line-height: 1.15; }
.brand-name { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; }
.brand-sub { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.primary-nav { display: flex; align-items: center; gap: .15rem; }
.primary-nav a { padding: .5rem .85rem; border-radius: var(--r-pill); color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 500; position: relative; transition: background-color .2s, color .2s; }
.primary-nav a:hover { background: var(--primary-soft); }
.primary-nav a[aria-current="page"] { color: var(--primary); font-weight: 600; }
.primary-nav a[aria-current="page"]::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; border-radius: 50%; background: var(--gold); transform: translateX(-50%); }
.primary-nav a, .brand-text { white-space: nowrap; }
@media (max-width: 1180px) and (min-width: 981px) { .primary-nav a { padding: .5rem .6rem; font-size: .86rem; } .brand-sub { display: none; } }
.header-actions { display: flex; align-items: center; gap: .5rem; }
.nav-toggle { display: none; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media (max-width: 980px) {
  .nav-toggle { display: inline-grid; }
  .header-actions .btn { display: none; }
  .primary-nav {
    /* .site-header memakai backdrop-filter, sehingga menjadi acuan posisi fixed: tinggi panel harus eksplisit. */
    position: fixed; inset: var(--header-h) 0 auto 0; height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h));
    background: var(--bg); flex-direction: column; align-items: stretch;
    padding: 1.25rem var(--gutter) 2rem; gap: .25rem; overflow-y: auto; transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: opacity .25s var(--ease), transform .25s var(--ease), visibility .25s;
  }
  .primary-nav.is-open { opacity: 1; transform: none; visibility: visible; }
  .primary-nav a { padding: .95rem 1rem; font-size: 1.05rem; border-bottom: 1px solid var(--border); border-radius: 0; }
  .primary-nav a[aria-current="page"]::after { display: none; }
  .primary-nav .nav-login { display: block; margin-top: 1rem; border: 0; }
  body.nav-open { overflow: hidden; }
}
@media (min-width: 981px) { .nav-login { display: none; } }

/* ---------- Footer ---------- */
.site-footer { background: var(--burgundy); color: #EADDE2; margin-top: 0; position: relative; }
:root[data-theme="dark"] .site-footer { background: #120D15; border-top: 1px solid var(--border); }
.site-footer a { color: #F3E5CB; }
.footer-grid { display: grid; gap: 2.5rem; grid-template-columns: 1.4fr 1fr 1fr 1.2fr; padding-block: 4rem 2.5rem; }
.footer-grid h3 { font-family: var(--font-body); font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-weight: 600; margin-bottom: 1rem; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; font-size: .92rem; }
.footer-grid a { text-decoration: none; opacity: .92; }
.footer-grid a:hover { text-decoration: underline; opacity: 1; }
.footer-brand .brand-name { color: #fff; font-size: 1.3rem; }
.footer-brand p { color: #D9C6CE; font-size: .93rem; max-width: 36ch; margin-top: 1rem; }
.social { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.25rem; }
.social a { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 .85rem; border-radius: var(--r-pill); border: 1px solid rgba(243, 229, 203, .3); font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-decoration: none; transition: background-color .2s, color .2s; }
.social a:hover { background: var(--gold); color: #2A1D0A; text-decoration: none; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .12); padding-block: 1.4rem; font-size: .84rem; color: #CDB8C1; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.back-top { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 90; opacity: 0; transform: translateY(12px); pointer-events: none; background: var(--primary); color: var(--on-primary); border: 0; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.back-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1 / -1; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; padding-block: 3rem 2rem; } }

/* ---------- Page hero ---------- */
.page-hero { padding-block: clamp(2.75rem, 6vw, 5rem) clamp(2rem, 4vw, 3rem); border-bottom: 1px solid var(--border); position: relative; overflow: hidden; }
.page-hero::after { content: ""; position: absolute; right: -80px; top: -120px; width: 380px; height: 380px; border-radius: 50%; border: 1px solid var(--border-strong); opacity: .6; pointer-events: none; }
.page-hero h1 { margin-bottom: .5rem; }
.page-hero p { max-width: 62ch; margin: 0; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .84rem; color: var(--muted); margin-bottom: 1.25rem; list-style: none; padding: 0; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumb li + li::before { content: "/"; margin-right: .4rem; opacity: .5; }

/* ---------- Kartu ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s; position: relative; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card-media { aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
.card:hover .card-media img { transform: scale(1.04); }
.card-body { padding: 1.4rem 1.5rem 1.6rem; display: flex; flex-direction: column; gap: .6rem; flex: 1; }
.card-body h3 { font-size: 1.25rem; margin: 0; }
.card-body h3 a { color: var(--text); text-decoration: none; }
.card-body h3 a::after { content: ""; position: absolute; inset: 0; } /* seluruh kartu dapat diklik */
.card-body p { color: var(--muted); font-size: .94rem; margin: 0; }
.card-meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--muted); margin-top: auto; padding-top: .75rem; }
.card-meta span { display: inline-flex; align-items: center; gap: .35rem; }
.card a:not(.card-link-main), .card button { position: relative; z-index: 2; }
.tag { display: inline-flex; align-items: center; padding: .22rem .7rem; border-radius: var(--r-pill); background: var(--primary-soft); color: var(--primary); font-size: .74rem; font-weight: 600; letter-spacing: .02em; text-decoration: none; }
a.tag:hover { background: var(--primary); color: var(--on-primary); }
.tag--gold { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--accent); }
.tag--outline { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; }

.badge { display: inline-block; padding: .18rem .6rem; border-radius: var(--r-pill); font-size: .72rem; font-weight: 600; background: var(--muted-bg); color: var(--muted); }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--bad { background: var(--bad-bg); color: var(--bad); }
.badge--muted { background: var(--muted-bg); color: var(--muted); }
.lock-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; color: var(--accent); }

/* ---------- Filter bar ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 2rem; box-shadow: var(--shadow-sm); }
.filters .field { margin: 0; flex: 1 1 160px; min-width: 0; }
.filters .field--search { flex: 2 1 260px; position: relative; }
.filters .field--search .icon { position: absolute; left: .9rem; bottom: .85rem; color: var(--muted); pointer-events: none; }
.filters .field--search .input { padding-left: 2.6rem; }
.results-info { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.results { transition: opacity .2s; }
.results.is-loading { opacity: .45; pointer-events: none; }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(100deg, var(--surface-2) 30%, color-mix(in srgb, var(--surface-2) 55%, var(--surface)) 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card { height: 320px; border-radius: var(--r-lg); }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-top: 2.5rem; }
.pagination a, .pagination span { min-width: 42px; height: 42px; display: inline-grid; place-items: center; padding: 0 .8rem; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); font-size: .9rem; font-weight: 500; }
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination [aria-current="page"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pagination .is-disabled { opacity: .4; }

/* ---------- Accordion & Tab ---------- */
.accordion { display: grid; gap: .75rem; }
.acc-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; transition: border-color .25s, box-shadow .25s; }
.acc-item.is-open { border-color: var(--rose); box-shadow: var(--shadow-sm); }
.acc-trigger { width: 100%; display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; background: none; border: 0; text-align: left; font-weight: 600; }
.acc-num { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-family: var(--font-head); font-size: 1rem; }
.acc-title { flex: 1; font-size: 1.02rem; }
.acc-title small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
.acc-trigger .icon { transition: transform .3s var(--ease); flex: none; }
.acc-item.is-open .acc-trigger .icon { transform: rotate(180deg); }
.acc-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); }
.acc-item.is-open .acc-panel { grid-template-rows: 1fr; }
.acc-panel > div { overflow: hidden; }
.acc-content { padding: 0 1.25rem 1.25rem 4.5rem; }
@media (max-width: 600px) { .acc-content { padding-left: 1.25rem; } }
.material-row { display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--border); margin-top: .6rem; text-decoration: none; color: var(--text); transition: border-color .2s, transform .2s; }
.material-row:hover { border-color: var(--primary); transform: translateX(3px); }
.material-row .icon { color: var(--primary); flex: none; }
.material-row strong { font-weight: 600; font-size: .94rem; display: block; }
.material-row small { color: var(--muted); font-size: .78rem; }
.material-row .lock-chip { margin-left: auto; flex: none; }

.tabs [role="tablist"] { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; margin-bottom: 1.75rem; scrollbar-width: thin; }
.tabs [role="tab"] { background: none; border: 0; padding: .9rem 1.2rem; font-weight: 600; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .2s, border-color .2s; }
.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--primary); border-bottom-color: var(--gold); }
.tabs [role="tabpanel"][hidden] { display: none; }

/* ---------- Toast ---------- */
.toasts { position: fixed; top: calc(var(--header-h) + 12px); right: 1rem; z-index: 300; display: grid; gap: .6rem; width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--surface); border: 1px solid var(--border-strong); border-left: 4px solid var(--primary); border-radius: var(--r-sm); padding: .9rem 1.1rem; box-shadow: var(--shadow-lg); font-size: .92rem; display: flex; gap: .75rem; align-items: flex-start; animation: toast-in .4s var(--ease); }
.toast--success { border-left-color: var(--ok); }
.toast--error { border-left-color: var(--bad); }
.toast button { margin-left: auto; background: none; border: 0; color: var(--muted); padding: 0; line-height: 1; }
.toast.is-leaving { opacity: 0; transform: translateX(20px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }

/* ---------- Modal / Lightbox ---------- */
dialog.lightbox { border: 0; padding: 0; background: transparent; max-width: min(1100px, 94vw); width: 100%; color: #fff; overflow: visible; }
dialog.lightbox::backdrop { background: rgba(20, 10, 16, .88); backdrop-filter: blur(6px); }
.lightbox figure { margin: 0; display: grid; gap: 1rem; }
.lightbox img { max-height: 76vh; width: 100%; object-fit: contain; border-radius: var(--r); background: #000; }
.lightbox figcaption { text-align: center; font-size: .95rem; }
.lightbox figcaption small { display: block; opacity: .75; margin-top: .25rem; }
.lightbox .lb-close, .lightbox .lb-nav { position: absolute; background: rgba(255, 255, 255, .14); border: 0; color: #fff; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; }
.lightbox .lb-close:hover, .lightbox .lb-nav:hover { background: rgba(255, 255, 255, .28); }
.lightbox .lb-close { top: -56px; right: 0; }
.lightbox .lb-prev { left: .75rem; top: 38%; }
.lightbox .lb-next { right: .75rem; top: 38%; }

/* ---------- Progress & reveal ---------- */
.read-progress { position: fixed; top: 0; left: 0; height: 3px; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, var(--gold), var(--rose)); z-index: 250; }
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: var(--d, 0ms); }
.reveal.is-visible { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

/* ---------- Prose (isi artikel & materi) ---------- */
.prose { font-size: 1.08rem; line-height: 1.85; }
.prose > * + * { margin-top: 1.25em; }
.prose h2 { font-size: 1.75rem; margin-top: 2.2em; }
.prose h3 { font-size: 1.35rem; margin-top: 1.9em; }
.prose a { text-decoration: underline; }
.prose blockquote { margin-inline: 0; padding: .4rem 0 .4rem 1.5rem; border-left: 3px solid var(--gold); font-family: var(--font-head); font-style: italic; font-size: 1.25rem; color: var(--text); }
.prose img { border-radius: var(--r); margin-inline: auto; }
.prose figure { margin-inline: 0; }
.prose figcaption { font-size: .85rem; color: var(--muted); text-align: center; margin-top: .5rem; }
.prose pre { background: var(--surface-2); border: 1px solid var(--border); padding: 1rem 1.25rem; border-radius: var(--r-sm); overflow-x: auto; font-size: .9rem; line-height: 1.6; }
.prose code { background: var(--surface-2); padding: .12em .4em; border-radius: 6px; font-size: .9em; }
.prose pre code { background: none; padding: 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: .6rem .85rem; text-align: left; }
.prose th { background: var(--surface-2); }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li + li { margin-top: .4em; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 3.5rem 1.5rem; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); color: var(--muted); background: var(--surface); }
.empty .icon { margin: 0 auto 1rem; color: var(--rose); width: 44px; height: 44px; }
.empty h3 { color: var(--text); font-size: 1.25rem; }

/* ---------- Tabel ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: .85rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
