/* ==========================================================================
   Beranda Cerita Kawan, desain B "Ruang baca Kawan" (desktop & mobile).
   Dimuat hanya di beranda & arsip topik subdomain (partials/kawan_home/_seo). Token warna
   dari kawan.css (--kawan-*), jadi mode gelap ikut otomatis.
   Tanpa JS, tanpa font tambahan; ukuran gambar tetap (width/height) agar CLS 0.
   ========================================================================== */

.kh {
    --kh-radius: 20px;
    --kh-radius-sm: 12px;
    --kh-red: #e30003;
    --kh-muted: var(--kawan-text-2);
    --kh-line-soft: color-mix(in srgb, var(--kawan-border) 60%, transparent);
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    color: var(--kawan-text);
    padding: 40px 0 80px;
}

.kh a { text-decoration: none; }
.kh a:focus-visible { outline: 2px solid var(--kawan-accent); outline-offset: 2px; border-radius: 4px; }
.kh h1, .kh h2, .kh h3, .kh h4, .kh p { font-family: inherit; color: var(--kawan-text); }

.kh-wrap { max-width: 1170px; margin: 0 auto; padding: 0 15px; box-sizing: border-box; }
.kh-shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 48px; align-items: start; }
.kh-rail { align-self: stretch; display: flex; flex-direction: column; gap: 20px; }
.kh-stick { position: sticky; top: 96px; }
.kh-main { display: flex; flex-direction: column; gap: 56px; min-width: 0; }

.kh-card { background: var(--kawan-surface); border: 1px solid var(--kawan-border); border-radius: var(--kh-radius); }
.kh-accent { color: var(--kawan-accent); }
.kh-one { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kh-clamp-2, .kh-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.kh-clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.kh-clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
.kh-push { margin-top: auto; }

/* Tombol */
.kh-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 0 20px; border-radius: 8px;
    font-weight: 700; font-size: 15px; line-height: 1;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
.kh-btn--primary { background: var(--kawan-accent); color: var(--kawan-on-accent) !important; }
.kh-btn--primary:hover { background: var(--kawan-accent-hover); }
.kh-btn--ghost { border: 1px solid var(--kawan-border); background: var(--kawan-surface); color: var(--kawan-text) !important; }
.kh-btn--ghost:hover { border-color: var(--kawan-accent-line); background: var(--kawan-accent-soft); }

/* Avatar inisial & byline */
.kh-avatar {
    --kh-avatar: 28px;
    flex: 0 0 auto; width: var(--kh-avatar); height: var(--kh-avatar); border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--kawan-accent); color: var(--kawan-on-accent);
    font-weight: 800; font-size: calc(var(--kh-avatar) * .38); line-height: 1;
}
.kh-byline { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.kh-byline__name { color: var(--kawan-text) !important; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kh-byline__name:hover { color: var(--kawan-accent) !important; }
.kh-meta { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; font-size: 13px; color: var(--kh-muted); }
.kh-topic { color: var(--kh-red) !important; font-weight: 800; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.kh-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; }

/* Gambar */
.kh-cover { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--kawan-border); }

/* Judul section */
.kh-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.kh-head__title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 800; letter-spacing: -.015em; }

/* -------- Rel kiri -------- */
.kh-greet { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.kh-greet__title { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
.kh-greet__page { display: block; margin-top: 6px; font-size: 15px; font-weight: 600; color: var(--kh-muted); letter-spacing: 0; }
.kh-greet__text { margin: 0; font-size: 14px; line-height: 1.6; color: var(--kh-muted); }
.kh-crumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; font-weight: 700; color: var(--kh-muted); }
.kh-crumb a { display: inline-flex; align-items: center; min-height: 32px; color: var(--kawan-accent) !important; }
.kh-crumb a:hover { text-decoration: underline; }
.kh-greet__rules { align-self: center; display: inline-flex; align-items: center; min-height: 36px; font-weight: 700; font-size: 13px; color: var(--kawan-accent) !important; }

/* Profil kontributor */
.kh-profile { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.kh-profile__id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.kh-profile__photo { flex: 0 0 auto; width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--kawan-border); }
.kh-profile__photo.kh-avatar { background: var(--kawan-accent); }
.kh-profile__who { min-width: 0; }
.kh-profile__name { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 800; letter-spacing: -.015em; overflow-wrap: anywhere; }
.kh-profile__verified { display: inline-block; margin-left: 2px; vertical-align: -2px; color: var(--kawan-accent); }
.kh-profile__handle { margin: 4px 0 0; font-size: 13px; color: var(--kh-muted); overflow-wrap: anywhere; }
.kh-profile__bio { margin: 0; font-size: 14px; line-height: 1.6; color: var(--kawan-text); }
.kh-profile__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--kh-line-soft); border-bottom: 1px solid var(--kh-line-soft); }
.kh-profile__stats > div { padding: 12px 4px; text-align: center; }
.kh-profile__stats > div + div { border-left: 1px solid var(--kh-line-soft); }
.kh-profile__stats dt { font-size: 12px; font-weight: 600; color: var(--kh-muted); }
.kh-profile__stats dd { margin: 0 0 2px; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--kawan-text); }
.kh-profile__stats > div { display: flex; flex-direction: column-reverse; }
.kh-profile__join { margin: 0; font-size: 13px; color: var(--kh-muted); }
.kh-profile__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kh-profile__actions .kh-btn { flex: 1 1 auto; }

