/* ================= TOKENS ================= */
:root {
  --bg: #0a0a0a;
  --fg: #efefef;
  --muted: #8c8c8c;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #2e3cff;             /* suit la palette active (main.js) */
  --blue: #2e3cff;
  --panel-dark: #111111;
  --mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --pad: clamp(14px, 1.8vw, 28px);
  --ease: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  cursor: none;
}
@media (hover: none) { body { cursor: auto; } }
a, button { color: inherit; text-decoration: none; background: none; border: 0; font: inherit; cursor: none; }
@media (hover: none) { a, button { cursor: pointer; } }
::selection { background: var(--blue); color: #fff; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; text-transform: uppercase; }
.muted { color: var(--muted); }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; }

/* ================= CURSOR ================= */
#cursor {
  position: fixed; left: 0; top: 0; z-index: 400; pointer-events: none;
  width: 0; height: 0; mix-blend-mode: difference;
}
#cursor::before {
  content: ""; position: absolute; left: -42px; top: -42px; width: 84px; height: 84px; border-radius: 50%;
  background: #fff; scale: 0.1667; transition: scale .4s var(--ease-out);
}
#cursor.big::before { scale: 1; }
#cursor.drag::before { scale: 0.45; }
#cursor-label {
  position: absolute; left: 0; top: 0; translate: -50% -50%; white-space: nowrap;
  font-family: var(--mono); font-size: 10px; color: #000; text-transform: uppercase; opacity: 0; transition: opacity .2s;
}
#cursor.big #cursor-label { opacity: 1; }
@media (hover: none) { #cursor { display: none; } }

/* ================= UI SHELL ================= */
.ui { position: fixed; z-index: 10; transition: opacity .5s var(--ease-out); }
body.ui-hidden .ui { opacity: 0; pointer-events: none; }
body.ui-hidden .ui * { pointer-events: none; }

#top { top: 0; left: 0; right: 0; padding: var(--pad); display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; pointer-events: none; }
#top > * { pointer-events: auto; }
.logo { display: grid; gap: 4px; }
.logo-name { font-weight: 800; font-stretch: 125%; font-size: 15px; letter-spacing: -0.01em; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pills button {
  height: 30px; padding: 0 12px; display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: 30px;
  transition: background .25s, color .25s, border-color .25s;
}
.pills button:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.pills button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

#hint { left: 50%; bottom: 150px; transform: translateX(-50%); color: var(--muted); white-space: nowrap; pointer-events: none; }
body.has-source #hint { opacity: 0; }

/* ================= BOTTOM ================= */
#bottom {
  left: 0; right: 0; bottom: 0; padding: var(--pad);
  display: grid; grid-template-columns: 240px minmax(0, 1fr) 240px;
  gap: 24px; align-items: end; pointer-events: none;
}
#bottom > * { pointer-events: auto; }

.meters { display: grid; gap: 7px; width: min(240px, 100%); }
.meters > div { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 10px; }
.meters dt { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.meters dd { display: grid; grid-template-columns: 1fr 22px; align-items: center; gap: 10px; }
.meters b { font-weight: 400; text-align: right; font-variant-numeric: tabular-nums; }
.bar { display: block; height: 3px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--fg); transform-origin: left; transform: scaleX(0); }
#kick-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: 0.12; }

.deck { display: grid; gap: 14px; justify-items: center; min-width: 0; }
#transport { display: flex; align-items: center; gap: 12px; width: min(480px, 100%); }

/* bibliothèque : même geste que la liste de projets du portfolio */
#library { display: flex; justify-content: center; gap: 2px; flex-wrap: wrap; }
#library button {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 10px; border-radius: 2px;
  font-weight: 700; font-stretch: 75%; font-size: 17px; text-transform: uppercase; letter-spacing: 0.01em;
  transition: background .2s, color .2s;
}
#library button sup { font-family: var(--mono); font-size: 9px; font-weight: 400; color: var(--muted); }
#library button:hover, #library button.on { background: var(--blue); color: #fff; }
#library button:hover sup, #library button.on sup { color: rgba(255, 255, 255, 0.72); }
#library button.on.playing::after {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: #fff; align-self: center;
  animation: blink 1s steps(2, jump-none) infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }
#play-btn {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
  display: grid; place-items: center; transition: background .25s, border-color .25s;
}
#play-btn:hover { background: var(--fg); border-color: var(--fg); }
#play-btn:hover svg { fill: var(--bg); }
#play-btn svg { width: 10px; height: 10px; fill: var(--fg); grid-area: 1 / 1; }
#play-btn .i-play { display: none; }
body.paused #play-btn .i-play { display: block; }
body.paused #play-btn .i-pause { display: none; }
#t-label, #t-time { flex: none; font-variant-numeric: tabular-nums; }
#t-label { max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#t-time { color: var(--muted); }
#seek { flex: 1; height: 20px; display: flex; align-items: center; position: relative; }
#seek::before { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
#seek-fill { position: relative; height: 1px; width: 100%; background: var(--fg); transform-origin: left; transform: scaleX(0); }
#transport.no-seek #seek { pointer-events: none; }
#transport.live #seek { visibility: hidden; }

.tools { display: flex; gap: 12px 16px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.tools > button { transition: color .2s; }
.tools > button:hover { color: var(--fg); }
#shot-btn, #full-btn { color: var(--fg); }
#palettes { display: flex; gap: 8px; flex-basis: 100%; justify-content: flex-end; }
#palettes button {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--sw); box-shadow: 0 0 0 1px rgba(255,255,255,.18) inset;
  outline-offset: 3px; transition: transform .3s var(--ease-out);
}
#palettes button:hover { transform: scale(1.25); }
#palettes button.on { outline: 1px solid var(--fg); }

/* ================= HELP PANEL ================= */
.panel {
  position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
  background: var(--panel-dark); border-left: 1px solid var(--line);
  padding: var(--pad); display: flex; flex-direction: column; gap: 32px;
  transform: translateX(101%); transition: transform .7s var(--ease);
}
.panel[aria-hidden="false"] { transform: none; }
.panel-bar { display: flex; justify-content: space-between; }
.panel-bar button { color: var(--muted); transition: color .2s; }
.panel-bar button:hover { color: var(--fg); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 14px 18px; align-items: center; }
.keys dt { display: flex; gap: 4px; }
.keys kbd { font-family: var(--mono); font-size: 13px; min-width: 38px; height: 38px; padding: 0 8px; display: grid; place-items: center; background: var(--fg); color: var(--bg); border-radius: 4px; }
.keys dd { font-family: var(--mono); font-size: 11px; text-transform: uppercase; }
.panel-note { margin-top: auto; text-transform: none; line-height: 1.6; }

/* ================= DROP ================= */
#drop {
  position: fixed; inset: 0; z-index: 200; background: var(--blue); color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 18px; padding: var(--pad);
  clip-path: inset(100% 0 0 0); transition: clip-path .6s var(--ease); pointer-events: none;
}
body.dragging #drop { clip-path: inset(0 0 0 0); }
.drop-word {
  font-weight: 900; font-stretch: 125%; text-transform: uppercase;
  font-size: clamp(90px, 22vw, 380px); line-height: 0.8; letter-spacing: -0.05em;
}

/* ================= TOAST ================= */
#toast {
  position: fixed; z-index: 60; left: 50%; top: calc(var(--pad) + 44px);
  transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  background: var(--fg); color: var(--bg); padding: 8px 12px; border-radius: 30px;
  transition: opacity .3s, transform .5s var(--ease-out);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= SMALL SCREENS ================= */
@media (max-width: 820px) {
  #top { flex-direction: column; }
  .pills { justify-content: flex-start; }
  #bottom { grid-template-columns: 1fr; gap: 16px; }
  .deck { order: -1; justify-items: stretch; }
  #transport { width: 100%; }
  #library { justify-content: flex-start; }
  #library button { font-size: 15px; padding: 5px 8px; }
  .meters { display: none; }
  .tools { justify-content: space-between; gap: 12px; }
  #hint { bottom: 230px; white-space: normal; width: calc(100% - 2 * var(--pad)); text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, #drop, #toast { transition-duration: .01s; }
}
