/* Sélecteur d'éditions — intégré au header vert du sidebar */
#edition-selector {
  padding: 0;
  border: none;
}
#edition-selector .edition-links {
  display: flex;
  align-items: center;
}
#edition-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.edition-link {
  display: block;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--MENU-HEADER-LINK-color, rgba(255,255,255,0.7));
  text-decoration: none;
  border-radius: 3px;
  cursor: pointer;
}
.edition-link .edition-icon {
  opacity: 0.4;
  margin-right: 2px;
}
a.edition-link:hover {
  color: var(--MENU-HEADER-LINK-HOVER-color, #fff);
  background: rgba(255,255,255,0.1);
}
a.edition-link:hover .edition-icon {
  opacity: 0.7;
}
.edition-link.active {
  color: var(--MENU-HEADER-LINK-color, #fff);
  font-weight: bold;
  cursor: default;
}
.edition-link.active .edition-icon {
  opacity: 0.85;
}

/* Splash pleine page - thème Relearn */
#splash-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #6eb043;
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
#splash-overlay.hidden {
  transform: translateY(-100%);
}
.splash-content {
  max-width: 800px;
  padding: 2rem;
  text-align: center;
}
.splash-title {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: #ffffff;
  font-weight: bold;
}
.splash-title:last-of-type {
  margin-bottom: 2rem;
}
.principes-box {
  padding: 1.5rem 2rem;
  background: #ffffff;
  border-radius: 8px;
  text-align: left;
  color: #000000;
}
.principe-line {
  display: flex;
  align-items: center;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.5rem 0;
  color: #1a1a1a;
}
.principe-line .emoji {
  font-size: 1.3rem;
  margin-right: 0.75rem;
  flex-shrink: 0;
}
.conclusion {
  margin-top: 2rem;
  font-style: italic;
  color: #ffffff;
}
.splash-enter {
  margin-top: 2rem;
  font-size: 1.5rem;
  cursor: pointer;
  animation: bounce 2s infinite;
}
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

/* Cacher le titre h1 automatique de Relearn - on utilise notre format h2 + chapter-title */
/* Le h1 suit le header.headline dans la structure Relearn */
article.default > h1,
article > header.headline + h1,
.headline + h1 {
  display: none !important;
}

/* Titres de chapitres et appendices - format deux lignes */
.chapter-title {
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
  margin: 0.5rem 0 2rem 0;
  color: var(--INTERNAL-MAIN-TEXT-color, #333);
}

/* Centrer les titres h2 des chapitres/appendices */
h2:has(+ .chapter-title),
h2:first-of-type {
  text-align: center;
  border-bottom: none;
}

/* Cacher le sélecteur de variante Relearn (pinceau) - on utilise notre bouton soleil/lune */
li.R-variantswitcher {
  display: none !important;
}

/* === Sélecteur de langue avec drapeaux === */
/* Cacher le dropdown natif et l'icône globe */
li.R-languageswitcher .control-style,
li.R-languageswitcher > .padding > i,
li.R-languageswitcher > .padding > span {
  display: none !important;
}

/* Conteneur des drapeaux */
.lang-flags {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 8px 0;
}

/* Style des drapeaux */
.lang-flag {
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.2s;
  text-decoration: none;
}
.lang-flag:hover {
  opacity: 0.8;
  transform: scale(1.1);
}
.lang-flag.active {
  opacity: 1;
  transform: scale(1.15);
}

/* Ajuster le padding du conteneur */
li.R-languageswitcher > .padding {
  padding: 0 !important;
}

/* === Resize handle pour le menu latéral === */
#sidebar-resize-handle {
  position: fixed;
  top: 0;
  width: 5px;
  height: 100vh;
  cursor: col-resize;
  z-index: 1000;
  background: transparent;
  transition: background 0.2s;
}
#sidebar-resize-handle:hover,
#sidebar-resize-handle.dragging {
  background: var(--INTERNAL-MENU-HEADER-BG-color, rgba(0,0,0,0.15));
}
/* Cacher le handle en mobile (sidebar masquée) */
@media screen and (max-width: 56.25em) {
  #sidebar-resize-handle {
    display: none;
  }
}

