@import url('https://fonts.googleapis.com/css2?family=Bruno+Ace+SC&family=Cinzel+Decorative:wght@400;700&family=EB+Garamond:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* --- READER ROOT & THEMES --- */
#subd-liseuse-root,
#subd-liseuse-root.theme-light {
  /* Default: Light Theme Variables */
  --sl-bg: #f0eeee;
  --sl-topbar-bg: #f7f7f8;
  --sl-fg: #111111;
  --sl-muted: #666666;
  --sl-border: #e6e6e6;
  --sl-accent: #6c5ce7;
  --sl-btn-bg: #f5f4f4;
  --sl-btn-fg: #111111;
  --sl-btn-bd: #dddddd;
  --sl-toc-bg: #ebebeb;
  --sl-shadow: 0 2px 10px rgba(0,0,0,.05);
}

#subd-liseuse-root.theme-dark {
  --sl-bg: #111416;
  --sl-topbar-bg: #0d1012;
  --sl-fg: #e7e9ea;
  --sl-muted: #a0a7ad;
  --sl-border: #22272a;
  --sl-accent: #8ab4f8;
  --sl-btn-bg: #171a1c;
  --sl-btn-fg: #e7e9ea;
  --sl-btn-bd: #2a2f33;
  --sl-toc-bg: #0e1113;
  --sl-shadow: 0 2px 10px rgba(0,0,0,.35);
}

#subd-liseuse-root.theme-amber {
  /* Egossum Theme Variables */
  --sl-bg: #ea9b13;
  --sl-topbar-bg: #d97706;
  --sl-fg: #ffffff;
  --sl-muted: rgba(255, 255, 255, 0.85);
  --sl-border: #b45309;
  --sl-accent: #fef08a;
  --sl-btn-bg: rgba(255, 255, 255, 0.18);
  --sl-btn-fg: #ffffff;
  --sl-btn-bd: rgba(255, 255, 255, 0.35);
  --sl-toc-bg: #d97706;
  --sl-shadow: 0 2px 10px rgba(0,0,0,.25);
}

#subd-liseuse-root.theme-sepia {
  --sl-bg: #f4ecd8;
  --sl-topbar-bg: #efe5cf;
  --sl-fg: #5b4636;
  --sl-muted: #7a6a58;
  --sl-border: #e2d3b5;
  --sl-accent: #a67c52;
  --sl-btn-bg: #f8f1e5;
  --sl-btn-fg: #5b4636;
  --sl-btn-bd: #d9c6a9;
  --sl-toc-bg: #f8f1e5;
  --sl-shadow: 0 2px 6px rgba(0,0,0,.1);
}

#subd-liseuse-root.theme-blue {
  /* Bleu Pétrole */
  --sl-bg: #0d1b2a;
  --sl-topbar-bg: #1b263b;
  --sl-fg: #e0e8f9;
  --sl-muted: #9db4d3;
  --sl-border: #415a77;
  --sl-accent: #4cc9f0;
  --sl-btn-bg: #1b263b;
  --sl-btn-fg: #e0e8f9;
  --sl-btn-bd: #415a77;
  --sl-toc-bg: #0f2233;
  --sl-shadow: 0 2px 8px rgba(0,0,0,.4);
}

#subd-liseuse-root.theme-red {
  /* Cerise Noire */
  --sl-bg: #1a0b0b;
  --sl-topbar-bg: #220e0e;
  --sl-fg: #f5dada;
  --sl-muted: #d6a5a5;
  --sl-border: #3a1c1c;
  --sl-accent: #ff4b2b;
  --sl-btn-bg: #2a1212;
  --sl-btn-fg: #f5dada;
  --sl-btn-bd: #4c2a2a;
  --sl-toc-bg: #1e0e0e;
  --sl-shadow: 0 2px 10px rgba(0,0,0,.4);
}

/* --- OVERLAY LAYOUT --- */
#subd-liseuse-root {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  background: var(--sl-bg);
  color: var(--sl-fg);
  font-family: 'EB Garamond', Georgia, serif;
  transition: background 0.25s, color 0.25s;
}

/* --- TOPBAR --- */
.sl-topbar {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--sl-topbar-bg);
  border-bottom: none !important;
}

.sl-left, .sl-center, .sl-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sl-right {
  justify-content: flex-end;
}

