/* hab/hab.css — enjin Hab App (27 Okt 2026). Bina atas kedai.css (token) + tools.css (.tl-kad, hue Bhg 41).
   Tepi 4px edge to edge (Bhg 1.2), grid 3 lajur <=480px tidak dipakai kerana kad berteks (Bhg 48), sentuh >= 32px. */
.hb-main { padding-top: 12px; padding-bottom: 32px; }
.hb-hero { text-align: center; padding: 18px 8px 6px; }
.hb-hero h1 { margin: 0 0 6px; font-size: clamp(1.35rem, 3.4vw, 2rem); line-height: 1.2; }
.hb-hero p { margin: 0 auto; max-width: 46em; color: var(--text-muted); }

.hb-nav { position: sticky; top: var(--kepala-h); z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; background: var(--bg); }
.hb-nav input { width: 100%; max-width: 560px; min-height: 44px; padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--card); color: var(--text); font: inherit; font-size: 16px; }
.hb-nav input:focus { outline: 3px solid var(--primary-bd); border-color: var(--primary); }
.hb-cip { list-style: none; margin: 0; padding: 0 4px; display: flex; gap: 8px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.hb-cip::-webkit-scrollbar { display: none; }
.hb-cip button { min-height: 36px; padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--card); color: var(--text); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; }
.hb-cip button small { display: inline-block; min-width: 1.6em; margin-left: 4px; padding: 0 6px; border-radius: var(--radius-full); background: var(--primary-bg); color: var(--primary-text); font-size: .78em; font-weight: 700; }
/* 28 Okt 2026 (WCAG AA): cip aktif #047857 (5.5:1 dengan teks putih; dahulu --primary #059669 = 3.76:1) */
.hb-cip button.aktif { background: #047857; border-color: #047857; color: #fff; }
.hb-cip button.aktif small { background: rgba(0,0,0,.22); color: #fff; }

.hb-grid { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: var(--gap-t); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .hb-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .hb-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.hb-kad { flex-direction: column; gap: 8px; height: 100%; padding: 14px; }
.hb-atas { display: flex; align-items: flex-start; justify-content: space-between; width: 100%; }
.hb-kad .tl-ikon { width: 48px; height: 48px; flex-basis: 48px; }
.hb-kad .tl-ikon svg { width: 26px; height: 26px; }
.hb-popular { padding: 2px 8px; border-radius: var(--radius-full); background: var(--danger-bg); color: var(--danger-text); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.hb-kad .tl-nama { font-size: 1.02em; }
.hb-desk { color: var(--text-muted); font-size: .86em; line-height: 1.45; flex: 1; }
.hb-kad .tl-bawah { width: 100%; margin-top: 2px; flex-wrap: wrap; }
@media (max-width: 480px) { .hb-kad { padding: 10px; } .hb-desk { font-size: .82em; } .hb-kad .tl-tag { font-size: .72em; } }

/* 29 Okt (pemilik: bawah hab serabut): Hab berkaitan = kad berikon; kaki = jenama + pautan tersusun. */
.hb-bk { margin: 28px 0 8px; }
.hb-bk h2 { margin: 0 0 10px; font-size: 1.1em; font-weight: 800; color: var(--text); }
.hb-bk-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.hb-bk-grid a { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--card, #fff); color: var(--text); text-decoration: none; }
.hb-bk-grid a:hover { border-color: var(--primary); }
.hb-bk-grid a:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.hb-bk-ikon { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--hl, #6ee7b7), var(--h, #047857) 55%, var(--hd, #065f46)); }
.hb-bk-ikon svg { width: 24px; height: 24px; fill: #fff; }
.hb-bk-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.hb-bk-t b { font-weight: 800; line-height: 1.25; }
.hb-bk-t small { color: var(--text-muted); font-size: .82em; }
.hb-bk-p { font-size: 1.4em; color: var(--text-muted); }
.hb-kaki { margin-top: 24px; border-top: 1px solid var(--border); }
.hb-kaki-isi { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; padding: 16px 4px; }
.hb-kaki-jenama { display: flex; flex-direction: column; gap: 2px; }
.hb-kaki-jenama span { color: var(--text-muted); font-size: .85em; }
.hb-kaki-pautan { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.hb-kaki-pautan a { color: var(--primary-text); font-weight: 600; font-size: .9em; padding: 6px 0; }
@media (max-width: 480px) { .hb-bk-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; } .hb-kaki-isi { flex-direction: column; align-items: flex-start; } }

/* ===== MOD APP (27 Okt 2026, Bhg 61B) — tool dibuka DI DALAM hab: sidebar kategori + ruang kerja (iframe /?hab=1#hash).
   Laptop & tablet landskap: sidebar 248px kiri. Telefon & tablet potret (Bhg 34): jalur tool mendatar + nav kategori bawah. */
.hb-app { display: none; }
body.hb-app-on .hb-main, body.hb-app-on .kd-kaki { display: none; }
body.hb-app-on { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }   /* app penuh skrin: tiada jalur kosong di bawah ruang kerja */
body.hb-app-on > .kd-kepala { flex: none; }
body.hb-app-on .hb-app { display: grid; grid-template-columns: 72px minmax(0, 1fr); flex: 1; min-height: 0; }
.hb-semua { display: none; }
body.hb-app-on .hb-semua { display: inline-flex; align-items: center; height: 38px; padding: 0 14px; border: 0; border-radius: 10px; background: rgba(255,255,255,.18); color: #fff; font-weight: 700; font-size: .93em; text-decoration: none; }   /* = .kd-nav-app (kedai.css), versi lut sinar atas kepala hijau */
body.hb-app-on .hb-semua:hover { background: rgba(255,255,255,.28); }
.hb-sisi { display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 10px 8px; border-right: 1px solid var(--border); background: var(--card); }
.hb-sisi { position: relative; }
.hb-cari { position: absolute; left: 8px; top: 10px; z-index: 1; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; color: var(--text-muted); cursor: pointer; }   /* ikon cari: kelihatan walaupun sidebar dilipat */
.hb-cari svg { width: 20px; height: 20px; fill: currentColor; }
.hb-sisi input { width: 100%; min-height: 36px; padding: 6px 12px 6px 44px; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }
.hb-sisi-senarai { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; scrollbar-width: thin; }
.hb-sisi-senarai ul { list-style: none; margin: 0; padding: 0; }
.hb-sisi-kat { margin: 10px 8px 4px; color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.hb-it { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 5px 8px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 14px; }
.hb-it:hover { background: var(--bg); }
.hb-it.aktif { background: var(--primary-bg); color: var(--primary-text); font-weight: 700; }
.hb-it .tl-ikon { width: 28px; height: 28px; flex: 0 0 28px; }
.hb-it .tl-ikon svg { width: 17px; height: 17px; }
.hb-it-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-kerja { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.hb-kerja-kepala { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--card); }
.hb-kerja-kepala h1, .hb-kerja-kepala h2 { margin: 0; font-size: 1.15rem; line-height: 1.25; }
.hb-kerja-kepala p { margin: 2px 0 0; color: var(--text-muted); font-size: .86em; }
.hb-kerja-aksi { display: flex; align-items: center; gap: 10px; flex: none; }
.hb-bingkai { flex: 1; width: 100%; min-height: 0; border: 0; background: var(--bg); }
.hb-navb { display: none; }
/* Sidebar DILIPAT (Bhg 57): 72px ikon sahaja (termasuk ikon cari); tetikus/fokus = kembang 248px.
   28 Okt (pemilik: "tidak responsif bila sidebar terbuka"): kembang MENOLAK ruang kerja (lajur grid .hb-buka, hab.js), bukan menutupnya. */
@media (min-width: 900px) and (orientation: landscape), (min-width: 1367px) {
    .hb-app { transition: grid-template-columns .16s ease; }
    body.hb-app-on .hb-app.hb-buka { grid-template-columns: 248px minmax(0, 1fr); }
    .hb-sisi { z-index: 6; overflow: hidden; }
    .hb-it-n, .hb-sisi input { transition: opacity .12s; }
    .hb-app:not(.hb-buka) .hb-it-n { opacity: 0; }
    .hb-app:not(.hb-buka) .hb-sisi input { width: 36px; padding: 0; border-color: transparent; background: transparent; color: transparent; cursor: pointer; }
    .hb-app:not(.hb-buka) .hb-sisi input::placeholder { color: transparent; }
    .hb-cari { left: 18px; pointer-events: none; }
    .hb-app:not(.hb-buka) .hb-sisi input { margin-left: 10px; }
    .hb-app:not(.hb-buka) .hb-sisi-kat { height: 1px; margin: 8px 10px; overflow: hidden; background: var(--border); color: transparent; }
    .hb-it { padding: 5px 14px; }
    .hb-sisi-senarai { overflow-x: hidden; scrollbar-width: none; }
    .hb-app.hb-buka .hb-sisi-senarai { scrollbar-width: thin; }
}
@media (max-width: 899px), (max-width: 1366px) and (orientation: portrait) {
    body.hb-app-on .hb-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; }
    body.hb-app-on .hb-kerja { display: contents; }
    .hb-kerja-kepala { order: -1; }
    .hb-sisi { flex-direction: row; padding: 6px 4px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
    .hb-sisi input, .hb-sisi-kat, .hb-cari { display: none; }
    .hb-sisi-senarai, .hb-sisi-senarai ul, .hb-sisi-kump { display: flex; gap: 6px; overflow: visible; flex: none; }
    .hb-it { flex-direction: column; gap: 3px; width: 68px; min-height: 0; padding: 4px 2px; font-size: 10px; text-align: center; }
    .hb-it .tl-ikon { width: 36px; height: 36px; flex-basis: 36px; }
    .hb-it .tl-ikon svg { width: 21px; height: 21px; }
    .hb-it-n { width: 100%; white-space: normal; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .hb-kerja-kepala { padding: 6px 8px; }
    .hb-kerja-kepala h1, .hb-kerja-kepala h2 { font-size: 1rem; }
    .hb-kerja-kepala p { display: none; }
    body.hb-app-on .hb-navb { display: flex; justify-content: space-around; gap: 4px; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--card); }
    .hb-navb button { flex: 1; min-height: 40px; border: 0; border-radius: var(--radius-full); background: none; color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 600; }
    .hb-navb button.aktif { background: var(--primary-bg); color: var(--primary-text); }
    body.hb-app-on .kd-nav-app { display: none; }
}
.hb-it.aktif .tl-ikon { outline: 2px solid var(--primary); outline-offset: 2px; }   /* aktif jelas walaupun sidebar dilipat */
/* Satu tirai ruang kerja semasa tukar tool (hab.js tirai()): iframe disorok, satu pemutar, dipapar sekali */
body.hb-app-on .hb-app { position: relative; }
.hb-app.hb-memuat .hb-bingkai { visibility: hidden; }
.hb-app.hb-memuat::after { content: ""; position: absolute; left: calc(50% + 36px); top: 45%; width: 32px; height: 32px; margin: -16px 0 0 -16px; box-sizing: border-box; border-radius: 50%; border: 3px solid var(--primary-bd); border-top-color: var(--primary); animation: hbPusing .8s linear infinite; z-index: 7; }
@keyframes hbPusing { to { transform: rotate(360deg); } }
@media (max-width: 899px), (max-width: 1366px) and (orientation: portrait) { .hb-app.hb-memuat::after { left: 50%; } .hb-kerja-kepala { padding: 6px 8px; } }
/* Tepi 4px edge to edge (Bhg 1.2): kepala ruang kerja teks diinset 8px, iframe rapat 4px (MOD HAB index.html) */
.hb-kerja-kepala { padding: 8px; }
/* 28 Okt (semakan vision telefon): iframe dalam grid TIDAK meregang sendiri (tinggi lalai 150px) -> isi baris 1fr penuh. */
body.hb-app-on .hb-bingkai { height: 100%; align-self: stretch; }
/* Nama hab panjang (cth "Pendidikan Islam & al-Quran"): kekal SATU baris kepala, nama dipendekkan dengan ellipsis. */
.kd-kepala-isi { flex-wrap: nowrap; }
.kd-logo { min-width: 0; flex: 1 1 auto; }
.kd-logo > span:last-child { min-width: 0; }
.kd-logo b, .kd-logo small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kd-nav { flex: none; }
/* Nav kategori bawah: label satu baris, tatal mendatar jika kategori banyak. */
@media (max-width: 899px), (max-width: 1366px) and (orientation: portrait) {
    body.hb-app-on .hb-navb { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
    body.hb-app-on .hb-navb::-webkit-scrollbar { display: none; }
    .hb-navb button { flex: 1 0 auto; padding: 0 12px; white-space: nowrap; }
}
