/* ═══════════════════════════════════════════════════════
   UI ENHANCEMENTS: Dark/Light, Search, Scroll-Top,
   Tab Animations, Progress Tracker
   ═══════════════════════════════════════════════════════ */

/* ─── TAB TRANSITION ─────────────────────────────────── */
.section {
  animation: none;
}
.section.active {
  animation: tabFadeIn .35s ease;
}
@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── SCROLL TO TOP ──────────────────────────────────── */
.scroll-top-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border2);
  color: var(--accent1);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s, background .2s;
  transform: translateY(10px);
  box-shadow: var(--glow);
}
.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.scroll-top-btn:hover {
  background: var(--accent1);
  color: #fff;
}

/* ─── SEARCH OVERLAY ─────────────────────────────────── */
.search-toggle {
  position: fixed;
  bottom: 28px;
  right: 84px;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border2);
  color: var(--accent1);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  box-shadow: var(--glow);
}
.search-toggle:hover {
  background: var(--accent1);
  color: #fff;
}

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(6,5,14,.92);
  backdrop-filter: blur(20px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}
.search-overlay.open {
  display: flex;
  animation: searchFadeIn .2s ease;
}
@keyframes searchFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.search-box {
  width: 90%;
  max-width: 640px;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--accent1);
  padding: 14px 20px;
  box-shadow: 0 0 40px rgba(139,92,246,.2);
}
.search-input-wrap .search-icon {
  color: var(--accent1);
  font-size: 18px;
  flex-shrink: 0;
}
.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: 'Crimson Pro', serif;
  font-size: 18px;
  color: var(--text-main);
}
.search-input::placeholder {
  color: var(--text-dim);
}
.search-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
.search-close-btn:hover { color: var(--text-main); }

.search-results {
  margin-top: 12px;
  max-height: 50vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--text-dim) transparent;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 4px;
  cursor: pointer;
  transition: border-color .2s;
  text-decoration: none;
  color: inherit;
}
.search-result-item:hover {
  border-color: var(--accent1);
}
.search-result-tab {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent1);
  margin-bottom: 2px;
}
.search-result-title {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 600;
}
.search-result-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.search-result-desc mark {
  background: rgba(139,92,246,.25);
  color: var(--text-main);
  padding: 0 2px;
}
.search-no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* ─── DARK/LIGHT TOGGLE ──────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 200;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .3s;
}
.theme-toggle:hover {
  border-color: var(--accent1);
  color: var(--accent1);
}

/* Light mode overrides */
html.light-mode {
  --bg-deep:    #f5f3ff;
  --bg-mid:     #ede9fe;
  --bg-card:    #ffffff;
  --bg-card2:   #f5f3ff;
  --text-main:  #1e1b4b;
  --text-muted: #4c4982;
  --text-dim:   #8b86b0;
  --border:     rgba(139,92,246,0.2);
  --border2:    rgba(139,92,246,0.35);
  --glow:       0 2px 12px rgba(139,92,246,0.1);
  --glow2:      0 4px 24px rgba(139,92,246,0.08);
}
html.light-mode body::before { opacity: .02; }
html.light-mode .amb-1 { background: rgba(139,92,246,.04); }
html.light-mode .amb-2 { background: rgba(220,38,38,.03); }
html.light-mode .amb-3 { background: rgba(192,38,211,.03); }

/* ─── PROGRESS TRACKER BAR ───────────────────────────── */
.progress-bar-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: rgba(6,5,14,.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 8px 20px;
  display: none;
  align-items: center;
  gap: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: .05em;
}
.progress-bar-wrap.visible {
  display: flex;
}
.progress-label {
  white-space: nowrap;
  flex-shrink: 0;
}
.progress-bar-track {
  flex: 1;
  height: 4px;
  background: var(--bg-card2);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent1);
  border-radius: 2px;
  transition: width .5s ease;
}
.progress-bar-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
}
.progress-bar-close:hover { color: var(--text-main); }

@media (max-width: 640px) {
  .scroll-top-btn { bottom: 20px; right: 16px; width: 38px; height: 38px; }
  .search-toggle { bottom: 20px; right: 66px; width: 38px; height: 38px; }
  .theme-toggle { top: 12px; right: 12px; width: 34px; height: 34px; }
}
