/* PixelCover — clair, sobre, typographique.
   Pensé pour une TV (grand, lisible de loin, pilotable au clavier) et pour le téléphone. */
:root {
  --bg: #ffffff;
  --soft: #f5f5f3;
  --ink: #111111;
  --muted: #767676;
  --line: #e4e4e1;
  --orange: #e73703; /* la couleur de fond de l'illustration */
  --accent: #e73703;
  --blue: #1f5bff;
  --paper: #fff6ec;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { font-size: clamp(16px, 1.1vw + 10px, 26px); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }

/* mise en page */
.page { max-width: 56rem; margin: 0 auto; padding: 2rem 1.25rem 5rem; display: grid; gap: 2.2rem; }
.page.wide { max-width: 90rem; }
.hero { padding: 1rem 0 0.2rem; }
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); font-weight: 700; letter-spacing: -0.045em; line-height: 1; }
.hero h1 span { font-weight: 300; }
.lead { color: var(--muted); font-size: 1.05rem; margin-top: 0.6rem; }
h1.small { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.03em; }

.card { border-top: 1px solid var(--ink); padding-top: 0.9rem; display: grid; gap: 1.2rem; }
.card.accent { border-top: 3px solid var(--accent); }
.card.sticky { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-bottom: 0.9rem; border-bottom: 1px solid var(--line); }
.card h2 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; }
.field { display: grid; gap: 0.5rem; }
.field > label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.field.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; color: var(--muted); font-size: 0.9rem; }
.check { color: var(--ink); display: inline-flex; align-items: center; gap: 0.4rem; text-transform: none; letter-spacing: 0; font-size: 0.95rem; }
.filters { display: grid; gap: 1.1rem; }
.count { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.count.warn { color: var(--accent); }
.foot { color: var(--muted); font-size: 0.75rem; }

.row { display: flex; gap: 0.7rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: flex-start; flex-wrap: wrap; }

/* mini-présentation du tuto (la pixelisation expliquée) */
html.explaining { font-size: clamp(15px, 1.8vh, 24px); }
.explain { max-width: 64rem; }
.slide { display: grid; gap: 1.1rem; }
.slide > div { display: grid; gap: 1.1rem; }
.slide h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); text-transform: none; letter-spacing: -0.03em; font-weight: 700; }
.slide p { font-size: 1.1rem; max-width: 52rem; }
.slide .aside { color: var(--muted); font-size: 1rem; }
.steps { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.6rem; font-size: 1.1rem; max-width: 52rem; }
.fig { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1.2rem; }
.fig figure { margin: 0; display: grid; gap: 0.4rem; justify-items: center; max-width: 22rem; text-align: center; }
.fig figcaption { color: var(--muted); font-size: 0.85rem; }
.fig .arrow, .fig .op { font-size: 2rem; color: var(--muted); }
.fig-canvas { width: min(100%, 20rem); aspect-ratio: 1; background: var(--soft); cursor: default; }
#app .slide canvas:not(.small):hover { cursor: crosshair; }
.fig-canvas.small { width: min(100%, 13rem); }
.cells { display: grid; width: min(100%, 20rem); aspect-ratio: 1; }
.cell { display: grid; place-content: center; text-align: center; font-size: 0.7rem; line-height: 1.15; font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, monospace; }
.math { font-family: ui-monospace, Menlo, monospace; font-size: 0.95rem; background: var(--soft); padding: 0.9rem 1.1rem; display: grid; gap: 0.3rem; line-height: 1.5; overflow-wrap: anywhere; }
.swatch-row { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.3rem; }
.swatch { width: 2.2rem; height: 2.2rem; flex: none; border: 1px solid var(--ink); }
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.8rem; }
.levels figure { margin: 0; display: grid; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); }
.level-canvas { width: 100%; aspect-ratio: 1; background: var(--soft); }
.matrix { border-collapse: collapse; font-family: ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
.matrix td { border: 1px solid var(--line); padding: 0.35rem 0.7rem; text-align: center; min-width: 2.6rem; }
.matrix.values td { background: var(--soft); }
.fig.kernels .result { font-family: ui-monospace, Menlo, monospace; font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.explain-nav { margin-top: 0.5rem; }
.slide .eq { font-family: ui-monospace, Menlo, monospace; font-size: 1rem; background: var(--soft); padding: 0.8rem 1.1rem; max-width: none; overflow-wrap: anywhere; line-height: 1.6; overflow-x: auto; }
.slide code { font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; background: var(--soft); padding: 0.05rem 0.35rem; }
.math .rule { height: 1px; background: var(--line); margin: 0.4rem 0; }
.math { white-space: normal; font-family: inherit; font-size: 1rem; }
.tex-fallback { font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; }
.tex-display { margin: 0; }
.slide .eq { white-space: normal; }
table.data { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
table.data th { text-align: right; color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.3rem 0.9rem; border-bottom: 1px solid var(--ink); }
table.data td { text-align: right; padding: 0.3rem 0.9rem; border-bottom: 1px solid var(--line); font-family: ui-monospace, Menlo, monospace; }

/* QCM */
.quiz { display: grid; gap: 1rem; }
.quiz h2 { font-size: clamp(1.4rem, 2.6vw, 2.1rem); }
.answers { display: grid; gap: 0.6rem; max-width: 40rem; }
.answer { display: flex; align-items: baseline; gap: 0.9rem; text-align: left; background: transparent; border: 1px solid var(--line); border-radius: 2px; padding: 0.8rem 1rem; font-size: 1.1rem; cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.answer:hover:not(:disabled) { border-color: var(--ink); }
.answer:disabled { cursor: default; }
.answer .key { border: 1px solid var(--line); border-radius: 2px; padding: 0 0.45rem; color: var(--muted); font-size: 0.8rem; }
.answer.right { background: var(--ink); border-color: var(--ink); color: #fff; }
.answer.right .key { border-color: #666; color: #ddd; }
.answer.wrong { border-color: var(--accent); color: var(--accent); text-decoration: line-through; }
.feedback { display: grid; gap: 0.6rem; justify-items: start; }
.verdict { font-weight: 700; font-size: 1.15rem; }
.quiz-row { display: flex; align-items: center; gap: 0.7rem; }
.quiz-row input[type="radio"] { accent-color: var(--ink); width: 1.1rem; height: 1.1rem; flex: none; }

/* pochette d'intro (photo perso jouée en premier) */
details.card > summary { cursor: pointer; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: " +"; color: var(--muted); }
details.card[open] > summary::after { content: " −"; }
.intro { display: grid; gap: 1rem; margin-top: 1rem; }
.intro-photo { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: flex-start; }
.intro-preview { width: min(100%, 15rem); aspect-ratio: 1; background: var(--soft); }
.intro-crop { display: grid; gap: 0.6rem; flex: 1 1 14rem; align-content: start; }
.intro-slider { display: grid; gap: 0.2rem; color: var(--muted); font-size: 0.85rem; }
.intro-slider input { width: 100%; accent-color: var(--ink); }
.intro-fields { display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem; }
.intro-field { display: grid; gap: 0.2rem; flex: 1 1 10rem; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.intro-field input { text-transform: none; letter-spacing: 0; font-size: 1rem; color: var(--ink); }
input[type="number"] { background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 0.5rem 0; min-width: 0; }
input[type="number"]:focus { outline: none; border-bottom-color: var(--ink); }

/* barre de lancement toujours visible, comme dans une application */
.dock { position: sticky; bottom: 0; z-index: 6; margin: 0 -1.25rem; padding: 0.8rem 1.25rem calc(0.8rem + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.summary { color: var(--muted); font-size: 0.95rem; flex: 1 1 14rem; }
.dock-actions { display: flex; align-items: center; gap: 0.6rem; margin-left: auto; }
.dock .btn.xl { min-width: 9rem; }

/* pastilles */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { background: transparent; border: 1px solid var(--line); border-radius: 2px; padding: 0.4rem 0.8rem; cursor: pointer; font-size: 0.95rem; transition: border-color 0.12s; }
.chip:hover { border-color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* boutons */
.btn { background: transparent; border: 1px solid var(--ink); border-radius: 2px; padding: 0.6rem 1.1rem; cursor: pointer; font-weight: 500; transition: background 0.12s, color 0.12s; }
.btn:hover:not(:disabled) { background: var(--soft); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #333; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--ink); background: transparent; }
.btn.danger { color: var(--accent); }
.btn.small { padding: 0.3rem 0.8rem; font-size: 0.9rem; }
.btn.xl { padding: 0.9rem 2rem; font-size: 1.1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

input[type="text"], input[type="search"] {
  background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  padding: 0.5rem 0; min-width: 0; flex: 1 1 14rem; transition: border-color 0.12s;
}
input[type="text"]:focus, input[type="search"]:focus { outline: none; border-bottom-color: var(--ink); }
.team-inputs { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
.team-inputs input { flex: 1 1 9rem; }
input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--ink); }

.deck-list { list-style: none; margin: 0; padding: 0; }
.deck-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.deck-name small { color: var(--muted); }

/* éditeur de decks */
.bar { display: flex; align-items: center; gap: 1rem; }
.status { color: var(--muted); font-size: 0.9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 1rem 0.8rem; }
.tile { position: relative; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; display: block; }
.tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--soft); outline: 3px solid transparent; outline-offset: -3px; transition: opacity 0.12s; }
.tile .cap { display: grid; padding-top: 0.4rem; font-size: 0.8rem; }
.tile .cap small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .cap strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .cap .flag { color: var(--accent); }
.tile:not(.on):hover img { opacity: 0.85; }
.tile.on img { outline-color: var(--ink); }
.tile.on::after { content: "✓"; position: absolute; top: 0; right: 0; background: var(--ink); color: #fff; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; font-size: 0.9rem; }

/* jeu : la pochette est l'élément principal (grande, centrée), tout le reste est dessous.
   Sur ordinateur et TV, l'échelle suit la hauteur de l'écran et tout tient sans défiler :
   la pochette prend la place restante, le panneau du bas reste compact. */
html.playing { font-size: clamp(13px, 1.7vh, 22px); }
.game { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 0.7rem; padding: 0.6rem 1.2rem 0.9rem; }
.game-top { display: flex; align-items: center; gap: 1rem; }
.progress { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timer { flex: 1; height: 2px; background: var(--line); }
.timer-bar { height: 100%; width: 0; background: var(--ink); transition: width 0.1s linear; }
.stage { display: contents; }
.cover-wrap { height: 100%; max-width: 100%; aspect-ratio: 1; justify-self: center; background: var(--soft); }
.cover { display: block; width: 100%; height: 100%; }
.side { width: min(100%, 64rem); justify-self: center; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem 1.5rem; align-items: center; }
.side > .teams, .side > .hints { grid-column: 1 / -1; }
.info { min-width: 0; }
.info h2 { font-size: clamp(1.4rem, 2.4vw, 2.2rem); font-weight: 700; line-height: 1.05; letter-spacing: -0.035em; }
.info .album { display: inline; font-size: clamp(1.05rem, 1.7vw, 1.5rem); letter-spacing: -0.02em; }
.info .year, .info .track { display: inline; color: var(--muted); font-size: 1rem; }
.info .year::before, .info .track::before { content: "·"; margin: 0 0.5rem; }
.info .help { display: block; margin-top: 0.4rem; color: var(--muted); font-size: 0.9rem; }
.info.hidden h2 { color: var(--muted); font-weight: 300; }
.info.hidden .album { color: var(--muted); font-size: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }

.teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(21rem, 1fr)); gap: 0 1.2rem; }
.teams-title { grid-column: 1 / -1; color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; padding-bottom: 0.2rem; }
.team-block { border-top: 1px solid var(--line); transition: background 0.12s; }
.team-block.won { background: var(--soft); box-shadow: inset 3px 0 0 var(--accent); }
.team { width: 100%; display: grid; grid-template-columns: auto 1fr auto auto; gap: 0.8rem; align-items: center; text-align: left; background: transparent; border: 0; border-radius: 0; padding: 0.4rem 0.3rem; cursor: pointer; font-size: 1.05rem; transition: background 0.12s; }
.team:disabled { cursor: default; }
.team:hover:not(:disabled) { background: var(--soft); }
.crit { display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0 0.3rem 0.5rem 2.3rem; }
.crit-btn { background: transparent; border: 1px solid var(--line); border-radius: 2px; padding: 0.2rem 0.6rem; cursor: pointer; font-size: 0.85rem; display: inline-flex; gap: 0.4rem; align-items: baseline; transition: border-color 0.12s; }
.crit-btn small { color: var(--muted); font-size: 0.8em; }
.crit-btn:hover { border-color: var(--ink); }
.crit-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.crit-btn.on small { color: #ddd; }
.crit-btn.taken { opacity: 0.4; }
.team .key { border: 1px solid var(--line); border-radius: 2px; padding: 0 0.45rem; color: var(--muted); font-size: 0.75rem; }
.team .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.team .score { font-size: 1.4rem; font-weight: 700; min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.team .plus { color: var(--muted); min-width: 3.5ch; text-align: right; font-variant-numeric: tabular-nums; }
.team.won .plus { color: var(--accent); font-weight: 600; }
.hints { color: var(--muted); font-size: 0.7rem; }

/* résultats */
.results { text-align: left; }
.results h1 { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -0.045em; line-height: 1; }
.ranking { list-style: none; margin: 0; padding: 0; width: min(34rem, 100%); }
.ranking li { display: grid; grid-template-columns: 2.5rem 1fr auto; align-items: baseline; gap: 0.6rem; padding: 0.9rem 0; border-bottom: 1px solid var(--line); font-size: 1.4rem; }
.ranking .rank { color: var(--muted); font-size: 1rem; }
.ranking .score { font-weight: 700; font-variant-numeric: tabular-nums; }
.ranking li.first { border-bottom-color: var(--ink); }
.ranking li.first .score { color: var(--accent); }
.ranking li.first .name { font-weight: 700; }
.recap { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 1rem 0.8rem; margin-top: 1rem; }
.recap-item { margin: 0; }
.recap-item img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--soft); outline: 3px solid transparent; outline-offset: -3px; }
.recap-item.found img { outline-color: var(--accent); }
.recap-item figcaption { padding-top: 0.35rem; font-size: 0.75rem; color: var(--muted); }
.recap-item strong { color: var(--ink); font-weight: 600; }
.recap-item .by { color: var(--accent); }

/* téléphone / portrait */
@media (max-width: 800px), (orientation: portrait) {
  html.playing { font-size: 16px; }
  .game { height: auto; min-height: 100vh; display: flex; flex-direction: column; padding: 0.7rem 0.9rem 1.4rem; gap: 0.9rem; }
  .stage { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
  .cover-wrap { height: auto; width: min(100%, 70vh); }
  .side { width: 100%; grid-template-columns: 1fr; text-align: center; }
  .actions { justify-content: center; }
  .teams { text-align: left; }
  .page { padding-top: 1.2rem; }
}
::selection { background: var(--blue); color: #fff; }

/* ───────── Habillage artistique ─────────
   Règle d'or : la couleur ne touche jamais les pochettes. L'orange n'existe que sur l'accueil ; pendant le jeu,
   le tuto, l'éditeur de decks et les résultats, le fond reste neutre (blanc) pour ne pas fausser la lecture des couleurs. */

/* fond d'accueil : aplat orange + illustration posée derrière les cartes */
body:has(.page.home) { background: var(--orange); overflow-x: clip; }
/* ton illustration : posée en grand à droite, fondue dans l'orange à gauche ; les cartes défilent devant */
body:has(.page.home)::before {
  content: ""; position: fixed; top: 0; right: 0; height: 100vh; width: 100vh; max-width: 100vw; z-index: -1; pointer-events: none;
  background: url(art/home.webp) no-repeat right top / auto 100%;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 22%); mask-image: linear-gradient(to right, transparent 0, #000 22%);
}
.home .hero, .home .card { position: relative; z-index: 1; }
@media (min-width: 1000px) and (orientation: landscape) { /* écran large : colonne à gauche, illustration entière à droite */
  .page.home { margin-left: 4vw; max-width: 46vw; }
}
body:has(.page.home)::after { /* léger grain, pour le côté sérigraphie */
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.04; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.home .hero { padding: 1.4rem 0 0.4rem; display: grid; gap: 0.9rem; }
.home .hero h1 { margin: 0; line-height: 0; }
.pixel-title { display: block; width: min(100%, 24rem); height: auto; }

.home .card {
  background: #fff; border: 2px solid var(--ink); padding: 1.1rem 1.2rem 1.3rem; box-shadow: 0.4rem 0.4rem 0 var(--ink);
}
.home .card.accent { background: #e6edff; border-top: 2px solid var(--ink); box-shadow: 0.4rem 0.4rem 0 var(--blue); }
.home .card h2, .home details.card > summary { color: var(--ink); }
.home .chip { border-color: #cfc9c0; }
.home .chip:hover { border-color: var(--ink); }
.home .chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); box-shadow: 0.15rem 0.15rem 0 var(--orange); }
.home .foot { color: var(--ink); font-weight: 600; }

.home .dock { background: var(--ink); color: #fff; border-top: 0; }
.home .dock .summary { color: #cfc9c0; }
.home .dock .btn.ghost { color: #fff; }
.home .dock .btn.ghost:hover:not(:disabled) { color: var(--orange); }
.home .dock .btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0.25rem 0.25rem 0 var(--orange); }
.home .dock .btn.primary:hover:not(:disabled) { background: #3b73ff; }
.home .dock .btn.primary:active:not(:disabled) { transform: translate(0.15rem, 0.15rem); box-shadow: 0.1rem 0.1rem 0 var(--orange); }
.home :focus-visible { outline-color: var(--blue); }

/* jeu : un liseré orange en haut et la barre de temps orange ; la pochette reste sur fond neutre */
.game { border-top: 0.4rem solid var(--orange); }
.timer-bar { background: var(--orange); }
.timer { height: 4px; }
.info h2 { font-weight: 800; }

@media (max-width: 800px), (orientation: portrait) {
  body:has(.page.home)::before { height: 62vh; width: 62vh; max-width: none; right: -24vh; top: 4vh; opacity: 0.4; /* sur téléphone l'image passe en filigrane pour garder le titre lisible */ }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
