/* Neogie Wordplay. Les couleurs viennent des jetons de charte.css, le thème sombre suit tout seul.
   Une barre, un casier de tuiles, des réglages à gauche et des mots à droite (empilés sur un téléphone). */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--surface-page); -webkit-text-size-adjust: 100%; }
html.attente body { visibility: hidden; }
body {
  --barre: 60px;
  --bord: max(var(--space-4), env(safe-area-inset-left), env(safe-area-inset-right));
  margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--surface-page); color: var(--text);
  font: var(--type-body)/var(--leading-text) var(--font-ui);
}
.cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sans-script { margin: var(--space-6) var(--space-4); text-align: center; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--link); }
button svg path, button svg circle, .langue svg path, .langue svg circle { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

select {
  min-height: var(--target); width: 100%; padding: 0 var(--space-3); border: 1px solid var(--border-field);
  border-radius: var(--radius-control); background: var(--surface-raised); color: var(--text-strong);
}

/* ---------- la barre ---------- */

.barre {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: var(--space-2);
  height: calc(var(--barre) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--bord) 0;
  border-bottom: 1px solid var(--border); background: var(--surface-raised);
}
/* « Neogie Wordplay » : la marque puis le nom, deux dessins de 64 unités de haut tracés dans la même
   police, au même em et sur la même ligne de base (nom_svg.py). À la même hauteur, ils s'alignent
   exactement ; l'écart vaut une espace du mot. La hauteur suit la largeur libre du téléphone. */
.barre { --h: clamp(18px, calc((100vw - 160px) / 7.5), 30px); }
.neogie { display: flex; flex: none; align-items: center; min-height: var(--target); color: var(--text-strong); line-height: 0; }
.neogie svg, .nom-appli svg { display: block; height: var(--h); width: auto; }
.nom-appli { display: flex; flex: none; margin: 0 auto 0 calc(var(--h) * 0.2 - var(--space-2)); color: var(--text-strong); line-height: 0; }
/* La langue : un globe et son code ; la liste native, posée dessus, reste invisible. */
.langue {
  position: relative; display: flex; flex: none; align-items: center; gap: var(--space-1); min-height: var(--target);
  padding: 0 var(--space-2); border: 1px solid var(--border-field); border-radius: var(--radius-control); color: var(--text-strong);
}
.langue:hover { background: var(--surface-hover); }
.langue:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.langue b { font-size: var(--type-body-sm); }
.langue select { position: absolute; inset: 0; width: 100%; min-height: 0; height: 100%; opacity: 0; cursor: pointer; }
.icone {
  display: grid; flex: none; place-items: center; width: var(--target); height: var(--target); padding: 0;
  border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text-strong);
}
.icone:hover { background: var(--surface-hover); }
.secondaire, .proposition-action {
  min-height: var(--target); padding: 0 var(--space-4); border: 1px solid var(--border-field);
  border-radius: var(--radius-control); background: var(--surface-raised); color: var(--text-strong); font-weight: 600;
}
.secondaire:hover { background: var(--surface-hover); }

/* Téléphone étroit : la barre se resserre. */
@media (max-width: 349px) {
  .langue { padding: 0 6px; }
}

/* ---------- la recherche ---------- */

.corps { display: grid; grid-template-columns: minmax(0, 1fr); }
.recherche { padding: var(--space-4) var(--bord) var(--space-5); background: var(--surface-raised); border-bottom: 1px solid var(--border); }

/* Le bandeau qui propose l'installation, au lancement. */
.proposition {
  display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-card); background: var(--surface-sunken);
}
.proposition img { flex: none; border-radius: 10px; }
.proposition-texte { display: grid; flex: 1; min-width: 0; gap: 2px; font-size: var(--type-caption); color: var(--text-muted); line-height: var(--leading-tight); }
.proposition-texte b { color: var(--text-strong); font-size: var(--type-body-sm); }
.proposition-action { flex: none; padding: 0 var(--space-3); border-color: var(--action); background: var(--action); color: var(--action-text); }
.proposition-action:hover { background: var(--action-hover); }
.proposition .icone { margin-left: calc(-1 * var(--space-2)); }

