/* Anzi · identité « Kabylie de nuit », reprise de Fournée comme Taddart :
   couleurs de la terre, frise des poteries, losanges des tapis, Bricolage Grotesque.
   Propre à Anzi : chaque mot est une tuile de poterie, que l'on retisse dans une
   bande de tapis bordée de losanges. */

@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url('polices/bricolage-grotesque-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;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url('polices/bricolage-grotesque-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Noto Sans (700) pour le kabyle : contrairement à Bricolage Grotesque, elle a ɛ ɣ ḍ ṭ ẓ ḥ ǧ ṛ ṣ. */
@font-face {
  font-family: 'Noto Sans Anzi';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('polices/noto-sans-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;
}
@font-face {
  font-family: 'Noto Sans Anzi';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('polices/noto-sans-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Sans Tifinagh';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('polices/noto-sans-tifinagh.woff2') format('woff2');
  unicode-range: U+02C7, U+0301-0302, U+0304, U+0306-0309, U+0323, U+0331, U+200C-200D, U+202E, U+25CC, U+2D30-2D7F;
}

/* Jetons de Fournée : mêmes noms et mêmes valeurs, aucune autre palette. */
:root {
  --nuit: #120d0a;
  --argile: #1b1310;
  --argile-claire: #231913;
  --bordure: #2c1f17;
  --bordure-forte: #3a2a1f;
  --laine: #f4e9d8;
  --laine-2: #d9c7b0;
  --sable: #a8927c;
  --eteint: #7d6a58;
  --terre-cuite: #d4512f;
  --safran: #f2b335;
  --olivier: #3f8a73;
  --rayon-carte: 12px;
  --rayon-tuile: 4px 4px 16px 16px;
  --rayon-mot: 4px 4px 12px 12px;
  --court: 150ms;
  --moyen: 250ms;
  --police: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  /* Bricolage Grotesque n'a pas les lettres kabyles (ɛ, ɣ, ḍ, ṭ, ẓ…) : le kabyle
     s'affiche en Noto Sans, hébergée avec le site (police système en secours). */
  --police-kabyle: 'Noto Sans Anzi', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --dents: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='6'><path d='M0 6 L6 0 L12 6Z' fill='%23d4512f'/></svg>");
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--laine);
  font: 600 15px/1.45 var(--police);
  background:
    radial-gradient(120% 40% at 50% 0%, rgba(184, 67, 42, 0.16), transparent 60%) no-repeat,
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28'><path d='M14 2 L26 14 L14 26 L2 14Z' fill='none' stroke='%23f4e9d8' stroke-opacity='.035' stroke-width='1'/></svg>"),
    var(--nuit);
}

:lang(kab) {
  font-family: var(--police-kabyle);
}

.tifinagh {
  font-family: 'Noto Sans Tifinagh', var(--police);
  font-weight: 400;
}

a {
  color: var(--safran);
}

button {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

/* ─── Motifs ─────────────────────────────────────────────────────────────── */

/* Frise de triangles terre cuite et safran, avec un petit creux de nuit au centre. */
.frieze {
  position: relative;
  height: 22px;
  overflow: hidden;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='22'><path d='M0 22 L11 6 L22 22 Z' fill='%23d4512f'/><path d='M22 22 L33 6 L44 22 Z' fill='%23f2b335'/><path d='M8 22 L11 16 L14 22Z M30 22 L33 16 L36 22Z' fill='%23120d0a'/></svg>") repeat-x;
}

/* À l'ouverture, la frise se dessine de gauche à droite. */
.frieze::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--nuit);
  animation: frieze-draw 450ms ease-out 80ms forwards;
}

@keyframes frieze-draw {
  to {
    transform: translateX(100%);
  }
}

.frieze--small {
  height: 18px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='36' height='18'><path d='M0 18 L9 5 L18 18 Z' fill='%23d4512f'/><path d='M18 18 L27 5 L36 18 Z' fill='%23f2b335'/><path d='M6 18 L9 13 L12 18Z M24 18 L27 13 L30 18Z' fill='%231b1310'/></svg>") repeat-x;
}

.frieze--small::after {
  display: none;
}

/* Tuile de poterie : coins inégaux et rangée de petits triangles en bas. */
.pottery {
  position: relative;
  overflow: hidden;
  background: var(--argile);
  border-radius: var(--rayon-tuile);
  box-shadow: inset 0 0 0 1px var(--bordure-forte);
}

.pottery::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: var(--dents) repeat-x;
  pointer-events: none;
}

