/* [12/09 — porteur : «clean, pro, robuste et very mobile friendly»] Page publique وزّان (/wezzan/).
 *
 * Identité ديار (jetons de waran.css) : fond crème, ambre pour l'action, olive pour ce qui est juste.
 * Un seul élément fort : le verdict et sa RÈGLE DE MESURE, où chaque تفعيلة occupe une largeur
 * proportionnelle à sa longueur (le vers « pesé »). Le reste est sobre : saisie sur lignes de cahier,
 * en Amiri, qui rend les harakat.
 * Mobile d'abord : une colonne, cibles de 44 px au moins, texte de 14 px au moins, champs à 20 px
 * (pas de zoom automatique sur iPhone), rien ne déborde en largeur.
 */

.page-wezzan main { padding-block-end: 32px; }
.wz { max-width: 820px; }
/* L'attribut hidden doit toujours l'emporter : une règle display:flex l'écrasait (barre de تشكيل rendue au
   chargement, en bas de page, et Amiri téléchargé pour rien). */
.wz [hidden] { display: none !important; }
.wz-invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- en-tête --------------------------------------------------------------------------------- */
.wz-tete { padding-block: 28px 8px; }
.wz-tete h1 { font-size: clamp(34px, 9vw, 52px); line-height: 1.15; }
.wz-tete p { margin: 8px 0 0; color: var(--text-mute); font-size: 17px; max-width: 58ch; }

/* --- choix du registre ----------------------------------------------------------------------- */
.wz-saisie { margin-top: 18px; }
.wz-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0 0 14px; padding: 4px; border: 1px solid var(--border);
  border-radius: var(--radius-pill); background: var(--surface-2); }
.wz-mode label { position: relative; display: block; cursor: pointer; }
.wz-mode input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.wz-mode span { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; padding: 4px 10px;
  border-radius: var(--radius-pill); font-weight: 700; font-size: 17px; line-height: 1.2; color: var(--text-mute);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease); }
.wz-mode small { font-weight: 400; font-size: 14px; }
.wz-mode input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.wz-mode input:focus-visible + span { box-shadow: var(--focus-ring); }

.wz-consigne { margin: 0 0 12px; color: var(--text-mute); font-size: 15px; }

/* --- les أبيات : lignes de cahier ------------------------------------------------------------------ */
.wz-abyat { list-style: none; margin: 0; padding: 0; counter-reset: bayt; }
.wz-bayt { position: relative; display: grid; grid-template-columns: 30px 1fr 44px; grid-template-areas: "num sadr retirer" "num ajuz retirer" "num indice indice" "barre barre barre";
  column-gap: 8px; padding: 10px 0 8px; border-bottom: 1px solid var(--border); }
.wz-num { grid-area: num; align-self: start; padding-top: 30px; font-weight: 700; font-size: 16px; color: var(--muted); text-align: center; }
.wz-shatr:nth-of-type(1) { grid-area: sadr; }
.wz-shatr:nth-of-type(2) { grid-area: ajuz; }
.wz-shatr { display: block; min-width: 0; }
.wz-etiquette { display: block; font-size: 14px; color: var(--text-mute); line-height: 1.4; }
.wz-shatr input { width: 100%; min-height: 48px; padding: 4px 2px 6px; border: 0; border-bottom: 2px solid var(--border); border-radius: 0;
  background: transparent; color: var(--ink); font-family: var(--font-body); font-size: 21px; line-height: 1.9;
  transition: border-color var(--fast) var(--ease); }
