/* ==========================================================================
   Configurateur 3D SOA — thème « précision industrielle »
   Langage : marquage au sol d'atelier + fiche technique.
   Charte : jaune #FFDD00 / noir / blanc — motif : les cases du logo.
   ========================================================================== */

@font-face {
  font-family: 'Barlow Semi Condensed';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/barlow-semi-condensed-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/barlow-semi-condensed-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/barlow-semi-condensed-700.woff2') format('woff2');
}

:root {
  --y: #FFDD00;
  --y-dark: #e6c600;
  --bg: #0c0c0c;
  --panel: #101010;
  --hairline: rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --txt: #ececec;
  --muted: #9a9a9a;
  --faint: #6e6e6e;
  --font: 'Barlow Semi Condensed', 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  /* App installé sur l'écran d'accueil iOS : ne pas passer sous la barre home */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  letter-spacing: 0;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  /* App installé sur l'écran d'accueil iOS : ne pas passer sous l'encoche */
  padding: calc(11px + env(safe-area-inset-top, 0px))
           calc(22px + env(safe-area-inset-right, 0px))
           11px
           calc(22px + env(safe-area-inset-left, 0px));
  background: #000;
  border-bottom: 1px solid var(--hairline-strong);
  position: relative;
  flex: none;
}
/* Liseré jaune façon marquage : segment, pas pleine largeur. */
.topbar::after {
  content: "";
  position: absolute;
  left: 22px;
  bottom: -1px;
  width: 148px;
  height: 3px;
  background: var(--y);
}

.topbar-logo { height: 34px; width: auto; }

.topbar-title h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: #fff;
}
.topbar-title p {
  margin: 2px 0 0;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.topbar-link {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  padding: 7px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.topbar-link:hover { color: var(--y); border-bottom-color: var(--y); }

/* ------------------------------------------------------------------ layout */

#app {
  flex: 1;
  display: flex;
  min-height: 0;
}

#stage {
  flex: 1.7;
  position: relative;
  min-width: 0;
  background: radial-gradient(1100px 700px at 50% 38%, #1d1d1d 0%, #0a0a0a 100%);
}

model-viewer {
  width: 100%;
  height: 100%;
  min-height: 480px;
  --progress-bar-color: transparent;
}

#panel {
  width: 440px;
  flex: none;
  overflow-y: auto;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 28px),
    var(--panel);
  border-left: 1px solid var(--hairline);
}

/* --------------------------------------------------------------- overlays */

.stage-brand {
  position: absolute;
  left: 20px;
  bottom: 18px;
  pointer-events: none;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 10px;
}
.stage-brand img { height: 26px; display: block; }
.stage-brand::after {
  content: "CONFIGURATEUR PUPITRES";
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--faint);
}

.nav-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 188px;
  background: rgba(8, 8, 8, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--hairline);
  border-top: 2px solid var(--y);
  padding: 12px 14px 11px;
}

.nav-panel h4 {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-panel .sq { display: none; }

#view-buttons button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #9a9a9a;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 7px 2px 7px 16px;
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}
#view-buttons button::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border: 1px solid #555;
  transition: background 0.15s, border-color 0.15s;
}
#view-buttons button:hover { color: #fff; }
#view-buttons button.active { color: var(--y); }
#view-buttons button.active::before { background: var(--y); border-color: var(--y); }

.nav-hints {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--hairline);
}
.nav-hints p { margin: 0; font-size: 10.5px; line-height: 1.75; color: #8c8c8c; }
.nav-hints span { color: var(--y); }

/* --- carte de chargement --- */

.loading-card {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 240px;
  height: fit-content;
  background: rgba(10, 10, 10, 0.92);
  border: 1px solid var(--hairline-strong);
  border-top: 2px solid var(--y);
  padding: 20px 22px;
  backdrop-filter: blur(8px);
}
.loading-card.hide { display: none; }

.loading-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--txt);
  margin-bottom: 12px;
}
.loading-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin-bottom: 8px;
}
.loading-fill {
  width: 0%;
  height: 100%;
  background: var(--y);
  transition: width 0.25s ease-out;
}
.loading-pct {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ étapes */

.step-block {
  padding: 22px 24px;
  border-bottom: 1px solid var(--hairline);
  animation: step-in 0.45s cubic-bezier(0.2, 0.6, 0.2, 1) both;
}
.step-block:nth-child(1) { animation-delay: 0.05s; }
.step-block:nth-child(2) { animation-delay: 0.12s; }
.step-block:nth-child(3) { animation-delay: 0.19s; }
.step-block:nth-child(4) { animation-delay: 0.26s; }
.step-block:nth-child(5) { animation-delay: 0.33s; }
@keyframes step-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.step-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.step-num {
  font-size: 27px;
  font-weight: 700;
  line-height: 1;
  color: var(--y);
  flex: none;
  letter-spacing: 0.02em;
}
.step-num::before { content: "0"; opacity: 0.45; }
.step-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #fff;
  flex: 1;
  position: relative;
  top: -2px;
}
.step-head h2::after {
  content: "";
  display: block;
  margin-top: 7px;
  height: 1px;
  background: linear-gradient(90deg, var(--hairline-strong), transparent);
}