/* Étiquette en capitales suivie d'une ligne de losanges. */
.label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font: 700 10.5px/1.2 var(--police);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sable);
}

.label::after {
  content: '';
  flex: 1;
  height: 8px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='8'><path d='M0 4 L5 0 L10 4 L5 8Z' fill='none' stroke='%23a8927c' stroke-width='1.1'/></svg>") repeat-x center;
  opacity: 0.4;
}

/* ─── Mise en page ───────────────────────────────────────────────────────── */

.page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.kicker {
  margin: 0 0 2px;
  font: 700 11px/1.3 var(--police);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sable);
}

.kicker .tifinagh {
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: none;
  color: var(--safran);
}

h1 {
  margin: 0;
  font: 800 36px/1 var(--police);
  letter-spacing: -0.035em;
}

h1 .number {
  color: var(--terre-cuite);
}

/* Bouton en losange (aide). */
.diamond-button {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  color: var(--laine-2);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
}

.diamond-button::before {
  content: '';
  position: absolute;
  inset: 8px;
  z-index: -1;
  transform: rotate(45deg);
  border-radius: 5px;
  background: var(--argile-claire);
  box-shadow: inset 0 0 0 1px var(--bordure-forte);
  transition: background var(--court);
}

.diamond-button:hover::before {
  background: var(--bordure-forte);
}

.loading {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin: 48px 0;
  color: var(--sable);
  font-size: 13px;
}

/* Chargement : un losange safran qui tourne. */
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--safran);
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(45deg);
  }
  to {
    transform: rotate(405deg);
  }
}

.message {
  padding: 18px 16px 24px;
  text-align: center;
}

.message h1,
.message h2 {
  margin: 0;
  font: 800 22px/1.15 var(--police);
  letter-spacing: -0.02em;
}

.message p {
  margin: 8px 0 0;
  color: var(--sable);
}

.message .button-primary {
  margin-top: 18px;
}

