/* ═══════════════════════════ Mots croisés : la grille de vos mots ═══════════════════════════
 *
 * La grille d'une personne ou d'une famille, bâtie avec ses propres mots. Servie **seulement** sur sa
 * fiche (`views/product-affiche.liquid`). Le dessin (`public/js/mots-croises-calcul.mjs`) ne porte
 * que des classes : tout ce qui se voit est ici.
 *
 * ── Quatre styles, quatre ambiances (pas quatre palettes) ──
 *
 * - **Journal** : la page de jeux d'un quotidien. Papier journal, filets noirs, Playfair en capitales,
 *   des cases blanches à fin trait. Sobre, le plus « vrai ».
 * - **Cahier** : une feuille quadrillée d'écolier, encre bleu-noir, Damion pour le titre et les
 *   lettres, la note de la maîtresse en rouge dans le coin (« Très bien ! 20/20 »).
 * - **Pop** : chaque mot a sa couleur — la case, le numéro et la définition —, Fredoka, un
 *   autocollant jaune. Le plus joyeux, celui des enfants et des anniversaires.
 * - **Ardoise** : le menu d'un bistrot, à la craie sur un tableau vert dans un cadre de bois.
 *
 * ── Les couleurs ──
 *
 * **Ce sont des couleurs de produit, pas de charte** (point 6 quater) : en clair, toutes ici, en
 * tête, et nulle part ailleurs. `[data-style]` ne nomme pas `.mc` exprès, pour que les échantillons
 * du formulaire se colorent avec les mêmes variables.
 * --m-fond : le papier ; --m-encre : le titre et le texte ; --m-doux : ce qui est secondaire (la
 * longueur d'un mot, l'intitulé du sens) ; --m-case / --m-trait : une case et son contour ;
 * --m-num / --m-lettre : le numéro d'une case et sa lettre ; --m-accent : la touche du style.
 * **Contrastes mesurés** (`tests/mots-croises.test.js`) : texte et lettres ≥ 7 sur le papier,
 * texte secondaire ≥ 4,5, et, en Pop, le texte sur chacune des dix couleurs de mot ≥ 4,5.
 */