.hint { color: var(--faint); font-size: 12px; margin: 10px 0 0; }

/* --- cartes pupitre --- */

.pupitre-cards { display: flex; gap: 10px; }

.pupitre-card {
  flex: 1;
  padding: 14px 12px 12px;
  background: transparent;
  border: 1px solid var(--hairline);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.pupitre-card .name {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--txt);
  line-height: 1;
}
.pupitre-card .desc {
  font-size: 9.5px;
  color: var(--faint);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.55;
}
.pupitre-card:hover { border-color: var(--hairline-strong); background: rgba(255, 255, 255, 0.02); }
.pupitre-card.active { border-color: rgba(255, 221, 0, 0.55); }
.pupitre-card.active .name { color: var(--y); }
/* Coin renforcé façon marquage au sol. */
.pupitre-card.active::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  width: 12px;
  height: 12px;
  border-top: 3px solid var(--y);
  border-left: 3px solid var(--y);
}

/* --- interrupteur mur d'images --- */

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 13.5px;
  user-select: none;
}
.switch-row input { position: absolute; opacity: 0; }
.switch {
  width: 42px;
  height: 22px;
  background: #262626;
  border: 1px solid var(--hairline-strong);
  position: relative;
  flex: none;
  transition: background 0.2s, border-color 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #0c0c0c;
  border: 1px solid #565656;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}
.switch-row input:checked + .switch { background: var(--y); border-color: var(--y); }
.switch-row input:checked + .switch::after { transform: translateX(20px); border-color: #000; }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--y); outline-offset: 2px; }

/* --- liste des parties --- */

.part-list { display: flex; flex-direction: column; }

.part-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 10px 11px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  position: relative;
  transition: background 0.15s;
}
.part-btn:first-child { border-top: 1px solid var(--hairline); }
.part-btn::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border: 1px solid #4a4a4a;
  transition: background 0.15s, border-color 0.15s;
}
.part-btn:hover { background: rgba(255, 255, 255, 0.025); }
.part-btn.active { background: rgba(255, 221, 0, 0.05); }
.part-btn.active::before { background: var(--y); border-color: var(--y); }
.part-btn .part-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--txt);
}
.part-btn.active .part-name { color: var(--y); }
.part-btn .part-finish {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  line-height: 1.5;
}
.part-btn .part-finish code { color: var(--faint); display: block; font-size: 10px; }
.part-btn.active .part-finish code { color: rgba(255, 221, 0, 0.75); }

/* --- nuanciers --- */

.finish-category { margin-bottom: 14px; }
.finish-category h3 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--muted);
  margin: 16px 0 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.finish-category h3::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--y);
  flex: none;
}

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }

/* Échantillons carrés, comme un nuancier Egger réel. */
.swatch {
  width: 46px;
  height: 46px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.7);
  box-shadow: 0 0 0 1px var(--hairline-strong);
  cursor: pointer;
  padding: 0;
  background-size: cover;
  background-position: center;
  transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
}
.swatch:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--y), 0 6px 14px rgba(0, 0, 0, 0.55); }
.swatch.selected { box-shadow: 0 0 0 2px var(--y); }
.swatch.selected::after {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  width: 10px;
  height: 10px;
  border-top: 3px solid var(--y);
  border-left: 3px solid var(--y);
}
.swatch.loading { animation: swatch-pulse 0.9s ease-in-out infinite; }
@keyframes swatch-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--y); }
  50% { box-shadow: 0 0 0 5px rgba(255, 221, 0, 0.3); }
}