/* Hamburger sidebar : visible aussi sur desktop (Relearn le cache par défaut) */
#R-sidebar-toggle {
  display: inline-flex !important;
}

/* Fond gris clair derrière les SVG transparents (lisibilité en dark mode) */
img.figure-image[src$=".svg"],
img.lightbox-image[src$=".svg"] {
  background: #f0f0f0;
  border-radius: 8px;
  padding: 1rem;
}

/* Catégories d'index thématique (h3.index-category en Hugo) */
.index-category {
  font-size: 1.1em;
  font-weight: bold;
  font-variant: small-caps;
  border-bottom: 1px solid #999;
  padding-bottom: 0.2em;
  margin-top: 1.5em;
  margin-bottom: 0.3em;
}
h3.index-category {
  color: inherit;
  letter-spacing: 0;
}
.index-entries {
  line-height: 1.4;
  margin: 0.2em 0;
  font-size: 0.95em;
}

/* === SIGNETS & REPRISE DE LECTURE === */

/* Bandeau reprise de lecture */
#resume-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: rgba(56, 132, 244, 0.95);
  color: #fff;
  font-size: 0.9rem;
  animation: resumeSlideDown 0.3s ease-out;
  backdrop-filter: blur(4px);
}
@keyframes resumeSlideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}
#resume-banner a {
  color: #fff;
  text-decoration: underline;
  cursor: pointer;
}
#resume-banner a:hover {
  color: #e0e0e0;
}
#resume-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
}

/* Bouton signets topbar */
#bookmarks-btn {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
}
#bookmarks-count {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  background: #e53935;
  color: #fff;
  font-size: 0.65rem;
  font-weight: bold;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 50%;
  padding: 0 3px;
}
#bookmarks-count.has-bookmarks {
  display: block;
}

/* Panneau signets (slide-in depuis la droite) */
:root { --BOOKMARKS-WIDTH: 380px; }
#bookmarks-panel {
  position: fixed;
  top: 3.25rem;
  right: 0;
  width: var(--BOOKMARKS-WIDTH);
  max-width: 50vw;
  height: calc(100vh - 3.25rem);
  z-index: 1200;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow: hidden;
}
#bookmarks-panel.open {
  transform: translateX(0);
}
body.dark #bookmarks-panel {
  background: #1e1e1e;
  color: #ddd;
  box-shadow: -4px 0 20px rgba(0,0,0,0.5);
}
/* Contenu poussé à côté quand panneau ouvert */
body { transition: padding-right 0.3s ease; }
body.bookmarks-open { padding-right: var(--BOOKMARKS-WIDTH); }
/* Handle de redimensionnement signets */
#bookmarks-resize-handle {
  position: fixed;
  top: 3.25rem;
  width: 5px;
  height: calc(100vh - 3.25rem);
  cursor: col-resize;
  z-index: 1201;
  background: transparent;
  transition: background 0.2s;
  display: none;
}
body.bookmarks-open #bookmarks-resize-handle { display: block; }
#bookmarks-resize-handle:hover,
#bookmarks-resize-handle.dragging {
  background: var(--INTERNAL-MENU-HEADER-BG-color, rgba(0,0,0,0.15));
}
body.dark #bookmarks-resize-handle:hover,
body.dark #bookmarks-resize-handle.dragging {
  background: rgba(255,255,255,0.15);
}
#bookmarks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}
body.dark #bookmarks-header {
  border-bottom-color: #444;
}
#bookmarks-header h3 {
  margin: 0;
  font-size: 1.1rem;
}
#bookmarks-header button {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: inherit;
  margin-left: 0.3rem;
}
body.dark #bookmarks-header button {
  border-color: #555;
}
#bookmarks-local-hint {
  font-size: 0.7rem;
  color: #999;
  font-style: italic;
}
#bookmarks-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}
#bookmarks-empty {
  display: none;
  text-align: center;
  color: #999;
  padding: 3rem 1rem;
  font-style: italic;
}
#bookmarks-empty.visible {
  display: block;
}