/* Amiri (125 Ko, rend les harakat) ne se charge qu'à l'écriture : un visiteur qui lit la page ne le paie pas. */
.wz-shatr input:focus, .wz-shatr input.wz-rempli { font-family: var(--font-verse); }
.wz-shatr input:focus { outline: none; border-bottom-color: var(--primary); }
.wz-shatr input:focus-visible { box-shadow: 0 3px 0 -1px rgba(228, 163, 61, .35); }
.wz-retirer { grid-area: retirer; align-self: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.wz-retirer:hover, .wz-retirer:focus-visible { background: var(--surface-2); color: var(--ink); outline: none; }
.wz-indice { grid-area: indice; margin: 6px 0 0; font-size: 14px; color: var(--text-mute); }
.wz-bayt--ok .wz-indice { color: var(--olive); }
.wz-bayt--attention .wz-indice { color: var(--amber-text); }
.wz-bayt--erreur .wz-indice { color: #9B2C2C; font-weight: 600; }
.wz-bayt--erreur input { border-bottom-color: #C0504D; }

/* --- barre de تشكيل : sous le بيت en cours de saisie ------------------------------------------------ */
.wz-tashkil { grid-area: barre; display: flex; gap: 6px; margin-top: 8px; padding: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; scrollbar-width: none; }
.wz-tashkil::-webkit-scrollbar { display: none; }
.wz-tashkil button { flex: 0 0 auto; min-width: 46px; height: 46px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt);
  font-family: var(--font-verse); font-size: 26px; line-height: 1; color: var(--ink); cursor: pointer; touch-action: manipulation; }
.wz-tashkil button:active { background: var(--surface-2); }
.wz-tashkil button:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* --- outils et action ------------------------------------------------------------------------------------ */
.wz-outils { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 4px; }
.wz-lien { min-height: 44px; padding: 0 2px; border: 0; background: none; color: var(--accent-text); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.wz-lien:hover { text-decoration: underline; }
.wz-lien:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }
.wz-info { margin: 10px 0; padding: 10px 14px; border-radius: 12px; background: var(--surface-2, #EEF4EC); color: var(--ink); font-weight: 600; }
.wz-erreur { margin: 10px 0; padding: 10px 14px; border-radius: 12px; background: #FBEAEA; color: #7F1D1D; font-weight: 600; }
.wz-peser { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px; margin-top: 14px; padding: 0 22px;
  border: 0; border-radius: var(--radius-pill); background: var(--primary-grad); color: var(--primary-ink); font: inherit; font-size: 19px; font-weight: 800;
  box-shadow: var(--shadow); cursor: pointer; touch-action: manipulation; }
.wz-peser:hover { filter: brightness(1.03); }
.wz-peser:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.wz-peser:disabled { cursor: progress; opacity: .75; }
.wz-peser--attente::after { content: ""; width: 18px; height: 18px; border: 3px solid rgba(58, 43, 20, .3); border-top-color: var(--primary-ink);
  border-radius: 50%; animation: wz-tourne .8s linear infinite; }
@keyframes wz-tourne { to { transform: rotate(360deg); } }
.wz-peser--second { width: auto; margin-top: 0; background: var(--surface); border: 2px solid var(--primary); box-shadow: none; font-size: 17px; min-height: 48px; }
.wz-prive { margin: 10px 0 0; text-align: center; color: var(--text-mute); font-size: 14px; }

/* --- verdict -------------------------------------------------------------------------------------------------- */
.wz-resultat { margin-top: 30px; scroll-margin-top: calc(var(--header-h) + 12px); outline: none; }
.wz-verdict { padding: 22px 20px 20px; border-radius: var(--radius-card); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.wz-verdict-type { margin: 0; color: var(--text-mute); font-size: 15px; font-weight: 600; }
.wz-verdict-nom { margin: 2px 0 0; font-family: var(--font-poem-title); font-weight: 700; font-size: clamp(44px, 13vw, 68px); line-height: 1.1; color: var(--ink); }
.wz-verdict-sous { margin: 4px 0 0; font-size: 17px; font-weight: 600; color: var(--accent-text); }
.wz-certitude { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 14px; }
.wz-jauge { position: relative; flex: 0 0 120px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.wz-jauge i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 99px; background: var(--primary); }
.wz-verdict--sur .wz-jauge i { background: var(--olive); }
.wz-verdict--incertain .wz-jauge i { background: #C0504D; }
.wz-certitude-texte { font-weight: 700; font-size: 16px; }
.wz-verdict--sur .wz-certitude-texte { color: var(--olive); }
.wz-verdict--incertain .wz-certitude-texte { color: #9B2C2C; }
.wz-wazn { margin: 14px 0 0; padding-top: 12px; border-top: 1px dashed var(--border); font-family: var(--font-verse); font-size: 20px; color: var(--text-mute); word-spacing: .35em; }
.wz-wazn--def { font-family: var(--font-body); font-size: 16px; word-spacing: normal; }

.wz-conseils { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.wz-conseil { padding: 10px 14px; border-inline-start: 4px solid var(--primary); border-radius: 8px; background: var(--surface-alt); font-size: 15px; }

/* --- la règle de mesure (فصيح) --------------------------------------------------------------------------------- */
.wz-taqti3, .wz-tafaliwt { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.wz-res-bayt, .wz-res-taflwit { padding: 12px 14px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.wz-res-bayt--ecart, .wz-res-taflwit--ecart { border-color: #E4B3A8; background: #FFF8F6; }
.wz-res-shatr + .wz-res-shatr { margin-top: 12px; }
.wz-vers { margin: 0; font-family: var(--font-verse); font-size: var(--verse-size); line-height: 1.9; overflow-wrap: anywhere; }
.wz-regle { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.wz-taf { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1 1 0; min-width: 64px; min-height: 44px; padding: 4px 6px;
  border-radius: 8px; text-align: center; line-height: 1.25; }
.wz-taf b { font-family: var(--font-verse); font-weight: 700; font-size: 17px; }
.wz-taf small { font-size: 14px; }
.wz-taf--ok { background: var(--olive-bg); color: #2F5710; }
.wz-taf--casse { background: #FBEAEA; color: #8A2525; outline: 2px dashed #D98A84; outline-offset: -2px; }
.wz-ecart { margin: 8px 0 0; font-size: 15px; font-weight: 600; color: #8A2525; }

/* --- les تيفلواتن (لغن) ------------------------------------------------------------------------------------------- */
.wz-taflwit-tete { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.wz-compte { flex: 0 0 auto; min-width: 58px; padding: 2px 10px; border-radius: var(--radius-pill); background: var(--olive-bg); color: #2F5710;
  font-weight: 800; font-size: 16px; text-align: center; direction: ltr; }
.wz-compte--ecart { background: #FBEAEA; color: #8A2525; }
.wz-unites { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.wz-unite { padding: 2px 9px; border-radius: 8px; background: var(--surface-2); font-family: var(--font-verse); font-size: 18px; line-height: 1.7; }
.wz-unite--kad3a { background: #FBE3B5; box-shadow: inset 0 -3px 0 var(--primary); }
.wz-taflwit-note { margin: 8px 0 0; font-size: 14px; color: var(--text-mute); }

.wz-alt { margin: 14px 0 0; color: var(--text-mute); font-size: 15px; }
.wz-res-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 18px; }
.wz-diar { display: inline-flex; align-items: center; min-height: 44px; margin-top: 14px; color: var(--accent-text); font-weight: 700; }
.wz-res-actions .wz-diar { margin-top: 0; }
.wz-diar:hover { text-decoration: underline; }

/* --- correction (widget) -------------------------------------------------------------------------------------------- */
.wz-correction { margin-top: 28px; scroll-margin-top: calc(var(--header-h) + 12px); }
.wz-correction h2 { font-size: 24px; }
.wz-correction p { margin: 6px 0 12px; color: var(--text-mute); }
.wz-correction wezzan-widget {
  --wezzan-font: var(--font-verse); --wezzan-fg: var(--ink); --wezzan-bg: var(--surface); --wezzan-muted: var(--text-mute);
  --wezzan-border: var(--border); --wezzan-accent: #316B54; --wezzan-mutaharrik: #D9942C; --wezzan-sakin: #3B6D11;
  --wezzan-gad3a: #FBE3B5; border-radius: var(--radius-card);
}

/* --- guide et référence --------------------------------------------------------------------------------------------- */
.wz-guide, .wz-reference { margin-top: 26px; border-top: 1px solid var(--border); }
.wz-guide summary, .wz-reference summary { display: flex; align-items: center; min-height: 52px; font-family: var(--font-display); font-weight: 800; font-size: 19px; cursor: pointer; list-style: none; }
.wz-guide summary::-webkit-details-marker, .wz-reference summary::-webkit-details-marker { display: none; }
.wz-guide summary::before, .wz-reference summary::before { content: "+"; display: inline-grid; place-items: center; width: 28px; height: 28px; margin-inline-end: 10px;
  border-radius: 50%; background: var(--surface-2); font-family: var(--font-body); font-size: 20px; }
.wz-guide[open] summary::before, .wz-reference[open] summary::before { content: "−"; }
.wz-guide summary:focus-visible, .wz-reference summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 8px; }
.wz-guide-cols { display: grid; gap: 18px; padding-bottom: 12px; }
.wz-guide h3 { font-size: 17px; margin-bottom: 4px; }
.wz-guide ul { margin: 0; padding-inline-start: 20px; }
.wz-guide li { margin: 4px 0; }
.wz-reference h3 { font-size: 17px; margin-bottom: 8px; }
.wz-liste { margin: 0; display: grid; gap: 2px; }
.wz-liste div { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 12px; padding: 6px 0; border-bottom: 1px dotted var(--border); }
.wz-liste dt { font-weight: 700; }
.wz-liste dd { margin: 0; color: var(--text-mute); font-size: 15px; }

/* --- dialogue de collage ------------------------------------------------------------------------------------------------ */
.wz-dialogue { width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 20px; border: 0; border-radius: var(--radius-card);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.wz-dialogue::backdrop { background: rgba(30, 25, 18, .45); }
.wz-dialogue h2 { font-size: 22px; }
.wz-dialogue p { margin: 6px 0 10px; color: var(--text-mute); font-size: 15px; }
.wz-dialogue textarea { width: 100%; min-height: 200px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; font-family: var(--font-verse); font-size: 20px; line-height: 1.9; resize: vertical; }
.wz-dialogue textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.wz-dialogue-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.wz-dialogue-actions .wz-peser { width: auto; margin-top: 10px; }

/* --- ordinateur : شطران côte à côte, comme dans un ديوان imprimé ------------------------------------------------------------ */
@media (min-width: 720px) {
  .wz-bayt { grid-template-columns: 36px 1fr 1fr 44px; grid-template-areas: "num sadr ajuz retirer" "num indice indice indice" "barre barre barre barre"; column-gap: 28px; }
  .wz-num { padding-top: 32px; }
  .wz-peser:not(.wz-peser--second) { width: auto; min-width: 280px; }
  .wz-saisie > .wz-peser { margin-inline: auto; }
  .wz-res-bayt { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; }
  .wz-res-bayt .wz-res-shatr + .wz-res-shatr { margin-top: 0; }
  .wz-res-bayt .wz-ecart { grid-column: 1 / -1; }
  .wz-guide-cols { grid-template-columns: 1fr 1fr; gap: 32px; }
  .wz-verdict { padding: 28px 30px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .wz-peser--attente::after { animation: none; }
  .wz-mode span, .wz-shatr input { transition: none; }
}
