/* =========================================================================
 *  Snippet Extractor — thème "studio rack" dark, mobile-first
 * ========================================================================= */

:root {
  --bg:        #0a0b0e;
  --bg-2:      #111319;
  --panel:     #15171f;
  --line:      #23262f;
  --ink:       #f4f5f7;
  --muted:     #8b909c;
  --accent:    #d4ff3f;   /* vert acide façon VU-mètre */
  --accent-2:  #ff3d7f;   /* magenta chaud */
  --radius:    16px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --display: "Syne", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--mono);
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(212,255,63,0.06), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(255,61,127,0.07), transparent 55%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding: clamp(14px, 4vw, 40px);
  line-height: 1.5;
}

.fatal {
  max-width: 480px; margin: 20vh auto; text-align: center;
  font-size: 1.1rem; color: var(--accent-2); line-height: 1.6;
}

/* ---- Layout ----------------------------------------------------------- */
#app { max-width: 980px; margin: 0 auto; display: grid; gap: 22px; }

/* ---- Header ----------------------------------------------------------- */
.header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  box-shadow: 0 0 40px rgba(212,255,63,0.25);
}
.logo svg { width: 30px; height: 30px; }
.header h1 {
  font-family: var(--display); font-weight: 800; letter-spacing: -0.03em;
  font-size: clamp(1.6rem, 6vw, 2.6rem); line-height: 1;
}
.header h1 b { color: var(--accent); }
.header .tag { color: var(--muted); font-size: 0.8rem; width: 100%; }
.state {
  font-size: 0.75rem; color: var(--accent);
  border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px;
  background: var(--bg-2); white-space: nowrap;
}
.btn-help {
  margin-left: auto; font-family: var(--mono); font-size: 0.75rem; color: var(--ink);
  border: 1px solid var(--line); background: var(--bg-2); padding: 6px 14px; border-radius: 999px;
  cursor: pointer; white-space: nowrap; transition: border-color .15s, color .15s;
}
.btn-help:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Dropzone --------------------------------------------------------- */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  padding: clamp(28px, 8vw, 60px) 20px; text-align: center; cursor: pointer;
  transition: border-color .2s, transform .2s, background .2s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: rgba(212,255,63,0.06); transform: scale(1.01); }
.dropzone .ico { font-size: 2.4rem; }
.dropzone .big { font-family: var(--display); font-weight: 700; font-size: 1.2rem; margin-top: 8px; }
.dropzone .sub { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }
[data-state="preview"] .dropzone,
[data-state="analyzing"] .dropzone,
[data-state="rendering"] .dropzone { padding: 18px; }
[data-state="preview"] .dropzone .ico,
[data-state="preview"] .dropzone .sub { display: none; }

/* ---- Progress --------------------------------------------------------- */
.progress { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.progress .track { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress .bar {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s;
}
.progress .txt { font-size: 0.75rem; color: var(--muted); margin-top: 8px; }

/* ---- Error ------------------------------------------------------------ */
.error {
  background: rgba(255,61,127,0.1); border: 1px solid var(--accent-2);
  color: #ffb8cf; padding: 12px 16px; border-radius: 12px; font-size: 0.85rem;
}

/* ---- Cards ------------------------------------------------------------ */
#cards { display: grid; gap: 14px; }
[data-state="idle"] #cards,
[data-state="uploading"] #cards { display: none; }

.card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; transition: border-color .2s;
}
.card:hover { border-color: #33373f; }
.card__num {
  font-family: var(--display); font-weight: 800; font-size: 1.8rem;
  color: var(--accent); line-height: 1;
}
.card__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card__label { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.card__hint { color: var(--muted); font-size: 0.72rem; }
.card__time { color: var(--muted); font-size: 0.72rem; margin-top: 8px; }

/* trim début / fin */
.card__trim { display: grid; gap: 6px; margin-top: 10px; }
.card__trim .trim { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 10px; }
.card__trim .trim span { color: var(--muted); font-size: 0.7rem; }
.card__trim input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 99px; background: var(--line); cursor: pointer;
}
.card__trim input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg); cursor: pointer;
}
.card__trim input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: none; cursor: pointer;
}

/* mini-waveform */
.card__wave { display: flex; align-items: center; gap: 2px; height: 44px; margin-top: 8px; }
.card__wave i {
  flex: 1; min-width: 1px; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), #5a6b1a);
  opacity: 0.85;
}

.card__actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.btn-play {
  width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--ink); color: var(--bg); font-size: 1rem; display: grid; place-items: center;
  transition: transform .15s, background .15s;
}
.btn-play:hover { transform: scale(1.08); }
.btn-play[data-playing="1"] { background: var(--accent); }

