/*
 * Page du garant : identité « Fanous » de Himaya (ADR 0011), valeurs reprises de ui/design/tokens.json 1.0.0
 * (mêmes couleurs que ui/.../HimayaColors.kt). Aucun visuel ajouté : couleurs, polices, halo et formes des jetons.
 * Contrastes (ui/.../HimayaColors.kt) : texte principal 14,6:1 (sombre) et 13,7:1 (clair) ; texte des boutons 9,8:1 et 6,4:1 ;
 * laiton en texte 6,0:1 et 5,0:1. En thème clair, l'ambre (2,1:1) ne sert jamais de texte ni de contour porteur.
 */

@font-face {
  font-family: "Reem Kufi";
  src: url("polices/reem-kufi.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Geologica";
  src: url("polices/geologica.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  /* thème sombre (jetons « dark ») */
  --fond: #1A1511;
  --surface: #26201A;
  --surface-variante: #332A22;
  --contour: #3A3028;
  --texte: #F0E6D2;
  --texte-second: #CBBFA8;
  --texte-discret: #A6977F;
  --ambre: #F0B445;
  --sur-ambre: #1A1511;
  --ambre-texte: #F0B445;
  --laiton: #B78D47;
  --laiton-texte: #B78D47;
  --halo: 240, 180, 69;
  --bord-champ: #B78D47;   /* laiton : 6,0:1 sur le fond */
  --focus: #F0B445;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --fond: #F5EFE3;
    --surface: #FBF7EF;
    --surface-variante: #EFE6D6;
    --contour: #E3D9C6;
    --texte: #2A2219;
    --texte-second: #5E5343;
    --texte-discret: #716451;
    --ambre: #D99A2B;
    --sur-ambre: #2A2219;
    --ambre-texte: #80612B;
    --laiton: #B78D47;
    --laiton-texte: #80612B;
    --halo: 217, 154, 43;
    --bord-champ: #716451;   /* onBackgroundMuted : 5,0:1 (le laiton n'atteint que 2,7:1 en clair) */
    --focus: #80612B;
    color-scheme: light;
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--fond);
  /* un seul halo par écran, centré, derrière l'élément principal (jeton motifs.halo) */
  background-image: radial-gradient(circle 260px at 50% 90px, rgba(var(--halo), 0.26) 0%, rgba(var(--halo), 0.06) 40%, rgba(var(--halo), 0) 70%);
  background-repeat: no-repeat;
  color: var(--texte);
  font-family: "Geologica", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

.entete,
main,
.pied {
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.entete {
  padding-top: 2.5rem;
  padding-bottom: 0.5rem;
  text-align: center;
}

.marque {
  margin: 0;
  font-family: "Reem Kufi", "Geologica", sans-serif;
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--laiton-texte);
}

h1,
h2,
h3 {
  font-family: "Reem Kufi", "Geologica", sans-serif;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 2.125rem;
  margin-top: 0.25rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

.intro {
  font-size: 1.0625rem;
  color: var(--texte);
  margin: 1rem 0 0.5rem;
}

.intro-suite,
.note,
.aide,
.vide {
  color: var(--texte-second);
}

.intro-suite {
  margin: 0;
  font-size: 0.9375rem;
}

main {
  padding-top: 1.375rem;
  padding-bottom: 1.5rem;
}

section,
details {
  margin-bottom: 1.375rem;
}

p {
  margin: 0 0 0.75rem;
}

.panneau {
  background: var(--surface);
  border: 1px solid var(--contour);
  border-radius: 28px;
  padding: 1.25rem 1.125rem;
}

/* ---------- Cartes de code ---------- */

.cartes {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

/* la lanterne (jeton motifs.arch) : arche en haut, angles de 28 px en bas, contour laiton */
.carte {
  background: var(--surface);
  border: 1px solid var(--laiton);
  border-radius: 131px 131px 28px 28px;
  padding: 2.25rem 1.125rem 1.125rem;
  text-align: center;
}

.carte .nom {
  font-size: 1.25rem;
  margin: 0 2.5rem 0.25rem;
  overflow-wrap: anywhere;
}

.code {
  font-family: "Reem Kufi", "Geologica", sans-serif;
  font-weight: 500;
  font-size: 2.75rem;
  line-height: 1.1;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--ambre-texte);
  margin: 0.25rem 0 0.75rem;
  white-space: nowrap;
}

.temps {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.jauge {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-variante);
  overflow: hidden;
}

.jauge::-webkit-progress-bar {
  background: var(--surface-variante);
  border-radius: 999px;
}

.jauge::-webkit-progress-value {
  background: var(--laiton);
  border-radius: 999px;
}

.jauge::-moz-progress-bar {
  background: var(--laiton);
  border-radius: 999px;
}

.secondes {
  font-size: 0.875rem;
  color: var(--texte-second);
  font-variant-numeric: tabular-nums;
}

.carte .copier {
  margin-top: 0;
}

/* action secondaire et rare : pas d'ambre (réservé à l'action principale), confirmation demandée */
.carte .supprimer {
  margin-top: 0.25rem;
  color: var(--texte-second);
}

.premier {
  background: var(--surface-variante);
  border-radius: 14px;
  padding: 0.75rem 0.875rem;
  font-size: 0.9375rem;
  text-align: left;
}

/* ---------- Formulaires ---------- */

label {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0.875rem 0 0.375rem;
}

input,
textarea {
  display: block;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.75rem 0.875rem;
  font: inherit;
  font-size: 1rem; /* 16 px au moins : pas de zoom forcé sur iPhone */
  color: var(--texte);
  background: var(--fond);
  border: 1px solid var(--bord-champ);
  border-radius: 14px;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, "Cascadia Mono", "Roboto Mono", monospace;
  letter-spacing: 0.02em;
  word-break: break-all;
}

input[type="file"] {
  padding: 0.625rem;
}

.aide {
  font-size: 0.875rem;
  margin: 0.375rem 0 0;
}

.erreur {
  color: var(--ambre-texte);
  font-weight: 600;
  margin: 0.625rem 0 0;
  min-height: 0;
}

.erreur:empty {
  display: none;
}

.etat {
  background: var(--surface-variante);
  border: 1px solid var(--laiton);
  border-radius: 14px;
  padding: 0.875rem 1rem;
  font-weight: 600;
}

/* ---------- Boutons ---------- */

button {
  font: inherit;
  cursor: pointer;
}

.principal,
.secondaire {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  margin-top: 1rem;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
}

.principal {
  background: var(--ambre);
  color: var(--sur-ambre);
  border: 1px solid var(--ambre);
}

.secondaire {
  background: transparent;
  color: var(--texte);
  border: 1px solid var(--bord-champ);
}

.actions {
  display: grid;
  gap: 0.5rem;
}

.actions .principal,
.actions .secondaire {
  margin-top: 0;
}

.lien {
  display: inline-block;
  min-height: 3rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0;
  background: none;
  border: 0;
  color: var(--ambre-texte);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

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

input:focus-visible,
textarea:focus-visible {
  outline-offset: 1px;
}

/* ---------- Caméra ---------- */

.zone-camera {
  margin-top: 1rem;
}

.zone-camera video {
  display: block;
  width: 100%;
  max-height: 60vh;
  object-fit: cover;
  border-radius: 28px;
  border: 1px solid var(--laiton);
  background: var(--fond);
}

/* ---------- Sections repliées ---------- */

.replie {
  background: var(--surface);
  border: 1px solid var(--contour);
  border-radius: 28px;
  padding: 0 1.125rem;
}

.replie summary {
  min-height: 3.5rem;
  padding: 1rem 0;
  font-weight: 600;
  cursor: pointer;
  list-style-position: inside;
}

.replie[open] {
  padding-bottom: 1.125rem;
}

.replie[open] summary {
  margin-bottom: 0.25rem;
}

/* « Ajouter une personne » : titre de section dans le résumé (ouvert tant que la liste est vide) */
.ajout summary h2 {
  display: inline;
  font-size: 1.375rem;
  margin: 0;
}

.replie form + form {
  margin-top: 1.75rem;
}

.replie h3 {
  font-size: 1.125rem;
  margin-top: 1rem;
}

.puces {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--texte-second);
}

.puces li + li {
  margin-top: 0.5rem;
}

/* ---------- Pied et utilitaires ---------- */

.pied {
  padding-bottom: 2rem;
  font-size: 0.8125rem;
  color: var(--texte-discret);
  text-align: center;
}

.pied a {
  color: var(--texte-second);
}

[hidden] {
  display: none !important;
}

.lecteur-seul {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 30rem) {
  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
