/* Faites Mieux - Toolbar d'accessibilité universelle
   Par Ti Racoon
   Version 3.1 - Bouton compact déplaçable + Voix + NVDA
*/

/* POLICES ACCESSIBLES */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/gh/antijingoist/open-dyslexic/alternatives/OpenDyslexic-Regular.otf') format('opentype');
    font-style: normal;
    font-weight: normal;
}
@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/gh/antijingoist/open-dyslexic/alternatives/OpenDyslexic-Bold.otf') format('opentype');
    font-style: normal;
    font-weight: bold;
}
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* Variables */
:root {
  --fm-font: "Lexend", system-ui, sans-serif;
  --fm-accent: #005f73;
  --fm-focus: #ffb703;
  --fm-z: 2147483000;
}

/* Bouton d'ouverture - Version compacte et déplaçable */
#fm-toggle-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: calc(var(--fm-z) + 1);
  background: linear-gradient(135deg, #005f73 0%, #0a9396 100%);
  color: white;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: move;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: box-shadow 0.3s ease;
  font-family: var(--fm-font);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}

#fm-toggle-btn.dragging {
  transition: none;
  cursor: grabbing;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

#fm-toggle-btn.compact {
  width: 44px;
}

#fm-toggle-btn.expanded {
  width: auto;
  padding: 12px 20px;
}

/* Gestion de l'affichage du texte */
#fm-toggle-btn .btn-text-full {
  display: none;
}

#fm-toggle-btn .btn-text-compact {
  display: none;
}

#fm-toggle-btn.compact .btn-text-compact {
  display: inline;
}

#fm-toggle-btn.compact .btn-text-full {
  display: none;
}

#fm-toggle-btn.expanded .btn-text-compact {
  display: none;
}

#fm-toggle-btn.expanded .btn-text-full {
  display: inline;
}

#fm-toggle-btn:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

#fm-toggle-btn:focus {
  outline: 3px solid var(--fm-focus);
  outline-offset: 2px;
}

/* Toolbar container */
#fm-toolbar {
  font-family: var(--fm-font) !important;
  position: fixed;
  left: 12px;
  top: 68px;
  z-index: var(--fm-z);
  width: 380px;
  max-width: calc(100% - 24px);
  background: rgba(255,255,255,0.98) !important;
  border: 1px solid #d0d0d0 !important;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
  color: #000 !important;
  font-size: 0.95rem !important;
  display: none;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}

#fm-toolbar * {
  font-family: var(--fm-font) !important;
  color: #000 !important;
}

#fm-toolbar.visible {
  display: block;
}

/* Media queries pour mobile */
@media (max-width: 768px) { 
  #fm-toolbar { 
    left: 8px; 
    right: 8px; 
    width: auto;
    top: 60px;
    font-size: 0.9rem !important;
    padding: 12px;
  }
  
  #fm-toggle-btn { 
    left: 8px;
    font-size: 0.85rem;
    padding: 10px 16px;
  }
  
  .fm-row {
    flex-direction: column;
    align-items: flex-start !important;
  }
  
  .fm-row label {
    min-width: auto !important;
    width: 100%;
  }
  
  .fm-row input[type="range"] {
    width: 100% !important;
  }
  
  .fm-value {
    align-self: flex-end;
  }
}

#fm-toolbar header { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 8px; 
  margin-bottom: 12px; 
}

#fm-toolbar h2 { 
  margin: 0; 
  font-size: 1.1rem !important; 
  color: #000 !important;
  font-weight: 700 !important;
}

#fm-toolbar .fm-close { 
  background: none; 
  border: none; 
  padding: 6px; 
  cursor: pointer; 
  border-radius: 6px; 
  font-size: 1.5rem !important; 
  color: #000 !important; 
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
}

#fm-toolbar .fm-close:hover { 
  background: rgba(0,0,0,0.05); 
}

#fm-toolbar .fm-close:focus { 
  outline: 3px solid var(--fm-focus); 
  outline-offset: 2px; 
}

.fm-section { 
  margin-top: 12px; 
}

.fm-section label { 
  color: #000 !important;
  display: block;
  font-weight: 600 !important;
  font-size: 0.92rem !important;
  margin-bottom: 6px;
}

.fm-row { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  margin-top: 8px; 
}

.fm-row label { 
  min-width: 110px; 
  margin-bottom: 0;
}

.fm-control { 
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d0d0d0 !important;
  border-radius: 6px;
  background: white !important;
  color: #000 !important;
  font-family: inherit;
  font-size: 0.9rem !important;
}

.fm-control:focus { 
  outline: 3px solid var(--fm-focus); 
  outline-offset: 2px; 
}

input[type="range"] { 
  width: 100%; 
  -webkit-appearance: none; 
  appearance: none; 
  height: 8px; 
  background: #e6e6e6 !important; 
  border-radius: 6px; 
  border: none !important;
}

input[type="range"]::-webkit-slider-thumb { 
  -webkit-appearance: none; 
  width: 18px; 
  height: 18px; 
  border-radius: 50%; 
  background: var(--fm-accent) !important; 
  border: 2px solid #fff; 
  box-shadow: 0 2px 6px rgba(0,0,0,0.2); 
  cursor: pointer; 
}

