/**
 * Pendahuluan Page Styles - Sesuai UI materi.html & Interaksi Murni di Dalam Gambar
 * Miftah Kaidah Shorof - Pondok Pesantren Al-Ikhlas Mantingan
 */

:root {
  --color-page-bg: #f9f7f2;
  --color-desktop-bg: #ebe7de;
  --color-primary-green: #144233;
  --color-primary-dark: #0d2f24;
  --color-green-surface: #edf5f0;

  --color-gold: #c88a22;
  --color-gold-light: #fede94;
  --color-gold-hover: #e09f2c;

  --color-text-title: #103326;
  --color-text-body: #2c4237;
  --color-text-muted: #6b8276;

  --color-card-bg: #ffffff;
  --color-card-border: #e6dfd1;
  --color-synopsis-bg: #f4eee3;
  --color-synopsis-border: #e5dac6;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-arabic: 'Amiri', 'Traditional Arabic', serif;

  --shadow-card: 0 4px 14px rgba(16, 51, 38, 0.06);
  --shadow-hover: 0 8px 24px rgba(16, 51, 38, 0.14);
  --shadow-scroll: 0 8px 20px rgba(16, 51, 38, 0.2), 0 2px 6px rgba(0, 0, 0, 0.08);

  --radius-card: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
  background-color: var(--color-desktop-bg);
  font-family: var(--font-sans);
  color: var(--color-text-body);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Page Container: Native Mobile Layout on Phones, Centered Frame on Desktop (Persis materi.html) */
.pendahuluan-body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 0;
}

@media (min-width: 600px) {
  .pendahuluan-body {
    padding: 1.5rem 1rem 3rem;
  }
}

.pendahuluan-container {
  width: 100%;
  max-width: 780px;
  min-height: 100vh;
  background-color: var(--color-page-bg);
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  padding: 1.25rem 1.4rem 2.5rem;
}

@media (min-width: 600px) {
  .pendahuluan-container {
    min-height: auto;
    border-radius: 28px;
    border: 1px solid var(--color-card-border);
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.1);
    padding: 1.75rem 1.75rem 3rem;
  }
}

@media (min-width: 900px) {
  .pendahuluan-container {
    max-width: 900px;
  }
}

@media (min-width: 1200px) {
  .pendahuluan-container {
    max-width: 980px;
  }
}

/* ==========================================================
   TOP NAVIGATION BAR (IDENTIK DENGAN materi.html)
   ========================================================== */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-card-border);
}

.nav-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-primary-green);
  text-decoration: none;
  transition: var(--transition);
}

.nav-back-link:hover {
  color: var(--color-gold);
  transform: translateX(-2px);
}

.nav-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ==========================================================
   HEADER SECTION (IDENTIK DENGAN materi.html)
   ========================================================== */
.page-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 0.25rem;
}

.header-eyebrow {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9c6c1f;
}

.page-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--color-primary-green);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  line-height: 1.45;
}

/* ==========================================================
   MAIN INTERACTIVE TREE CARD
   ========================================================== */
.tree-card {
  position: relative;
  width: 100%;
  background: var(--color-card-bg);
  border: 1.5px solid var(--color-card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.tree-card:hover {
  border-color: #d8cbb8;
}

.tree-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1408 / 768;
  /* Rasio asli pohon-pertama.jpg */
  user-select: none;
  -webkit-user-drag: none;
  background-color: #dceef3;
  overflow: hidden;
}

/* Base Tree Image (pohon-pertama.jpg) */
.tree-img-base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  z-index: 1;
}

/* In-canvas Title Header */
.tree-canvas-title {
  position: absolute;
  top: 2.8%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: clamp(0.92rem, 2.2vw, 1.55rem);
  font-weight: 800;
  color: #12382c;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 8px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  white-space: nowrap;
}

/* ==========================================================
   PAPAN EMAS INTERAKTIF PADA GAMBAR
   ========================================================== */
.hotspots-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 8;
  pointer-events: none;
}