/* --- BUTTONS --- */
.sl-btn {
  min-height: 32px;
  padding: 0 12px;
  background: var(--sl-btn-bg);
  color: var(--sl-btn-fg);
  border: 1px solid var(--sl-btn-bd);
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Bruno Ace SC', sans-serif !important;
  font-size: 13px;
  transition: background 0.2s;
}

.sl-btn:hover {
  background: color-mix(in srgb, var(--sl-btn-bg), var(--sl-fg) 4%);
}

.sl-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.sl-quick-theme {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

.sl-quick-theme .icon-sun,
.sl-quick-theme .icon-moon {
  display: none;
}

/* Dark tone: show moon icon (click to go light) */
.sl-quick-theme[data-tone="dark"] .icon-moon {
  display: block;
}

/* Light tone: show sun icon (click to go dark) */
.sl-quick-theme[data-tone="light"] .icon-sun {
  display: block;
}

.sl-close {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
}

/* --- PRODUCT BADGE --- */
.sl-product {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(60vw, 720px);
}

.sl-product-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
}

.sl-product-title {
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Bruno Ace SC', 'Cinzel Decorative', cursive, sans-serif !important;
}

/* --- PROGRESS BAR --- */
.sl-progress {
  flex: 1;
  max-width: 520px;
  height: 6px;
  border-radius: 3px;
  background: var(--sl-border);
  position: relative;
  overflow: hidden;
}

.sl-progress > span {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--sl-accent);
  transition: width 0.2s ease-out;
}

.sl-pct {
  font-size: 13px;
  color: var(--sl-muted);
  min-width: 40px;
  text-align: right;
  font-family: 'Bruno Ace SC', sans-serif !important;
}

/* --- THEME PICKER (OPTIONS) --- */
.sl-theme-picker {
  position: relative;
}

.sl-options-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--sl-bg);
  border: 1px solid var(--sl-border);
  border-radius: 6px;
  box-shadow: var(--sl-shadow);
  min-width: 160px;
  z-index: 20;
  padding: 4px 0;
  font-family: 'Bruno Ace SC', sans-serif !important;
}

.sl-options-menu[hidden] {
  display: none;
}

.sl-options-title {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sl-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'Bruno Ace SC', sans-serif !important;
}

.sl-option-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Bruno Ace SC', sans-serif !important;
}

.sl-option-item:hover {
  background: var(--sl-accent);
  color: #fff;
}

.sl-option-item::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid var(--sl-border);
}

