/* Palette DA reprise de CarrouselHudWidget.cpp */
@font-face { font-family: "Marcellus"; src: url("../public/fonts/Marcellus-Regular.ttf"); }
@font-face { font-family: "Jost"; src: url("../public/fonts/Jost-Light.ttf"); font-weight: 300; }

:root {
  --gold: #C98A67;
  --gold-text: #D8A882;
  --gold-overline: #E0AA72;
  --text: #D9D8D4;
  --title: #E6E4DF;
  --muted: #8E8D89;
  --body: #B9B8B4;
  --panel: rgba(16, 17, 21, 0.89);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #2a2b30 0%, #121317 70%, #0b0c0f 100%);
  color: var(--text); font-family: "Jost", system-ui, sans-serif; font-weight: 300;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#leaders { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#labels { position: fixed; inset: 0; pointer-events: none; }

.label {
  position: absolute; transform: translateY(-50%); white-space: nowrap;
  font-size: 13px; letter-spacing: .04em; color: var(--text);
  padding: 3px 8px; border: 1px solid rgba(217,216,212,.22); border-radius: 3px;
  background: rgba(16,17,21,.55); pointer-events: auto; cursor: pointer;
  transition: opacity .2s, border-color .2s;
}
.label:hover { border-color: var(--gold); color: var(--gold-text); }
.label.left { transform: translate(-100%, -50%); }

/* Logo centre en haut de la fenetre, indications de l'etape juste en dessous */
#brand { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); width: min(640px, calc(100% - 32px));
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; pointer-events: none; }
#brand img { height: 42px; opacity: .85; }
.overline { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold-overline); }
.step .title { font-family: "Marcellus", serif; font-size: 24px; color: var(--title); margin: 4px 0 2px; }
.step .helper { font-size: 13px; color: var(--muted); }

#hud { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; }
#hud button, #infoClose {
  font: inherit; font-size: 13px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text); background: rgba(255,255,255,.0); cursor: pointer;
  border: 1px solid rgba(217,216,212,.22); border-radius: 3px; padding: 10px 18px;
  transition: border-color .15s, background .15s;
}
#hud button:hover { border-color: rgba(217,216,212,.4); background: rgba(255,255,255,.06); }
#hud button.gold { color: var(--gold-text); border-color: rgba(201,138,103,.65); }
#hud button.gold:hover { border-color: rgba(201,138,103,.85); background: rgba(201,138,103,.08); }
#hud button.round { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 18px; letter-spacing: 0;
  border-color: rgba(217,216,212,.45); background: rgba(255,255,255,.04); }
#hud button.round.off { color: var(--muted); border-style: dashed; }
#hud button:disabled { opacity: .35; cursor: default; }

#info {
  position: fixed; top: 0; right: 0; bottom: 0; width: 25vw; min-width: 280px; max-width: 460px;
  background: linear-gradient(to bottom, var(--panel) 60%, rgba(16,17,21,0));
  padding: 64px 32px 32px; animation: slide .35s ease-out;
}
#info[hidden] { display: none; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
#infoClose { position: absolute; top: 18px; right: 18px; padding: 6px 12px; color: var(--body); }
#info h1 { font-family: "Marcellus", serif; font-weight: normal; font-size: 30px; color: var(--title); margin: 8px 0 14px; }
#info .rule { width: 48px; height: 1px; background: var(--gold); margin-bottom: 18px; }
#info p { font-size: 15px; line-height: 1.6; color: var(--body); }

#tooltip { position: fixed; pointer-events: none; font-size: 12px; letter-spacing: .06em; padding: 3px 8px;
  background: rgba(16,17,21,.8); border: 1px solid rgba(201,138,103,.5); border-radius: 3px; color: var(--gold-text); }
#version { position: fixed; bottom: 10px; left: 14px; font-size: 11px; color: rgba(142,141,137,.6); }

#loading { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center;
  background: #0b0c0f; transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading .bar { width: 220px; height: 1px; background: rgba(217,216,212,.15); }
#loadingFill { height: 100%; width: 0; background: var(--gold); transition: width .2s; }
#loadingText { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }

@media (max-width: 700px) {
  #brand { top: 14px; gap: 6px; }
  #brand img { height: 30px; }
  .step .title { font-size: 20px; }
  #info { width: 100%; max-width: none; top: auto; height: 50%; }
  #hud button { padding: 9px 12px; letter-spacing: .08em; }
}
#hud button[hidden] { display: none; }
#hud button { white-space: nowrap; }
/* lisibilite sur le bureau (cuir / bois clairs) */
#brand, #version { text-shadow: 0 1px 8px rgba(0,0,0,.85), 0 0 2px rgba(0,0,0,.6); }
#hud button { background: rgba(16,17,21,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

