/* ProPlay — variables de design. AUCUNE couleur/taille en dur ailleurs. */

:root {
  /* Échelle globale façon Blender (réglage ui.scale) */
  --ui-scale: 1;

  /* Typographie */
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  --fs-base: 12px;
  --fs-sm: calc(11px * var(--ui-scale));
  --fs: calc(var(--fs-base) * var(--ui-scale));
  --fs-lg: calc(14px * var(--ui-scale));

  /* Espacements et tailles (tous proportionnels) */
  --sp-1: calc(2px * var(--ui-scale));
  --sp-2: calc(4px * var(--ui-scale));
  --sp-3: calc(8px * var(--ui-scale));
  --sp-4: calc(12px * var(--ui-scale));
  --row-h: calc(22px * var(--ui-scale));      /* hauteur d'une ligne de réglage */
  --header-h: calc(26px * var(--ui-scale));   /* en-tête de zone */
  --radius: calc(4px * var(--ui-scale));
  --border: 1px;

  /* Mouvement : court et discret */
  --t-fast: 80ms;
  --t: 150ms;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Thème sombre (défaut) : DA PROPLAY, rouge laqué sur fond noir */
  --bg-app: #08080a;
  --bg-zone: #0e0c0e;
  --bg-header: #151214;
  --bg-field: #221c1f;
  --bg-field-hover: #2e2629;
  --bg-field-active: #a8101a;
  --bg-menu: #0b090a;
  --line: #1b181b;
  --line-soft: #2e2a2d;
  --text: #f2f0f2;
  --text-dim: #948c90;
  --accent: #e8141f;
  --focus: #ff4a5c;
  --bid: #f2f0f2;
  --ask: #ff2a36;
  --up: #ffffff;
  --down: #e8141f;
  --warn: #ffcc4d;

  color-scheme: dark;
}

/* Sombre doux pour longues sessions */
:root[data-theme="dim"] {
  --bg-app: #202124;
  --bg-zone: #25262a;
  --bg-header: #2c2d31;
  --bg-field: #36373c;
  --text: #cfd0d4;
  --text-dim: #8d8e95;
  --accent: #6b93d6;
}

/* Daltonien : bleu / orange au lieu de vert / rouge */
:root[data-theme="cvd"] {
  --bid: #3b82f6;
  --ask: #f59e0b;
  --up: #3b82f6;
  --down: #f59e0b;
}

@media (prefers-reduced-motion: reduce) {
  :root { --t-fast: 0ms; --t: 0ms; }
}

/* ——— Base ——— */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-app);
  color: var(--text);
  font: var(--fs)/1.3 var(--font-ui);
  overflow: hidden;              /* l'appli ne défile jamais : ce sont les zones qui défilent */
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
input, select, button { font: inherit; color: inherit; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ——— Squelette de l'appli ——— */
.pp-app {
  display: grid;
  grid-template-rows: var(--header-h) minmax(0, 1fr) auto var(--header-h);
  height: 100dvh;
}
.pp-topbar, .pp-statusbar {
  display: flex; align-items: center; gap: var(--sp-3);
  min-width: 0; padding: 0 var(--sp-3);
  background: var(--bg-header); border-bottom: var(--border) solid var(--line);
}
.pp-statusbar { border-bottom: 0; border-top: var(--border) solid var(--line); color: var(--text-dim); }
.pp-workspaces {
  display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  min-width: 0; gap: var(--sp-1);
}
.pp-workspaces [role="tab"] {
  flex: none; padding: 0 var(--sp-3); height: calc(var(--header-h) - 6px);
  border: 0; border-radius: var(--radius); background: transparent; color: var(--text-dim);
  white-space: nowrap; cursor: pointer;
}
.pp-workspaces [role="tab"][aria-selected="true"] { background: var(--bg-field); color: var(--text); }
.pp-dock { min-width: 0; min-height: 0; }

/* ——— Zones / éditeurs ——— */
.pp-editor {
  display: flex; flex-direction: column;
  width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--bg-zone);
}
.pp-editor.is-hovered { outline: 1px solid var(--line-soft); outline-offset: -1px; }
.pp-editor canvas { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; }