.sl-option-item[data-theme="amber"]::before { background: #ea9b13; }
.sl-option-item[data-theme="light"]::before { background: #f0eeee; }
.sl-option-item[data-theme="dark"]::before { background: #111416; }
.sl-option-item[data-theme="sepia"]::before { background: #f4ecd8; }
.sl-option-item[data-theme="blue"]::before { background: #0d1b2a; }
.sl-option-item[data-theme="red"]::before { background: #1a0b0b; }

/* --- BODY & VIEWPORT --- */
.sl-body {
  flex: 1;
  position: relative;
  min-height: 0;
  display: flex;
}

.sl-viewport {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 20px;
  background: var(--sl-bg);
  color: var(--sl-fg);
  scroll-behavior: smooth;
}

/* --- TOC SIDEBAR --- */
.sl-toc {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  overflow-y: auto;
  background: var(--sl-toc-bg);
  border-right: none !important;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  padding: 16px 8px;
  box-sizing: border-box;
}

.sl-toc.open {
  transform: translateX(0);
}

.sl-toc ol {
  list-style: none;
  margin: 0;
  padding: 8px 12px 8px 18px;
}

.sl-toc li {
  padding: 4px 0;
}

.sl-toc li.indent {
  padding-left: 20px;
}

.sl-toc a {
  display: block;
  text-decoration: none;
  color: var(--sl-fg);
  padding: 8px 12px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  font-family: 'Bruno Ace SC', sans-serif !important;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.sl-toc a:hover {
  background: var(--sl-btn-bg);
  color: var(--sl-accent);
}

/* --- CONTENT TYPOGRAPHY --- */
.sl-content {
  max-width: 800px;
  width: 100%;
  margin: 1rem auto 4rem;
  font-size: clamp(16px, 1.25vw, 19px);
  line-height: 1.8;
  text-align: justify;
  hyphens: none;
}

.sl-content h1, .sl-content h2, .sl-content h3 {
  font-family: 'Bruno Ace SC', 'Cinzel Decorative', cursive, sans-serif !important;
  text-transform: none !important;
  font-weight: 400 !important;
  font-size: clamp(24px, 3.5vw, 40px);
  line-height: 48px;
  scroll-margin-top: 56px;
  text-align: center;
  margin: 40px 0 20px;
  color: var(--sl-fg);
}

.sl-content p {
  margin: 0 0 1em;
  text-align: justify;
}

.sl-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.25rem auto;
  border-radius: 4px;
}

.sl-content [style*='color'],
.sl-content [style*='background'] {
  color: inherit !important;
  background: transparent !important;
}

/* --- LOADER & ERROR --- */
#subd-liseuse-loader {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  background: var(--sl-bg);
}

.sl-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--sl-border);
  border-top: 4px solid var(--sl-accent);
  border-radius: 50%;
  animation: sl-spin 1s linear infinite;
}

.sl-error {
  text-align: center;
  padding: 40px;
  color: var(--sl-muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@keyframes sl-spin {
  to { transform: rotate(360deg); }
}

/* --- CTA BUTTON NATIVE (On Page) --- */
.subd-liseuse-cta {
  display: block !important;
  width: 100% !important;
  max-width: 580px !important;
  margin: 20px 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  clear: both !important;
}

.subd-liseuse-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: 100% !important;
  box-sizing: border-box !important;
  padding: 12px 24px !important;
  gap: 14px !important;
  border-radius: 50px !important;
  background: #ef9b18 !important;
  border: none !important;
  color: #ffffff !important;
  text-decoration: none !important;
  outline: none !important;
  cursor: pointer !important;
  transition: all 0.2s ease-in-out !important;
  box-shadow: 0 4px 14px rgba(239, 155, 24, 0.35) !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  line-height: 1.2 !important;
  text-align: left !important;
  margin: 0 !important;
  min-height: auto !important;
  height: auto !important;
  max-height: none !important;
}

.subd-liseuse-btn:hover,
.subd-liseuse-btn:focus {
  background: #d8890e !important;
  border: none !important;
  color: #ffffff !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 18px rgba(239, 155, 24, 0.5) !important;
  text-decoration: none !important;
}

.subd-liseuse-btn:active {
  transform: translateY(0) !important;
}

.subd-liseuse-btn__icon-wrap {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  border-radius: 50px !important;
  background: rgba(255, 255, 255, 0.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
  color: #ffffff !important;
  flex-shrink: 0 !important;
  transition: transform 0.2s ease, background-color 0.2s !important;
}

.subd-liseuse-btn:hover .subd-liseuse-btn__icon-wrap {
  background: rgba(255, 255, 255, 0.3) !important;
  color: #ffffff !important;
  transform: scale(1.05) !important;
}

.subd-liseuse-btn__icon {
  width: 22px !important;
  height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  fill: none !important;
  stroke: #ffffff !important;
  stroke-width: 2 !important;
  display: block !important;
}

.subd-liseuse-btn__text {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: center !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
}

.subd-liseuse-btn__label {
  display: block !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  font-weight: 700 !important;
  font-size: 15px !important;
  color: #ffffff !important;
  margin-bottom: 2px !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
}

.subd-liseuse-btn__sub {
  display: block !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  text-transform: none !important;
  line-height: 1.3 !important;
  color: rgba(255, 255, 255, 0.95) !important;
  opacity: 0.95 !important;
}

@media (max-width: 600px) {
  .subd-liseuse-btn {
    padding: 10px 14px !important;
    gap: 10px !important;
  }
  .subd-liseuse-btn__icon-wrap {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
  }
  .subd-liseuse-btn__icon {
    width: 18px !important;
    height: 18px !important;
  }
  .subd-liseuse-btn__label {
    font-size: 14px !important;
  }
  .subd-liseuse-btn__sub {
    font-size: 12px !important;
  }
}

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
  .sl-topbar {
    grid-template-columns: 1fr;
    row-gap: 6px;
  }
  .sl-left {
    order: 2;
  }
  .sl-center {
    order: 1;
    justify-content: center;
  }
  .sl-right {
    order: 3;
    justify-content: center;
    flex-wrap: wrap;
  }
  .sl-product-title {
    white-space: normal;
    text-align: center;
  }
}

@media (max-width: 720px) {
  /* Hide button text labels, keep icons */
  #sl-toc-btn span,
  #sl-options-btn span {
    display: none;
  }
  .sl-toc {
    width: 240px;
  }
}

@media (max-width: 520px) {
  .sl-progress {
    max-width: 120px;
  }
}

