/* =====================================================================
   Fenêtre des outils Cap555 - socle commun
   Utilisé par chaque outil du dossier outils/ (sauf la Dream machine,
   qui a son propre fichier). Ne dépend ni de style.css ni du menu du site.
   Chaque outil choisit sa couleur avec les variables --of-1 à --of-3,
   --of-lueur-haut et --of-lueur-bas.
   ===================================================================== */

.of {
  --of-1: #152359;            /* haut de la fenêtre */
  --of-2: #121e4e;            /* milieu */
  --of-3: #070d26;            /* bas */
  --of-lueur-haut: rgba(72, 108, 215, .36);
  --of-lueur-bas: rgba(107, 29, 43, .38);
  --of-champ: rgba(5, 8, 22, .72);
  --of-texte: #f3efe6;
  --of-doux: #c3c8d8;
  --of-orange: #ff7a1a;
  --of-orange-doux: #e8893a;
  --of-grenat: #6b1d2b;
  --of-grenat-vif: #9c3145;
  --of-sapin: #1f4d32;
  --of-vert-clair: #c6e3cf;
  display: block;
  color: var(--of-texte);
  font-family: 'Varela Round', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
}
.of *, .of *::before, .of *::after { box-sizing: border-box; }
.of p { margin: 0; }
.of .cache, .of [hidden] { display: none !important; }

/* ---------- La fenêtre ---------- */
.of-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%, var(--of-lueur-haut), transparent 72%),
    radial-gradient(90% 45% at 100% 100%, var(--of-lueur-bas), transparent 65%),
    linear-gradient(175deg, var(--of-1) 0%, var(--of-2) 50%, var(--of-3) 100%);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: background .6s;
}
.of-fenetre::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .65;
  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%);
}
.of-ciel { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

.of-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));
}
.of-points { display: flex; gap: .45rem; flex: none; }
.of-points i { display: block; width: 11px; height: 11px; border-radius: 50%; }
.of-points i:nth-child(1) { background: var(--of-orange); box-shadow: 0 0 8px rgba(255, 122, 26, .7); }
.of-points i:nth-child(2) { background: var(--of-sapin); border: 1px solid var(--of-vert-clair); }
.of-points i:nth-child(3) { background: var(--of-grenat-vif); }
.of-titre { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.2rem; letter-spacing: .01em; color: var(--of-texte); }
.of-etat {
  margin-left: auto;
  font-size: .78rem;
  color: var(--of-vert-clair);
  border: 1px solid rgba(198, 227, 207, .3);
  border-radius: 999px;
  padding: .15rem .75rem;
  white-space: nowrap;
}
.of-corps { position: relative; padding: 1.4rem; }

/* ---------- Panneaux et textes ---------- */
.of-panneau {
  border-radius: 18px;
  padding: 1rem 1.15rem 1.15rem;
  border: 1px solid rgba(255, 255, 255, .09);
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02));
}
.of .of-sous-titre { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.15rem; color: var(--of-orange-doux); margin: 0 0 .5rem; }
.of .of-petit { font-size: .84rem; color: var(--of-doux); }
.of a { color: var(--of-vert-clair); text-decoration: underline; text-decoration-color: var(--of-orange); text-underline-offset: 3px; }
.of a:hover { color: var(--of-orange); }

/* ---------- Commandes ---------- */
.of-segments input, .of-interrupteur input, .of-tuile input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
}
.of-segments {
  display: flex; flex-wrap: wrap; gap: .25rem;
  width: fit-content; max-width: 100%;
  padding: .25rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: var(--of-champ);
}
.of-segments label, .of-segments button { position: relative; cursor: pointer; }
.of-segments span, .of-segments button {
  display: block;
  padding: .4rem 1rem;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: .92rem;
  color: var(--of-doux);
  background: transparent;
  transition: background .2s, color .2s;
}
.of-segments label:hover span, .of-segments button:hover { color: var(--of-texte); }
.of-segments input:checked + span, .of-segments button[aria-selected="true"], .of-segments button[aria-pressed="true"] {
  color: #fff4ea;
  background: linear-gradient(180deg, var(--of-grenat-vif), var(--of-grenat));
  box-shadow: 0 0 0 1px rgba(255, 122, 26, .75);
}
.of-segments input:focus-visible + span, .of-segments button:focus-visible { outline: 2px solid var(--of-vert-clair); outline-offset: 2px; }