input[type="range"]::-moz-range-thumb {
  width: 18px; 
  height: 18px; 
  border-radius: 50%; 
  background: var(--fm-accent) !important; 
  border: 2px solid #fff; 
  box-shadow: 0 2px 6px rgba(0,0,0,0.2); 
  cursor: pointer;
}

input[type="range"]:focus { 
  outline: 3px solid var(--fm-focus); 
  outline-offset: 2px; 
}

.fm-btn { 
  background: var(--fm-accent) !important; 
  color: white !important; 
  border: none; 
  padding: 10px 12px; 
  border-radius: 8px; 
  cursor: pointer; 
  font-weight: 700 !important; 
  min-height: 44px;
  font-size: 0.85rem !important;
}

.fm-btn:hover { 
  opacity: 0.9; 
}

.fm-btn:focus { 
  outline: 3px solid var(--fm-focus); 
  outline-offset: 2px; 
}

.fm-btn-secondary {
  background: #6c757d !important;
}

.fm-btn-nvda {
  background: #9933cc !important;
}

.fm-reset-btn {
  background: #dc2626 !important;
}

.fm-reset-btn:hover {
  background: #b91c1c !important;
}

.fm-value { 
  min-width: 50px; 
  text-align: right; 
  font-weight: 700 !important; 
  color: #000 !important; 
  font-size: 0.85rem !important;
}

.fm-voice-info {
  font-size: 0.85rem !important;
  color: #666 !important;
  margin-top: 4px;
  font-style: italic;
}

/* Exclusion de la toolbar pour TOUS les effets */
#fm-toggle-btn,
#fm-toolbar,
#fm-toolbar *,
#fm-toggle-btn * {
  filter: none !important;
  -webkit-filter: none !important;
}

/* THÈMES */
body.fm-theme-dark:not(#fm-toolbar):not(#fm-toggle-btn) {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
}

body.fm-theme-dark *:not(#fm-toolbar):not(#fm-toolbar *):not(#fm-toggle-btn):not(#fm-toggle-btn *) {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
}

body.fm-theme-dark .glass-effect,
body.fm-theme-dark .result-box,
body.fm-theme-dark .bg-white {
  background: rgba(30, 30, 30, 0.95) !important;
  color: #ffffff !important;
}

body.fm-theme-sepia {
  background-color: #f4ecd8 !important;
  color: #2d2d25 !important;
}

body.fm-theme-sepia *:not(#fm-toolbar):not(#fm-toolbar *):not(#fm-toggle-btn):not(#fm-toggle-btn *) {
  background-color: #f4ecd8 !important;
  color: #2d2d25 !important;
}

body.fm-theme-red {
  background-color: #fff5f5 !important;
  color: #3b0000 !important;
}

body.fm-theme-red *:not(#fm-toolbar):not(#fm-toolbar *):not(#fm-toggle-btn):not(#fm-toggle-btn *) {
  background-color: #fff5f5 !important;
  color: #3b0000 !important;
}

body.fm-theme-blue {
  background-color: #f0f7ff !important;
  color: #002b4d !important;
}

body.fm-theme-blue *:not(#fm-toolbar):not(#fm-toolbar *):not(#fm-toggle-btn):not(#fm-toggle-btn *) {
  background-color: #f0f7ff !important;
  color: #002b4d !important;
}

/* CONTRASTE ÉLEVÉ */
body.fm-theme-high-contrast {
  background-color: #ffffff !important;
  color: #000000 !important;
}

body.fm-theme-high-contrast *:not(#fm-toolbar):not(#fm-toolbar *):not(#fm-toggle-btn):not(#fm-toggle-btn *) {
  background-color: #ffffff !important;
  color: #000000 !important;
  border-color: #000000 !important;
  border-width: 2px !important;
}

body.fm-theme-high-contrast a:not(#fm-toolbar *) {
  color: #0000ff !important;
  text-decoration: underline !important;
  font-weight: 700 !important;
}

body.fm-theme-high-contrast button:not(#fm-toolbar *),
body.fm-theme-high-contrast input:not(#fm-toolbar *),
body.fm-theme-high-contrast select:not(#fm-toolbar *),
body.fm-theme-high-contrast textarea:not(#fm-toolbar *) {
  border: 3px solid #000000 !important;
}

body.fm-theme-high-contrast .glass-effect,
body.fm-theme-high-contrast .result-box,
body.fm-theme-high-contrast .bg-white {
  background-color: #ffffff !important;
  color: #000000 !important;
  border: 3px solid #000000 !important;
}

/* MODE FALC */
body.fm-falc-1 *:not(#fm-toolbar):not(#fm-toolbar *):not(#fm-toggle-btn) {
  font-size: 18px !important;
  line-height: 1.8 !important;
  letter-spacing: 0.05em !important;
  word-spacing: 0.1em !important;
}

body.fm-falc-2 *:not(#fm-toolbar):not(#fm-toolbar *):not(#fm-toggle-btn) {
  font-size: 20px !important;
  line-height: 2 !important;
  letter-spacing: 0.08em !important;
  word-spacing: 0.15em !important;
}

body.fm-falc-3 *:not(#fm-toolbar):not(#fm-toolbar *):not(#fm-toggle-btn) {
  font-size: 22px !important;
  line-height: 2.2 !important;
  letter-spacing: 0.1em !important;
  word-spacing: 0.2em !important;
}
