/* Charte commune (page de lecture, admin, pages d'erreur) : claire par défaut,
   sombre si le système le demande. Toutes les couleurs passent par ces variables. */
:root {
  color-scheme: light;
  --fond: #f7f5f2;
  --surface: #ffffff;
  --surface-2: #f1eee9;
  --bordure: #e6e1da;
  --bordure-forte: #cbc3b9;
  --texte: #1f1c19;
  --texte-doux: #6b645c;
  --accent: #5b4fd6;
  --accent-survol: #4b40c0;
  --accent-texte: #ffffff;
  --accent-doux: #efedfd;
  --surlignage: #ffe17a;
  --surlignage-texte: #1f1c19;
  --focus: #5b4fd6;
  --rouge: #d13d32;
  --danger: #c93c33;
  --danger-doux: #fcebe8;
  --bandeau-fond: #fcebe8;
  --bandeau-texte: #7a1f17;
  --logo-fond: #1f1c19;
  --ombre: 0 1px 2px rgb(31 28 25 / 6%), 0 10px 30px rgb(31 28 25 / 10%);
  --ombre-legere: 0 1px 2px rgb(31 28 25 / 5%), 0 2px 8px rgb(31 28 25 / 4%);
  --rayon: 14px;
  --rayon-petit: 10px;
  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --fond: #141312;
    --surface: #1e1c1a;
    --surface-2: #2a2724;
    --bordure: #34302c;
    --bordure-forte: #514b45;
    --texte: #f2efea;
    --texte-doux: #a9a198;
    --accent: #9d93ff;
    --accent-survol: #b3abff;
    --accent-texte: #16142a;
    --accent-doux: #2b2747;
    --surlignage: #6b5a12;
    --surlignage-texte: #fff6d6;
    --focus: #9d93ff;
    --rouge: #ff6b5f;
    --danger-doux: #3a211e;
    --bandeau-fond: #3a221f;
    --bandeau-texte: #ffd7d2;
    --logo-fond: #3a3632;
    --ombre: 0 1px 2px rgb(0 0 0 / 30%), 0 12px 32px rgb(0 0 0 / 35%);
    --ombre-legere: 0 1px 2px rgb(0 0 0 / 25%);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  --largeur: 1000px;
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

a { color: var(--accent); }

.hors-ecran {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- En-tête discret : pictogramme et domaine ---- */

.entete {
  max-width: var(--largeur);
  margin: 0 auto;
  padding: 20px 24px 0;
}

.marque {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--texte-doux);
  font-size: 14px;
  font-weight: 500;
}

.logo { width: 22px; height: 22px; flex: none; }
.logo-fond { fill: var(--logo-fond); }

/* ---- Mise en page ---- */

.page {
  max-width: var(--largeur);
  margin: 0 auto;
  padding: 20px 24px 48px;
}

body.large { --largeur: 1320px; }

@media (max-width: 640px) {
  .entete { padding: 14px 16px 0; }
  .page { padding: 14px 16px 32px; }
}

.grille {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

/* Écran large : vidéo à gauche, transcription à droite, à la hauteur de la colonne vidéo. */
@media (min-width: 1024px) {
  .avec-transcription .grille {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 28px;
  }
  .avec-transcription .transcription {
    contain: size;
    min-height: 440px;
  }
}

/* ---- Lecteur ---- */

.cadre {
  background: #000;
  border-radius: var(--rayon);
  overflow: hidden;
  box-shadow: var(--ombre);
}

video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 78vh;
  background: #000;
}

.bandeau {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: var(--rayon-petit);
  background: var(--bandeau-fond);
  color: var(--bandeau-texte);
  font-size: 15px;
}

.point {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rouge);
  animation: pulsation 1.6s ease-in-out infinite;
}

@keyframes pulsation { 50% { opacity: 0.3; } }

.erreur {
  margin: 12px 0 0;
  color: var(--rouge);
}

