/* Touch Music — style calqué sur la référence sound.gojaehyun.com */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: #000; color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  overflow: hidden;
  touch-action: none;            /* pas de scroll/zoom tactile : l'écran est l'instrument */
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* La vidéo source est cachée : tout est composé sur le canvas (→ enregistrable) */
#video { display: none; }
#canvas { position: fixed; inset: 0; width: 100%; height: 100%; }

/* ── Moniteur temps réel ────────────────────────────── */
#hud {
  position: fixed; top: 16px; right: 16px;
  background: rgba(0,0,0,0.55);
  padding: 10px 14px; border-radius: 8px;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px; line-height: 1.7; z-index: 10;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#hud span { color: #4a9eff; }

/* ── Barre de contrôle ──────────────────────────────── */
#controls {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 12px);
  background: rgba(0,0,0,0.6);
  padding: 10px 18px; border-radius: 40px;
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px 20px; align-items: center; z-index: 10;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 13px;
}
#controls label { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; white-space: nowrap; }
#controls select {
  background: #222; color: #fff; border: 1px solid #444;
  padding: 4px 8px; border-radius: 4px; font-size: 13px;
}
#controls input[type=checkbox] { accent-color: #4a9eff; }
#controls .short { display: none; }

/* ── Boutons tactiles (plein écran / performance / REC) ── */
#quick-buttons {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: calc(16px + env(safe-area-inset-left, 0px));
  z-index: 15; display: flex; gap: 10px;
}
#quick-buttons button {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  font-size: 17px; line-height: 1; cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#quick-buttons button:active { background: rgba(255,255,255,0.25); }
#btn-rec { color: #ff5a6e; font-size: 20px; }
#btn-rec.recording {
  background: rgba(200,20,40,0.85); color: #fff;
  border-color: transparent;
  animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: 0.4; } }

#hint {
  position: fixed; bottom: 22px; right: 16px; z-index: 10;
  font-size: 11px; opacity: 0.4; letter-spacing: 0.04em;
}

/* ── Écran de démarrage ─────────────────────────────── */
#start-screen {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; z-index: 20; text-align: center; padding: 20px;
}
#start-screen h1 { font-size: 40px; font-weight: 200; letter-spacing: 6px; }
.desc { opacity: 0.75; max-width: 520px; line-height: 1.8; font-size: 15px; }
.desc b { color: #4a9eff; font-weight: 500; }
.desc i { color: #ff9e4a; font-style: normal; font-weight: 500; }
#start-btn {
  padding: 14px 44px; font-size: 18px; background: #fff; color: #000;
  border: none; border-radius: 40px; cursor: pointer; letter-spacing: 1px;
  transition: transform 0.15s;
}
#start-btn:hover { transform: scale(1.05); }
#start-btn:disabled { opacity: 0.5; cursor: wait; transform: none; }
.keys { font-size: 12px; opacity: 0.45; }

/* ── Mode performance (touche H / bouton 👁) ─────────── */
/* Les boutons tactiles restent visibles (sinon impossible d'en sortir au doigt) */
body.perf #hud,
body.perf #controls,
body.perf #hint { display: none; }
body.perf #quick-buttons { opacity: 0.45; }

/* ── Mobile en portrait : demander le paysage ───────── */
#portrait-warning {
  position: fixed; inset: 0; background: #000; color: #fff;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; z-index: 100; padding: 40px; text-align: center;
}
#portrait-warning .icon { font-size: 64px; animation: rotate-hint 2s ease-in-out infinite; }
#portrait-warning h2 { font-size: 22px; font-weight: 300; letter-spacing: 3px; }
#portrait-warning p { opacity: 0.7; font-size: 14px; line-height: 1.6; }
@keyframes rotate-hint {
  0%, 100% { transform: rotate(-90deg); }
  50% { transform: rotate(0deg); }
}

/* ── Petits écrans (mêmes seuils que la référence) ──── */
@media (max-width: 900px) {
  #hud, #hint { display: none; }
  #controls {
    padding: 7px 12px; gap: 6px 10px; font-size: 12px; border-radius: 24px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  #controls select { padding: 3px 6px; font-size: 12px; }
  #controls .full { display: none; }
  #controls .short { display: inline; }
  #quick-buttons { top: calc(10px + env(safe-area-inset-top, 0px)); gap: 8px; }
  #quick-buttons button { width: 38px; height: 38px; font-size: 15px; }
  #start-screen { gap: 14px; }
  #start-screen h1 { font-size: 34px; letter-spacing: 3px; }
  .desc { font-size: 15px; line-height: 1.5; }
  #start-btn { padding: 14px 40px; font-size: 20px; }
}
@media (orientation: portrait) and (max-width: 900px) {
  #portrait-warning { display: flex; }
}