/* --- HUD V8 : boutons ronds a icones, etat actif dore, volet Historique --- */
#hud button.active { color: var(--gold-text); border-color: rgba(201,138,103,.65); }
#round { position: fixed; right: 24px; bottom: 32px; display: flex; gap: 12px; }
#round button.round {
  width: 48px; height: 48px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(217,216,212,.45); background: rgba(16,17,21,.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: grid; place-items: center; transition: border-color .15s, background .15s;
}
#round button.round:hover { border-color: rgba(217,216,212,.8); background: rgba(255,255,255,.08); }
#round button.round:disabled { opacity: .35; cursor: default; }
#round button.round i {
  width: 22px; height: 22px; background: var(--text);
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
#round button.round.active { border-color: var(--gold); }
#round button.round.active i { background: var(--gold-text); }
#hud { bottom: 32px; }
#version .wordmark { letter-spacing: .22em; text-transform: uppercase; }
.group-label { pointer-events: none; font-size: 14px; letter-spacing: .2em; text-transform: uppercase;
  border: none; background: none; color: #C9C8C4; text-shadow: 1.5px 1.5px 2px rgba(0,0,0,.85); }

#historique {
  position: fixed; top: 0; right: 0; bottom: 0; width: 33vw; min-width: 300px; max-width: 560px;
  background: var(--panel); padding: 44px 34px 36px; animation: slide .35s ease-out;
}
#historique[hidden] { display: none; }
#historique .scroll { height: 100%; overflow-y: auto; padding-right: 10px; }
#historique .scroll::-webkit-scrollbar { width: 4px; }
#historique .scroll::-webkit-scrollbar-thumb { background: rgba(142,141,137,.55); border-radius: 2px; }
#historique h1 { font-family: "Marcellus", serif; font-weight: normal; font-size: 30px; color: var(--title); margin: 8px 0 14px; }
#historique h2 { font-family: "Marcellus", serif; font-weight: normal; font-size: 19px; color: var(--gold-text); margin: 26px 0 8px; }
#historique .rule { width: 48px; height: 1px; background: var(--gold); margin-bottom: 18px; }
#historique p { font-size: 15px; line-height: 1.6; color: var(--body); margin: 0 0 10px; }
#historique .media { margin: 16px 0; padding: 26px 16px; border: 1px solid rgba(217,216,212,.35); border-radius: 6px;
  background: rgba(255,255,255,.03); color: var(--muted); font-size: 13px; letter-spacing: .04em; text-align: center; }
#historiqueClose { position: absolute; top: 12px; right: 14px; font: inherit; font-size: 20px; color: var(--body);
  background: none; border: none; cursor: pointer; padding: 6px 10px; }
@media (max-width: 700px) {
  #historique { width: 100%; max-width: none; }
  #round { right: 12px; bottom: 90px; flex-direction: column; }
}
#groupLabels { position: fixed; inset: 0; pointer-events: none; }
#hud, #round { z-index: 5; } #historique, #info { z-index: 4; }
#groupLeaders { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* --- Reglages de rendu en direct (?reglages ou touche R) --- */
#tuning {
  position: fixed; left: 14px; bottom: 34px; width: 270px; padding: 12px 14px 14px;
  background: var(--panel); border: 1px solid rgba(217,216,212,.22); border-radius: 3px;
  display: flex; flex-direction: column; gap: 10px; font-size: 13px;
}
#tuning[hidden] { display: none; }
#tuning { max-height: calc(100vh - 60px); }
#tuningBody { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; padding-right: 4px; }
#tuningBody details { display: flex; flex-direction: column; }
#tuningBody details[open] > label { margin-top: 10px; }
#tuningBody summary { cursor: pointer; list-style: none; padding-right: 28px; }
#tuningBody summary::-webkit-details-marker { display: none; }
#tuningBody summary::before { content: '\25B8'; display: inline-block; width: 1.1em; transition: transform .15s; }
#tuningBody details[open] > summary::before { transform: rotate(90deg); }
#tuning input[type=color] { width: 100%; height: 24px; padding: 0; border: 1px solid rgba(217,216,212,.22);
  border-radius: 3px; background: none; cursor: pointer; }
#tuningClose { position: absolute; top: 8px; right: 8px; }
#tuning label { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; color: var(--body); }
#tuning output { color: var(--gold-text); font-variant-numeric: tabular-nums; }
#tuning input[type=range] { width: 100%; accent-color: var(--gold); }
#tuning button {
  font: inherit; color: var(--text); background: none; cursor: pointer;
  border: 1px solid rgba(217,216,212,.22); border-radius: 3px; padding: 5px 10px;
}
#tuning button:hover { border-color: rgba(217,216,212,.45); }
#tuningClose { padding: 0 8px !important; font-size: 16px !important; }

/* --- page comparative : boutons ronds a texte (fil de fer, CAO) --- */
#round button.round.text { font-size: 11px; letter-spacing: .08em; color: var(--text); }
#round button.round.text.active { color: var(--gold-text); border-color: var(--gold); }
#round button.round[hidden] { display: none; }
#round button.round.mini { width: 26px; height: 26px; font-size: 10px; align-self: center; opacity: .55; }
#round button.round.mini:hover { opacity: 1; }


/* Historique : medias (images, image animee, video en boucle) */
#historique .media-fig { margin: 16px 0; border-radius: 6px; overflow: hidden; background: #000;
  border: 1px solid rgba(217,216,212,.18); }