.finish-selected {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--hairline);
  padding-top: 10px;
}
.finish-selected strong { color: var(--txt); font-weight: 600; }
.finish-selected code { color: rgba(255, 221, 0, 0.8); margin-left: 6px; }

/* --- récapitulatif --- */

.recap {
  border: 1px solid var(--hairline);
  border-top: 2px solid var(--y);
  padding: 14px 16px;
  margin-bottom: 18px;
  background: rgba(0, 0, 0, 0.25);
}
.recap h3 {
  margin: 0 0 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--muted);
}
.recap ul { margin: 0; padding: 0; list-style: none; }
.recap li {
  margin: 0;
  padding: 5px 0;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed var(--hairline);
}
.recap li:last-child { border-bottom: none; }
.recap .val { font-weight: 600; color: var(--txt); text-align: right; }
.recap .val code { color: rgba(255, 221, 0, 0.8); }

/* --- formulaire --- */

.field { margin-bottom: 13px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.field input, .field textarea {
  width: 100%;
  padding: 11px 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--hairline-strong);
  border-radius: 0;
  color: var(--txt);
  font-family: var(--font);
  font-size: 14px;
}
.field input:focus, .field textarea:focus {
  border-color: var(--y);
  box-shadow: 0 0 0 2px rgba(255, 221, 0, 0.22);
  outline: none;
}

/* Piège anti-robots : caché visuellement, présent pour les bots */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  width: 1px; height: 1px;
  overflow: hidden;
}

#submit-btn {
  width: 100%;
  padding: 15px;
  margin-top: 6px;
  background: var(--y);
  color: #000;
  border: none;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
#submit-btn::after {
  content: "→";
  position: absolute;
  right: 16px;
  transition: transform 0.15s;
}
#submit-btn:hover { background: var(--y-dark); }
#submit-btn:hover::after { transform: translateX(4px); }
#submit-btn:disabled { background: #333; color: #808080; cursor: not-allowed; }
#submit-btn:disabled::after { content: ""; }

.form-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; }

.rgpd-note { font-size: 10.5px; color: var(--faint); margin-top: 8px; line-height: 1.6; }
.rgpd-note a { color: rgba(255, 221, 0, 0.85); }

.status-message { margin-top: 14px; padding: 12px 14px; font-size: 13px; border: 1px solid; }
.status-message.success { background: rgba(30, 90, 45, 0.28); color: #8fe3a8; border-color: rgba(60, 160, 90, 0.5); }
.status-message.error { background: rgba(110, 25, 30, 0.28); color: #f0a0a5; border-color: rgba(190, 60, 70, 0.5); }

/* ---------------------------------------------------------------- footer */

.site-footer {
  flex: none;
  background: #000;
  border-top: 1px solid var(--hairline);
  padding: 11px 22px;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.site-footer a { color: inherit; }
.site-footer a:hover { color: var(--y); }

/* -------------------------------------------------------------- responsive */

@media (max-width: 1020px) {
  body { height: auto; min-height: 100dvh; overflow: auto; }
  #app { flex-direction: column; }
  #stage { min-height: 56vh; position: sticky; top: 0; z-index: 5; }
  model-viewer { min-height: 56vh; }
  #panel { width: 100%; border-left: none; border-top: 1px solid var(--hairline); overflow: visible; }
  .nav-panel {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    padding: 6px 8px;
    border-top: 1px solid var(--hairline);
    border-left: 2px solid var(--y);
  }
  .nav-panel h4 { display: none; }
  #view-buttons { display: flex; flex-wrap: wrap; gap: 2px; }
  #view-buttons button { width: auto; flex: 1 1 auto; text-align: center; padding: 8px 6px; font-size: 10.5px; }
  #view-buttons button::before { display: none; }
  #view-buttons button.active { box-shadow: inset 0 -2px 0 var(--y); }
  .nav-hints { display: none; }
  .stage-brand { bottom: auto; top: 14px; left: 14px; }
  .stage-brand img { height: 22px; }
  .stage-brand::after { display: none; }
}

@media (max-width: 560px) {
  .topbar { gap: 10px; }
  .topbar-title h1 { font-size: 13px; letter-spacing: 0.16em; }
  .topbar-title p { display: none; }
  .topbar-link { display: none; }
  .pupitre-cards { flex-direction: column; }
  .field-row { flex-direction: column; gap: 0; }
  #stage { min-height: 48vh; }
  model-viewer { min-height: 48vh; }
}

/* Respect de la préférence « réduire les animations ». */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
