/*
 * Lecteur Lizio — feuille de style.
 *
 * Deux thèmes, pilotés par la préférence système ou par `data-theme` sur la
 * racine. Le mode sombre n'est pas optionnel dans ce projet.
 *
 * Les cibles interactives font au moins 24 px (WCAG 2.2, critère 2.5.8) et
 * chacune a un état de focus visible.
 */

.lz {
  --lz-bg:        #f3f2f5;
  --lz-surface:   #ffffff;
  --lz-ink:       #1a1720;
  --lz-muted:     #6b6478;
  --lz-rule:      #e2dee8;
  --lz-accent:    #b8005f;   /* brand-600 */
  --lz-shadow:    0 1px 2px rgba(20, 16, 26, .08), 0 12px 32px -14px rgba(20, 16, 26, .35);
  --lz-strip-bg:  #eceaf0;

  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--lz-bg);
  color: var(--lz-ink);
  font: 400 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lz {
    --lz-bg:       #121016;
    --lz-surface:  #1b1822;
    --lz-ink:      #ece8f0;
    --lz-muted:    #a49cb0;
    --lz-rule:     #2f2939;
    --lz-accent:   #f07cb4;   /* brand-300 */
    --lz-shadow:   0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px -14px rgba(0, 0, 0, .8);
    --lz-strip-bg: #17141d;
  }
}
:root[data-theme="dark"] .lz {
  --lz-bg:       #121016;
  --lz-surface:  #1b1822;
  --lz-ink:      #ece8f0;
  --lz-muted:    #a49cb0;
  --lz-rule:     #2f2939;
  --lz-accent:   #f07cb4;   /* brand-300 */
  --lz-shadow:   0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px -14px rgba(0, 0, 0, .8);
  --lz-strip-bg: #17141d;
}

.lz *, .lz *::before, .lz *::after { box-sizing: border-box; }

/* --- barre de titre --- */
.lz-bar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; padding: 10px 16px;
  border-bottom: 1px solid var(--lz-rule);
  background: var(--lz-surface);
  flex: 0 0 auto;
}
.lz-title   { font-weight: 600; letter-spacing: -.01em; }
.lz-counter { color: var(--lz-muted); font-variant-numeric: tabular-nums; font-size: 13.5px; }

/* --- scène --- */
.lz-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px 56px;
  cursor: pointer;
}
.lz-stage:focus-visible { outline: 2px solid var(--lz-accent); outline-offset: -4px; }

.lz-spread { display: flex; box-shadow: var(--lz-shadow); background: var(--lz-surface); }

.lz-leaf {
  position: relative;
  overflow: hidden;
  background: var(--lz-surface);
}
/* Un fond neutre le temps du décodage, plutôt qu'un trou blanc clignotant. */
.lz-leaf::after {
  content: ""; position: absolute; inset: 0;
  background: var(--lz-rule); opacity: .5;
  transition: opacity .18s ease;
}
.lz-leaf.is-loaded::after { opacity: 0; }

/* L'INDICATEUR D'ATTENTE.
   Une page qui met 400 ms a arriver laisse un rectangle gris muet : on ne sait
   pas si ca charge ou si c'est casse. D'ou ce disque qui tourne.

   Il apparait avec 220 ms de RETARD, et c'est tout l'interet : une page deja en
   cache s'affiche bien avant, donc l'indicateur ne clignote pas pour rien. Un
   temoin qui s'allume a chaque tour de page est pire que pas de temoin -- on
   apprend a le voir comme du bruit.

   Pas de JavaScript : la classe `is-loaded` retire la feuille de la selection,
   ce qui suffit a effacer le disque. */
.lz-leaf:not(.is-loaded)::before {
  content: ""; position: absolute; z-index: 1;
  top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border: 3px solid var(--lz-rule);
  border-top-color: var(--lz-accent);
  border-radius: 50%;
  opacity: 0;
  animation: lz-apparait .2s ease 220ms forwards, lz-tourne .7s linear 220ms infinite;
}
@keyframes lz-tourne { to { transform: rotate(360deg); } }
@keyframes lz-apparait { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  /* Pas de rotation, mais l'information reste : un disque qui respire. */
  .lz-leaf:not(.is-loaded)::before {
    animation: lz-respire 1.4s ease-in-out 220ms infinite;
    border-color: var(--lz-accent);
  }
  @keyframes lz-respire { 0%, 100% { opacity: .25; } 50% { opacity: .8; } }
}