.tree-plaque-btn {
  position: absolute;
  pointer-events: auto;
  background: rgba(200, 138, 34, 0.05);
  border: 2px solid rgba(200, 138, 34, 0.55);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  transition: var(--transition);
  animation: plaqueGlowLoop 2.8s infinite ease-in-out;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-plaque-btn:hover,
.tree-plaque-btn:focus-visible {
  border-color: #ffd27d;
  background: rgba(254, 222, 148, 0.25);
  box-shadow: 0 0 20px rgba(200, 138, 34, 0.8), inset 0 0 10px rgba(254, 222, 148, 0.4);
  transform: scale(1.04);
}

.tree-plaque-btn.is-active {
  border-color: var(--color-gold);
  background: rgba(20, 66, 51, 0.2);
  animation: none;
  box-shadow: 0 0 12px rgba(200, 138, 34, 0.5);
}

/* Tap indicator symbol (+) in plaque button */
.plaque-tap-indicator {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--color-primary-green);
  border: 1px solid var(--color-gold-light);
  color: var(--color-gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: var(--transition);
}

.tree-plaque-btn:hover .plaque-tap-indicator {
  background: var(--color-gold);
  color: #103326;
  transform: scale(1.15);
}

.tree-plaque-btn.is-active .plaque-tap-indicator {
  background: #c82222;
  color: #ffffff;
  border-color: #ff9d9d;
  transform: rotate(45deg);
}

/* Koordinat Presisi Sesuai Papan Emas pohon-pertama.jpg */
.plaque-objek {
  top: 33.6%;
  left: 24.6%;
  width: 9.8%;
  height: 10.8%;
  border-radius: 8px;
}

.plaque-tujuan {
  top: 26.5%;
  left: 69.6%;
  width: 10.2%;
  height: 10.8%;
  border-radius: 8px;
}

.plaque-tokoh {
  top: 53.2%;
  left: 45.6%;
  width: 8.8%;
  height: 18.5%;
  border-radius: 10px;
}

.plaque-definisi {
  top: 75.3%;
  left: 41.3%;
  width: 17.5%;
  height: 17.2%;
  border-radius: 14px;
}

@keyframes plaqueGlowLoop {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(200, 138, 34, 0.35);
    border-color: rgba(200, 138, 34, 0.5);
  }
  50% {
    box-shadow: 0 0 22px rgba(200, 138, 34, 0.85), inset 0 0 10px rgba(254, 222, 148, 0.45);
    border-color: #ffd27d;
  }
}

/* ==========================================================
   KONTEN INTERAKTIF DI DALAM GAMBAR (FLOATING BRANCH CARDS)
   ========================================================== */
.tree-branch-content {
  position: absolute;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: clamp(0.28rem, 0.6vw, 0.52rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  filter: drop-shadow(0 10px 24px rgba(10, 32, 22, 0.25));
}

.tree-branch-content.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* 1. DAHAN KIRI: OBJEK BAHASAN */
/* Diposisikan aman dari batas kiri stage agar TIDAK PERNAH terpotong */
.branch-left {
  top: 39%;
  left: 14px;
  transform: translateY(-50%) scale(0.95);
  width: clamp(210px, 28vw, 260px);
  max-width: calc(100% - 28px);
}

.branch-left.is-open {
  transform: translateY(-50%) scale(1);
}

/* 2. DAHAN KANAN: TUJUAN BELAJAR */
/* Diposisikan aman dari batas kanan stage agar TIDAK PERNAH terpotong */
.branch-right {
  top: 32%;
  right: 14px;
  transform: translateY(-50%) scale(0.95);
  width: clamp(205px, 26vw, 250px);
  max-width: calc(100% - 28px);
}

.branch-right.is-open {
  transform: translateY(-50%) scale(1);
}

/* 3. BATANG TENGAH: TOKOH PENCETUS */
/* Papan Tokoh berada di top: 53.2%, left: 45.6%, width: 8.8% -> right edge = 54.4% */
.branch-center {
  top: 62.5%;
  left: calc(54.4% + 10px);
  transform: translateY(-50%) scale(0.95);
  width: clamp(225px, 26vw, 280px);
  max-width: calc(100% - 54.4% - 20px);
}

.branch-center.is-open {
  transform: translateY(-50%) scale(1);
}

/* 4. PANGKAL AKAR: DEFINISI SHOROF */
/* Papan Definisi berada di top: 75.3%, left: 41.3%, width: 17.5% */
.branch-root {
  bottom: 2.2%;
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  width: clamp(330px, 90%, 580px);
  max-width: calc(100% - 28px);
}

.branch-root.is-open {
  transform: translateX(-50%) scale(1);
}

/* ==========================================================
   BARIS JUDUL & BADGE KARTU (SESUAI DESAIN ASLI PILBOX & CLOSE)
   ========================================================== */
.branch-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.1rem;
}