/* Le casier : les lettres tapées deviennent des tuiles. */
.casier {
  --tuile: 52px;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 6px;
  min-height: 92px; padding: var(--space-3) var(--space-2) var(--space-4); border-radius: var(--radius-card);
  background: var(--surface-page); cursor: text;
}
.tuile {
  display: grid; place-items: center; width: var(--tuile); height: calc(var(--tuile) * 1.12);
  border: 1px solid var(--border-strong); border-radius: calc(var(--tuile) * 0.18);
  background: var(--surface-raised); box-shadow: 0 4px 0 var(--border-strong); color: var(--text-strong);
  font: var(--weight-display) calc(var(--tuile) * 0.56)/1 var(--font-display); text-transform: uppercase;
}
.tuile.nouvelle { animation: poser var(--t-mid) var(--spring); }
.tuile.une { border: 2px dashed var(--action); color: var(--link); }
.tuile.suite { border-color: var(--accent-pop); background: var(--accent-pop); box-shadow: 0 4px 0 var(--action); color: var(--accent-pop-text); }
.tuile.vide { border: 2px dashed var(--border); background: transparent; box-shadow: none; }
@keyframes poser { from { transform: translateY(-8px) scale(0.85); opacity: 0; } }

.saisie { position: relative; margin-top: var(--space-3); }
.saisie input {
  width: 100%; min-height: 56px; padding: 0 56px 0 var(--space-4); border: 2px solid var(--border-field);
  border-radius: var(--radius-card); background: var(--surface-sunken); color: var(--text-strong);
  font-size: var(--type-h2); font-weight: 600; letter-spacing: 0.04em;
}
.saisie input::placeholder { color: var(--text-subtle); font-size: var(--type-body); font-weight: 400; letter-spacing: 0; }
.saisie input:focus { border-color: var(--action); outline: none; box-shadow: var(--glow-action); }
.vider { position: absolute; top: 6px; right: 6px; }

.jokers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: var(--space-2); }
.joker {
  display: flex; align-items: center; gap: var(--space-2); min-height: var(--target); padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-control); background: transparent; text-align: start;
  color: var(--text-muted); font-size: var(--type-caption); line-height: var(--leading-tight);
}
.joker:hover { background: var(--surface-hover); }
.joker b { display: grid; flex: none; place-items: center; width: 28px; height: 30px; border-radius: 6px; font: var(--weight-display) var(--type-title)/1 var(--font-display); }
.joker[data-signe="?"] b { border: 2px dashed var(--action); color: var(--link); }
.joker[data-signe="*"] b { background: var(--accent-pop); color: var(--accent-pop-text); }

/* La recherche choisie : son nom et ce qu'elle fait, sur un seul bouton qui ouvre la feuille des choix. */
.choix-type {
  display: grid; grid-template-columns: 1fr auto; column-gap: var(--space-2); width: 100%; margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3); border: 1px solid var(--border-field); border-radius: var(--radius-control);
  background: var(--surface-raised); color: var(--text); text-align: left; cursor: pointer;
}
.choix-type:hover { background: var(--surface-hover); }
.choix-type-etiquette { grid-column: 1; color: var(--text-muted); font-size: var(--type-caption); font-weight: 600; }
.choix-type-nom { grid-column: 1; color: var(--text-strong); font: var(--weight-display) var(--type-title-sm)/1.3 var(--font-display); }
.choix-type .aide { grid-column: 1; margin: 0; }
.choix-type svg { grid-column: 2; grid-row: 1 / span 3; align-self: center; color: var(--text-muted); }
.aide { color: var(--text-muted); font-size: var(--type-body-sm); }

/* La feuille des choix : monte du bas sur téléphone, au centre sur un grand écran. */
.feuille {
  width: min(480px, calc(100vw - 2 * var(--space-4))); max-height: calc(100dvh - 2 * var(--space-4)); padding: var(--space-4) var(--space-4) var(--space-5);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sheet); background: var(--surface-raised); color: var(--text);
  box-shadow: var(--shadow-3);
}
.feuille::backdrop { background: var(--scrim); }
.feuille h2 { margin: 0; color: var(--text-strong); font: var(--weight-display) var(--type-title)/var(--leading-tight) var(--font-display); }
.famille { margin: var(--space-2) 0 2px; color: var(--text-muted); font-size: var(--type-caption); font-weight: 700; }
.famille:first-child { margin-top: 0; }
.option-type {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: 4px var(--space-3);
  border: 1px solid transparent; border-radius: var(--radius-control); cursor: pointer;
}
.option-type:hover { background: var(--surface-hover); }
.option-type:has(input:checked) { border-color: var(--action); background: var(--surface-selected); }
.option-type input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--action); }
.option-type b { display: block; color: var(--text-strong); font-weight: 700; }
.option-type span span { display: block; color: var(--text-muted); font-size: var(--type-body-sm); }
@media (max-width: 879px) {
  .feuille {
    width: 100%; max-width: none; max-height: 88dvh; margin: auto 0 0; padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
    border-width: 1px 0 0; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  }
}