.lz-page { display: block; width: 100%; height: 100%; object-fit: contain; }

/* --- boutons de navigation --- */
.lz-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 56px;            /* bien au-delà des 24 px exigés */
  display: grid; place-items: center;
  font-size: 26px; line-height: 1;
  color: var(--lz-ink);
  background: var(--lz-surface);
  border: 1px solid var(--lz-rule);
  border-radius: 6px;
  box-shadow: var(--lz-shadow);
  cursor: pointer;
}
.lz-nav-prev { left: 8px; }
.lz-nav-next { right: 8px; }
.lz-nav:hover:not(:disabled) { color: var(--lz-accent); border-color: var(--lz-accent); }
.lz-nav:focus-visible { outline: 2px solid var(--lz-accent); outline-offset: 2px; }
.lz-nav:disabled { opacity: .3; cursor: default; }

/* --- bandeau de miniatures --- */
.lz-strip {
  flex: 0 0 auto;
  display: flex; gap: 8px;
  padding: 10px 12px;
  overflow-x: auto; overflow-y: hidden;
  background: var(--lz-strip-bg);
  border-top: 1px solid var(--lz-rule);
  scrollbar-width: thin;
}
.lz-thumb {
  position: relative; flex: 0 0 auto;
  width: 44px; height: 66px;
  padding: 0; border: 1px solid var(--lz-rule); border-radius: 3px;
  background-color: var(--lz-surface);
  background-repeat: no-repeat;
  /* Les vignettes sont découpées dans une planche-contact : on la met à
     l'échelle de la cellule affichée. */
  transform-origin: top left;
  cursor: pointer;
  overflow: hidden;
}
.lz-thumb > * { pointer-events: none; }
.lz-thumb:hover { border-color: var(--lz-accent); }
.lz-thumb:focus-visible { outline: 2px solid var(--lz-accent); outline-offset: 2px; }
.lz-thumb.is-current { border-color: var(--lz-accent); box-shadow: 0 0 0 2px var(--lz-accent); }
.lz-thumb-n {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 9px; line-height: 13px; text-align: center;
  color: #fff; background: rgba(0, 0, 0, .55);
  font-variant-numeric: tabular-nums;
}