/* ——— Panneau Propriétés ——— */
.pp-properties { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.pp-properties__search {
  margin: var(--sp-2); height: var(--row-h); padding: 0 var(--sp-3);
  border: 0; border-radius: var(--radius); background: var(--bg-field);
}
.pp-properties__body { overflow-y: auto; min-height: 0; padding-bottom: var(--sp-4); }
.pp-section > summary {
  display: flex; align-items: center; height: var(--row-h); padding: 0 var(--sp-3);
  background: var(--bg-header); cursor: pointer; list-style: none; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pp-section > summary::before { content: "▸"; margin-right: var(--sp-2); transition: transform var(--t-fast); }
.pp-section[open] > summary::before { transform: rotate(90deg); }
.pp-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: var(--sp-2); align-items: center; min-height: var(--row-h);
  padding: var(--sp-1) var(--sp-3);
}
.pp-row__label {
  color: var(--text-dim); text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@container (max-width: 220px) {
  .pp-row { grid-template-columns: minmax(0, 1fr); }
  .pp-row__label { text-align: left; }
}
.pp-properties__body { container-type: inline-size; }

/* ——— Widgets ——— */
.w {
  display: flex; align-items: center; min-width: 0; height: var(--row-h);
  border-radius: var(--radius); background: var(--bg-field);
  transition: background var(--t-fast) var(--ease);
  outline: none;
}
.w:hover { background: var(--bg-field-hover); }
.w:focus-visible, .w:focus-within { box-shadow: 0 0 0 1px var(--focus); }

.w-number { position: relative; justify-content: center; cursor: ew-resize; overflow: hidden; }
.w-number__fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: var(--bg-field-active); opacity: .55; pointer-events: none;
}
.w-number__text {
  position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.w-number__arrow {
  position: relative; flex: none; width: var(--row-h); height: 100%;
  border: 0; background: transparent; color: var(--text-dim); cursor: pointer; opacity: 0;
}
.w-number:hover .w-number__arrow { opacity: 1; }
.w-number__arrow--l { margin-right: auto; }
.w-number__arrow--r { margin-left: auto; }
.w-number__input {
  width: 100%; height: 100%; border: 0; padding: 0 var(--sp-3);
  background: var(--bg-app); text-align: center; font-family: var(--font-mono); outline: none;
}
.w-number.is-dragging { background: var(--bg-field-active); }

.w-toggle { gap: var(--sp-2); padding: 0 var(--sp-2); background: transparent; cursor: pointer; }
.w-toggle__box {
  flex: none; width: calc(14px * var(--ui-scale)); height: calc(14px * var(--ui-scale));
  border-radius: calc(3px * var(--ui-scale)); background: var(--bg-field);
  display: grid; place-items: center; font-size: var(--fs-sm);
}
.w-toggle[aria-checked="true"] .w-toggle__box { background: var(--accent); }
.w-toggle[aria-checked="true"] .w-toggle__box::after { content: "✓"; }

.w-select { padding: 0 var(--sp-3); border: 0; cursor: pointer; appearance: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-color { padding: var(--sp-1); cursor: pointer; }
.w-color__swatch { flex: 1; height: 100%; border-radius: calc(var(--radius) - 1px); }
.w-color input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.w-button {
  justify-content: center; padding: 0 var(--sp-3); border: 0; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.w-button:active { background: var(--bg-field-active); }

/* ——— Info-bulles, menus, palette, toasts (overlays : seuls position:fixed autorisés) ——— */
.pp-tooltip, .pp-menu, .pp-palette, .pp-toast {
  position: fixed; z-index: 1000; background: var(--bg-menu); color: var(--text);
  border: var(--border) solid var(--line-soft); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgb(0 0 0 / .45);
  animation: pp-pop var(--t) var(--ease);
}
.pp-tooltip { max-width: min(320px, 90vw); padding: var(--sp-2) var(--sp-3); pointer-events: none; }
.pp-tooltip kbd, .pp-menu kbd, .pp-palette kbd {
  font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-dim);
}
.pp-menu { min-width: 180px; max-width: 90vw; padding: var(--sp-1); }
.pp-menu__item, .pp-palette__item {
  display: flex; align-items: center; gap: var(--sp-3); height: var(--row-h);
  padding: 0 var(--sp-3); border-radius: calc(var(--radius) - 1px); cursor: pointer; white-space: nowrap;
}
.pp-menu__item > span:first-child, .pp-palette__item > span:first-child {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.pp-menu__item:hover, .pp-palette__item.is-active { background: var(--accent); }
.pp-palette {
  top: 15vh; left: 50%; transform: translateX(-50%);
  width: min(560px, 92vw); display: flex; flex-direction: column; max-height: 60vh;
}
.pp-palette input {
  height: calc(var(--row-h) * 1.6); padding: 0 var(--sp-4); border: 0;
  border-bottom: var(--border) solid var(--line-soft); background: transparent; outline: none;
  font-size: var(--fs-lg);
}
.pp-palette__list { overflow-y: auto; min-height: 0; padding: var(--sp-1); }
.pp-toast { bottom: calc(var(--header-h) + var(--sp-4)); left: 50%; transform: translateX(-50%);
  padding: var(--sp-2) var(--sp-4); white-space: nowrap; }

@keyframes pp-pop { from { opacity: 0; transform: translateY(2px) scale(.98); } }
.pp-palette, .pp-toast { animation-name: pp-pop-center; }
@keyframes pp-pop-center { from { opacity: 0; transform: translate(-50%, 4px); } }