.branch-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: clamp(0.64rem, 0.8vw, 0.74rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
  user-select: none;
}

.badge-blue {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.badge-green {
  background: linear-gradient(135deg, #15803d 0%, #16a34a 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-close-card {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #ffffff;
  border: 1.5px solid #fca5a5;
  color: #dc2626;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
  transition: all 0.18s ease;
  padding: 0;
  flex-shrink: 0;
}

.btn-close-card:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
  transform: scale(1.08);
}

.btn-close-card:active {
  transform: scale(0.94);
}

/* ==========================================================
   SCROLL CARDS (KARTU PUTIH/GADING DENGAN RIBBON BIRU/HIJAU)
   ========================================================== */
.scroll-card {
  background: linear-gradient(180deg, #ffffff 0%, #fffef8 100%);
  border: 1.5px solid #d8be8d;
  border-radius: 8px;
  padding: clamp(0.38rem, 0.65vw, 0.58rem) clamp(0.5rem, 0.8vw, 0.8rem);
  box-shadow: 0 4px 14px rgba(16, 51, 38, 0.14);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.scroll-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 51, 38, 0.2);
  border-color: #c88a22;
}

.scroll-header {
  display: flex;
  align-items: center;
  gap: 0.38rem;
}

.scroll-ribbon {
  width: 4px;
  height: clamp(11px, 1.2vw, 15px);
  border-radius: 2px;
  flex-shrink: 0;
}

.ribbon-blue {
  background-color: #2563eb;
}

.ribbon-green {
  background-color: #16a34a;
}

.scroll-title {
  font-family: var(--font-sans);
  font-size: clamp(0.72rem, 0.94vw, 0.86rem);
  font-weight: 800;
  color: #144233;
  line-height: 1.2;
  margin: 0;
}

.scroll-desc {
  font-family: var(--font-sans);
  font-size: clamp(0.62rem, 0.78vw, 0.72rem);
  color: #3d594b;
  line-height: 1.35;
  margin: 0;
}

.scroll-arabic {
  font-family: var(--font-arabic);
  font-size: clamp(0.88rem, 1.25vw, 1.15rem);
  font-weight: 700;
  color: #144233;
  margin-top: 0.12rem;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

/* ==========================================================
   TOKOH PENCETUS POPUP
   ========================================================== */
.tokoh-popup-card {
  background: linear-gradient(180deg, #ffffff 0%, #faf3e2 100%);
  border: 1.5px solid #d4a948;
  border-radius: 10px;
  padding: clamp(0.45rem, 0.75vw, 0.75rem);
  box-shadow: 0 8px 24px rgba(16, 51, 38, 0.25);
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 0.8vw, 0.75rem);
  position: relative;
}

.close-tokoh {
  position: absolute;
  top: 5px;
  right: 5px;
}

.tokoh-avatar-wrap {
  width: clamp(48px, 5.5vw, 62px);
  height: clamp(48px, 5.5vw, 62px);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #d4a948;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
  flex-shrink: 0;
  background-color: #ffffff;
}

.tokoh-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tokoh-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-right: 1.2rem;
}

.tokoh-tag {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #8c5b16;
  text-transform: uppercase;
}

.tokoh-fullname {
  font-family: var(--font-serif);
  font-size: clamp(0.78rem, 1.05vw, 0.94rem);
  font-weight: 800;
  color: #144233;
  margin: 0;
  line-height: 1.2;
}

.tokoh-desc {
  font-family: var(--font-sans);
  font-size: clamp(0.6rem, 0.76vw, 0.7rem);
  color: #3d594b;
  line-height: 1.35;
  margin: 0;
}

/* ==========================================================
   DEFINISI SHOROF ROOT CARD
   ========================================================== */
.definisi-root-card {
  background: linear-gradient(180deg, #ffffff 0%, #faf3e2 100%);
  border: 2px solid #d4a948;
  border-radius: 12px;
  padding: clamp(0.45rem, 0.8vw, 0.75rem) clamp(0.65rem, 1.2vw, 1.15rem);
  box-shadow: 0 12px 30px rgba(16, 51, 38, 0.25);
  display: flex;
  flex-direction: column;
  gap: clamp(0.25rem, 0.45vw, 0.45rem);
  position: relative;
}

.definisi-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #ebd39c;
  padding-bottom: clamp(0.2rem, 0.35vw, 0.35rem);
  gap: 0.65rem;
}

.definisi-kicker {
  font-family: var(--font-sans);
  font-size: clamp(0.58rem, 0.75vw, 0.68rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #8c5b16;
  white-space: nowrap;
}

.definisi-arabic {
  font-family: var(--font-arabic);
  font-size: clamp(0.95rem, 1.4vw, 1.28rem);
  font-weight: 700;
  color: #144233;
  line-height: 1.2;
}

.close-def {
  flex-shrink: 0;
}

.definisi-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(0.45rem, 0.9vw, 0.8rem);
}

.def-box {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #ebd39c;
  border-radius: 6px;
  padding: clamp(0.35rem, 0.55vw, 0.55rem);
}

.def-title {
  display: block;
  font-family: var(--font-sans);
  font-size: clamp(0.66rem, 0.82vw, 0.74rem);
  font-weight: 800;
  color: #8c5b16;
  margin-bottom: 0.15rem;
}

.def-text {
  font-family: var(--font-sans);
  font-size: clamp(0.62rem, 0.78vw, 0.7rem);
  color: #2e473b;
  line-height: 1.35;
  margin: 0;
}

.ar-inline {
  font-family: var(--font-arabic);
  font-size: 1.1em;
  font-weight: 700;
  color: #144233;
}

/* ==========================================================
   HINT BAR DI BAWAH GAMBAR
   ========================================================== */
.tree-hint-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1rem;
  background: #fbf9f4;
  border-top: 1px solid var(--color-card-border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.tree-hint-bar svg {
  color: var(--color-gold);
  flex-shrink: 0;
}

/* ==========================================================
   NEXT CHAPTER & ACTION CARD (SESUAI TOMBOL MENU UTAMA)
   ========================================================== */
.action-card,
.chapter-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  background: linear-gradient(135deg, #174a38 0%, #0e3226 100%);
  border: 1.5px solid #23654d;
  border-radius: var(--radius-card);
  text-decoration: none;
  color: #ffffff;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  min-height: 70px;
}

.action-card:hover,
.chapter-card:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #1b533f 0%, #113c2d 100%);
  border-color: var(--color-gold);
  box-shadow: var(--shadow-hover);
}

.action-card:active,
.chapter-card:active {
  transform: translateY(1px);
}

.action-icon,
.chapter-index {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-gold-light);
  font-size: 1.05rem;
  font-weight: 800;
  font-family: var(--font-sans);
  transition: var(--transition);
}