/* Le nombre de lettres : deux curseurs sur une même piste. */
.longueurs { grid-column: 1 / -1; }
.longueurs-valeur { display: block; color: var(--text-strong); font: var(--weight-display) var(--type-title-sm)/1.3 var(--font-display); }
.double { --de: 0%; --a: 100%; position: relative; height: var(--target); margin: 0 14px; }
.double::before, .double::after { content: ''; position: absolute; top: 50%; height: 6px; margin-top: -3px; border-radius: var(--radius-pill); }
.double::before { right: -14px; left: -14px; background: var(--surface-selected); }
.double::after { left: var(--de); right: calc(100% - var(--a)); background: var(--action); }
.double input {
  position: absolute; inset: 0 -14px; z-index: 1; width: calc(100% + 28px); height: 100%; margin: 0;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.double input::-webkit-slider-runnable-track { background: none; }
.double input::-webkit-slider-thumb {
  width: 30px; height: 30px; border: 3px solid var(--surface-raised); border-radius: 50%; background: var(--action);
  box-shadow: var(--shadow-2); cursor: grab; pointer-events: auto; -webkit-appearance: none; appearance: none;
}
.double input::-moz-range-track { background: none; }
.double input::-moz-range-thumb {
  width: 24px; height: 24px; border: 3px solid var(--surface-raised); border-radius: 50%; background: var(--action);
  box-shadow: var(--shadow-2); cursor: grab; pointer-events: auto;
}
.double input:focus-visible { outline: none; }
.double input:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--focus); outline-offset: 2px; }
.double input:focus-visible::-moz-range-thumb { outline: 3px solid var(--focus); outline-offset: 2px; }
.longueurs-bornes { display: flex; justify-content: space-between; color: var(--text-subtle); font-size: var(--type-caption); }

/* Les options, repliées sur téléphone sous une ligne qui les résume. */
.options { margin-top: var(--space-3); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.options summary {
  display: flex; align-items: center; gap: var(--space-2); min-height: var(--target); cursor: pointer; list-style: none;
  color: var(--text-strong); font-size: var(--type-body-sm); font-weight: 600;
}
.options summary::-webkit-details-marker { display: none; }
.options summary::after {
  content: ''; width: 8px; height: 8px; margin: 0 var(--space-1) 4px auto; border: solid var(--text-muted);
  border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform var(--t-fast) var(--ease);
}
.options[open] summary::after { margin-bottom: -4px; transform: rotate(-135deg); }
.resume { min-width: 0; overflow: hidden; color: var(--text-muted); font-weight: 400; white-space: nowrap; text-overflow: ellipsis; }
.options[open] { padding-bottom: var(--space-3); }
.reglage-lignes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-1); }
.reglage { display: block; min-width: 0; }
.reglage > span { display: block; margin-bottom: var(--space-1); color: var(--text-muted); font-size: var(--type-caption); font-weight: 600; }
.reglage-large { grid-column: 1 / -1; }
.bascule { display: flex; align-items: center; gap: var(--space-3); min-height: var(--target); margin-top: var(--space-2); cursor: pointer; }
.bascule input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--action); }
.bascule input:disabled + span { color: var(--text-subtle); }

.chercher {
  width: 100%; min-height: 56px; margin-top: var(--space-3); border: 0; border-radius: var(--radius-card);
  background: var(--action); color: var(--action-text); font: var(--weight-display) var(--type-title)/1 var(--font-display);
}
.chercher:hover { background: var(--action-hover); }

/* Revenir à la saisie depuis les résultats, sur téléphone. */
.remonter {
  position: fixed; right: max(var(--space-4), env(safe-area-inset-right)); bottom: calc(var(--space-4) + env(safe-area-inset-bottom)); z-index: 9;
  display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
  background: var(--action); color: var(--action-text); box-shadow: var(--shadow-3);
}
.remonter:hover { background: var(--action-hover); }

/* Téléphone : la saisie reste en haut de l'écran. */
@media (max-width: 879px) {
  .casier { --tuile: 44px; min-height: 76px; padding: var(--space-3) var(--space-2); }
}
.hors-ligne { min-height: 1.45em; margin: var(--space-3) 0 0; color: var(--text-muted); font-size: var(--type-caption); text-align: center; }

/* ---------- les résultats ---------- */

