@font-face {
  font-family: "Recursive";
  src: url("assets/fonts/Recursive_VF_1.085--subset_range_english_basic.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  unicode-range: U+0020-007E;
}

@font-face {
  font-family: "Recursive";
  src: url("assets/fonts/Recursive_VF_1.085--subset_range_latin_1_punc.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  unicode-range: U+00A0-00FF;
}

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

* { font-variation-settings: "CRSV" 1; }

:root {
  --sidebar-width: 220px;
  --sections-width: 180px;
  --sidebar-bg: #18181b;
  --sidebar-border: #27272a;
  --text-muted: #71717a;
  --text-base: #d4d4d8;
  --text-bright: #fafafa;
  --accent: #154A79;
  --accent-bg: rgba(21, 74, 121, 0.1);
  --hover-bg: rgba(255,255,255,0.05);
}

html, body { height: 100%; font-family: "Recursive", sans-serif; font-variation-settings: "CRSV" 1; background: #09090b; color: var(--text-base); }

#app { display: flex; height: 100vh; }

/* ── Main sidebar ── */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
}

#sidebar-header {
  padding: 16px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

#sidebar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar-toggle {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s, transform 0.2s;
}

#sidebar-toggle:hover { background: var(--hover-bg); color: var(--text-bright); }

#sidebar-nav { overflow-y: auto; flex: 1; padding: 8px 0; }

#sidebar-footer {
  padding: 16px;
  flex-shrink: 0;
}

#sidebar-footer img {
  width: 60%;
  max-width: 110px;
  height: auto;
  display: block;
  opacity: 0.85;
}

/* ── Sections panel ── */
#sections-panel {
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: #111113;
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
}

#sections-panel.visible {
  width: var(--sections-width);
  min-width: var(--sections-width);
}

#sections-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

#sections-lesson-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sections-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

#sections-nav { overflow-y: auto; flex: 1; padding: 8px 0; }

.section-item {
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.1s, background 0.1s;
  border-left: 2px solid transparent;
}

.section-item:hover { color: var(--text-bright); background: var(--hover-bg); }
.section-item.active { color: var(--text-bright); border-left-color: var(--accent); background: var(--accent-bg); }

.section-num { color: var(--text-muted); margin-right: 4px; font-variant-numeric: tabular-nums; }

/* ── Nav item number/label badges ── */
.nav-num {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  color: var(--text-base);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.nav-label { display: inline; }

/* ── Flat page ── */
.nav-page {
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--text-base);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s, color 0.1s;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-page:hover { background: var(--hover-bg); color: var(--text-bright); }
.nav-page.active { border-left-color: var(--accent); background: var(--accent-bg); color: var(--text-bright); font-weight: 500; }

/* ── Parent label ── */
.nav-parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--text-base);
  cursor: pointer;
  user-select: none;
  transition: color 0.1s;
}

.nav-parent:hover { color: var(--text-bright); }
.nav-parent .chevron { color: #fff; opacity: 0.9; transition: transform 0.2s; flex-shrink: 0; }
.nav-parent.open .chevron { transform: rotate(90deg); }

/* ── Children ── */
.nav-children { display: none; flex-direction: column; }
.nav-children.open { display: flex; }

.nav-child {
  padding: 6px 16px 6px 28px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s, color 0.1s;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-child:hover { background: var(--hover-bg); color: var(--text-bright); }
.nav-child.active { border-left-color: var(--accent); background: var(--accent-bg); color: var(--text-bright); }
.nav-child.active .nav-num, .nav-page.active .nav-num { background: var(--accent); color: #fff; }

/* ── Collapsed sidebar ── */
#sidebar.collapsed { width: 48px; min-width: 48px; }
#sidebar.collapsed #sidebar-title,
#sidebar.collapsed #sidebar-footer,
#sidebar.collapsed .nav-parent,
#sidebar.collapsed .nav-label { display: none; }
#sidebar.collapsed #sidebar-header { justify-content: center; padding: 12px 0; }
#sidebar.collapsed #sidebar-toggle svg { transform: rotate(180deg); }
#sidebar.collapsed .nav-children { display: flex; }
#sidebar.collapsed .nav-page,
#sidebar.collapsed .nav-child {
  padding: 6px 0;
  justify-content: center;
  gap: 0;
}
#sidebar.collapsed .nav-num { display: inline-flex; }

/* ── Content pane ── */
#content { flex: 1; overflow: hidden; position: relative; }
#content iframe { width: 100%; height: 100%; border: none; display: block; }
#content-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 14px; }

/* ── Loading spinner ── */
.content-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  z-index: 2;
  transition: opacity 0.3s;
}

.content-loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d4d4d8;
  margin: 0 4px;
  animation: loader-bounce 1s ease-in-out infinite;
}

.loader-dot:nth-child(2) { animation-delay: 0.15s; }
.loader-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes loader-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}