.details { padding-top: 18px; }

h1 {
  margin: 0 0 4px;
  font-size: clamp(1.3rem, 1.05rem + 1vw, 1.75rem);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.infos {
  margin: 0;
  color: var(--texte-doux);
  font-size: 15px;
}

#duree:not(:first-child)::before {
  content: "·";
  margin: 0 0.5em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 480px) {
  .actions > .principal { flex: 1 1 100%; }
  .actions > .selecteur, .actions > #sous-titres { flex: 1 1 0; justify-content: center; }
}

/* ---- Boutons et sélecteurs ---- */

.icone { width: 18px; height: 18px; flex: none; }

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.bouton:hover { border-color: var(--bordure-forte); background: var(--surface-2); }

.bouton.principal {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-texte);
  font-weight: 600;
}

.bouton.principal:hover { border-color: var(--accent-survol); background: var(--accent-survol); }

.bouton.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}

.bouton.danger:hover { filter: brightness(1.08); }

.bouton[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-doux);
  color: var(--accent);
}

.bouton:focus-visible,
.recherche input:focus-visible,
.replique:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Copier le lien : coche à la place du maillon une fois copié. */
.icone-coche { display: none; }
[data-etat="copie"] .icone-coche { display: block; }
[data-etat="copie"] .icone-lien { display: none; }

.selecteur {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  background: var(--surface);
  color: var(--texte);
  font-size: 15px;
  transition: border-color 0.15s;
}

.selecteur:hover { border-color: var(--bordure-forte); }

.selecteur:has(select:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.selecteur-libelle {
  padding-left: 16px;
  color: var(--texte-doux);
  white-space: nowrap;
}

.selecteur select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 38px;
  padding: 8px 36px 8px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.selecteur select:focus-visible { outline: none; }

.selecteur::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--texte-doux);
  border-bottom: 2px solid var(--texte-doux);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Champ de recherche avec loupe */
.recherche { position: relative; }

.recherche .icone {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--texte-doux);
  transform: translateY(-50%);
  pointer-events: none;
}

.recherche input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--surface-2);
  color: var(--texte);
  font: inherit;
  font-size: 15px;
}

.recherche input::placeholder { color: var(--texte-doux); opacity: 1; }

/* ---- Transcription ---- */

.transcription {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: var(--surface);
  box-shadow: var(--ombre-legere);
}

.transcription-tete {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--bordure);
}

.transcription h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.transcription-etat {
  margin: 0;
  padding: 12px 18px 0;
  color: var(--texte-doux);
  font-size: 14px;
}

.transcription-etat:empty { display: none; }

.repliques {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

@media (max-width: 1023px) {
  .repliques { max-height: min(55vh, 460px); }
}

.replique {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--rayon-petit);
  background: none;
  color: var(--texte);
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
}

.replique:hover { background: var(--surface-2); }

.replique:focus-visible { outline-offset: -2px; }

.horodatage {
  flex: none;
  min-width: 2.9em;
  padding-top: 1px;
  color: var(--texte-doux);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.replique[aria-current="true"] { background: var(--accent-doux); }
.replique[aria-current="true"] .horodatage { color: var(--accent); font-weight: 650; }

mark {
  padding: 0 1px;
  border-radius: 3px;
  background: var(--surlignage);
  color: var(--surlignage-texte);
}

/* ---- Aide clavier ---- */

.aide {
  margin: 32px 0 0;
  color: var(--texte-doux);
  font-size: 13px;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.35em;
  border: 1px solid var(--bordure);
  border-radius: 4px;
  background: var(--surface);
  font: inherit;
  text-align: center;
}

@media (hover: none) {
  .aide { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .point { animation: none; }
  * { transition: none !important; }
}

/* ---- Pages « rien à voir ici » et erreurs ---- */

.vide {
  padding-top: 18vh;
  text-align: center;
}

.vide p { color: var(--texte-doux); }