.resultats { min-width: 0; padding: var(--space-4) var(--bord) calc(var(--space-7) + env(safe-area-inset-bottom)); scroll-margin-top: var(--barre); }
.etat { color: var(--text-muted); }
.etat.erreur { color: var(--negative); font-weight: 600; }
.progres { height: 6px; margin-top: var(--space-2); overflow: hidden; border-radius: var(--radius-pill); background: var(--surface-selected); }
.progres i { display: block; width: 0; height: 100%; background: var(--action); transition: width var(--t-mid) var(--ease); }
.note { margin: var(--space-2) 0 0; color: var(--text-muted); font-size: var(--type-body-sm); }
.accueil { padding: var(--space-5) 0; text-align: center; }
.accueil p { max-width: 36ch; margin: 0 auto var(--space-4); color: var(--text-muted); }
.exemples { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
.exemple {
  display: grid; gap: 2px; min-width: 130px; min-height: var(--target); padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface-raised);
}
.exemple:hover { border-color: var(--action); }
.exemple b { color: var(--text-strong); font: var(--weight-display) var(--type-title)/var(--leading-tight) var(--font-display); }
.exemple small { color: var(--text-muted); font-size: var(--type-caption); }

.bilan { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.bilan p { margin: 0; color: var(--text-strong); font: var(--weight-display) var(--type-h2)/var(--leading-tight) var(--font-display); }
.legende { margin: var(--space-2) 0 0; color: var(--text-muted); font-size: var(--type-caption); }
.groupe h3 {
  position: sticky; top: calc(var(--barre) + env(safe-area-inset-top)); z-index: 2; display: flex; align-items: center;
  justify-content: space-between; gap: var(--space-3); margin: var(--space-3) 0 0; padding: var(--space-2) 0;
  border-bottom: 2px solid var(--border); background: var(--surface-page); color: var(--text-strong); font-size: var(--type-title-sm);
}
.groupe h3 span { min-width: 2.5em; padding: 0 var(--space-2); border-radius: var(--radius-pill); background: var(--surface-selected); font-size: var(--type-caption); text-align: center; font-variant-numeric: tabular-nums; }
.mots { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-2); margin: var(--space-3) 0 0; padding: 0; list-style: none; }
.mots li { display: flex; min-width: 0; }
.mot {
  flex: 1; min-height: var(--target); padding: var(--space-2) var(--space-3); border: 1px solid var(--border);
  border-radius: var(--radius-control); background: var(--surface-raised); color: var(--text-strong); text-align: start;
  font-weight: 600; overflow-wrap: anywhere;
}
.mot:hover { border-color: var(--action); }
.mot:active { background: var(--surface-selected); }
.mot .tapee { color: var(--link); }
.groupe .secondaire { margin-top: var(--space-3); width: 100%; }
.tronque { color: var(--text-muted); font-size: var(--type-body-sm); }
.credits { margin: var(--space-2) 0 0; color: var(--text-muted); font-size: var(--type-caption); }

/* ---------- réglages, messages ---------- */

.reglages {
  width: min(440px, calc(100vw - 2 * var(--space-4))); max-height: calc(100dvh - 2 * var(--space-4)); padding: var(--space-4) var(--space-5) var(--space-5);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sheet); background: var(--surface-raised); color: var(--text);
  box-shadow: var(--shadow-3);
}
.reglages::backdrop { background: var(--scrim); }
.reglages-tete { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.reglages h2 { margin: 0; color: var(--text-strong); font: var(--weight-display) var(--type-title)/var(--leading-tight) var(--font-display); }
.reglages h3 { margin: var(--space-5) 0 var(--space-1); color: var(--text-strong); font-size: var(--type-title-sm); }
.reglages p { margin: 0 0 var(--space-2); font-size: var(--type-body-sm); }
.liens { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-4) !important; }
.liens a { display: inline-flex; align-items: center; min-height: var(--target); }
.bandeau {
  position: fixed; right: var(--space-4); bottom: calc(var(--space-4) + env(safe-area-inset-bottom)); left: var(--space-4); z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); max-width: 480px; margin: 0 auto;
  padding: var(--space-3) var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-card);
  background: var(--surface-raised); box-shadow: var(--shadow-3);
}
.bulle {
  position: fixed; bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); left: 50%; z-index: 11; max-width: calc(100vw - 2 * var(--space-4));
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-pill); background: var(--text-strong); color: var(--surface-raised);
  font-weight: 600; opacity: 0; pointer-events: none; transform: translate(-50%, 8px);
  transition: opacity var(--t-fast), transform var(--t-mid) var(--ease);
}
.bulle.visible { opacity: 1; transform: translate(-50%, 0); }
.bulle:empty { display: none; }

/* ---------- grand écran : deux volets qui défilent chacun de leur côté ---------- */

@media (min-width: 880px) {
  body { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
  .barre { flex: none; }
  .corps { flex: 1; min-height: 0; grid-template-columns: minmax(380px, 440px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .recherche { overflow-y: auto; border-right: 1px solid var(--border); border-bottom: 0; }
  .resultats { overflow-y: auto; padding-inline: var(--space-6); }
  .groupe h3 { top: calc(-1 * var(--space-4)); }
  .accueil { padding-top: 12vh; }
}