@font-face {
  font-family: "Damion";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/damion-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Damion";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/damion-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

[data-style="Journal"] {
  --m-fond: #eee6d0; --m-encre: #1b1813; --m-doux: #5a5242; --m-case: #fbf7ea; --m-trait: #1b1813;
  --m-num: #1b1813; --m-lettre: #1b1813; --m-accent: #9a2b1f;
}
[data-style="Cahier"] {
  --m-fond: #fbfaf4; --m-encre: #1f2d5a; --m-doux: #4a5a8a; --m-case: #ffffff; --m-trait: #2a4aa0;
  --m-num: #2a4aa0; --m-lettre: #1f2d5a; --m-accent: #c93a33;
  /* Le quadrillage et la marge de la feuille. */
  --m-ligne: #cdd7ef; --m-marge: #e58b84;
}
[data-style="Pop"] {
  --m-fond: #fff3d2; --m-encre: #1e1840; --m-doux: #4a4170; --m-case: #ffffff; --m-trait: #1e1840;
  --m-num: #1e1840; --m-lettre: #1e1840; --m-accent: #ff5d5d; --m-sticker: #ffd23f;
  /* Une couleur par mot, dans l'ordre des lignes du formulaire. */
  --p1: #ff6b6b; --p2: #ffc145; --p3: #4cd7b0; --p4: #9b8aff; --p5: #ff9a4d;
  --p6: #5cc8ff; --p7: #ff7eb6; --p8: #b6e35b; --p9: #ffb8a1; --p10: #c9b8ff;
}
[data-style="Ardoise"] {
  --m-fond: #25403a; --m-encre: #f3f0e4; --m-doux: #c4cdbf; --m-case: transparent; --m-trait: #e9e5d4;
  --m-num: #c4cdbf; --m-lettre: #f3f0e4; --m-accent: #f2c94c;
  /* Le cadre de bois du tableau. */
  --m-bois: #8a5c32; --m-bois-ombre: #5e3d1e;
}

/* ── L'affiche ──
 *
 * Tout est en `cqw` : l'affiche se lit sur sa propre largeur. Les rapports vendus vont de 1,333
 * (30 × 40) à 1,5 (40 × 60). `--mc-t` (1 à 0,6) resserre le corps du texte quand les définitions
 * ne tiennent pas, `--mc-tt` le titre ; **jamais la place de la grille**, qui vient de son
 * rapport (`--mc-l` colonnes sur `--mc-h` rangées, posés par le serveur et par l'éditeur). */
.mc {
  --fond: var(--m-fond); --texte: var(--m-encre);
  --t: var(--mc-t, 1); --tt: var(--mc-tt, 1);
  position: relative; display: flex; flex-direction: column; justify-content: center; gap: calc(3cqw * var(--t));
  padding: 6.5cqw 6.5cqw 5.5cqw; line-height: 1.2; font-family: "Inter", system-ui, sans-serif;
}
.mc :where(p, ol, h3) { margin: 0; padding: 0; }
.mc [hidden] { display: none !important; }
/* L'exemple est montré en pleine couleur (Fred, 8 oct. 2026 : à 40 % d'opacité, la première vue de
   la fiche était délavée). La classe reste : la fabrication le masque. */
.mc .affiche-exemple { opacity: 1; }

.mc__tete { position: relative; display: grid; gap: calc(1.1cqw * var(--t)); text-align: center; }
.mc__kicker { font-size: calc(1.9cqw * var(--t)); }
.mc__kicker span { display: none; }
.mc[data-style="Journal"] .mc__kicker [data-k="Journal"],
.mc[data-style="Cahier"] .mc__kicker [data-k="Cahier"],
.mc[data-style="Pop"] .mc__kicker [data-k="Pop"],
.mc[data-style="Ardoise"] .mc__kicker [data-k="Ardoise"] { display: inline; }
.mc__titre { font-size: calc(7.4cqw * var(--tt)); line-height: 1.04; overflow-wrap: anywhere; text-wrap: balance; }
.mc__sous { font-size: calc(2.7cqw * var(--t)); color: var(--m-doux); overflow-wrap: anywhere; }
.mc__note, .mc__sticker { display: none; }

/* La grille : sa place se déduit de son rapport. Au plus 56 cqw de haut, 87 de large. */
.mc__zone { display: flex; justify-content: center; }
.mc__grille {
  --gh: calc(56cqw * var(--t)); flex: none;
  width: min(100%, calc(var(--gh) * var(--mc-l, 1) / var(--mc-h, 1))); aspect-ratio: var(--mc-l, 1) / var(--mc-h, 1);
}
.mc__svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mc__svg .case { fill: var(--m-case); stroke: var(--m-trait); stroke-width: .55; }
.mc__svg .n { font: 600 2.7px/1 "Inter", system-ui, sans-serif; fill: var(--m-num); }
.mc__svg .l { font: 600 6.3px/1 "Inter", system-ui, sans-serif; fill: var(--m-lettre); text-anchor: middle; dominant-baseline: central; }

/* Les définitions, rangées par sens ; la solution à droite quand la grille est à résoudre. */
.mc__bas { display: grid; grid-template-columns: minmax(0, 1fr); gap: calc(3cqw * var(--t)); align-items: start; }
.mc[data-resoudre] .mc__bas { grid-template-columns: minmax(0, 1fr) 27cqw; }
.mc__indices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: calc(3cqw * var(--t)); }
.mc__sens:only-child { grid-column: 1 / -1; }
.mc__sens h3 { margin-bottom: calc(.9cqw * var(--t)); font-size: calc(1.9cqw * var(--t)); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--m-doux); }
.mc__sens ol { list-style: none; display: grid; gap: calc(.8cqw * var(--t)); }
.mc__sens li { font-size: calc(2.15cqw * var(--t)); line-height: 1.25; overflow-wrap: anywhere; }
.mc__sens li b { font-weight: 700; margin-right: .15em; }
.mc__sens li i { font-style: normal; color: var(--m-doux); white-space: nowrap; }

