/* =====================================================================
   Dream machine Cap555 - bloc autonome
   Ce fichier et dream-machine.js suffisent à faire fonctionner l'outil :
   ils ne dépendent ni de style.css, ni du menu, ni du fond du site.
   Tout est préfixé « dmo » pour ne rien changer au reste de la page.
   ===================================================================== */

.dmo {
  --dmo-nuit: #0b1433;
  --dmo-nuit-fonce: #050918;
  --dmo-champ: #070c22;
  --dmo-texte: #f3efe6;
  --dmo-doux: #b8c2dc;
  --dmo-orange: #ff7a1a;
  --dmo-orange-doux: #e8893a;
  --dmo-grenat: #6b1d2b;
  --dmo-grenat-vif: #9c3145;
  --dmo-sapin: #1f4d32;
  --dmo-vert-clair: #c6e3cf;
  display: block;
  color: var(--dmo-texte);
  font-family: 'Varela Round', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
}
.dmo *, .dmo *::before, .dmo *::after { box-sizing: border-box; }
.dmo p { margin: 0; }
.dmo .cache { display: none !important; }

/* ---------- La fenêtre ---------- */
.dmo-fenetre {
  position: relative;
  overflow: hidden;
  overflow: clip;
  border-radius: 22px;
  border: 1px solid rgba(255, 122, 26, .45);
  background:
    radial-gradient(150% 120% at 15% 0%, rgba(72, 108, 215, .36), transparent 72%),
    radial-gradient(90% 45% at 100% 100%, rgba(107, 29, 43, .38), transparent 65%),
    linear-gradient(175deg, #152359 0%, #121e4e 50%, #0c1638 82%, #070d26 100%);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
}
/* ciel étoilé discret */
.dmo-fenetre::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .7;
  background-image:
    radial-gradient(1.2px 1.2px at 8% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 23% 64%, #fff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 41% 12%, #ffe2c2 50%, transparent 51%),
    radial-gradient(1px 1px at 57% 48%, #fff 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 69% 83%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 82% 30%, #c6e3cf 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 93% 61%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 92%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 76% 6%, #fff 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 15% 80%, #ffe2c2 50%, transparent 51%);
}

/* calque des étoiles filantes, créé par le script */
.dmo-ciel { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

/* barre de titre */
.dmo-barre {
  position: relative;
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .85rem 1.3rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, 0));
}
.dmo-points { display: flex; gap: .45rem; }
.dmo-points i { display: block; width: 11px; height: 11px; border-radius: 50%; }
.dmo-points i:nth-child(1) { background: var(--dmo-orange); box-shadow: 0 0 8px rgba(255, 122, 26, .7); }
.dmo-points i:nth-child(2) { background: var(--dmo-sapin); border: 1px solid var(--dmo-vert-clair); }
.dmo-points i:nth-child(3) { background: var(--dmo-grenat-vif); }
.dmo-titre {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: .01em;
  color: var(--dmo-texte);
}
.dmo-etat {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  color: var(--dmo-vert-clair);
  border: 1px solid rgba(198, 227, 207, .3);
  border-radius: 999px;
  padding: .15rem .75rem;
  white-space: nowrap;
}
.dmo-etat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dmo-vert-clair); box-shadow: 0 0 6px var(--dmo-vert-clair); }

/* ---------- Disposition ---------- */
.dmo-corps {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  gap: 1.4rem;
  padding: 1.4rem;
}
.dmo-gauche {
  position: sticky;
  top: 1rem;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---------- Aperçu ---------- */
.dmo-apercu {
  position: relative;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .08);
  background:
    radial-gradient(70% 55% at 50% 42%, rgba(255, 190, 110, .09), transparent 70%),
    #03061a;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, .7);
}
.dmo-apercu canvas { display: block; width: 100%; height: 360px; }
.dmo-legende { padding: .1rem .2rem 0; font-size: .78rem; color: var(--dmo-doux); }
.dmo-resume { display: flex; flex-wrap: wrap; gap: .4rem; }
.dmo-resume span {
  font-size: .82rem;
  padding: .18rem .7rem;
  border-radius: 999px;
  color: var(--dmo-vert-clair);
  background: rgba(107, 29, 43, .6);
  border: 1px solid rgba(156, 49, 69, .95);
}

/* ---------- Panneaux de réglages ---------- */
.dmo-panneau {
  border-radius: 18px;
  padding: 1rem 1.15rem 1.15rem;
  border: 1px solid rgba(255, 255, 255, .08);
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .02));
}
.dmo-panneau + .dmo-panneau { margin-top: 1rem; }
.dmo .dmo-panneau-titre {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 .9rem;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.08rem;
  color: var(--dmo-orange-doux);
}
.dmo-panneau-titre svg { width: 22px; height: 22px; flex: none; }
.dmo .dmo-petit { margin-top: .6rem; font-size: .82rem; color: var(--dmo-doux); }

