/* chope : un jaune franc, une police système arrondie, un seul élément fort (le bouton qui se remplit). */

@property --p {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

:root {
  --bg: #ffe45e;
  --paper: #fffbea;
  --ink: #1d1b16;
  --ink-soft: #5c5641;
  --rule: rgb(29 27 22 / 0.16);
  --button: #1d1b16;
  --button-ink: #ffe45e;
  --fill: #ffe45e;     /* partie téléchargée du bouton */
  --track: #fffbea;    /* partie restante */
  --danger: #a3241c;
  --focus: #2747d6;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17160f;
    --paper: #23211a;
    --ink: #f5efd6;
    --ink-soft: #b5ad8e;
    --rule: rgb(245 239 214 / 0.14);
    --button: #ffe45e;
    --button-ink: #17160f;
    --fill: #5b5221;
    --track: #23211a;
    --danger: #ff8a80;
    --focus: #9db0ff;
    color-scheme: dark;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

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

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

.page {
  max-width: 34rem;
  margin: 0 auto;
  padding: clamp(2rem, 9vh, 5.5rem) 1rem 4rem;
}

/* --- En-tête --- */

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.logo {
  margin: 0;
  font-size: clamp(4rem, 19vw, 6.75rem);
  font-weight: 900;
  letter-spacing: -0.065em;
  line-height: 1;
}

.lede {
  margin: 0.75rem 0 2rem;
  color: var(--ink-soft);
  font-size: 1.125rem;
  line-height: 1.4;
}

.text-button {
  margin-top: 0.5rem;
  padding: 0.25rem 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* --- Champ de recherche --- */

.search {
  display: flex;
  gap: 0.5rem;
  padding: 0.375rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
}
.search:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.search input {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 0.875rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
}
.search input::placeholder { color: var(--ink-soft); }
.search input:focus-visible { outline: none; }

.button {
  flex: none;
  padding: 0.625rem 1.25rem;
  border: 0;
  border-radius: 999px;
  background: var(--button);
  color: var(--button-ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.button:active:not(:disabled) { transform: scale(0.98); }
.button:disabled { cursor: default; opacity: 0.6; }

.message {
  min-height: 1.5rem;
  margin: 0.75rem 0.25rem 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.message[data-tone="error"] { color: var(--danger); font-weight: 700; }

/* --- Vidéo trouvée --- */

.card {
  margin-top: 1rem;
  padding: 1rem;
  border: 2px solid var(--ink);
  border-radius: 24px;
  background: var(--paper);
}

.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 14px;
  background: var(--rule);
}

.title {
  margin: 1rem 0 0;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.25;
  text-wrap: balance;
}

.meta {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.choice {
  min-width: 0;
  margin: 1rem 0 0;
  padding: 0;
  border: 0;
}

.chips {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chips input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.chips label {
  padding: 0.4375rem 0.9375rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}
.chips input:checked + label { background: var(--ink); color: var(--paper); }
.chips input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Le bouton devient la barre de progression. */
.button-big {
  display: block;
  width: 100%;
  margin-top: 1.25rem;
  padding: 1rem;
  font-size: 1.0625rem;
  font-variant-numeric: tabular-nums;
}
.button-big.is-busy {
  background: linear-gradient(90deg, var(--fill) var(--p), var(--track) var(--p));
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
  opacity: 1;
  transition: --p 0.6s linear;
}

.done-note {
  margin: 0.75rem 0.25rem 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.done-note a { color: var(--ink); font-weight: 700; }

/* --- Historique --- */

.history { margin-top: 2.5rem; }

.history-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 800;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.job {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1rem;
  padding: 0.75rem 0;
  border-top: 2px solid var(--rule);
}

.job-title {
  overflow: hidden;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.job-status {
  grid-column: 1;
  color: var(--ink-soft);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
.job[data-state="error"] .job-status { color: var(--danger); }

.job-link {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--ink);
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  .button-big.is-busy { transition: none; }
  .button:active:not(:disabled) { transform: none; }
}
