:root {
  --paper: #efede6;
  --ink: #0b0b0a;
  --yellow: #e4ff3a;
  --mute: #5a5852;
  --dim: #6a6862;
  --soft: #9c9a93;
  --line: #3a3a38;
  --well: #1f1f1e;
  --hatch-light: repeating-linear-gradient(45deg, #d8d6ce 0 6px, #cfcdc5 6px 12px);
  --hatch-dark: repeating-linear-gradient(45deg, #2a2a28 0 6px, #232321 6px 12px);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Archivo', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* ---------- Écrans ---------- */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 24px calc(28px + env(safe-area-inset-bottom));
}
.paper { background: var(--paper); color: var(--ink); }
.ink { background: var(--ink); color: var(--paper); padding: 0; }

.top { display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -0.03em; }

.middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  padding: 24px 0;
}

.title, .big {
  margin: 0;
  font-weight: 900;
  font-stretch: 62%;
  font-size: clamp(64px, 24vw, 92px);
  line-height: 0.84;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
.strong { font-weight: 800; font-size: 17px; line-height: 1.3; }
.note { margin: 0; font: 500 11px/1.4 var(--mono); color: var(--mute); }
.ink .note { color: var(--soft); }

/* Le carré : bouton d'accueil, cadre d'image, aperçu du résultat. */
.square {
  position: relative;
  width: min(342px, 100%);
  aspect-ratio: 1;
  flex: none;
}
.pick {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pick:focus-within { outline: 3px solid var(--yellow); outline-offset: 3px; }
.pick[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.pick.over { outline: 3px dashed var(--yellow); outline-offset: 3px; }
.pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.plus { font-weight: 300; font-size: 64px; line-height: 0.8; }
.pickText { font-weight: 800; font-size: 20px; line-height: 1.2; }

.frame { background: var(--hatch-light); overflow: hidden; }
.frame.dark { background: var(--hatch-dark); }
.frame > canvas, .frame > video, .frame > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: transparent;
}
.tag {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 2;
  font: 500 10px/1 var(--mono);
  color: var(--dim);
  text-transform: uppercase;
}
.fill { position: absolute; background: rgba(11, 11, 10, 0.82); z-index: 1; transition: height 0.2s, width 0.2s; }
.fill.up { left: 0; right: 0; bottom: 0; height: 0; }
.fill.side { left: 0; top: 0; bottom: 0; width: 0; }

.link {
  all: unset;
  cursor: pointer;
  align-self: flex-start;
  font: 500 13px/1 var(--mono);
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 6px 0;
}
.link:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  font: 500 11px/1.4 var(--mono);
  color: var(--mute);
}
.fast { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.fast input { width: 14px; height: 14px; margin: 0; accent-color: var(--ink); }
#version { margin-left: auto; color: var(--dim); }

.error {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: var(--ink);
  color: var(--yellow);
  font: 500 13px/1.45 var(--mono);
}

/* ---------- Vérification ---------- */

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--hatch-dark);
  overflow: hidden;
  touch-action: none;
}
.stage > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.banner {
  position: absolute;
  left: 16px;
  top: 16px;
  right: 16px;
  margin: 0;
  padding: 10px 12px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  font-size: 14px;
  line-height: 1.3;
  pointer-events: none;
}
.link.small {
  position: absolute;
  left: 16px;
  bottom: 12px;
  font-size: 11px;
  color: var(--yellow);
  background: var(--ink);
  padding: 6px 8px;
}
.maskBar {
  position: absolute;
  display: flex;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 800;
  font-size: 18px;
  z-index: 3;
}
.maskBar button {
  all: unset;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.maskBar button.sep { border-left: 2px solid var(--ink); }
.maskBar button:active { background: rgba(11, 11, 10, 0.12); }

.deck {
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.timeline { display: flex; gap: 6px; align-items: stretch; height: 36px; }
.step {
  all: unset;
  cursor: pointer;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  font: 700 18px/1 var(--mono);
}
.track { position: relative; flex: 1; background: var(--well); }
.track canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.track input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  touch-action: none;
}
.row { display: flex; gap: 6px; align-items: stretch; }
.ctl {
  all: unset;
  cursor: pointer;
  flex: none;
  width: 56px;
  height: 56px;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  text-align: center;
}
.ctl.mono { font: 700 11px/1 var(--mono); }
.ctl.on { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.ctl .sq { width: 18px; height: 18px; background: var(--paper); }
.ctl.on .sq { background: var(--ink); }
.go {
  all: unset;
  cursor: pointer;
  flex: 1;
  height: 56px;
  background: var(--paper);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-stretch: 75%;
  font-size: 20px;
  text-transform: uppercase;
}
.ctl:focus-visible, .go:focus-visible, .step:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ---------- Résultat ---------- */

.bottom { display: flex; flex-direction: column; gap: 14px; }
.cta {
  height: 64px;
  padding: 0 20px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 900;
  font-stretch: 75%;
  font-size: 22px;
  text-transform: uppercase;
  text-decoration: none;
}
.links { display: flex; flex-wrap: wrap; gap: 4px 20px; }

#stats { padding: 8px 24px; }

/* La vidéo d'origine reste dans la page (les navigateurs ne décodent pas toujours une vidéo retirée), mais invisible. */
.src {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Ordinateur ---------- */

@media (min-width: 900px) {
  .screen { padding: 28px 48px 36px; }
  .ink { padding: 0; }
  .brand { font-size: 22px; }
  /* Titre et carré côte à côte, au centre, à la même hauteur : un mot par ligne, le carré donne la taille. */
  #s-home .middle { --s: min(34vw, 62vh, 760px); flex-direction: row; align-items: center; justify-content: center; gap: clamp(40px, 5vw, 96px); }
  #s-home .title { flex: none; width: min-content; font-size: calc(var(--s) * 0.42); line-height: 0.82; }
  #s-home .square { width: var(--s); padding: calc(var(--s) * 0.06); }
  #s-home .plus { font-size: 88px; }
  #s-home .pickText { font-size: 24px; line-height: 1.25; }
  .foot { font-size: 12px; }
  .middle:not(#s-home .middle) { align-items: flex-start; }
  .banner { right: auto; left: 20px; top: 20px; font-size: 15px; padding: 10px 14px; }
  .deck { flex-direction: row; align-items: center; gap: 10px; padding: 16px 24px 20px; }
  .timeline { flex: 2; min-width: 240px; height: 52px; order: 1; }
  .row { order: 2; }
  .ctl { width: 52px; height: 52px; }
  .go { flex: none; height: 52px; padding: 0 32px; }
  #audioNote { order: 3; flex: 1; min-width: 0; }
  #play { order: 0; }
}
.maskBar button.on { background: rgba(11, 11, 10, 0.18); }