.kh-topics { padding: 8px; }
.kh-topics__title { margin: 0; padding: 12px 14px 8px; font-size: 15px; font-weight: 800; }
.kh-topics__list { list-style: none; margin: 0; padding: 0; }
.kh-topics__link {
    display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: var(--kh-radius-sm);
    color: var(--kawan-text) !important; transition: background-color .2s ease;
}
.kh-topics__link:hover { background: var(--kawan-accent-soft); }
.kh-topics__link.is-current { background: var(--kawan-accent-soft); box-shadow: inset 3px 0 0 var(--kawan-accent); }
.kh-topics__link.is-current .kh-topics__name { color: var(--kawan-accent); }
.kh-topics__name { flex: 1; font-weight: 700; font-size: 15px; }
.kh-topics__count { font-size: 13px; color: var(--kh-muted); }
.kh-topics__link svg { color: var(--kh-muted); }

.kh-popular { padding: 20px 20px 8px; }
.kh-popular__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.kh-popular__title { margin: 0; font-size: 15px; font-weight: 800; }
.kh-popular__period { font-size: 12px; color: var(--kh-muted); }
.kh-popular__list { list-style: none; margin: 0; padding: 0; }
.kh-popular__item { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--kh-line-soft); }
.kh-popular__pos { flex: 0 0 22px; font-size: 22px; line-height: 1; font-weight: 800; color: var(--kh-muted); }
.kh-popular__pos.is-top { color: var(--kawan-accent); }
.kh-popular__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kh-popular__link { color: var(--kawan-text) !important; font-weight: 700; font-size: 14px; line-height: 20px; }
.kh-popular__link:hover { color: var(--kawan-accent) !important; }
.kh-popular__author { font-size: 12px; color: var(--kh-muted); }

/* -------- Mozaik pilihan -------- */
.kh-picks { display: flex; flex-direction: column; gap: 20px; }
.kh-bento { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 20px; }
.kh-lead { grid-column: span 4; grid-row: span 2; display: flex; flex-direction: column; overflow: hidden; }
.kh-lead__media { display: block; flex: 1; min-height: 300px; aspect-ratio: 560 / 340; overflow: hidden; }
.kh-lead__body { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 12px; }
.kh-lead__title { margin: 0; font-size: 30px; line-height: 1.18; font-weight: 800; letter-spacing: -.02em; text-wrap: balance; }
.kh-lead__title a, .kh-tile__title a, .kh-entry__title a { color: var(--kawan-text) !important; }
.kh-lead__title a:hover, .kh-tile__title a:hover, .kh-entry__title a:hover { color: var(--kawan-accent) !important; }

.kh-tile { grid-column: span 2; display: flex; flex-direction: column; gap: 10px; padding: 20px; }
.kh-tile--accent { background: var(--kawan-accent-soft); border-color: var(--kawan-accent-line); }
.kh-tile__media { display: block; aspect-ratio: 16 / 9; border-radius: var(--kh-radius-sm); overflow: hidden; }
.kh-tile__title { margin: 0; font-size: 17px; line-height: 23px; min-height: 69px; font-weight: 800; }

.kh-ad:empty { display: none; }

