/* Vidéos — fond noir traversé de dégradés colorés, cadres en verre liquide
   (flou + saturation + reflets sur les bords), barre de recherche en bas. */
:root {
  --fond: #000;
  --texte: #fff;
  --texte-2: rgba(255, 255, 255, 0.62);
  --texte-3: rgba(255, 255, 255, 0.4);
  --danger: #ff6159;
  --r-cadre: 30px;
  --r-media: 23px;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  --gauche: env(safe-area-inset-left, 0px);
  --droite: env(safe-area-inset-right, 0px);
  --sortie: cubic-bezier(0.22, 1, 0.36, 1);
  --ressort: cubic-bezier(0.32, 0.72, 0, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; -webkit-user-select: text; user-select: text; }
svg.lucide { width: 22px; height: 22px; stroke-width: 2; flex: none; }

/* --- Le fond : des taches de couleur floues qui dérivent lentement ----- */
.fond-couleurs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: #000; }
.fond-couleurs i {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; filter: blur(70px); opacity: 0.55;
  will-change: transform;
}
.fond-couleurs i:nth-child(1) { background: radial-gradient(circle, #7b3cff 0%, transparent 65%); top: -25vmax; left: -20vmax; animation: derive1 26s ease-in-out infinite alternate; }
.fond-couleurs i:nth-child(2) { background: radial-gradient(circle, #ff4f8b 0%, transparent 65%); top: 20vh; right: -30vmax; animation: derive2 32s ease-in-out infinite alternate; }
.fond-couleurs i:nth-child(3) { background: radial-gradient(circle, #1fa2ff 0%, transparent 65%); bottom: -30vmax; left: -10vmax; animation: derive3 29s ease-in-out infinite alternate; }
.fond-couleurs i:nth-child(4) { background: radial-gradient(circle, #ff9f1c 0%, transparent 65%); bottom: 10vh; right: -25vmax; opacity: 0.35; animation: derive1 35s ease-in-out infinite alternate-reverse; }
@keyframes derive1 { to { transform: translate(18vw, 22vh) scale(1.15); } }
@keyframes derive2 { to { transform: translate(-22vw, 18vh) scale(0.9); } }
@keyframes derive3 { to { transform: translate(20vw, -20vh) scale(1.1); } }

/* --- Le verre liquide -------------------------------------------------- */
.verre-liquide {
  position: relative;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05) 45%, rgba(255, 255, 255, 0.09));
  -webkit-backdrop-filter: blur(26px) saturate(190%);
  backdrop-filter: blur(26px) saturate(190%);
  box-shadow:
    inset 0 1px 0.5px rgba(255, 255, 255, 0.45),
    inset 0 -1px 0.5px rgba(255, 255, 255, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 12px 32px rgba(0, 0, 0, 0.35);
}
/* reflet : un liseré plus clair en haut à gauche, comme sur une goutte */
.verre-liquide::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 60% at 15% 0%, rgba(255, 255, 255, 0.22), transparent 55%);
  mix-blend-mode: screen;
}

/* --- Ordinateur et écrans d'information -------------------------------- */
.message-plein {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
.message-plein .verre-liquide { max-width: 380px; text-align: center; padding: 36px 28px; border-radius: 32px; }
.message-plein h1 { font-size: 22px; margin: 18px 0 8px; letter-spacing: -0.02em; }
.message-plein p { color: var(--texte-2); margin: 0 0 6px; }
.message-plein code { color: var(--texte); font: 600 15px/1 ui-monospace, Menlo, monospace; }
.pastille-icone {
  width: 64px; height: 64px; border-radius: 50%; display: inline-grid; place-items: center;
}
.pastille-icone svg.lucide { width: 28px; height: 28px; position: relative; }

/* --- Code PIN --------------------------------------------------------- */
.pin {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--haut) + 24px) 24px calc(var(--bas) + 24px);
}
.pin h1 { font-size: 22px; letter-spacing: -0.02em; margin: 22px 0 6px; font-weight: 700; }
.pin .aide { color: var(--texte-2); font-size: 15px; min-height: 21px; margin: 0; text-align: center; }
.pin .aide.erreur { color: var(--danger); }
.points { display: flex; gap: 18px; margin: 28px 0 40px; }
.points span {
  width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55);
  transition: background 160ms var(--sortie), transform 160ms var(--sortie);
}
.points span.plein { background: #fff; transform: scale(1.1); }
.points.secoue { animation: secoue 380ms var(--sortie); }
@keyframes secoue {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px); } 40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(4px); }
}
.clavier { display: grid; grid-template-columns: repeat(3, 78px); gap: 16px 24px; }
.clavier button {
  height: 78px; border-radius: 50%; font-size: 32px; font-weight: 400; display: grid; place-items: center;
  transition: transform 120ms var(--sortie), filter 120ms;
}
.clavier button:active { transform: scale(0.92); filter: brightness(1.6); }
.clavier button.vide { visibility: hidden; }
.clavier button.effacer { background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.clavier button.effacer::before { display: none; }
.clavier button:disabled { opacity: 0.35; }

/* --- La liste --------------------------------------------------------- */
.biblio {
  padding: calc(var(--haut) + 12px) calc(var(--droite) + 14px) calc(var(--bas) + 104px) calc(var(--gauche) + 14px);
  max-width: 640px; margin: 0 auto;
}
.liste { display: flex; flex-direction: column; gap: 18px; }
.cadre {
  border-radius: var(--r-cadre); padding: 7px; animation: apparait 360ms var(--sortie) both;
}
@keyframes apparait { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.media {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--r-media);
  overflow: hidden; background: rgba(255, 255, 255, 0.06); isolation: isolate;
}
.media img, .media video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.media video { opacity: 0; transition: opacity 400ms var(--sortie); }
.media video.visible { opacity: 1; }
/* aperçu YouTube : les images prises dans la vidéo, en fondu enchaîné */
.media img.diapo { opacity: 0; transition: opacity 500ms ease; }
.media img.diapo.visible { opacity: 1; }
.media .sans-image { position: absolute; inset: 0; display: grid; place-items: center; color: var(--texte-3); }
.media .sans-image svg.lucide { width: 34px; height: 34px; }
.cadre.vue .media img, .cadre.vue .media video { filter: saturate(0.5) brightness(0.75); }
.media .ombre-bas { position: absolute; inset: auto 0 0 0; height: 45%; background: linear-gradient(transparent, rgba(0, 0, 0, 0.45)); pointer-events: none; }
.puce {
  position: absolute; z-index: 2; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; color: #fff;
}
.puce > * { position: relative; }
.puce svg.lucide { width: 13px; height: 13px; stroke-width: 2.6; }
.puce.duree { right: 10px; bottom: 10px; }
.puce.vu { left: 10px; bottom: 10px; }
.progression { position: absolute; z-index: 2; left: 14px; right: 14px; bottom: 4px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.progression i { display: block; height: 100%; background: #fff; border-radius: 2px; }
.cadre .bas { display: flex; gap: 6px; align-items: center; padding: 10px 4px 5px 10px; position: relative; }
.cadre .textes { flex: 1; min-width: 0; }
.cadre h2 {
  font-size: 15.5px; line-height: 1.3; margin: 0; font-weight: 650; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cadre .meta { color: var(--texte-2); font-size: 13px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cadre .plus { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--texte-2); flex: none; }
.cadre .plus:active { background: rgba(255, 255, 255, 0.12); }
/* le cadre parti en plein écran laisse sa place vide */
.cadre.en-lecture .media > * { visibility: hidden; }

.vide-etat { text-align: center; padding: 18vh 24px 24px; }
.vide-etat h2 { font-size: 21px; margin: 20px 0 6px; letter-spacing: -0.02em; }
.vide-etat p { color: var(--texte-2); margin: 0; }

/* --- Barre du bas ----------------------------------------------------- */
.barre-bas {
  position: fixed; z-index: 20; left: calc(var(--gauche) + 14px); right: calc(var(--droite) + 14px);
  bottom: calc(var(--bas) + 12px); display: flex; gap: 10px; align-items: center;
  max-width: 612px; margin: 0 auto;
}
.rond {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; flex: none;
  transition: transform 140ms var(--sortie);
}
.rond:active { transform: scale(0.92); }
.rond.blanc { background: #fff; color: #000; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4); }
.rond.blanc::before { display: none; }
.rond svg.lucide { width: 23px; height: 23px; position: relative; }
.recherche {
  flex: 1; min-width: 0; height: 54px; border-radius: 999px; display: flex; align-items: center; gap: 10px; padding: 0 16px 0 18px;
}
.recherche > * { position: relative; }
.recherche svg.lucide { width: 19px; height: 19px; color: var(--texte-2); }
.recherche input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 17px; }
.recherche input::placeholder { color: var(--texte-2); }
.recherche input::-webkit-search-cancel-button { display: none; }
.recherche .effacer { display: grid; place-items: center; color: var(--texte-2); }

/* --- Feuilles qui montent du bas -------------------------------------- */
.voile {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 50;
  animation: fondu 220ms var(--sortie) both;
}
.voile.part { animation: fondu 180ms ease-in reverse both; }
@keyframes fondu { from { opacity: 0; } }
.feuille {
  position: fixed; left: 8px; right: 8px; bottom: calc(var(--bas) + 8px); z-index: 51;
  border-radius: 34px; padding: 10px 18px 18px; max-width: 560px; margin: 0 auto;
  background: linear-gradient(160deg, rgba(60, 60, 70, 0.62), rgba(28, 28, 34, 0.7));
  animation: monte 340ms var(--ressort) both;
}
.feuille.part { animation: descend 200ms ease-in both; }
@keyframes monte { from { transform: translateY(110%); } }
@keyframes descend { to { transform: translateY(110%); } }
.feuille > * { position: relative; }
.feuille .poignee { width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); margin: 0 auto 14px; }
.feuille h3 { font-size: 20px; margin: 0 4px 14px; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feuille .sous-titre { color: var(--texte-2); font-size: 14px; margin: -10px 4px 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.champ {
  display: flex; align-items: center; gap: 8px; height: 54px; padding: 0 6px 0 16px;
  background: rgba(255, 255, 255, 0.08); border-radius: 18px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.champ input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 16px; }
.champ input::placeholder { color: var(--texte-3); }
.champ .coller {
  height: 42px; padding: 0 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.14); font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px;
}
.champ .coller svg.lucide { width: 17px; height: 17px; }
.message { font-size: 14px; color: var(--danger); margin: 10px 4px 0; }
.message:empty { display: none; }
.message.info { color: var(--texte-2); }
.principal {
  width: 100%; height: 54px; border-radius: 999px; background: #fff; color: #000;
  font-weight: 650; font-size: 17px; margin-top: 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 120ms var(--sortie), opacity 160ms;
}
.principal:active { transform: scale(0.98); }
.principal:disabled { opacity: 0.55; }
.tourne { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(0, 0, 0, 0.2); border-top-color: #000; animation: tourne 700ms linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

.menu { display: flex; flex-direction: column; background: rgba(255, 255, 255, 0.07); border-radius: 22px; overflow: hidden; }
.menu button {
  display: flex; align-items: center; gap: 14px; height: 54px; padding: 0 18px; text-align: left; font-size: 16px; font-weight: 500;
}
.menu button + button { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.menu button:active { background: rgba(255, 255, 255, 0.1); }
.menu button.danger { color: var(--danger); }
.menu button svg.lucide { width: 20px; height: 20px; }

#toast {
  position: fixed; left: 50%; top: calc(var(--haut) + 12px); z-index: 120;
  transform: translate(-50%, -160%); transition: transform 300ms var(--ressort), visibility 0s 300ms;
  padding: 12px 18px; border-radius: 999px; font-size: 15px; font-weight: 600;
  max-width: calc(100vw - 32px); pointer-events: none; visibility: hidden;
}
#toast.visible { transform: translate(-50%, 0); visibility: visible; transition: transform 300ms var(--ressort); }

/* --- Lecteur ---------------------------------------------------------- */
.lecteur {
  position: fixed; inset: 0; z-index: 80; background: #000; color: #fff; overflow: hidden;
  touch-action: none; transform-origin: 0 0;
}
.lecteur.glisse-entree { animation: lecteur-entre 320ms var(--ressort) both; }
@keyframes lecteur-entre { from { transform: translateY(100%); } }
/* iPhone : pas de plein écran pour une page, donc on tourne le lecteur. */
@media (orientation: portrait) {
  .lecteur.paysage {
    inset: auto; top: 0; left: 100vw; width: 100vh; width: 100dvh; height: 100vw;
    transform: rotate(90deg); animation: none;
  }
}
.scene { position: absolute; inset: 0; display: grid; place-items: center; }
.scene video, .scene iframe, .scene > div { width: 100%; height: 100%; border: 0; display: block; }
.scene video { object-fit: contain; background: #000; }
.scene .affiche {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none;
  transition: opacity 300ms ease;
}
.scene .affiche.partie { opacity: 0; }
.couche { position: absolute; inset: 0; }
.lecteur.attente-tactile .couche { pointer-events: none; }
.lecteur.attente-tactile .commandes .haut { pointer-events: auto; }

.commandes {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 220ms var(--sortie);
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent 26%, transparent 70%, rgba(0, 0, 0, 0.5));
}
.lecteur.commandes-visibles .commandes { opacity: 1; }
.lecteur.commandes-visibles .commandes > * { pointer-events: auto; }
.lecteur.anime .commandes { opacity: 0 !important; transition: none; }
.commandes .haut {
  position: absolute; top: calc(var(--haut) + 8px); left: calc(var(--gauche) + 12px); right: calc(var(--droite) + 12px);
  display: flex; align-items: center; gap: 8px;
}
.lecteur.paysage .commandes .haut { top: 12px; left: calc(var(--haut) + 14px); right: 14px; }
.commandes .titre {
  flex: 1; min-width: 0; height: 44px; line-height: 44px; padding: 0 16px; border-radius: 999px;
  font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.verre {
  height: 44px; min-width: 44px; padding: 0 11px; border-radius: 999px; display: inline-grid; place-items: center;
  font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; transition: transform 120ms var(--sortie);
}
.verre:active { transform: scale(0.9); }
.verre svg.lucide { width: 20px; height: 20px; position: relative; }
.commandes .centre {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 30px;
}
.commandes .centre .verre { width: 58px; height: 58px; }
.commandes .centre .verre svg.lucide { width: 24px; height: 24px; }
.commandes .centre .lecture { width: 80px; height: 80px; }
.commandes .centre .lecture svg.lucide { width: 34px; height: 34px; fill: #fff; }
.commandes .bas {
  position: absolute; left: calc(var(--gauche) + 12px); right: calc(var(--droite) + 12px); bottom: calc(var(--bas) + 10px);
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 6px 0 18px; border-radius: 999px;
}
.commandes .bas > * { position: relative; }
.lecteur.paysage .commandes .bas { left: calc(var(--haut) + 18px); right: 14px; bottom: 12px; }
.temps { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 38px; }
.temps.total { color: var(--texte-2); text-align: right; }
.barre { flex: 1; height: 40px; display: flex; align-items: center; touch-action: none; }
.barre .piste { position: relative; width: 100%; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.22); }
.barre .tampon, .barre .rempli { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.barre .tampon { background: rgba(255, 255, 255, 0.3); }
.barre .rempli { background: #fff; }
.barre .curseur {
  position: absolute; top: 50%; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4); transition: transform 140ms var(--sortie);
}
.barre.active .curseur { transform: scale(1.5); }
.commandes .bas .verre { height: 44px; min-width: 44px; background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.commandes .bas .verre::before { display: none; }

.saut {
  position: absolute; top: 0; bottom: 0; width: 38%; display: grid; place-items: center; pointer-events: none; opacity: 0;
  transition: opacity 220ms var(--sortie);
}
.saut.gauche { left: 0; border-radius: 0 50% 50% 0 / 0 50% 50% 0; }
.saut.droite { right: 0; border-radius: 50% 0 0 50% / 50% 0 0 50%; }
.saut.visible { opacity: 1; background: rgba(255, 255, 255, 0.1); }
.saut span { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; }
.apercu-temps {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); pointer-events: none;
  padding: 10px 20px; border-radius: 999px; font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums; opacity: 0; transition: opacity 140ms;
}
.apercu-temps.visible { opacity: 1; }
.apercu-temps > * { position: relative; }
.apercu-temps small { font-size: 15px; opacity: 0.7; font-weight: 600; }
.charge {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: tourne 800ms linear infinite;
  pointer-events: none; opacity: 0; transition: opacity 200ms;
}
.lecteur.en-charge .charge { opacity: 1; }
.lecteur.en-charge .commandes .centre .lecture { opacity: 0; }
.bandeau {
  position: absolute; left: 50%; bottom: calc(var(--bas) + 78px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; white-space: nowrap; animation: fondu 220ms var(--sortie) both;
}
.bandeau > * { position: relative; }
.bandeau button { height: 32px; padding: 0 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); font-weight: 650; }
.erreur-lecture {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 32px; text-align: center; background: rgba(0, 0, 0, 0.82);
}
.erreur-lecture p { margin: 0; color: var(--texte-2); max-width: 320px; }
.erreur-lecture .actions { display: flex; gap: 10px; }
.erreur-lecture .actions button { height: 44px; padding: 0 18px; border-radius: 999px; background: #fff; color: #000; font-weight: 650; }
.erreur-lecture .actions button.fantome { background: rgba(255, 255, 255, 0.16); color: #fff; }
.indication {
  position: absolute; left: 50%; bottom: calc(var(--bas) + 84px); transform: translateX(-50%);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; pointer-events: none; white-space: nowrap;
}
.lecteur .voile, .lecteur .feuille { position: absolute; }
.vitesses { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.vitesses button {
  height: 52px; border-radius: 16px; background: rgba(255, 255, 255, 0.08); font-weight: 650; font-size: 16px; font-variant-numeric: tabular-nums;
}
.vitesses button.actif { background: #fff; color: #000; }

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