/* La solution, imprimée à l'envers comme dans un journal : pour tricher, il faut retourner l'affiche. */
.mc__solution { transform: rotate(180deg); text-align: center; }
.mc__solution-titre { margin-bottom: calc(.9cqw * var(--t)); font-size: calc(1.6cqw * var(--t)); font-weight: 700; text-transform: uppercase; letter-spacing: .18em; color: var(--m-doux); }
.mc__solution-grille { width: 100%; aspect-ratio: var(--mc-l, 1) / var(--mc-h, 1); }
.mc__solution .n { display: none; }

/* ── Journal ── */
.mc[data-style="Journal"] .mc__tete { padding: calc(1.6cqw * var(--t)) 0 calc(1.8cqw * var(--t)); border-top: .9cqw solid var(--m-encre); border-bottom: .3cqw solid var(--m-encre); }
.mc[data-style="Journal"] .mc__tete::before { content: ""; position: absolute; left: 0; right: 0; top: calc(-1.9cqw); border-top: .2cqw solid var(--m-encre); }
.mc[data-style="Journal"] .mc__kicker { font-weight: 600; text-transform: uppercase; letter-spacing: .2em; font-size: calc(1.7cqw * var(--t)); color: var(--m-doux); }
.mc[data-style="Journal"] .mc__titre { font-family: "Playfair Display", Georgia, serif; font-weight: 900; text-transform: uppercase; letter-spacing: .01em; }
.mc[data-style="Journal"] .mc__sous { font-family: "Playfair Display", Georgia, serif; font-style: italic; font-size: calc(2.9cqw * var(--t)); }
.mc[data-style="Journal"] .mc__svg .l { font-family: "Playfair Display", Georgia, serif; font-weight: 700; }
.mc[data-style="Journal"] .mc__sens li { font-family: "Playfair Display", Georgia, serif; font-weight: 500; }
.mc[data-style="Journal"] .mc__sens h3 { font-family: "Inter", system-ui, sans-serif; border-bottom: .2cqw solid var(--m-encre); padding-bottom: .5cqw; color: var(--m-encre); }

/* ── Cahier ── */
.mc[data-style="Cahier"] {
  padding-left: 13cqw;
  background-image:
    linear-gradient(to right, transparent 9cqw, var(--m-marge) 9cqw, var(--m-marge) 9.3cqw, transparent 9.3cqw),
    repeating-linear-gradient(to bottom, transparent 0, transparent 2.1cqw, var(--m-ligne) 2.1cqw, var(--m-ligne) 2.24cqw),
    repeating-linear-gradient(to right, transparent 0, transparent 8.36cqw, var(--m-ligne) 8.36cqw, var(--m-ligne) 8.5cqw);
}
.mc[data-style="Cahier"] .mc__tete { text-align: left; padding-top: calc(4.5cqw * var(--t)); }
.mc[data-style="Cahier"] .mc__kicker { font-family: "Josefin Sans", system-ui, sans-serif; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--m-doux); }
.mc[data-style="Cahier"] .mc__titre { font-family: "Damion", "Sacramento", cursive; font-weight: 400; color: var(--m-encre); font-size: calc(8.4cqw * var(--tt)); line-height: 1.08; text-wrap: pretty; padding-right: 17cqw; }
.mc[data-style="Cahier"] .mc__sous { font-family: "Damion", "Sacramento", cursive; font-size: calc(3.6cqw * var(--t)); }
.mc[data-style="Cahier"] .mc__note {
  display: block; position: absolute; top: 0; right: -1cqw; transform: rotate(-9deg); text-align: center; color: var(--m-accent);
  font-family: "Damion", "Sacramento", cursive; line-height: 1;
}
.mc[data-style="Cahier"] .mc__note b { display: block; font-weight: 400; font-size: calc(3.6cqw * var(--t)); }
.mc[data-style="Cahier"] .mc__note i { display: inline-block; margin-top: .4cqw; padding: .5cqw 1.6cqw; font-style: normal; font-size: calc(5.4cqw * var(--t)); border: .35cqw solid var(--m-accent); border-radius: 50%; }
.mc[data-style="Cahier"] .mc__svg .case { stroke-width: .7; }
.mc[data-style="Cahier"] .mc__svg .l { font-family: "Damion", "Sacramento", cursive; font-weight: 400; font-size: 7.4px; }
.mc[data-style="Cahier"] .mc__sens li { font-family: "Josefin Sans", system-ui, sans-serif; font-weight: 400; }
.mc[data-style="Cahier"] .mc__sens h3 { font-family: "Damion", "Sacramento", cursive; font-weight: 400; font-size: calc(3.2cqw * var(--t)); letter-spacing: 0; text-transform: none; color: var(--m-accent); }

