/* =============================================================
   Latent Differentiation — App layout
   Esthétique sobre, sombre, dispositif de recherche
   ============================================================= */

:root {
  --bg: #0e0e0f;
  --bg-elevated: #18181a;
  --bg-overlay: rgba(14, 14, 15, 0.97);
  --bg-panel: rgba(18, 18, 20, 0.92);
  
  --fg: #e5e5e7;
  --fg-muted: #999;
  --fg-dim: #666;
  --fg-faint: #444;
  
  --accent: #d4cdb8;
  --accent-dim: #8a8470;
  --link: #c8b78a;
  --link-hover: #f0e3b8;
  
  --rule: #2a2a2c;
  --rule-strong: #3a3a3c;
  
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Inter", system-ui, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
  
  --top-bar-h: 60px;
  --bottom-bar-h: 40px;
  --panel-w: 240px;
  --focus-w: 380px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
}

body {
  position: relative;
}

/* =============================================================
   Canvas 3D fullscreen
   ============================================================= */

#canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

#canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* =============================================================
   Top bar
   ============================================================= */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  background: linear-gradient(to bottom, rgba(14, 14, 15, 0.85), rgba(14, 14, 15, 0));
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.brand h1 {
  font-family: var(--font-serif);
  font-size: 1.25em;
  font-weight: 400;
  letter-spacing: -0.005em;
  line-height: 1;
  color: var(--fg);
}

.brand-subtitle {
  font-size: 0.72em;
  font-style: italic;
  color: var(--accent);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.top-nav {
  display: flex;
  gap: 8px;
}

.nav-button {
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 0.78em;
  letter-spacing: 0.05em;
  padding: 7px 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
}

.nav-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* =============================================================
   Left control panel
   ============================================================= */

.control-panel {
  position: fixed;
  top: var(--top-bar-h);
  left: 0;
  bottom: var(--bottom-bar-h);
  width: var(--panel-w);
  padding: 24px 20px;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.control-panel::-webkit-scrollbar {
  width: 6px;
}

.control-panel::-webkit-scrollbar-track {
  background: transparent;
}

.control-panel::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 3px;
}

/* Control groups */

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-title {
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.control-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.control-option {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 0.85em;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.12s ease;
  display: flex;
  align-items: baseline;
  gap: 8px;
  border-radius: 2px;
  width: 100%;
}

.control-option:hover {
  background: rgba(212, 205, 184, 0.05);
  color: var(--fg);
}

.control-option.active {
  background: rgba(212, 205, 184, 0.1);
  color: var(--accent);
  border-color: var(--accent-dim);
}

.option-num {
  font-family: var(--font-mono);
  font-size: 0.75em;
  color: var(--fg-dim);
  min-width: 12px;
  display: inline-block;
}

.control-option.active .option-num {
  color: var(--accent);
}

.option-label {
  flex: 1;
}

.option-hint {
  font-size: 0.78em;
  color: var(--fg-dim);
  font-style: italic;
  margin-left: 4px;
}

.control-option.active .option-hint {
  color: var(--accent-dim);
}

/* Status (en bas du panneau) */

.control-status {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.72em;
  color: var(--fg-dim);
}

.status-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.status-value {
  font-family: var(--font-mono);
  color: var(--fg-muted);
}

/* =============================================================
   Right focus panel (caché par défaut)
   ============================================================= */

.focus-panel {
  position: fixed;
  top: var(--top-bar-h);
  right: 0;
  bottom: var(--bottom-bar-h);
  width: var(--focus-w);
  padding: 24px;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  z-index: 6;
  transform: translateX(0);
  transition: transform 0.3s ease;
}

.focus-panel.hidden {
  transform: translateX(100%);
}

.focus-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--fg-muted);
  font-size: 1.6em;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.focus-close:hover {
  background: var(--rule);
  color: var(--fg);
}

/* =============================================================
   Bottom bar (stats)
   ============================================================= */

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-bar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(to top, rgba(14, 14, 15, 0.85), rgba(14, 14, 15, 0));
  z-index: 5;
  font-size: 0.78em;
  color: var(--fg-muted);
  pointer-events: none;
}

.stat-item strong {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--fg);
}

.stat-sep {
  color: var(--fg-faint);
}

/* =============================================================
   About overlay (visible au chargement, fermable)
   ============================================================= */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 24px;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  position: relative;
  max-width: 720px;
  width: 100%;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.7;
}

.overlay-close {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  color: var(--fg-muted);
  font-size: 1.6em;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.overlay-close:hover {
  background: var(--rule);
  color: var(--accent);
  border-color: var(--accent);
}

/* Overlay header */

.overlay-header {
  margin-bottom: 64px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--rule);
}

.overlay-title {
  font-family: var(--font-serif);
  font-size: 3.2em;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  color: var(--fg);
}

.overlay-subtitle {
  font-family: var(--font-sans);
  font-size: 1em;
  font-style: italic;
  color: var(--accent);
  margin-bottom: 24px;
  letter-spacing: 0.01em;
}

.overlay-author {
  font-family: var(--font-sans);
  font-size: 0.82em;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
}