/* champs cachés mais toujours accessibles au clavier */
.dmo-tuile input, .dmo-segments input, .dmo-interrupteur input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

/* tuiles illustrées (choix de l'affichage) */
.dmo-tuiles { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: .95rem; }
.dmo-tuile { position: relative; display: block; cursor: pointer; }
.dmo-tuile-corps {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .2rem;
  height: 100%;
  padding: .8rem .6rem .75rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(4, 7, 26, .55);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.dmo-tuile svg { width: 66px; height: 54px; margin-bottom: .2rem; }
.dmo-tuile-titre { font-weight: 600; color: var(--dmo-texte); }
.dmo-tuile-texte { font-size: .8rem; color: var(--dmo-doux); }
.dmo-tuile:hover .dmo-tuile-corps { border-color: rgba(255, 122, 26, .5); }
.dmo-tuile input:checked + .dmo-tuile-corps {
  border-color: var(--dmo-orange);
  background: linear-gradient(180deg, rgba(107, 29, 43, .65), rgba(4, 7, 26, .6));
  box-shadow: 0 0 0 3px rgba(255, 122, 26, .16), 0 0 26px rgba(255, 122, 26, .2);
}
.dmo-tuile input:focus-visible + .dmo-tuile-corps { outline: 2px solid var(--dmo-vert-clair); outline-offset: 2px; }

/* boutons segmentés */
.dmo-segments {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  width: fit-content;
  max-width: 100%;
  padding: .25rem;
  margin-bottom: .95rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(4, 7, 26, .7);
}
.dmo-segments label { position: relative; cursor: pointer; }
.dmo-segments span {
  display: block;
  padding: .38rem .95rem;
  border-radius: 999px;
  font-size: .9rem;
  color: var(--dmo-doux);
  transition: background .2s, color .2s;
}
.dmo-segments label:hover span { color: var(--dmo-texte); }
.dmo-segments input:checked + span {
  color: #fff4ea;
  background: linear-gradient(180deg, var(--dmo-grenat-vif), var(--dmo-grenat));
  box-shadow: 0 0 0 1px rgba(255, 122, 26, .75);
}
.dmo-segments input:focus-visible + span { outline: 2px solid var(--dmo-vert-clair); outline-offset: 2px; }

/* listes déroulantes */
.dmo-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; margin-bottom: .85rem; }
.dmo-champ { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--dmo-doux); }
.dmo select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  margin: 0;
  font: inherit;
  font-size: .95rem;
  color: var(--dmo-texte);
  padding: .5rem 2.1rem .5rem .75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 122, 26, .45);
  background: var(--dmo-champ) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23ff7a1a' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right .75rem center / 12px 8px;
  cursor: pointer;
}
.dmo select:hover { border-color: var(--dmo-orange); }
.dmo select:focus-visible { outline: 2px solid var(--dmo-vert-clair); outline-offset: 2px; }
.dmo select option { background: var(--dmo-champ); color: var(--dmo-texte); }

/* curseurs */
.dmo-curseur { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .85rem; margin: .5rem 0; }
.dmo-curseur label { font-size: .85rem; color: var(--dmo-doux); }
.dmo-valeur { min-width: 4.3em; text-align: right; font-weight: 600; color: var(--dmo-orange); }
.dmo input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 0;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(90deg, var(--dmo-orange) 0, var(--dmo-grenat-vif) var(--pct, 50%), rgba(255, 255, 255, .13) var(--pct, 50%));
}
.dmo input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff4ea, var(--dmo-orange) 62%);
  border: 2px solid var(--dmo-champ);
  box-shadow: 0 0 0 3px rgba(255, 122, 26, .25), 0 0 14px rgba(255, 122, 26, .6);
}
.dmo input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff4ea, var(--dmo-orange) 62%);
  border: 2px solid var(--dmo-champ);
  box-shadow: 0 0 0 3px rgba(255, 122, 26, .25), 0 0 14px rgba(255, 122, 26, .6);
}
.dmo input[type=range]::-moz-range-track { background: transparent; }
.dmo input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--dmo-vert-clair); outline-offset: 2px; }