a.button-primary {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.message-hint {
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.game {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Le proverbe en français : l'accroche de la page ────────────────────── */

.proverb {
  padding: 14px 16px 24px;
}

.translation {
  margin: 0;
  font: 800 clamp(22px, 6.4vw, 28px)/1.18 var(--police);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.translation .quote-mark {
  color: var(--safran);
}

/* ─── Tuiles de mots ─────────────────────────────────────────────────────── */

.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 46px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: var(--rayon-mot);
  background: var(--argile-claire);
  box-shadow: inset 0 0 0 1.5px var(--bordure-forte), 0 3px 0 #0b0806;
  color: var(--laine);
  font-family: var(--police-kabyle);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background var(--court), transform var(--court);
}

button.tile {
  cursor: pointer;
}

button.tile:hover:not(:disabled) {
  background: var(--bordure-forte);
}

button.tile:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 0 0 1.5px var(--bordure-forte), 0 1px 0 #0b0806;
}

button.tile:disabled {
  cursor: default;
}

.tile.is-found {
  background: var(--olivier);
  box-shadow: 0 3px 0 #1f4a3d;
  color: var(--nuit);
}

.tile.is-hint {
  background: var(--safran);
  box-shadow: 0 3px 0 #9a6a10;
  color: var(--nuit);
}

.tile.is-missed {
  background: var(--argile-claire);
  box-shadow: inset 0 0 0 1px var(--bordure);
  color: var(--sable);
}

/* Tuile déjà posée : sa place reste marquée dans la réserve. */
.tile.is-placed {
  background: transparent;
  box-shadow: none;
  outline: 1.5px dashed var(--bordure-forte);
  outline-offset: -1.5px;
  color: transparent;
}

.tile--small {
  min-width: 0;
  min-height: 30px;
  padding: 0 8px;
  font-size: 13.5px;
}

.tile--small.is-found,
.tile--small.is-hint {
  box-shadow: none;
}

/* ─── Essais précédents ──────────────────────────────────────────────────── */

.attempts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attempt {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px;
  border-radius: 10px;
  background: var(--argile);
  box-shadow: inset 0 0 0 1px var(--bordure);
}

/* Dernier essai d'une partie perdue : contour terre cuite. */
.attempt.is-failed {
  box-shadow: inset 0 0 0 1.5px var(--terre-cuite);
}

.attempt.is-new .tile {
  animation: arrive var(--moyen) ease-out both;
  animation-delay: calc(var(--i) * 60ms);
}

/* Proverbe retrouvé : la rangée pulse une fois, comme une ligne validée de Fournée. */
.attempt.is-new.is-won .tile {
  animation:
    arrive var(--moyen) ease-out both,
    pulse 900ms ease-out both;
  animation-delay: calc(var(--i) * 60ms), calc(var(--i) * 60ms + 250ms);
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@keyframes pulse {
  from {
    box-shadow: 0 0 0 0 rgba(63, 138, 115, 0.75);
  }
  to {
    box-shadow: 0 0 0 10px rgba(63, 138, 115, 0);
  }
}

/* ─── Essai en cours : la bande de tapis où l'on retisse le proverbe ─────── */

.loom {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 86px;
  margin: 0;
  padding: 22px 10px;
  list-style: none;
  background: var(--argile);
  border-radius: var(--rayon-carte);
  box-shadow: inset 0 0 0 1px var(--bordure-forte);
}

/* Bordures de tapis : une chaîne de losanges terre cuite et safran. */
.loom::before,
.loom::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  height: 8px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='8'><path d='M4 0 L8 4 L4 8 L0 4Z' fill='%23d4512f'/><path d='M12 0 L16 4 L12 8 L8 4Z' fill='%23f2b335'/></svg>") repeat-x;
  opacity: 0.85;
}

.loom::before {
  top: 7px;
}

.loom::after {
  bottom: 7px;
}

.slot {
  display: flex;
}

/* Case vide : un petit losange attend son mot. */
.slot.is-empty {
  min-width: 52px;
  min-height: 46px;
  border-radius: var(--rayon-mot);
  box-shadow: inset 0 0 0 1.5px var(--bordure-forte);
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'><path d='M5 0 L10 5 L5 10 L0 5Z' fill='none' stroke='%237d6a58' stroke-width='1.2'/></svg>") center no-repeat;
}

/* Hauteur réservée sur deux lignes : la page ne saute pas quand le message change. */
.status {
  min-height: 2.9em;
  margin: 8px 0 0;
  color: var(--sable);
  font-size: 13.5px;
  line-height: 1.45;
  text-align: center;
}

.status .hint {
  color: var(--safran);
}

.bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Les boutons restent au bas de l'écran, même quand les essais allongent la page. */
.actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding: 16px 0 max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--nuit) 80%, rgba(18, 13, 10, 0));
}

.actions .button-secondary {
  flex: 1;
}

.actions .button-primary {
  flex: 2;
}

/* ─── Boutons ────────────────────────────────────────────────────────────── */

/* Bouton principal : terre cuite, rangée de triangles au-dessus. */
.button-primary,
.button-secondary {
  position: relative;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font: 800 15px var(--police);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--court), filter var(--court), opacity var(--court);
}

.button-primary {
  background: var(--terre-cuite);
  color: var(--nuit);
}

.button-primary::before {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  top: -6px;
  height: 6px;
  background: var(--dents) repeat-x;
}

.button-secondary {
  background: var(--argile-claire);
  box-shadow: inset 0 0 0 1px var(--bordure-forte);
  color: var(--laine);
}

.button-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.button-primary:active:not(:disabled),
.button-secondary:active:not(:disabled) {
  transform: scale(0.98);
}