/* ── Pop ── */
.mc[data-style="Pop"] { font-family: "Fredoka", system-ui, sans-serif; }
.mc[data-style="Pop"] .mc__tete { text-align: left; padding-right: 17cqw; }
.mc[data-style="Pop"] .mc__kicker { font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--m-doux); }
.mc[data-style="Pop"] .mc__titre { font-weight: 600; font-size: calc(8cqw * var(--tt)); text-shadow: .5cqw .5cqw 0 var(--p1); }
.mc[data-style="Pop"] .mc__sous { font-weight: 500; }
.mc[data-style="Pop"] .mc__sticker {
  display: grid; place-items: center; position: absolute; top: -.5cqw; right: -1cqw; width: 15cqw; height: 15cqw; padding: 1.2cqw; box-sizing: border-box;
  transform: rotate(12deg); border: .5cqw solid var(--m-trait); border-radius: 50%; background: var(--m-sticker); color: var(--m-encre);
  font-weight: 600; font-size: calc(2.4cqw * var(--t)); line-height: 1.05; text-align: center; box-shadow: .6cqw .6cqw 0 var(--m-trait);
}
.mc[data-style="Pop"] .mc__svg .case { stroke-width: .9; }
.mc[data-style="Pop"] .mc__svg .l { font-family: "Fredoka", system-ui, sans-serif; font-weight: 600; }
.mc[data-style="Pop"] .mc__sens li { font-weight: 500; }
.mc[data-style="Pop"] .mc__sens li b { display: inline-block; min-width: 1.7em; padding: .05em .35em; margin-right: .3em; border-radius: 99rem; background: var(--wc, var(--p1)); text-align: center; }
.mc[data-style="Pop"] .mc__sens h3 { font-weight: 600; }
.mc[data-style="Pop"] .mc__solution-grille .case { stroke-width: .9; }
.mc[data-style="Pop"] [data-w="1"] { --wc: var(--p1); } .mc[data-style="Pop"] [data-w="2"] { --wc: var(--p2); }
.mc[data-style="Pop"] [data-w="3"] { --wc: var(--p3); } .mc[data-style="Pop"] [data-w="4"] { --wc: var(--p4); }
.mc[data-style="Pop"] [data-w="5"] { --wc: var(--p5); } .mc[data-style="Pop"] [data-w="6"] { --wc: var(--p6); }
.mc[data-style="Pop"] [data-w="7"] { --wc: var(--p7); } .mc[data-style="Pop"] [data-w="8"] { --wc: var(--p8); }
.mc[data-style="Pop"] [data-w="9"] { --wc: var(--p9); } .mc[data-style="Pop"] [data-w="10"] { --wc: var(--p10); }
.mc[data-style="Pop"] .mc__svg .c .case { fill: var(--wc, var(--m-case)); }

/* ── Ardoise ── */
.mc[data-style="Ardoise"] {
  padding: 9.5cqw 9cqw 8cqw;
  background-image: radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, .06), transparent 60%);
  box-shadow: inset 0 0 0 2.4cqw var(--m-bois), inset 0 0 0 2.9cqw var(--m-bois-ombre), inset 0 0 4cqw 3cqw rgba(0, 0, 0, .35);
}
.mc[data-style="Ardoise"] .mc__tete { gap: calc(.9cqw * var(--t)); }
.mc[data-style="Ardoise"] .mc__kicker { font-family: "Josefin Sans", system-ui, sans-serif; font-weight: 600; text-transform: uppercase; letter-spacing: .26em; color: var(--m-accent); }
.mc[data-style="Ardoise"] .mc__titre { font-family: "Damion", "Sacramento", cursive; font-weight: 400; font-size: calc(8.6cqw * var(--tt)); line-height: 1.06; text-shadow: 0 0 .5cqw rgba(255, 255, 255, .25); }
.mc[data-style="Ardoise"] .mc__sous { font-family: "Josefin Sans", system-ui, sans-serif; font-weight: 300; letter-spacing: .1em; text-transform: uppercase; font-size: calc(2.3cqw * var(--t)); }
.mc[data-style="Ardoise"] .mc__tete::after { content: ""; display: block; width: 36cqw; margin: calc(1.2cqw * var(--t)) auto 0; border-top: .35cqw dashed var(--m-doux); }
.mc[data-style="Ardoise"] .mc__svg .case { stroke-width: .5; }
.mc[data-style="Ardoise"] .mc__svg .l { font-family: "Josefin Sans", system-ui, sans-serif; font-weight: 600; }
.mc[data-style="Ardoise"] .mc__sens li { font-family: "Josefin Sans", system-ui, sans-serif; font-weight: 400; }
.mc[data-style="Ardoise"] .mc__sens h3 { font-family: "Josefin Sans", system-ui, sans-serif; color: var(--m-accent); }