.of-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; }
.of-champ { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--of-doux); }
.of select {
  -webkit-appearance: none; appearance: none;
  width: 100%; margin: 0;
  font: inherit; font-size: .95rem;
  color: var(--of-texte);
  padding: .5rem 2.1rem .5rem .75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 122, 26, .45);
  background: var(--of-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;
}
.of select:hover { border-color: var(--of-orange); }
.of select:focus-visible { outline: 2px solid var(--of-vert-clair); outline-offset: 2px; }
.of select:disabled { opacity: .5; cursor: default; }
.of select option { background: #0a0d1c; color: var(--of-texte); }

.of-curseur { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .85rem; }
.of-curseur label { font-size: .85rem; color: var(--of-doux); }
.of-valeur { min-width: 4.3em; text-align: right; font-weight: 600; color: var(--of-orange); }
.of 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(--of-orange) 0, var(--of-grenat-vif) var(--pct, 50%), rgba(255, 255, 255, .14) var(--pct, 50%));
}
.of 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(--of-orange) 62%);
  border: 2px solid #0a0d1c;
  box-shadow: 0 0 0 3px rgba(255, 122, 26, .25), 0 0 14px rgba(255, 122, 26, .6);
}
.of input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff4ea, var(--of-orange) 62%);
  border: 2px solid #0a0d1c;
  box-shadow: 0 0 0 3px rgba(255, 122, 26, .25), 0 0 14px rgba(255, 122, 26, .6);
}
.of input[type=range]::-moz-range-track { background: transparent; }
.of input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--of-vert-clair); outline-offset: 2px; }

.of-interrupteur { position: relative; display: flex; align-items: center; gap: .8rem; cursor: pointer; font-size: .92rem; color: var(--of-texte); }
.of-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;
}
.of-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;
}
.of-interrupteur input:checked + .of-bascule { background: linear-gradient(90deg, var(--of-grenat), var(--of-grenat-vif)); border-color: var(--of-orange); }
.of-interrupteur input:checked + .of-bascule::after { transform: translateX(20px); background: var(--of-orange); box-shadow: 0 0 10px rgba(255, 122, 26, .85); }
.of-interrupteur input:focus-visible + .of-bascule { outline: 2px solid var(--of-vert-clair); outline-offset: 2px; }
.of-interrupteur input:disabled + .of-bascule { opacity: .55; }
.of-interrupteur:has(input:disabled) { cursor: default; }

.of .of-bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  margin: 0;
  padding: .85rem 1.8rem;
  font: inherit; font-size: 1.05rem; font-weight: 600;
  color: #fff4ea;
  border-radius: 999px;
  border: 1px solid var(--of-orange);
  background: linear-gradient(180deg, #b02d44, var(--of-grenat));
  box-shadow: 0 0 0 4px rgba(255, 122, 26, .14), 0 12px 30px rgba(156, 49, 69, .45), inset 0 1px 0 rgba(255, 255, 255, .22);
  cursor: pointer;
  transition: box-shadow .25s, filter .25s;
}
.of .of-bouton: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); }
.of .of-bouton:focus-visible { outline: 2px solid var(--of-vert-clair); outline-offset: 3px; }
.of .of-bouton:disabled { cursor: not-allowed; color: rgba(243, 239, 230, .45); border-color: rgba(255, 255, 255, .15); background: rgba(22, 28, 56, .9); box-shadow: none; }
.of .of-bouton svg { width: 20px; height: 20px; }

/* ---------- Téléphone ---------- */
@media (max-width: 820px) {
  .of-corps { padding: 1rem; }
  .of-barre { padding: .75rem 1rem; }
  .of-etat { display: none; }
}
@media (max-width: 420px) {
  .of-panneau { padding: .9rem .85rem 1rem; }
  .of-curseur { grid-template-columns: 1fr auto; }
  .of-curseur label { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .of *, .of *::before, .of *::after, .of-fenetre { transition: none !important; animation: none !important; }
}