.button-primary:disabled,
.button-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.button-wide {
  width: 100%;
}

/* ─── Fin de partie ──────────────────────────────────────────────────────── */

.result {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-tile {
  padding: 16px 16px 24px;
}

.result-tile p {
  margin: 0;
}

.result-tile .label {
  color: var(--safran);
}

.result-tile .label.is-lost {
  color: var(--sable);
}

.result-tile h2:focus {
  outline: none;
}

.result-kab {
  font-family: var(--police-kabyle);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--safran);
  text-shadow: 0 0 24px rgba(242, 179, 53, 0.25);
  text-wrap: balance;
}

.result-tile .result-fr {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--laine-2);
}

.result-tile .result-meaning {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--sable);
}

.share-feedback {
  min-height: 1.4em;
  margin: -6px 0 0;
  font-size: 13px;
  text-align: center;
  color: var(--laine-2);
}

.share-text {
  width: 100%;
  min-height: 150px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--argile-claire);
  box-shadow: inset 0 0 0 1.5px var(--safran);
  color: var(--laine);
  font: 600 14px/1.5 var(--police);
  resize: vertical;
}

.result > .label {
  margin: 10px 0 -8px;
}

.countdown {
  margin: 0;
  font: 800 40px/1 var(--police);
  letter-spacing: -0.02em;
  color: var(--safran);
  font-variant-numeric: tabular-nums;
}

.figures {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: -6px 0 0;
  text-align: center;
}

.figures div {
  display: flex;
  flex-direction: column-reverse;
}

.figures dd {
  margin: 0;
  font: 800 30px/1 var(--police);
  color: var(--safran);
  font-variant-numeric: tabular-nums;
}

.figures dt {
  margin-top: 4px;
  font: 700 9.5px var(--police);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sable);
}

.distribution {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: -6px 0 0;
  padding: 0;
  list-style: none;
}

.distribution li {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--laine-2);
}

.distribution-label {
  font-variant-numeric: tabular-nums;
}

.distribution-bar {
  width: var(--share);
  min-width: 26px;
  padding: 3px 8px;
  border-radius: 3px 3px 8px 8px;
  background: var(--argile-claire);
  box-shadow: inset 0 0 0 1px var(--bordure-forte);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.distribution .is-today .distribution-bar {
  background: var(--olivier);
  box-shadow: none;
  color: var(--nuit);
}

.support {
  margin: 0;
  font-size: 13px;
  color: var(--sable);
}

/* ─── Pied de page ───────────────────────────────────────────────────────── */

.footer {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 28px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--sable);
}

.footer p {
  margin: 0;
}

/* ─── Dialogue « Comment jouer » ─────────────────────────────────────────── */

.dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: var(--rayon-tuile);
  background: var(--argile);
  color: var(--laine);
  box-shadow: inset 0 0 0 1px var(--bordure-forte), 0 24px 60px rgba(0, 0, 0, 0.6);
}

.dialog::backdrop {
  background: rgba(7, 5, 4, 0.82);
}

.dialog[open] {
  animation: rise var(--moyen) ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 20px;
}

.dialog h2 {
  margin: 0;
  font: 800 26px/1.1 var(--police);
  letter-spacing: -0.03em;
}

.dialog form {
  margin: 0;
}

.diamond-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--laine-2);
  font-size: 14px;
}

.diamond-list li {
  position: relative;
  padding-left: 20px;
}

.diamond-list li::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 0.55em;
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  background: var(--terre-cuite);
}

.diamond-list b {
  color: var(--laine);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.legend .tile {
  font-family: var(--police);
}

.noscript {
  max-width: 448px;
  margin: 16px auto;
}

/* ─── Mouvements réduits ─────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .frieze::after {
    display: none;
  }

  .attempt.is-new .tile,
  .attempt.is-new.is-won .tile,
  .dialog[open] {
    animation: none;
  }

  .spinner {
    animation-duration: 3s;
  }

  * {
    transition-duration: 0ms !important;
  }
}