.action-card:hover .action-icon,
.chapter-card:hover .chapter-index {
  background: rgba(254, 222, 148, 0.22);
  color: #ffffff;
  border-color: rgba(254, 222, 148, 0.4);
}

.action-content,
.chapter-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex-grow: 1;
  padding: 0 0.85rem;
  min-width: 0;
}

.chapter-header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-title,
.chapter-title {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  color: #ffffff;
}

.chapter-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: rgba(254, 222, 148, 0.2);
  color: var(--color-gold-light);
  border: 1px solid rgba(254, 222, 148, 0.35);
  line-height: 1.2;
}

.action-desc,
.chapter-desc {
  font-size: 0.78rem;
  color: #b3c9bf;
  line-height: 1.35;
}

.action-arrow,
.chapter-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-gold-light);
  transition: var(--transition);
  margin-left: 0.6rem;
}

.action-card:hover .action-arrow,
.chapter-card:hover .chapter-arrow {
  transform: translateX(3px);
  background: var(--color-gold);
  color: var(--color-primary-green);
}

/* ==========================================================
   FOOTER (IDENTIK DENGAN materi.html)
   ========================================================== */
.materi-footer {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-card-border);
}

.footer-quote {
  font-style: italic;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary-green);
  line-height: 1.4;
}

