/* Cabine : une régie sobre, pensée pour une salle sombre.
   Fond bleu pétrole, texte clair, une seule couleur vive : le rouge du voyant d'enregistrement. */

:root {
  --bg: #08171b;
  --panel: #0d2228;
  --raise: #143039;
  --raise-hover: #1a3d49;
  --line: #21444f;
  --line-strong: #2f5866;
  --text: #e3f0f0;
  --dim: #8dabb0;
  --lamp: #ff4d3d;
  --signal: #6fe0b5;
  --warn: #f2c14e;
  --radius: 10px;
  --font: 'Bricolage Grotesque', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }

/* ---------------------------------------------------------------- structure */
body.app {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.bar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-size: 1.35rem;
  font-weight: 700;
  font-variation-settings: 'wdth' 80;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.state {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rtt {
  margin-left: auto;
  color: var(--dim);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
}

.stage-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  min-width: 0;
}

.side {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.block {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.block h2 {
  font-size: 1rem;
  font-weight: 650;
  margin-bottom: 10px;
}

.hint {
  color: var(--dim);
  font-size: 0.88rem;
  margin-top: 8px;
}

.note {
  background: rgba(242, 193, 78, 0.1);
  border: 1px solid rgba(242, 193, 78, 0.45);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

/* ---------------------------------------------------------------- voyant */
.lamp {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line-strong);
}
.lamp[data-state='wait'] { background: var(--warn); }
.lamp[data-state='live'] { background: var(--signal); box-shadow: 0 0 10px rgba(111, 224, 181, 0.7); }
.lamp[data-state='bad']  { background: var(--lamp); }
.lamp[data-state='rec']  {
  background: var(--lamp);
  box-shadow: 0 0 14px rgba(255, 77, 61, 0.9);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------------------------------------------------------------- image */
.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 150px);
  width: 100%;
  background: #030c0e;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stage > video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: var(--dim);
}

.cam {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: min(26%, 260px);
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.cam:active { cursor: grabbing; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.cam.mirror video { transform: scaleX(-1); }

.stage-tools { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------- champs */
.btn {
  font: inherit;
  font-weight: 550;
  color: var(--text);
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--raise-hover); border-color: var(--line-strong); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { background: #ffffff; }
.btn.rec { background: var(--lamp); border-color: var(--lamp); color: #1d0805; }
.btn.rec:hover { background: #ff6657; }
.btn.wide { width: 100%; }
.btn[aria-pressed='false'].toggle { color: var(--dim); }

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

label { display: block; }
.field-label { color: var(--dim); font-size: 0.88rem; margin: 12px 0 4px; }

input[type='text'],
input[type='url'],
input[type='number'],
select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

input[type='range'] { width: 100%; accent-color: var(--signal); }

.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--dim); font-size: 0.9rem; }
.check input { accent-color: var(--signal); }

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }

.row { display: flex; align-items: center; gap: 8px; }
.row > select { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- vumètres */
.meter-label { color: var(--dim); font-size: 0.88rem; margin: 14px 0 4px; }
.meter { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.meter canvas { width: 100%; height: 14px; display: block; }
.meter .readout {
  min-width: 4.2em;
  text-align: right;
  color: var(--dim);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- timecode */
.tc {
  font-size: 1.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--dim);
}
.tc.run { color: var(--signal); }

/* ---------------------------------------------------------------- enregistrement */
.rec-line { display: flex; align-items: center; gap: 12px; }
.timer { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.rec-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: rgba(255, 77, 61, 0.12);
  border: 1px solid var(--lamp);
  border-radius: 8px;
}

.takes { list-style: none; margin: 10px 0 0; padding: 0; font-size: 0.88rem; }
.takes li { padding: 6px 0; border-top: 1px solid var(--line); color: var(--dim); overflow-wrap: anywhere; }
.takes a { color: var(--signal); }

/* ---------------------------------------------------------------- entrée */
.gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 12, 14, 0.9);
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}
.card h2 { font-size: 1.5rem; font-weight: 700; font-variation-settings: 'wdth' 85; margin-bottom: 8px; }
.card p { color: var(--dim); margin-bottom: 18px; }
.card .btn { margin-top: 18px; }
.error { color: var(--lamp); margin-top: 14px !important; margin-bottom: 0 !important; }

details.settings { margin-top: 14px; }
details.settings summary { cursor: pointer; font-weight: 550; }

/* ---------------------------------------------------------------- accueil */
.home { max-width: 760px; margin: 0 auto; padding: 14vh 24px 8vh; }
.home .wordmark { font-size: 1.6rem; display: inline-block; margin-bottom: 8vh; }
.home h1 {
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  line-height: 1;
  font-weight: 700;
  font-variation-settings: 'wdth' 78;
  letter-spacing: -0.02em;
  max-width: 14ch;
}
.home .lead { margin-top: 24px; max-width: 46ch; color: var(--dim); font-size: 1.1rem; }
.home .btn { margin-top: 32px; font-size: 1.1rem; padding: 14px 24px; }
.home ul { margin: 8vh 0 0; padding: 0; list-style: none; max-width: 52ch; }
.home li { padding: 12px 0; border-top: 1px solid var(--line); color: var(--dim); }
.home li strong { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- adaptation */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .bar { gap: 14px; flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .lamp[data-state='rec'] { animation: none; }
  .btn { transition: none; }
}