/* Overlay sections */

.overlay-section {
  margin-bottom: 24px;
}

.overlay-section.hidden {
  display: none;
}

.overlay-section h2 {
  font-family: var(--font-sans);
  font-size: 0.78em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-top: 56px;
  margin-bottom: 20px;
}

.overlay-section > h2:first-child {
  margin-top: 0;
}

.overlay-section p {
  margin-bottom: 22px;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.overlay-section em {
  font-style: italic;
  color: var(--fg);
}

.overlay-section strong {
  font-weight: 500;
  color: var(--accent);
}

/* Overlay levels list */

.overlay-levels {
  list-style: none;
  margin: 24px 0 28px 0;
  padding: 0;
}

.overlay-levels li {
  padding: 16px 0;
  border-top: 1px solid var(--rule);
  font-size: 0.96em;
  line-height: 1.55;
}

.overlay-levels li:last-child {
  border-bottom: 1px solid var(--rule);
}

.level-tag {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.72em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 6px;
}

/* Overlay enter button */

.overlay-enter {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  text-align: center;
}

.enter-button {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 1em;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  padding: 14px 28px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.enter-button:hover {
  background: var(--accent);
  color: var(--bg);
}

/* Overlay footer */

.overlay-footer {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: 0.78em;
  color: var(--fg-muted);
  line-height: 1.55;
}

.overlay-footer p {
  margin-bottom: 12px;
}

.overlay-credits {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  color: var(--fg-dim);
}

.overlay-footer a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.overlay-footer a:hover {
  border-bottom-color: var(--link);
}

/* =============================================================
   Utilities
   ============================================================= */

.hidden {
  /* note : pour focus-panel et overlay, on a une animation propre */
}

/* Focus visible (a11y) */

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--link-hover);
  outline-offset: 3px;
}

/* Sélection */

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* =============================================================
   Probe panel (groupe de contrôles)
   ============================================================= */

.control-group-probe {
  border-top: 1px dashed var(--rule);
  padding-top: 24px;
  margin-top: 12px;
}

.control-group-intro {
  font-family: var(--font-serif);
  font-size: 0.78em;
  color: var(--fg-muted);
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 16px;
  margin-top: -4px;
}

.probe-subsection {
  margin-bottom: 16px;
}

.probe-subtitle {
  font-size: 0.65em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

.prompt-family {
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 2px;
}

.prompt-family[open] {
  border-color: var(--rule);
}

.prompt-family-summary {
  padding: 6px 8px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78em;
  color: var(--fg-muted);
  user-select: none;
  border-radius: 2px;
  transition: all 0.12s ease;
}

.prompt-family-summary::-webkit-details-marker {
  display: none;
}

.prompt-family-summary::before {
  content: "▸";
  margin-right: 6px;
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--fg-dim);
}

.prompt-family[open] .prompt-family-summary::before {
  transform: rotate(90deg);
}

.prompt-family-summary:hover {
  color: var(--accent);
  background: rgba(212, 205, 184, 0.04);
}

.prompt-family-label {
  flex: 1;
}

.prompt-family-count {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--fg-dim);
  letter-spacing: 0.02em;
}

.prompt-list {
  padding: 4px 0 6px 18px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.prompt-option {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 0.8em;
  text-align: left;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.1s ease;
  border-radius: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.prompt-option:hover {
  background: rgba(212, 205, 184, 0.05);
  color: var(--fg);
}

.prompt-option.active {
  background: rgba(212, 205, 184, 0.12);
  color: var(--accent);
  border-color: var(--accent-dim);
}

.prompt-option-id {
  flex: 1;
  letter-spacing: 0.01em;
}

.prompt-l1-tag {
  font-family: var(--font-mono);
  font-size: 0.65em;
  background: var(--rule);
  color: var(--fg-dim);
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 0.05em;
}

.prompt-option.active .prompt-l1-tag {
  background: var(--accent-dim);
  color: var(--bg);
}

.probe-clear {
  margin-top: 12px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 0.75em;
  padding: 8px;
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.15s ease;
}

.probe-clear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* =============================================================
   Responsive — tablette / mobile
   ============================================================= */

@media (max-width: 900px) {
  :root {
    --panel-w: 200px;
    --focus-w: 100vw;
  }
  
  .brand-subtitle {
    display: none;
  }
}

@media (max-width: 640px) {
  :root {
    --panel-w: 100vw;
    --top-bar-h: 50px;
  }
  
  .control-panel {
    transform: translateY(100%);
    transition: transform 0.3s ease;
    top: auto;
    bottom: 0;
    height: 60vh;
    border-right: none;
    border-top: 1px solid var(--rule);
  }
  
  .overlay-title {
    font-size: 2.2em;
  }
  
  .overlay-content {
    font-size: 16px;
  }
  
  .top-bar {
    padding: 0 16px;
  }
  
  .brand h1 {
    font-size: 1.05em;
  }
  
  .nav-button {
    padding: 6px 10px;
    font-size: 0.72em;
  }
  
  .bottom-bar {
    font-size: 0.7em;
    gap: 8px;
    padding: 0 16px;
  }
}
