/* ==========================================================================
   Sticky Compact Reading Bar
   High-performance, accessible, glassmorphic reading & lesson progress bar
   ========================================================================== */

.sticky-reading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 990;
  background: color-mix(in srgb, var(--color-bg-surface, #ffffff) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
  box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.12);
  transform: translateY(-100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  opacity: 0;
  pointer-events: none;
}

.sticky-reading-bar.is-active {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Unified Reader Sticky Bar (Pinned at top of reading pages) */
.sticky-reading-bar.sticky-reader-unified {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  transform: translateY(0) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  margin-bottom: 2rem;
  background-color: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .sticky-reading-bar,
body.dark .sticky-reading-bar,
body.theme-dark .sticky-reading-bar {
  background-color: rgba(15, 23, 42, 0.94);
  border-bottom-color: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  box-shadow: 0 4px 25px -4px rgba(0, 0, 0, 0.5);
}

body.theme-sepia .sticky-reading-bar {
  background-color: rgba(246, 241, 233, 0.96);
  border-bottom-color: rgba(0, 0, 0, 0.08);
  color: #2d2a26;
}

body.theme-midnight .sticky-reading-bar {
  background-color: rgba(11, 15, 25, 0.96);
  border-bottom-color: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

body.zen-mode .sticky-reading-bar {
  top: 0 !important;
}

.sticky-bar-inner {
  max-width: 84rem;
  margin: 0 auto;
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sticky-reader-unified .sticky-bar-inner {
  padding: 0.4rem 1rem;
  gap: 0.65rem;
}

/* Center Group in Unified Bar */
.sticky-bar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-width: 0;
}

/* Right Group in Unified Bar */
.sticky-bar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 0 1 auto;
  flex-shrink: 0;
}

.sticky-bar-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Compact controls inside unified reading bar */
.sticky-reader-unified .speech-btn {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.sticky-reader-unified .controls-nav-btn {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.sticky-reader-unified .controls-chapter-label {
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0 0.25rem;
}

.sticky-reader-unified .tool-btn {
  width: 2.1rem;
  height: 2.1rem;
  font-size: 0.8rem;
}

.sticky-reader-unified .tool-btn-toc {
  width: auto;
  padding: 0 0.65rem;
}

.sticky-reader-unified .controls-quick-scaler {
  padding: 0.1rem 0.25rem;
}

.sticky-reader-unified .scaler-btn {
  width: 1.65rem;
  height: 1.65rem;
}

.sticky-reader-unified .scaler-label {
  font-size: 0.72rem;
  min-width: 2.35rem;
}

.sticky-reader-unified .settings-dropdown {
  top: calc(100% + 0.5rem);
  right: 0;
  width: min(440px, 94vw);
  max-width: 95vw;
}

/* Left Group */
.sticky-bar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}

.sticky-bar-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full, 9999px);
  background: var(--color-bg-base, rgba(0, 0, 0, 0.05));
  border: 1px solid var(--color-border, transparent);
  color: var(--color-text-main, inherit);
  text-decoration: none;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.sticky-bar-back-btn:hover {
  background: var(--color-primary, #3b82f6);
  color: #ffffff;
}

.sticky-bar-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sticky-bar-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-main, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.2;
}

.sticky-bar-subtitle {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-text-muted, #64748b);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.sticky-badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.68rem;
  font-weight: 800;
  background: color-mix(in srgb, var(--color-primary, #3b82f6) 15%, transparent);
  color: var(--color-primary, #3b82f6);
}

/* Center / Meta Metrics */
.sticky-bar-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted, #64748b);
  white-space: nowrap;
  flex-shrink: 0;
}

.sticky-time-left {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.sticky-pct-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full, 9999px);
  background: var(--color-bg-elevated, rgba(0, 0, 0, 0.06));
  border: 1px solid var(--color-border, transparent);
  font-family: var(--font-mono, monospace);
  font-weight: 800;
  font-size: 0.75rem;
  color: var(--color-primary, #3b82f6);
}

/* Right Quick Actions */
.sticky-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.sticky-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full, 9999px);
  background: var(--color-bg-base, rgba(0, 0, 0, 0.05));
  border: 1px solid var(--color-border, transparent);
  color: var(--color-text-main, inherit);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

.sticky-action-btn:hover {
  background: var(--color-primary, #3b82f6);
  color: #ffffff;
  border-color: var(--color-primary, #3b82f6);
}

.sticky-action-btn.active {
  background: var(--color-primary, #3b82f6);
  color: #ffffff;
}

/* Bottom Progress Track */
.sticky-progress-line {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: color-mix(in srgb, var(--color-border, #cbd5e1) 50%, transparent);
  overflow: hidden;
}

.sticky-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary, #3b82f6), var(--color-accent, #06b6d4));
  transition: width 0.1s linear;
}

/* Responsive collapse on mobile */
@media (max-width: 1024px) {
  .sticky-reader-unified .nav-text {
    display: none;
  }
  .sticky-reader-unified .sticky-time-left span {
    display: none;
  }
}

@media (max-width: 768px) {
  .sticky-reader-unified .sticky-bar-subtitle,
  .sticky-reader-unified #reader-session-timer-pill,
  .sticky-reader-unified .controls-quick-scaler {
    display: none;
  }
  .sticky-reader-unified .sticky-bar-inner {
    padding: 0.35rem 0.5rem;
    gap: 0.35rem;
  }
}

@media (max-width: 640px) {
  .sticky-bar-subtitle {
    display: none;
  }
  .sticky-time-left span {
    display: none;
  }
}