/* checkbox custom */
.chk { position: relative; cursor: pointer; }
.chk input { position: absolute; opacity: 0; }
.chk span {
  display: block; width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid var(--line); background: var(--bg); transition: .15s;
}
.chk input:checked + span { background: var(--accent); border-color: var(--accent); }
.chk input:checked + span::after {
  content: "✓"; color: var(--bg); font-weight: 800; font-size: 0.9rem;
  display: grid; place-items: center; height: 100%;
}

/* ---- Footer actions --------------------------------------------------- */
.actions { display: grid; gap: 12px; }
[data-state="idle"] .actions,
[data-state="uploading"] .actions { display: none; }

.mp4opt { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; color: var(--muted); }
.mp4opt input { width: 18px; height: 18px; accent-color: var(--accent); }

/* option image de fond */
.bgopt {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.bgopt__thumb {
  width: 38px; height: 67px; border-radius: 6px; flex: none;
  border: 1px solid var(--line); background-size: cover; background-position: center;
}
.bgopt__info { display: flex; flex-direction: column; gap: 2px; margin-right: auto; min-width: 0; }
.bgopt__title { font-family: var(--display); font-weight: 700; font-size: 0.9rem; }
.bgopt__hint { color: var(--muted); font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(60vw, 360px); }
.btn-ghost {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-family: var(--mono); font-size: 0.78rem; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  transition: border-color .15s, background .15s; flex: none;
}
.btn-ghost:hover { border-color: var(--accent); }

.btn-generate {
  width: 100%; border: none; cursor: pointer; padding: 18px;
  font-family: var(--display); font-weight: 800; font-size: 1.05rem; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0a0b0e;
  transition: opacity .2s, transform .1s;
}
.btn-generate:hover:not(:disabled) { transform: translateY(-1px); }
.btn-generate:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6); }

/* ---- Preview canvas (caché, sert au rendu + preview) ------------------ */
.stage {
  display: none; justify-self: center; width: min(260px, 70vw); aspect-ratio: 9/16;
  border-radius: 18px; overflow: hidden; border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
#app.previewing .stage,
[data-state="rendering"] .stage { display: block; }
#previewCanvas { width: 100%; height: 100%; display: block; }

/* ---- Render overlay --------------------------------------------------- */
.render-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(5,6,9,0.86); backdrop-filter: blur(8px); text-align: center; padding: 24px;
}
.render-overlay .spinner {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 22px;
  border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.render-overlay .txt { white-space: pre-line; font-size: 0.95rem; line-height: 1.7; }

/* ---- History ---------------------------------------------------------- */
.history h2 { font-family: var(--display); font-size: 0.9rem; color: var(--muted); margin-bottom: 10px; letter-spacing: 0.05em; text-transform: uppercase; }
#historyList { list-style: none; display: grid; gap: 8px; }
#historyList li {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 0.8rem;
}
#historyList .h-name { font-weight: 600; }
#historyList .h-meta { color: var(--muted); font-size: 0.72rem; text-align: right; }
#historyList .empty { color: var(--muted); justify-content: center; }

/* ---- Modal "Comment ça marche" --------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(5,6,9,0.78); backdrop-filter: blur(6px); }
.modal__panel {
  position: relative; width: min(560px, 100%); max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(22px, 5vw, 34px); box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal__close {
  position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--muted);
  font-size: 0.9rem; cursor: pointer; transition: border-color .15s, color .15s;
}
.modal__close:hover { border-color: var(--accent-2); color: var(--ink); }
.modal__panel h2 { font-family: var(--display); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.02em; padding-right: 40px; }
.modal__lead { color: var(--muted); font-size: 0.85rem; margin-top: 10px; }
.modal__steps { list-style: none; display: grid; gap: 16px; margin: 22px 0; counter-reset: step; }
.modal__steps li {
  position: relative; padding-left: 46px; font-size: 0.85rem; color: var(--muted); line-height: 1.55;
}
.modal__steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 0.95rem;
  color: #0a0b0e; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.modal__steps li b { display: block; color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 0.98rem; margin-bottom: 3px; }
.modal__steps li i { color: var(--accent); font-style: normal; }
.modal__note {
  font-size: 0.74rem; color: var(--muted); border-top: 1px solid var(--line);
  padding-top: 14px; line-height: 1.6;
}

[hidden] { display: none !important; }

/* ---- Desktop tweaks --------------------------------------------------- */
@media (min-width: 720px) {
  .actions { grid-template-columns: 1fr auto; align-items: center; }
  .actions .bgopt { grid-column: 1 / -1; }
  .actions .btn-generate { grid-column: 1 / -1; }
}