/* Item de signet — accordéon */
.bookmark-item {
  border-bottom: 1px solid #f0f0f0;
  position: relative;
}
body.dark .bookmark-item {
  border-bottom-color: #333;
}
.bookmark-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  user-select: none;
}
.bookmark-header:hover {
  background: rgba(0,0,0,0.03);
}
body.dark .bookmark-header:hover {
  background: rgba(255,255,255,0.05);
}
.bookmark-chevron {
  font-size: 0.6rem;
  transition: transform 0.2s;
  color: #999;
  flex-shrink: 0;
}
.bookmark-item.open .bookmark-chevron {
  transform: rotate(90deg);
}
.bookmark-header-title {
  font-weight: 600;
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bookmark-header-title a {
  color: inherit;
  text-decoration: none;
}
.bookmark-header-title a:hover {
  text-decoration: underline;
}
.bookmark-indicators {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}
.bookmark-note-indicator {
  font-size: 0.7rem;
  color: #999;
  flex-shrink: 0;
}
.bookmark-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  padding: 0 1rem;
}
.bookmark-item.open .bookmark-body {
  max-height: 500px;
  padding: 0.3rem 1rem 0.7rem;
}
.bookmark-heading {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.3rem;
}
body.dark .bookmark-heading {
  color: #aaa;
}
.bookmark-excerpt {
  font-size: 0.8rem;
  color: #888;
  font-style: italic;
  margin-bottom: 0.3rem;
}
.bookmark-note {
  width: 100%;
  min-height: 2em;
  max-height: 6em;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  resize: vertical;
  font-family: inherit;
  margin-top: 0.3rem;
  background: transparent;
  color: inherit;
}
body.dark .bookmark-note {
  border-color: #555;
}
.bookmark-color-picker {
  position: relative;
  display: inline-block;
  margin-top: 0.3rem;
}
.bookmark-color-select {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.8rem;
  background: transparent;
  color: inherit;
}
body.dark .bookmark-color-select {
  border-color: #555;
}
.bookmark-color-select:hover {
  border-color: #888;
}
.bookmark-color-select-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bookmark-color-dropdown {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.4rem;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.12);
  z-index: 10;
  display: none;
  flex-wrap: wrap;
  gap: 0.3rem;
  width: 180px;
  margin-bottom: 4px;
}
body.dark .bookmark-color-dropdown {
  background: #2a2a2a;
  border-color: #555;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.4);
}
.bookmark-color-dropdown.open {
  display: flex;
}
.bookmark-color-option {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  padding: 0;
  background: none;
}
.bookmark-color-option:hover {
  border-color: #888;
  transform: scale(1.15);
}
.bookmark-color-option.selected {
  border-color: #333;
}
body.dark .bookmark-color-option.selected {
  border-color: #fff;
}
.bookmark-color-none {
  background: #f0f0f0 !important;
  color: #999;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.dark .bookmark-color-none {
  background: #444 !important;
  color: #888;
}
.bookmark-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.3rem;
}
.bookmark-date {
  font-size: 0.7rem;
  color: #aaa;
}
.bookmark-delete-top {
  position: absolute;
  top: 0.5rem;
  right: 0.4rem;
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.bookmark-item:hover .bookmark-delete-top,
.bookmark-item.open .bookmark-delete-top {
  opacity: 1;
}
.bookmark-delete-top:hover {
  color: #e53935;
}

/* Marque-page de lecture */
.bookmark-item.reading-position {
  border-left: 3px solid #e67e22;
  background: rgba(230, 126, 34, 0.06);
}
body.dark .bookmark-item.reading-position {
  background: rgba(230, 126, 34, 0.12);
}
.bookmark-reading-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #e67e22;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

/* Icône signet sur les headings */
.heading-bookmark {
  opacity: 0;
  cursor: pointer;
  margin-right: 0.4em;
  font-size: 0.75em;
  vertical-align: middle;
  transition: opacity 0.2s;
  color: #999;
  display: inline-block;
}
.heading-bookmark:hover {
  color: #3884f4;
}
.heading-bookmark.active {
  opacity: 1;
  color: #3884f4;
}
.heading-bookmark.reading-mark {
  opacity: 1;
  color: #e67e22;
}
h2:hover .heading-bookmark,
h3:hover .heading-bookmark,
h4:hover .heading-bookmark {
  opacity: 1;
}
/* Signet paragraphe : icône en marge gauche, visible au survol */
.para-bookmark {
  position: absolute;
  left: -1.6em;
  top: 0.15em;
  opacity: 0;
  cursor: pointer;
  font-size: 0.7em;
  transition: opacity 0.2s;
  color: #999;
}
.para-bookmark:hover {
  color: #3884f4;
}
.para-bookmark.active {
  opacity: 1;
  color: #3884f4;
}
.para-bookmark.reading-mark {
  opacity: 1;
  color: #e67e22;
}
p[id]:hover .para-bookmark {
  opacity: 1;
}
p[id] {
  position: relative;
}
/* Toujours visible sur tactile */
@media (hover: none) {
  .heading-bookmark {
    opacity: 0.6;
  }
  .para-bookmark {
    opacity: 0.6;
  }
}

/* Lien ancre (permalink) en fin de paragraphe */
.para-permalink {
  opacity: 0;
  cursor: pointer;
  font-size: 0.65em;
  vertical-align: middle;
  transition: opacity 0.2s;
  color: #999;
  margin-left: 0.3em;
  text-decoration: none;
}
.para-permalink:hover {
  color: #3884f4;
}
p[id]:hover .para-permalink {
  opacity: 1;
}
@media (hover: none) {
  .para-permalink {
    opacity: 0.6;
  }
}

/* === FAB sélection === */
#selection-bookmark-fab {
  position: absolute;
  z-index: 1100;
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #3884f4;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  padding: 0;
  line-height: 32px;
  text-align: center;
  transition: transform 0.15s, background 0.15s;
}
#selection-bookmark-fab:hover {
  transform: scale(1.15);
  background: #2060c0;
}

