/* ==========================================================================
   Chrome bersama faqih.id — sidebar + bilah atas
   Dipakai slides.faqih.id dan course.faqih.id. Ubah di sini sekali, berlaku
   di semua situs yang memuatnya:
     <link rel="stylesheet" href="https://slides.faqih.id/shared/chrome.css">
   Wajib dimuat SETELAH https://faqih.id/brand.css (sumber warna dan font)
   dan font Inter + Fraunces dari Google Fonts. Markup-nya dibuat oleh
   renderShell() di chrome.js.
   ========================================================================== */

/* --- Token ---------------------------------------------------------------- */

:root {
  --bg: var(--brand-bg, #f4f3ef);
  --elevated: var(--brand-bg-elevated, #ecebe5);
  --text: var(--brand-text, #1b1c1e);
  --secondary: var(--brand-text-secondary, #4a4a46);
  --muted: var(--brand-text-muted, #8b897f);
  --border: var(--brand-border, #d8d6ce);
  --accent: var(--brand-accent, #8a6f3f);
  --danger: var(--brand-danger, #b3453a);
  --sans: var(--brand-font-body, "Inter", system-ui, sans-serif);
  --serif: var(--brand-font-display, "Fraunces", Georgia, serif);

  --rail: 288px;
}

/* brand.css sudah menangani gelap, baik dari setelan sistem maupun
   [data-theme="dark"], tapi belum punya jalan balik ke terang saat sistem
   gelap. Blok ini yang membuat tombol tema bisa memaksa terang. */
:root[data-theme="light"] {
  --brand-bg: #f4f3ef;
  --brand-bg-elevated: #ecebe5;
  --brand-text: #1b1c1e;
  --brand-text-secondary: #4a4a46;
  --brand-text-muted: #8b897f;
  --brand-border: #d8d6ce;
  --brand-accent: #8a6f3f;
}

/* --- Dasar ---------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar -------------------------------------------------------------- */

.rail {
  width: var(--rail);
  flex-shrink: 0;
  background: var(--elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.rail[hidden-rail] {
  margin-left: calc(var(--rail) * -1);
}

.rail-head {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.rail-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
  cursor: pointer;
}

.brand:hover {
  color: var(--accent);
}

.brand img {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

/* Logo mengikuti situs utama: warnanya dibalik saat mode gelap. Tidak bisa
   ikut token brand.css karena ini filter, bukan warna — jadi keadaan gelap
   ditulis ulang di sini, sama persis dengan aturan token. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand img {
    filter: invert(1);
  }
}

:root[data-theme="dark"] .brand img {
  filter: invert(1);
}

.rail-head p {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: -2px;
}

.search-wrap {
  padding: 14px 16px;
}

.search {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.search::placeholder {
  color: var(--muted);
}

.search:focus {
  border-color: var(--accent);
  outline: none;
}

/* --- Tab di bawah pencarian (opsional, lihat config.tabs) ----------------- */

.rail-tabs {
  display: flex;
  gap: 18px;
  margin: 0 16px 6px;
  border-bottom: 1px solid var(--border);
}

.rail-tabs[hidden] {
  display: none;
}

/* Garis bawah aksen untuk tab terpilih, senada dengan garis kiri item aktif */
.rail-tab {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  margin-bottom: -1px;
  padding: 8px 2px 9px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  transition:
    color 0.15s,
    border-color 0.15s;
}

.rail-tab:hover {
  color: var(--text);
}

.rail-tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Jumlah hasil, hanya terisi selama mencari */
.rail-tab .count {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

.rail-tab[aria-selected="true"] .count {
  color: var(--accent);
}

/* --- Daftar di sidebar ---------------------------------------------------- */

.rail-list {
  list-style: none;
  margin: 0;
  padding: 0 12px 16px;
  overflow-y: auto;
  flex: 1;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 0;
  padding: 10px 6px;
  cursor: pointer;
  font: inherit;
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  color: var(--secondary);
  text-align: left;
}

.group-head:hover {
  color: var(--text);
}

.group-head .chev {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.group-head[aria-expanded="false"] .chev {
  transform: rotate(-90deg);
}

.group-head .count {
  margin-left: auto;
  font-family: var(--sans);
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
}

.group-items {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
}

.group-items[hidden] {
  display: none;
}

.rail-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  color: var(--secondary);
  text-decoration: none;
  border-radius: 0 4px 4px 0;
  transition:
    color 0.15s,
    background 0.15s,
    border-color 0.15s;
}

.rail-item:hover {
  background: var(--bg);
  color: var(--text);
}

.rail-item strong {
  display: block;
  font-weight: 500;
  font-size: 14.5px;
  line-height: 1.4;
  color: inherit;
}

.rail-item span {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}

.rail-item[aria-current="page"] {
  background: var(--bg);
  border-left-color: var(--accent);
  color: var(--text);
}

.rail-item[aria-current="page"] strong {
  color: var(--accent);
}

.rail-item mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}

.lock-icon {
  width: 12px;
  height: 12px;
  margin-left: 4px;
  vertical-align: -1px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
}

.empty {
  padding: 14px 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* Tirai untuk layar sempit, lihat bagian Responsif */
.rail-backdrop {
  display: none;
}

/* --- Bilah atas dan tombol ------------------------------------------------ */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.bar h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 400;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--secondary);
  height: 32px;
  padding: 0 12px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  transition:
    border-color 0.15s,
    color 0.15s;
}

/* display: inline-flex di atas mengalahkan atribut hidden bawaan browser */
.btn[hidden] {
  display: none;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
}

.btn-icon {
  padding: 0;
  width: 32px;
  justify-content: center;
}

/* --- Responsif ------------------------------------------------------------ */

@media (max-width: 720px) {
  :root {
    --rail: 260px;
  }

  .rail {
    position: absolute;
    z-index: 5;
    height: 100%;
  }

  .rail:not([hidden-rail]) + .rail-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 4;
    background: rgba(0, 0, 0, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rail {
    transition: none;
  }
}