#historique .media-fig img, #historique .media-fig video { display: block; width: 100%; height: auto; }

/* Photo : bref eclair blanc a la prise de vue */
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 6; }
#flash.on { animation: photoFlash .45s ease-out; }
@keyframes photoFlash { from { opacity: .55; } to { opacity: 0; } }

/* ===== PROPOSITION MENUS : menu principal fixe + barre d'outils du mode actif au-dessus ===== */
#mainMenu { position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 5; }
#mainMenu button {
  font: inherit; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; white-space: nowrap;
  color: var(--text); cursor: pointer; border: 1px solid rgba(217,216,212,.22); border-radius: 3px; padding: 10px 18px;
  background: rgba(16,17,21,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: border-color .15s, background .15s, color .15s;
}
#mainMenu button:hover { border-color: rgba(217,216,212,.4); background: rgba(255,255,255,.06); }
#mainMenu button.active { color: var(--gold-text); border-color: rgba(201,138,103,.65); }
#mainMenu button:disabled { opacity: .45; cursor: default; }
/* barre d'outils du mode : plus discrete, juste au-dessus du menu principal */
#hud { bottom: 88px; gap: 8px; }
#hud[hidden] { display: none; }
#hud button { font-size: 11px; letter-spacing: .14em; padding: 7px 14px; }
#hud .chevron { font-size: 9px; margin-left: 4px; opacity: .8; }
/* liste des dispositions, ouverte vers le haut */
#layoutWrap { position: relative; display: flex; }
#layoutMenu { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); min-width: 100%;
  display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 4px;
  background: rgba(16,17,21,.82); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid rgba(217,216,212,.22); }
#layoutMenu[hidden] { display: none; }
#layoutMenu button { width: 100%; text-align: left; border-color: transparent; background: none; }
#layoutMenu button:hover { background: rgba(255,255,255,.08); }
#layoutMenu button.active { color: var(--gold-text); }
#layoutMenu button.active::before { content: '\2022'; margin-right: 8px; }
@media (max-width: 700px) {
  #mainMenu { gap: 6px; }
  #mainMenu button { padding: 9px 11px; letter-spacing: .08em; font-size: 12px; }
  #hud { bottom: 80px; }
  #round { bottom: 140px; }
}
/* ecran etroit : les boutons ronds passent en colonne a droite, au-dessus des deux barres (sinon ils
   recouvrent la fin du menu principal) */
@media (max-width: 1000px) {
  #round { right: 12px; bottom: 140px; flex-direction: column; }
}
@media (max-width: 480px) {
  #hud { gap: 5px; bottom: 76px; }
  #hud button { font-size: 10px; letter-spacing: .06em; padding: 6px 9px; }
  #hud .pref { display: none; }
}
/* telephone : le volet d'explication (Principe, fiche de piece) defile au-dessus des deux barres et laisse
   la colonne des boutons ronds a droite */
@media (max-width: 700px) {
  #info { overflow-y: auto; top: 44%; bottom: 0; height: auto; padding: 24px 22px 140px; background: var(--panel); }
}

/* Historique au premier plan : le volet passe au-dessus des menus et des boutons ronds */
#historique { z-index: 7; }
/* bouton de fermeture du volet : meme style que celui des fiches (« Fermer × ») */
#historiqueClose { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--text);
  border: 1px solid rgba(217,216,212,.22); border-radius: 3px; padding: 6px 12px; top: 14px; right: 16px;
  background: rgba(16,17,21,.55); }
#historiqueClose:hover { border-color: rgba(217,216,212,.4); background: rgba(255,255,255,.06); }
/* fiches du mode Details : fond plein jusqu'en bas de l'ecran (plus de degrade vers le transparent) */
#info { background: var(--panel); }

/* telephone en portrait : boutons ronds en colonne en haut a gauche, plus petits ; le bandeau d'etape
   centre se resserre pour ne pas passer dessous */
@media (max-width: 700px) {
  #round { top: 14px; left: 10px; right: auto; bottom: auto; flex-direction: column; gap: 8px; }
  #round button.round { width: 34px; height: 34px; }
  #round button.round i { width: 16px; height: 16px; }
  #brand { width: calc(100% - 104px); }
}

/* ligne doree entre le menu principal et la barre d'outils du mode, centree dans l'espace entre les deux */
#separateur { position: fixed; left: 50%; transform: translateX(-50%); bottom: 74px; width: min(512px, 92vw); height: 24px;
  background: url("../public/ui/T_Separateur_Menus.png") center / 100% 100% no-repeat; pointer-events: none; z-index: 5; }
#separateur[hidden] { display: none; }
#hud { bottom: 100px; }
@media (max-width: 700px) {
  #separateur { bottom: 72px; height: 18px; }
  #hud { bottom: 92px; }
}
@media (max-width: 480px) {
  #hud { bottom: 92px; }
}

/* diagnostic ?flou=0 : sans effet de verre depoli (backdrop-filter), couteux sur telephone au-dessus de la 3D */
.sans-flou *, .sans-flou *::before, .sans-flou *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