/* --- annonce pour les lecteurs d'écran --- */
.lz-live {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 820px) {
  .lz-stage { padding: 12px 44px; }
  .lz-nav { width: 34px; height: 48px; font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .lz *, .lz *::before, .lz *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* --- barre d'outils : zoom et plein écran --- */
.lz-tools { display: flex; align-items: center; gap: 4px; }
.lz-btn {
  min-width: 28px; height: 28px;      /* > 24 px exigés par WCAG 2.5.8 */
  padding: 0 6px;
  display: grid; place-items: center;
  font: inherit; font-size: 14px; line-height: 1;
  color: var(--lz-ink);
  background: var(--lz-surface);
  border: 1px solid var(--lz-rule);
  border-radius: 5px;
  cursor: pointer;
}
.lz-btn-wide { min-width: 52px; font-size: 12px; font-variant-numeric: tabular-nums; }
.lz-btn:hover { color: var(--lz-accent); border-color: var(--lz-accent); }
.lz-btn:focus-visible { outline: 2px solid var(--lz-accent); outline-offset: 2px; }

/* --- état zoomé --- */
.lz-stage { overflow: hidden; touch-action: pan-y; }
.lz-stage.is-zoomed { cursor: grab; touch-action: none; }
.lz-stage.is-zoomed:active { cursor: grabbing; }
.lz-spread { transform-origin: center center; will-change: transform; }

/* --- plein écran --- */
.lz.is-full { height: 100vh; }
.lz:fullscreen { background: var(--lz-bg); }

/* --- recherche --- */
.lz-find { display: flex; align-items: center; gap: 6px; }
.lz-find-input {
  width: 190px; height: 28px; padding: 0 9px;
  font: inherit; font-size: 13px;
  color: var(--lz-ink);
  background: var(--lz-surface);
  border: 1px solid var(--lz-rule); border-radius: 5px;
}
.lz-find-input::placeholder { color: var(--lz-muted); }
.lz-find-input:focus-visible { outline: 2px solid var(--lz-accent); outline-offset: 1px; }
.lz-find-count {
  font-size: 12px; color: var(--lz-muted);
  min-width: 68px; font-variant-numeric: tabular-nums;
}

.lz-results {
  flex: 0 0 auto; max-height: 34%; overflow-y: auto;
  border-top: 1px solid var(--lz-rule);
  background: var(--lz-surface);
}
.lz-result {
  display: block; width: 100%; text-align: left;
  padding: 8px 14px; min-height: 28px;
  font: inherit; font-size: 13.5px; color: var(--lz-ink);
  background: none; border: 0; border-bottom: 1px solid var(--lz-rule);
  cursor: pointer;
}
.lz-result:hover { background: var(--lz-bg); }
.lz-result:focus-visible { outline: 2px solid var(--lz-accent); outline-offset: -2px; }
.lz-result b { color: var(--lz-accent); margin-right: 8px; font-variant-numeric: tabular-nums; }
.lz-result span { color: var(--lz-muted); }

/* --- surlignage : posé en pourcentages, donc valable à tout niveau et tout zoom --- */
.lz-marks { position: absolute; inset: 0; pointer-events: none; }
.lz-mark {
  position: absolute;
  background: color-mix(in srgb, var(--lz-accent) 32%, transparent);
  outline: 1px solid color-mix(in srgb, var(--lz-accent) 65%, transparent);
  border-radius: 1px;
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lz-mark { mix-blend-mode: screen; }
}


/* --- modes d'affichage ---------------------------------------------------
   Trois reglages qui appartiennent au LECTEUR : une page ou deux, miniatures
   en bas, a gauche, ou nulle part. Ils passent par des attributs sur la racine
   (`data-pages`, `data-vignettes`), donc toute l'apparence reste decrite ici.  */

.lz-sep {
  width: 1px; height: 18px; margin: 0 2px;
  background: var(--lz-rule); flex: none;
}
.lz-modes { display: inline-flex; gap: 2px; }
/* Les boutons de mode portent un dessin, pas du texte : ils doivent etre
   carres, sinon la barre se deforme selon la largeur du glyphe. */
.lz-modes .lz-btn { display: inline-grid; place-items: center; padding: 0; width: 30px; }
/* Le mode actif se voit : sans ca, cinq boutons identiques ne disent jamais
   dans quel etat on se trouve. */
.lz-modes .lz-btn[aria-pressed="true"] {
  background: var(--lz-accent); color: #fff; border-color: var(--lz-accent);
}

/* Miniatures a gauche : la colonne defile verticalement et la scene prend ce
   qui reste. On bascule la direction du conteneur plutot que de repositionner
   chaque bloc -- une seule regle, et l'ordre du DOM reste inchange pour le
   clavier et les lecteurs d'ecran. */
.lz[data-vignettes="gauche"] {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr auto;
}
.lz[data-vignettes="gauche"] .lz-bar { grid-column: 1 / -1; }
.lz[data-vignettes="gauche"] .lz-results { grid-column: 1 / -1; }
.lz[data-vignettes="gauche"] .lz-strip {
  grid-row: 2 / 3; grid-column: 1;
  flex-direction: column;
  width: 84px; height: auto;
  overflow-x: hidden; overflow-y: auto;
  border-top: 0; border-right: 1px solid var(--lz-rule);
}
.lz[data-vignettes="gauche"] .lz-stage { grid-row: 2 / 3; grid-column: 2; }

@media (max-width: 640px) {
  /* Sur un telephone, une colonne de miniatures mange la moitie de la largeur
     utile : on la repose en bas, quel que soit le reglage. */
  .lz[data-vignettes="gauche"] { display: flex; }
  .lz[data-vignettes="gauche"] .lz-strip {
    flex-direction: row; width: auto;
    border-right: 0; border-top: 1px solid var(--lz-rule);
    overflow-x: auto; overflow-y: hidden;
  }
}