/* ── Le formulaire ── */
.mc-styles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.mc-styles input, .mc-versions input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.mc-styles label, .mc-versions label {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; cursor: pointer; margin: 0;
  font-size: 1.4rem; font-weight: 600; text-align: center; line-height: 1.25;
  border: .15rem solid rgba(var(--color-foreground), .15); border-radius: .8rem; padding: .8rem .6rem;
}
.mc-styles label small, .mc-versions label small { font-weight: 400; font-size: 1.2rem; opacity: .8; }
.mc-styles input:checked + label, .mc-versions input:checked + label { border-color: rgb(var(--color-foreground)); }
.mc-styles input:focus-visible + label, .mc-versions input:focus-visible + label { outline: .2rem solid rgb(var(--bleu-focus)); outline-offset: .2rem; }
/* L'échantillon : un petit bout de grille dans l'ambiance du style. */
.mc-echantillon {
  display: grid; grid-template-columns: repeat(3, 2.6rem); grid-template-rows: repeat(2, 2.6rem); gap: 0; justify-content: center; align-content: center;
  width: 100%; max-width: 12rem; height: 6.4rem; background: var(--m-fond); border-radius: .4rem; overflow: hidden;
}
.mc-echantillon i { background: var(--m-case); box-shadow: 0 0 0 .1rem var(--m-trait); }
.mc-echantillon i:nth-child(1) { grid-column: 1; grid-row: 1; }
.mc-echantillon i:nth-child(2) { grid-column: 2; grid-row: 1; }
.mc-echantillon i:nth-child(3) { grid-column: 3; grid-row: 1; }
.mc-echantillon i:nth-child(4) { grid-column: 2; grid-row: 2; }
.mc-styles [data-style="Pop"] .mc-echantillon i:nth-child(1) { background: var(--p1); }
.mc-styles [data-style="Pop"] .mc-echantillon i:nth-child(2) { background: var(--p3); }
.mc-styles [data-style="Pop"] .mc-echantillon i:nth-child(3) { background: var(--p2); }
.mc-styles [data-style="Pop"] .mc-echantillon i:nth-child(4) { background: var(--p4); }
.mc-versions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.mc-mots { display: grid; gap: 1.2rem; }
.mc-ligne { padding: 0; border: 0; margin: 0; min-width: 0; }
.mc-ligne legend { font-weight: 600; padding: 0; margin-bottom: .4rem; }
.mc-ligne__champs { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: .8rem; }
.mc-ligne label { display: block; font-size: 1.3rem; margin-bottom: .3rem; }
.mc-ligne input { width: 100%; }
.mc-alerte { margin: 0; padding: 1rem 1.2rem; border-radius: .6rem; border: .15rem solid rgba(var(--rouge), .5); background: rgb(var(--rouge-fond)); color: rgb(var(--rouge)); font-weight: 600; font-size: 1.4rem; }
.mc-pistes { font-size: 1.4rem; margin-top: .4rem; }
.mc-pistes summary { cursor: pointer; font-weight: 600; min-height: 4.4rem; display: flex; align-items: center; }
.mc-pistes ol { margin: .4rem 0 0; padding-left: 2.2rem; display: grid; gap: .4rem; }
@media (min-width: 750px) { .mc-styles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
