/* ============================================================
   style.css — Glutch
   ============================================================ */

:root {
  --bg: #050505;
  --panel-bg: #121316;
  --panel-bg-alt: #1a1c20;
  --border: #2b2e33;
  --text: #e9e9e7;
  --text-dim: #9aa0a6;
  --accent: #46e0c4;
  --accent-dim: rgba(70, 224, 196, 0.18);
  --danger: #e05a46;
  --key-red: #ff5f52;

  --sidebar-width: 360px;
  --toggle-size: 38px;
  --transition: 240ms ease;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

#app {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
}

#canvas-wrap canvas { display: block; }

#sidebar-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  width: var(--toggle-size);
  height: var(--toggle-size);
  padding: 0;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: right var(--transition), background var(--transition), border-color var(--transition);
}

#sidebar-toggle:hover { border-color: var(--accent); color: var(--accent); }
#app.sidebar-open #sidebar-toggle { right: calc(var(--sidebar-width) + 12px); }

#sidebar {
  position: relative;
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  margin-right: calc(-1 * var(--sidebar-width));
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  transition: margin-right var(--transition);
  z-index: 15;
}

#app.sidebar-open #sidebar { margin-right: 0; }

#sidebar::-webkit-scrollbar { width: 10px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); }

.sidebar__header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 10px;
}

.sidebar__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sidebar__title {
  margin: 0 0 10px;
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--text);
}

.sidebar__title small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

.quickbar-toggle {
  display: none;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.quickbar-toggle:hover { border-color: var(--accent); color: var(--accent); }
#quick-actions.collapsed { display: none; }

#app.kiosk #sidebar-toggle,
#app.kiosk #sidebar { display: none; }

.sidebar__fps {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.sidebar__body { padding: 4px 0 40px; }

/* ---------- Groupes repliables ---------- */

details.panel { border-bottom: 1px solid var(--border); }

details.panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

details.panel > summary::-webkit-details-marker { display: none; }

details.panel > summary::after {
  content: '+';
  color: var(--text-dim);
  font-weight: normal;
  margin-left: 8px;
}

details.panel[open] > summary::after { content: '\2212'; }
details.panel > summary:hover { color: var(--accent); }
.panel__content { padding: 0 16px 14px; }

details.subpanel {
  margin: 8px 0;
  border: 1px solid var(--border);
  background: var(--panel-bg-alt);
}

details.subpanel > summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

details.subpanel > summary::-webkit-details-marker { display: none; }
details.subpanel > summary::after { content: '+'; }
details.subpanel[open] > summary::after { content: '\2212'; }
.subpanel__content { padding: 0 10px 10px; }

.ui-heading { margin: 4px 0 8px; color: var(--text); }
.ui-heading h3, .ui-heading h4 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-transform: none;
}

.ui-note {
  margin: 4px 0 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
  font-style: italic;
}

/* Note "Raccourcis" : texte blanc, lettres des touches en rouge */
.ui-note--shortcuts {
  color: #ffffff;
  font-style: normal;
}
.ui-note--shortcuts .kbd {
  color: var(--key-red);
  font-weight: 700;
  font-style: normal;
  padding: 0 1px;
}

/* ---------- Contrôles ---------- */

.control { margin: 10px 0; }

.control__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.control__label { font-size: 12px; color: var(--text); }

.control__meta { display: flex; align-items: baseline; gap: 6px; flex: none; }

.control__value {
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
}

.control__midi {
  flex: none;
  font-size: 9.5px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  letter-spacing: 0.03em;
  user-select: none;
}

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

.control__midi.control__midi--fixed {
  border-color: var(--accent-dim);
  color: var(--accent);
  cursor: default;
}

.control__range,
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel-bg);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel-bg);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
}

.control--checkbox > div { display: flex; align-items: center; gap: 8px; }
.control--checkbox label { font-size: 12px; color: var(--text); cursor: pointer; }
.control--checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex: none;
}

.control--select select,
select {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  background: var(--panel-bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 12px;
}

.control--buttonrow { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Boutons ---------- */

.btn {
  padding: 7px 10px;
  background: var(--panel-bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { background: var(--accent-dim); }
.btn.btn--accent { border-color: var(--accent); color: var(--accent); }
.btn.btn--danger { border-color: var(--danger); color: var(--danger); }

.btn:focus-visible,
input[type="range"]:focus-visible,
select:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="file"] {
  width: 100%;
  margin: 6px 0;
  font-size: 11px;
  color: var(--text-dim);
}

input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  background: var(--panel-bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 12px;
}

input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Barre d'actions rapides (compacte, 2 lignes max) ---------- */

.sidebar__quickbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  max-height: 56px;      /* ~2 lignes */
  overflow: hidden;
}

.sidebar__quickbar .btn {
  padding: 4px 7px;
  font-size: 10px;
  letter-spacing: 0.01em;
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ============================================================
   MODE MOBILE
   ============================================================ */

body.mode-mobile #sidebar,
body.mode-mobile #sidebar-toggle { display: none !important; }

.ui-mobile-bar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 100;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ui-mobile-btn {
  pointer-events: auto;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.28);
  color: rgba(255, 255, 255, 0.92);
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  transition: background-color 120ms ease, transform 80ms ease, border-color 120ms ease;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.ui-mobile-btn.ui-pressed,
.ui-mobile-btn:active {
  background: rgba(70, 224, 196, 0.45);
  border-color: rgba(70, 224, 196, 0.9);
  color: #ffffff;
  transform: scale(0.90);
}

/* Très petits écrans (iPhone SE, etc.) */
@media (max-width: 360px) {
  .ui-mobile-btn { width: 44px; height: 44px; font-size: 17px; }
  .ui-mobile-bar { gap: 8px; }
}

/* Tablette / grands écrans tactiles */
@media (min-width: 700px) {
  .ui-mobile-btn { width: 56px; height: 56px; font-size: 20px; }
  .ui-mobile-bar { gap: 14px; }
}

/* ============================================================
   Responsive sidebar (fenêtre desktop étroite)
   ============================================================ */

@media (max-width: 860px) {
  :root { --sidebar-width: min(88vw, 380px); }
  html, body { font-size: 13px; }

  #sidebar {
    position: fixed;
    top: 0;
    right: 0;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
    background: rgba(18, 19, 22, 0.72);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    backdrop-filter: blur(14px) saturate(1.3);
  }

  .sidebar__header { background: transparent; padding: 10px 12px 6px; }
  #app.sidebar-open #sidebar-toggle { right: 12px; }
  .quickbar-toggle { display: inline-flex; }

  .panel__content { padding: 0 12px 10px; }
  details.panel > summary { padding: 9px 12px; font-size: 12px; }
  .control { margin: 7px 0; }
  .control__label { font-size: 11px; }
  .control__value { font-size: 10px; }
  .btn { padding: 6px 8px; font-size: 10.5px; }
  .sidebar__quickbar { gap: 3px; }
  .sidebar__quickbar .btn { padding: 3px 6px; font-size: 9.5px; }
  .ui-note { font-size: 10.5px; margin: 3px 0 7px; }
}

@media (prefers-reduced-motion: reduce) {
  #sidebar, #sidebar-toggle { transition: none; }
}