/* === Soulignement permanent des sélections === */
.selection-highlight {
  color: inherit;
  background: none;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: background 0.2s;
}
.selection-highlight:hover {
  background: rgba(128, 128, 128, 0.12);
}
.selection-highlight.flash {
  animation: highlight-flash 1s ease;
}
@keyframes highlight-flash {
  0%, 50% { background: rgba(128, 128, 128, 0.2); }
  100% { background: none; }
}

/* === Texte de sélection dans le panneau === */
.bookmark-selection-text {
  font-size: 0.8rem;
  font-style: italic;
  color: #555;
  background: rgba(56, 132, 244, 0.08);
  border-left: 2px solid #3884f4;
  padding: 0.3rem 0.5rem;
  margin-bottom: 0.3rem;
  border-radius: 0 4px 4px 0;
  max-height: 4em;
  overflow-y: auto;
}
body.dark .bookmark-selection-text {
  color: #bbb;
  background: rgba(56, 132, 244, 0.12);
}
.bookmark-selection-label {
  text-decoration: underline;
  text-underline-offset: 2px;
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 600px) {
  #bookmarks-panel {
    width: 100vw;
    max-width: 100vw;
  }
  body.bookmarks-open { padding-right: 0; }
  #bookmarks-resize-handle { display: none !important; }
}
