/* Thème clair/sombre, une seule colonne centrée, 720 px max (§13.1, §13.6). */

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f0f2f5;
  --text: #14161a;
  --muted: #5b6472;
  --border: #d5dae1;
  --accent: #b5121b;
  --accent-text: #ffffff;
  --danger: #a01019;
  --danger-bg: #fdecec;
  --focus: #1a6fd4;
  --radius: 10px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #101216;
  --surface: #191c22;
  --surface-alt: #22262e;
  --text: #eef1f5;
  --muted: #a4adba;
  --border: #333a45;
  --accent: #e0323d;
  --accent-text: #14161a;
  --danger: #ff8b93;
  --danger-bg: #2a1416;
  --focus: #7ab6ff;
}

* {
  box-sizing: border-box;
}

/* `hidden` doit l'emporter sur les display: flex des composants. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- En-tête et pied de page --- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-mini,
.button-mini {
  min-height: 36px;
  min-width: 44px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

main {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  flex: 1;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 20px 32px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer .note {
  max-width: 720px;
  margin: 8px auto 0;
}

/* --- Blocs --- */

.hero h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 16px 0 4px;
}

.lede {
  color: var(--muted);
  margin: 0 0 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card-error {
  border-color: var(--danger);
  background: var(--danger-bg);
}

/* --- Formulaire d'URL --- */

.url-form {
  display: flex;
  gap: 10px;
}

.input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text);
  font: inherit;
}

.button {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.button-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.button-block {
  width: 100%;
  margin-top: 8px;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.link-button {
  background: none;
  border: 0;
  padding: 4px;
  min-height: 24px;
  color: var(--focus);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.inline-error,
.inline-note {
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.inline-error {
  color: var(--danger);
}

.inline-note {
  color: var(--muted);
}

.muted {
  color: var(--muted);
  margin: 4px 0;
}

.note {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 8px 0 0;
}

.center {
  text-align: center;
}

/* --- Aperçu vidéo --- */

.preview {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.thumb {
  width: 200px;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.preview-body {
  min-width: 0;
}

.preview-heading {
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.info-button {
  background: none;
  border: 0;
  color: var(--focus);
  cursor: pointer;
  min-width: 24px;
  min-height: 24px;
  font-size: 1rem;
}

/* --- Cartes radio (nom et format) --- */

.fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
  /* Un fieldset a une largeur minimale intrinsèque : sans ça, il déborde sur mobile. */
  min-inline-size: 0;
}

.fieldset legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 10px;
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.preset {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  cursor: pointer;
  min-height: 44px;
}

.preset:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.preset.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.preset input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.preset-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preset-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.preset-label {
  font-weight: 600;
}

.preset-aside {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.preset-value,
.preset-desc {
  color: var(--muted);
  font-size: 0.88rem;
}

.preset-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Nom de fichier --- */

.filename-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.suffix {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.filename-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.counter {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.counter.warn {
  color: var(--accent);
}

.counter.over {
  color: var(--danger);
  font-weight: 600;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* --- Repli comparatif --- */

.details summary {
  cursor: pointer;
  padding: 8px 0;
  min-height: 24px;
}

.table-scroll {
  overflow-x: auto;
}

.compat-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

.compat-table th,
.compat-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.compat-table tr.is-disabled {
  opacity: 0.6;
}

/* --- Progression --- */

.progressbar {
  height: 12px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progressbar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s ease;
}

.progressbar.indeterminate .progressbar-fill {
  width: 40%;
  animation: slide 1.2s ease-in-out infinite alternate;
}

@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

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

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* --- Notification éphémère --- */

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 10;
  max-width: min(90vw, 480px);
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 24px rgb(0 0 0 / 22%);
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --- Responsive --- */

@media (max-width: 640px) {
  .url-form {
    flex-direction: column;
  }

  .preview {
    flex-direction: column;
  }

  .thumb {
    width: 100%;
  }

  .button-row .button {
    flex: 1;
  }

  /* Bouton de conversion collant en bas d'écran (§13.6). */
  .button-block {
    position: sticky;
    bottom: 12px;
    box-shadow: 0 6px 20px rgb(0 0 0 / 25%);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