/* boutons de préréglage */
.dmo-prereglages { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.dmo .dmo-prereglages button {
  font: inherit;
  font-size: .9rem;
  color: var(--dmo-doux);
  background: rgba(4, 7, 26, .7);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  padding: .4rem .95rem;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.dmo .dmo-prereglages button:hover { border-color: var(--dmo-orange); color: var(--dmo-texte); }
.dmo .dmo-prereglages button.actif {
  color: #fff4ea;
  border-color: var(--dmo-orange);
  background: linear-gradient(180deg, var(--dmo-grenat-vif), var(--dmo-grenat));
}

/* interrupteurs à bascule */
.dmo-interrupteur { position: relative; display: flex; align-items: center; gap: .8rem; margin: .7rem 0 .3rem; cursor: pointer; font-size: .92rem; color: var(--dmo-texte); }
.dmo-bascule {
  flex: none;
  position: relative;
  width: 46px; height: 26px;
  border-radius: 999px;
  background: #1b2140;
  border: 1px solid rgba(255, 255, 255, .2);
  transition: background .25s, border-color .25s;
}
.dmo-bascule::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #8a93ad;
  transition: transform .25s, background .25s, box-shadow .25s;
}
.dmo-interrupteur input:checked + .dmo-bascule { background: linear-gradient(90deg, var(--dmo-grenat), var(--dmo-grenat-vif)); border-color: var(--dmo-orange); }
.dmo-interrupteur input:checked + .dmo-bascule::after { transform: translateX(20px); background: var(--dmo-orange); box-shadow: 0 0 10px rgba(255, 122, 26, .85); }
.dmo-interrupteur input:focus-visible + .dmo-bascule { outline: 2px solid var(--dmo-vert-clair); outline-offset: 2px; }

/* choix de fichiers */
.dmo input[type=file] { width: 100%; font: inherit; font-size: .85rem; color: var(--dmo-doux); }
.dmo input[type=file]::file-selector-button {
  font: inherit;
  color: #fff4ea;
  background: linear-gradient(180deg, var(--dmo-grenat-vif), var(--dmo-grenat));
  border: 1px solid var(--dmo-orange);
  border-radius: 10px;
  padding: .4rem .95rem;
  margin-right: .75rem;
  cursor: pointer;
}

/* ---------- Lancement ---------- */
.dmo-lancement {
  border-radius: 18px;
  padding: 1rem 1.15rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .035);
}
.dmo-lancement .dmo-interrupteur { margin-top: 0; font-size: .88rem; }
.dmo .dmo-lancer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  width: 100%;
  margin: .9rem 0 0;
  padding: .95rem 1.4rem;
  font: inherit;
  font-size: 1.12rem;
  font-weight: 600;
  color: #fff4ea;
  border-radius: 999px;
  border: 1px solid var(--dmo-orange);
  background: linear-gradient(180deg, #b02d44, var(--dmo-grenat));
  box-shadow: 0 0 0 4px rgba(255, 122, 26, .14), 0 12px 32px rgba(156, 49, 69, .5), inset 0 1px 0 rgba(255, 255, 255, .22);
  cursor: pointer;
  transition: box-shadow .25s, filter .25s;
}
.dmo .dmo-lancer svg { width: 20px; height: 20px; }
.dmo .dmo-lancer:hover:not(:disabled) { filter: brightness(1.12); box-shadow: 0 0 0 5px rgba(255, 122, 26, .22), 0 14px 40px rgba(255, 122, 26, .35), inset 0 1px 0 rgba(255, 255, 255, .25); }
.dmo .dmo-lancer:focus-visible { outline: 2px solid var(--dmo-vert-clair); outline-offset: 3px; }
.dmo .dmo-lancer:disabled {
  cursor: not-allowed;
  color: rgba(243, 239, 230, .45);
  border-color: rgba(255, 255, 255, .15);
  background: #161c38;
  box-shadow: none;
}

/* ---------- Téléphone ---------- */
@media (max-width: 820px) {
  .dmo-corps { grid-template-columns: 1fr; gap: 1rem; padding: 1rem; }
  .dmo-gauche { display: contents; }
  .dmo-scene-apercu { order: 1; }
  .dmo-reglages { order: 2; }
  .dmo-lancement { order: 3; }
  .dmo-apercu canvas { height: 290px; }
  .dmo-barre { padding: .75rem 1rem; }
  .dmo-etat { display: none; }
}
@media (max-width: 420px) {
  .dmo-panneau { padding: .9rem .85rem 1rem; }
  .dmo-tuile svg { width: 54px; height: 44px; }
  .dmo-curseur { grid-template-columns: 1fr auto; }
  .dmo-curseur label { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .dmo *, .dmo *::before, .dmo *::after { transition: none !important; }
}

/* ---------- Séance plein écran (rattachée au document par le script) ---------- */
.dmo-seance { position: fixed; inset: 0; z-index: 10000; background: #000; cursor: none; }
.dmo-seance.cache, .dmo-seance .cache { display: none !important; }
.dmo-seance:hover { cursor: default; }
.dmo-seance #lumiere { position: absolute; inset: 0; opacity: 0; z-index: 2; pointer-events: none; }
.dmo-seance #lumiere.ecran-cyl { mix-blend-mode: screen; }
.dmo-seance #cylindre { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.dmo-seance #hud {
  position: absolute; left: 0; right: 0; bottom: 14px; z-index: 3;
  text-align: center;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  color: rgba(255, 255, 255, .55);
  pointer-events: none;
  mix-blend-mode: difference;
}