.footer-sub {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ==========================================================
   RESPONSIVE DESIGN (ADAPTIVE MOBILE EXPERIENCE)
   ========================================================== */
@media (max-width: 600px) {
  .pendahuluan-container {
    padding: 0.85rem 0.85rem 2.25rem;
    gap: 1rem;
  }

  .page-title {
    font-size: 1.4rem;
  }

  .page-subtitle {
    font-size: 0.82rem;
  }

  /* Target sentuh lebih luas pada papan emas */
  .tree-plaque-btn::after {
    content: '';
    position: absolute;
    inset: -8px;
  }

  /* Kartu Dahan Adaptif di Layar HP & Tablet Sempit (<= 768px) */
  .tree-branch-content.is-open {
    position: absolute;
    top: 3% !important;
    bottom: 3% !important;
    left: 3% !important;
    right: 3% !important;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid #d4a948;
    border-radius: 12px;
    padding: 0.5rem 0.65rem;
    box-shadow: 0 10px 30px rgba(16, 51, 38, 0.35);
    z-index: 35;
    overflow-y: auto;
  }

  .branch-top-bar {
    margin-bottom: 0.25rem;
  }

  .btn-close-card {
    width: 24px;
    height: 24px;
  }

  /* 1. Objek Bahasan di HP */
  .branch-left.is-open {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .branch-left.is-open .scroll-card {
    padding: 0.38rem 0.55rem;
  }

  /* 2. Tujuan Belajar di HP */
  .branch-right.is-open {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }

  .branch-right.is-open .scroll-card {
    padding: 0.35rem 0.5rem;
  }

  /* Tipografi teks scroll card pada HP */
  .scroll-card .scroll-title {
    font-size: 0.78rem;
    font-weight: 800;
  }

  .scroll-card .scroll-desc {
    font-size: 0.66rem;
    line-height: 1.25;
  }

  .scroll-card .scroll-arabic {
    font-size: 0.92rem;
    line-height: 1.2;
    margin-top: 0.1rem;
  }

  /* 3. Tokoh Pencetus di HP */
  .branch-center.is-open {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
  }

  .branch-center.is-open .tokoh-popup-card {
    width: 100%;
    max-width: 340px;
    padding: 0.65rem 0.85rem;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid var(--color-gold);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(16, 51, 38, 0.35);
  }

  .branch-center.is-open .tokoh-avatar-wrap {
    width: 52px;
    height: 52px;
  }

  .branch-center.is-open .tokoh-fullname {
    font-size: 0.88rem;
    font-weight: 800;
  }

  .branch-center.is-open .tokoh-desc {
    font-size: 0.7rem;
    line-height: 1.3;
  }

  /* 4. Definisi Shorof di HP */
  .branch-root.is-open {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .branch-root.is-open .definisi-root-card {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    gap: 0.35rem;
  }

  .branch-root.is-open .definisi-header-row {
    border-bottom: 1px solid #ebd39c;
    padding-bottom: 0.25rem;
  }

  .branch-root.is-open .definisi-arabic {
    font-size: 1.05rem;
  }

  .branch-root.is-open .definisi-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  .branch-root.is-open .def-title {
    font-size: 0.72rem;
    font-weight: 800;
  }

  .branch-root.is-open .def-text {
    font-size: 0.66rem;
    line-height: 1.3;
  }
}

/* ==========================================================
   FULLSCREEN & AUTOMATIC LANDSCAPE MODE
   ========================================================== */
.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}


.btn-tree-fullscreen {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  background: rgba(18, 56, 44, 0.9);
  color: #fede94;
  border: 1px solid rgba(254, 222, 148, 0.45);
  backdrop-filter: blur(6px);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  transition: var(--transition);
}

.btn-tree-fullscreen:hover {
  background: #144233;
  color: #ffffff;
  transform: scale(1.05);
  border-color: #ffd27d;
}

/* Fullscreen Elements Visibility in Normal Mode */
.fullscreen-top-bar,
.fs-portrait-hint {
  display: none;
}

/* FULLSCREEN ACTIVE STATE (Native :fullscreen & Pseudo fallback for iOS) */
.tree-card:fullscreen,
.tree-card:-webkit-full-screen,
.tree-card.is-pseudo-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background-color: #0b1d16 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  z-index: 999999 !important;
  overflow: hidden !important;
}

.tree-card:fullscreen .tree-stage,
.tree-card:-webkit-full-screen .tree-stage,
.tree-card.is-pseudo-fullscreen .tree-stage {
  /* Mempertahankan rasio asli 1408/768 secara matematis mutlak di layar laptop/desktop mana pun */
  width: min(100vw, calc(100vh * (1408 / 768))) !important;
  height: min(100vh, calc(100vw * (768 / 1408))) !important;
  aspect-ratio: 1408 / 768 !important;
  max-width: none !important;
  max-height: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative !important;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8) !important;
}