/* -------- Kawan pekan ini -------- */
.kh-week { padding: 28px; display: flex; flex-direction: column; gap: 20px; }
.kh-week__head { display: flex; flex-direction: column; gap: 6px; }
.kh-week__desc { margin: 0; font-size: 14px; color: var(--kh-muted); }
.kh-week__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kh-week__item { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 16px; border: 1px solid var(--kawan-border); background: var(--kawan-surface); }
.kh-week__item.is-top { background: var(--kawan-accent-soft); border-color: var(--kawan-accent-line); }
.kh-week__top { display: flex; align-items: center; justify-content: space-between; }
.kh-week__photo {
    width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--kawan-border);
    box-shadow: 0 0 0 3px var(--kawan-surface), 0 0 0 5px var(--kawan-accent-line);
}
.kh-week__photo.kh-avatar { background: var(--kawan-accent); color: var(--kawan-on-accent); }
.kh-week__pos { font-size: 28px; line-height: 1; font-weight: 800; color: var(--kh-muted); }
.kh-week__item.is-top .kh-week__pos { color: var(--kawan-accent); }
.kh-week__name { color: var(--kawan-text) !important; font-weight: 800; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.kh-week__name:hover { color: var(--kawan-accent) !important; }
.kh-week__stat { font-size: 12px; color: var(--kh-muted); }

/* -------- Linimasa -------- */
.kh-timeline { display: flex; flex-direction: column; }
.kh-timeline__title { margin-bottom: 8px; }
.kh-day { display: flex; flex-direction: column; }
.kh-day__label {
    position: sticky; top: 72px; z-index: 1; margin: 0; padding: 14px 0 10px;
    background: var(--kh-page-bg, #ffffff); border-bottom: 2px solid var(--kawan-text);
    display: flex; gap: 8px; align-items: baseline; font-size: 14px; font-weight: 800;
}
.kh-day__label time { font-weight: 600; color: var(--kh-muted); }
.kh-entry { display: grid; grid-template-columns: minmax(0, 1fr) 168px; gap: 24px; align-items: start; padding: 22px 0; border-bottom: 1px solid var(--kawan-border); }
.kh-entry__body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kh-entry__time { font-variant-numeric: tabular-nums; }
.kh-entry__title { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 800; letter-spacing: -.01em; }
.kh-entry__excerpt { margin: 0; font-size: 15px; line-height: 1.6; color: var(--kh-muted); }
.kh-entry__stat { font-size: 12px; font-weight: 700; color: var(--kawan-accent) !important; }
.kh-entry__media { display: block; aspect-ratio: 4 / 3; border-radius: var(--kh-radius-sm); overflow: hidden; }
.kh-empty { padding: 24px 0; color: var(--kh-muted); }
.kh-pager { display: flex; gap: 12px; justify-content: center; padding-top: 28px; }
.kh-pager .kh-btn { min-width: 220px; }

body.is-dark-mode .kh, body.dark .kh { --kh-page-bg: #121212; }

/* -------- Layar sedang: rel pindah ke atas -------- */
@media (max-width: 960px) {
    .kh-shell { grid-template-columns: minmax(0, 1fr); gap: 32px; }
    .kh-stick { position: static; }
    .kh-bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kh-lead { grid-column: span 2; grid-row: auto; }
    .kh-tile { grid-column: span 1; }
    .kh-week__list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kh-entry { grid-template-columns: minmax(0, 1fr) 112px; gap: 16px; }
}

/* -------- Mobile (layout mobile terpisah) -------- */
.kh--mobile { position: relative; padding: 22px 0 48px; overflow-x: hidden; }
/* position: relative agar elemen absolute (mis. .sr-only) ikut terpotong; clip memotong luberan
   horizontal tanpa mematikan sticky label hari */
@supports (overflow-x: clip) { .kh--mobile { overflow-x: clip; } }
.kh-ad { max-width: 100%; overflow: hidden; }
.kh-ad iframe, .kh-ad img, .kh-ad ins { max-width: 100%; }
.kh--mobile .kh-wrap { padding: 0 16px; }
.kh--mobile .kh-stack { display: flex; flex-direction: column; gap: 28px; }
.kh--mobile .kh-greet { padding: 0; border: 0; background: transparent; gap: 12px; }
.kh--mobile .kh-greet__title { font-size: 26px; }
.kh--mobile .kh-greet__rules { align-self: flex-start; }
.kh--mobile .kh-profile { padding: 0; border: 0; background: transparent; }
.kh--mobile .kh-profile__name { font-size: 24px; }
.kh--mobile .kh-head__title { font-size: 19px; }

.kh-chips {
    position: relative; display: flex; gap: 8px; overflow-x: auto; padding: 16px 16px 20px;
    scroll-padding-inline: 16px; scrollbar-width: none;
}
.kh-chips::-webkit-scrollbar { display: none; }
.kh-chip.is-current { background: var(--kawan-accent); border-color: var(--kawan-accent); color: var(--kawan-on-accent) !important; }
.kh-chip.is-current .kh-dot { box-shadow: 0 0 0 2px var(--kawan-on-accent); }
.kh-chip {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
    border-radius: 9999px; border: 1px solid var(--kawan-border); background: var(--kawan-surface);
    color: var(--kawan-text) !important; font-weight: 700; font-size: 14px;
}

.kh--mobile .kh-picks { gap: 12px; }
.kh--mobile .kh-bento { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kh--mobile .kh-lead { grid-column: span 2; border-radius: 16px; }
.kh--mobile .kh-lead__media { min-height: 0; aspect-ratio: 4 / 3; }
.kh--mobile .kh-lead__body { padding: 16px; gap: 10px; }
.kh--mobile .kh-lead__title { font-size: 22px; line-height: 1.22; }
.kh--mobile .kh-tile { grid-column: span 1; padding: 12px; gap: 8px; border-radius: 16px; }
.kh--mobile .kh-tile--accent { grid-column: span 2; padding: 14px; }
.kh--mobile .kh-tile__media { aspect-ratio: 4 / 3; border-radius: 10px; }
.kh--mobile .kh-tile--accent .kh-tile__media { aspect-ratio: 16 / 9; }
.kh--mobile .kh-tile__title { font-size: 14px; line-height: 20px; min-height: 40px; }
.kh--mobile .kh-tile--accent .kh-tile__title { font-size: 18px; line-height: 24px; min-height: 0; }

.kh--mobile .kh-ad { margin-top: 28px; }
/* Arsip topik: tanpa "Kawan pekan ini" di antara mozaik dan linimasa */
.kh--mobile .kh-ad + .kh-stack { margin-top: 28px; }
.kh--mobile .kh-week {
    margin: 28px 0; padding: 20px 0 18px; gap: 14px;
    border-radius: 0; border-left: 0; border-right: 0;
}
.kh--mobile .kh-week__head { padding: 0 16px; gap: 4px; }
.kh--mobile .kh-week__head .kh-head__title { font-size: 21px; }
.kh--mobile .kh-week__desc { font-size: 13px; }
.kh--mobile .kh-week__list {
    display: flex; gap: 12px; overflow-x: auto; padding: 4px 16px 6px;
    scroll-snap-type: x mandatory; scroll-padding-inline: 16px; scrollbar-width: none;
}
.kh--mobile .kh-week__list::-webkit-scrollbar { display: none; }
.kh--mobile .kh-week__item { flex: 0 0 156px; scroll-snap-align: start; padding: 14px; }
.kh--mobile .kh-week__photo { width: 52px; height: 52px; }
.kh--mobile .kh-week__pos { font-size: 24px; }
.kh--mobile .kh-week__name { font-size: 14px; }

.kh--mobile .kh-popular { padding: 16px 16px 4px; border-radius: 16px; }
.kh--mobile .kh-popular__title { font-size: 19px; }

.kh--mobile .kh-day__label { top: 56px; }
.kh--mobile .kh-entry { grid-template-columns: minmax(0, 1fr) 96px; gap: 14px; padding: 16px 0; }
.kh--mobile .kh-entry__media { aspect-ratio: 1; }
.kh--mobile .kh-entry__title { font-size: 16px; line-height: 1.4; }
.kh--mobile .kh-byline__name { font-size: 13px; }
.kh--mobile .kh-pager { flex-direction: column; }
.kh--mobile .kh-pager .kh-btn { width: 100%; min-height: 48px; }

.kh-cta { padding: 20px; border-radius: 16px; border: 1px solid var(--kawan-accent-line); background: var(--kawan-accent-soft); display: flex; flex-direction: column; gap: 12px; }
.kh-cta__title { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 800; }
.kh-cta__text { margin: 0; font-size: 14px; line-height: 1.6; color: var(--kh-muted); }
.kh-cta .kh-btn { width: 100%; min-height: 48px; }

@media (prefers-reduced-motion: reduce) {
    .kh * { transition: none !important; }
}
