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

:root {
  --bg:        #0d0d0f;
  --surface:   #15151a;
  --surface2:  #1e1e26;
  --border:    #2a2a36;
  --accent:    #ffab3f;
  --accent2:   #7b6ef6;
  --text:      #e8e8f0;
  --muted:     #8a8aa0; /* ≥4.5:1 sur --bg et --surface (WCAG AA) */
  --danger:    #ff4f64;
  --radius:    12px;
  --font-main: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Focus clavier ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Header ── */
header {
  border-bottom: 1px solid var(--border);
  padding: 20px 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
}

.logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
  filter: saturate(1.2);
}

.logo-mark svg {
  width: 30px; height: 30px;
}

.site-name {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 100px;
  margin-left: 4px;
}

/* ── Hero ── */
.hero {
  max-width: 760px;
  margin: 44px auto 0;
  padding: 0 24px;
  text-align: center;
}

.hero h1 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 14px;
}

.hero-accent { color: var(--accent); }

.hero p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
  max-width: 580px;
  margin: 0 auto;
}

.hero-points {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.hero-points span::before {
  content: '✓';
  color: var(--accent);
  margin-right: 7px;
  font-weight: 500;
}

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1100px;
  width: 100%;
  margin: 32px auto;
  padding: 0 24px;
  align-items: start;
  flex: 1;
}

/* ── Panel ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ── Dropzone ── */
#dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 20px;
}

#dropzone:hover, #dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(255, 171, 63, 0.04);
}

#dropzone .drop-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  display: block;
}

#dropzone p {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}

#dropzone strong { color: var(--accent); }

/* ── Frame Count Bar ── */
.frames-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 100px;
}

/* ── Grid frames ── */
#framesGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  min-height: 100px;
}

#emptyState {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: var(--muted);
  font-size: 0.82rem;
}

.frame-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: grab;
  transition: border-color 0.2s, transform 0.15s;
  aspect-ratio: 1;
  background: var(--surface2);
}

.frame-card:hover       { border-color: var(--accent2); }
.frame-card.dragging    { opacity: 0.4; transform: scale(0.95); }
.frame-card.drag-target { border-color: var(--accent); }

.frame-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.frame-number {
  position: absolute;
  top: 5px; left: 5px;
  background: rgba(0,0,0,0.7);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
}

.remove-btn {
  position: absolute;
  top: 5px; right: 5px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 20px; height: 20px;
  font-size: 0.6rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.frame-card:hover .remove-btn,
.frame-card:focus-within .remove-btn { display: flex; }

/* Sans souris (tactile) : pas de survol, le bouton doit rester visible et atteignable */
@media (hover: none) {
  .remove-btn { display: flex; width: 28px; height: 28px; font-size: 0.75rem; }
}

/* ── Sidebar Controls ── */
.control-group { margin-bottom: 18px; }

.control-group label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  flex: 1;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  min-width: 0;
}

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

.range-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  white-space: nowrap;
  min-width: 52px;
  text-align: right;
}

select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

select:focus { border-color: var(--accent2); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-label { font-size: 0.88rem; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px; height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent2); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Generate Button ── */
#generateBtn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #1a1000;
  border: none;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.02em;
}

#generateBtn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
#generateBtn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Progress ── */
#progressSection {
  margin-top: 20px;
  display: none;
}

.progress-track {
  background: var(--border);
  border-radius: 100px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

#progressBar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 100px;
  transition: width 0.3s;
  width: 0%;
}

#progressText {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}

/* ── Result ── */
.main-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

#resultSection { display: none; }

.result-panel {
  border-color: rgba(255, 171, 63, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 171, 63, 0.08), 0 16px 48px rgba(0, 0, 0, 0.4);
  animation: result-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes result-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.result-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  background: rgba(255, 171, 63, 0.1);
  border: 1px solid rgba(255, 171, 63, 0.4);
  padding: 3px 10px;
  border-radius: 100px;
}

.result-stage {
  display: grid;
  place-items: center;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    conic-gradient(var(--surface2) 90deg, var(--bg) 90deg 180deg,
                   var(--surface2) 180deg 270deg, var(--bg) 270deg)
    0 0 / 22px 22px;
}

#resultImg {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 8px;
  display: block;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.file-size-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.78rem;
}

.file-size-label { color: var(--muted); }

.file-size-value {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 500;
  font-size: 0.9rem;
}

#downloadBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: #1a1000;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: opacity 0.2s, transform 0.1s;
}

#downloadBtn:hover { opacity: 0.88; transform: translateY(-1px); }

/* ── FAQ ── */
.faq {
  max-width: 760px;
  width: 100%;
  margin: 16px auto 56px;
  padding: 0 24px;
}

.faq h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  transition: border-color 0.2s;
}

.faq details:hover { border-color: #3a3a4a; }

.faq summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: color 0.2s;
}

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

.faq summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.faq details[open] summary        { color: var(--accent); }
.faq details[open] summary::after { transform: rotate(45deg); }

.faq details p {
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
}

.footer-left {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.footer-right-group {
  display: flex;
  align-items: center;
  gap: 20px;
}

.footer-link {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-mono);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-link:hover { color: var(--accent); }

.footer-link svg {
  width: 15px; height: 15px;
  fill: currentColor;
  flex-shrink: 0;
}

.footer-link--arrow::after {
  content: '↗';
  font-size: 0.7rem;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 0.83rem;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  header  { padding: 16px 20px; }
  footer  { padding: 16px 20px; flex-direction: column; align-items: flex-start; gap: 12px; }

  .hero    { margin-top: 32px; }
  .hero h1 { font-size: 1.6rem; }

  .result-footer { flex-direction: column; align-items: stretch; }
  #downloadBtn   { justify-content: center; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .result-panel { animation: none; }

  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