.tree-card:fullscreen .tree-hint-bar,
.tree-card:-webkit-full-screen .tree-hint-bar,
.tree-card.is-pseudo-fullscreen .tree-hint-bar {
  display: none !important;
}

/* In fullscreen, hide the stage toggle button and show floating top bar */
.tree-card:fullscreen .btn-tree-fullscreen,
.tree-card:-webkit-full-screen .btn-tree-fullscreen,
.tree-card.is-pseudo-fullscreen .btn-tree-fullscreen {
  display: none !important;
}

.tree-card:fullscreen .fullscreen-top-bar,
.tree-card:-webkit-full-screen .fullscreen-top-bar,
.tree-card.is-pseudo-fullscreen .fullscreen-top-bar {
  display: flex !important;
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 60;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

/* Sizing Kartu Cabang saat Mode Layar Penuh */
.tree-card:fullscreen .branch-left,
.tree-card:-webkit-full-screen .branch-left,
.tree-card.is-pseudo-fullscreen .branch-left {
  width: clamp(260px, 20vw, 320px);
}

.tree-card:fullscreen .branch-right,
.tree-card:-webkit-full-screen .branch-right,
.tree-card.is-pseudo-fullscreen .branch-right {
  width: clamp(235px, 17.5vw, 275px);
}

.tree-card:fullscreen .branch-center,
.tree-card:-webkit-full-screen .branch-center,
.tree-card.is-pseudo-fullscreen .branch-center {
  width: clamp(255px, 19vw, 310px);
}

.tree-card:fullscreen .branch-root,
.tree-card:-webkit-full-screen .branch-root,
.tree-card.is-pseudo-fullscreen .branch-root {
  width: clamp(400px, 60%, 680px);
}

.btn-exit-fullscreen {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
  padding: 0.38rem 0.88rem;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-exit-fullscreen:hover {
  background: rgba(200, 138, 34, 0.95);
  color: #ffffff;
  border-color: #ffe4a0;
}

.fs-bar-title {
  color: #fede94;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(254, 222, 148, 0.25);
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
}

/* Portrait hint when user hasn't rotated yet */
@media (orientation: portrait) {
  .tree-card:fullscreen .fs-portrait-hint,
  .tree-card:-webkit-full-screen .fs-portrait-hint,
  .tree-card.is-pseudo-fullscreen .fs-portrait-hint {
    display: flex !important;
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 56, 44, 0.94);
    border: 1.5px solid rgba(254, 222, 148, 0.5);
    color: #fede94;
    padding: 0.55rem 1.15rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    align-items: center;
    gap: 0.55rem;
    z-index: 60;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    animation: pulseHint 2.2s infinite ease-in-out;
  }
}

@keyframes pulseHint {
  0%, 100% { opacity: 0.95; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.03); }
}