/* ---------------------------------------------------------------------------
   Composants, sans framework ni build. Couleurs, polices et formes viennent
   exclusivement des jetons de tokens.css, charge avant cette feuille.
   --------------------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

/* Une regle `display` d'un composant l'emporterait sur l'attribut `hidden` :
   un formulaire masque resterait affiche. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--t-bg);
  color: var(--t-text);
  font: 600 16px/1.5 var(--t-font-text);
}

a {
  color: var(--t-accent-text);
}

strong,
b {
  font-weight: 900;
}

h1,
h2,
h3 {
  font-family: var(--t-font-title);
  font-weight: 800;
  line-height: 1.2;
}

.card {
  background: var(--t-surface);
  border: 2px solid var(--t-border);
  border-radius: var(--t-radius-card);
  padding: 1.25rem;
}

.form {
  display: grid;
  gap: 0.75rem;
}

.field {
  display: grid;
  gap: 0.25rem;
}

/* Un champ ne deborde jamais de son formulaire. */
.field input,
.field select {
  width: 100%;
  max-width: 100%;
}

.field label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--t-muted);
}

input {
  min-height: 48px;
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--t-border);
  border-radius: var(--t-radius-field);
  background: var(--t-surface);
  color: inherit;
  font: inherit;
}

a:focus-visible,
input:focus-visible,
button:focus-visible {
  outline: 3px solid var(--t-accent-text);
  outline-offset: 2px;
}

/* Bouton principal : flamme, en relief (aplat clair en haut, tranche
   foncee en bas), comme sur Lycee en ligne. 56 px au moins. */
.button {
  justify-self: start;
  min-height: 56px;
  padding: 0.6rem 1.4rem;
  border: 0;
  border-radius: var(--t-radius-button);
  background: var(--t-accent);
  color: var(--t-on-accent);
  box-shadow: var(--t-relief-hi), 0 6px 0 var(--t-accent-edge);
  font-family: var(--t-font-title);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
  cursor: pointer;
}

.button:active {
  transform: translateY(3px);
  box-shadow: var(--t-relief-hi), 0 3px 0 var(--t-accent-edge);
}

/* Un lien habille en bouton se comporte comme un bouton. */
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
}

.button--block {
  justify-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.button:hover {
  filter: brightness(1.06);
}

/* Bouton premium : degrade dore, halo. Les appels a jouer principaux. */
.button--glow {
  min-height: 64px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--t-accent-light) 0%, var(--t-accent) 55%, var(--t-accent-deep) 100%);
  box-shadow: var(--t-relief-hi), 0 7px 0 var(--t-accent-edge), 0 14px 28px var(--t-glow-gold);
  font-size: 1.3rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.button--ghost {
  background: transparent;
  border: 2px solid var(--t-border);
  color: var(--t-text);
  box-shadow: none;
}

.button--ghost:active {
  box-shadow: none;
}

.button--violet {
  background: var(--t-violet);
  color: var(--t-on-violet);
  box-shadow: var(--t-relief-soft), 0 6px 0 var(--t-violet-edge);
}

.button--cyan {
  background: var(--t-cyan);
  color: var(--t-on-cyan);
  box-shadow: var(--t-relief-hi), 0 5px 0 var(--t-cyan-edge);
  letter-spacing: 0.04em;
}

.button--battle {
  background: var(--t-battle);
  color: var(--t-on-battle);
  box-shadow: var(--t-relief-soft), 0 6px 0 var(--t-battle-edge);
  letter-spacing: 0.04em;
}

/* Les boutons d'un meme formulaire restent sur une ligne, et passent a la
   ligne plutot que de deborder sur un ecran etroit. */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.identity {
  display: grid;
  gap: 0.75rem;
  justify-items: start;
}

.identity p {
  margin: 0;
  color: var(--t-muted);
}

.identity strong {
  color: var(--t-text);
}

.status {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--t-radius-field);
  font-size: 0.9rem;
  font-weight: 700;
}

.status[data-kind="error"] {
  border-color: var(--t-danger-border);
  background: var(--t-danger-bg);
  color: var(--t-danger);
}

.status[data-kind="success"] {
  border-color: var(--t-success-border);
  background: var(--t-success-bg);
  color: var(--t-success);
}

@media (prefers-reduced-motion: reduce) {
  .button:active {
    transform: none;
  }
}

/* Pastille d'information sur un aplat de couleur. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
  padding: 0 0.75rem;
  border-radius: var(--t-radius-pill);
  background: var(--t-soft);
  color: var(--t-text);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

/* --- Composants de formulaire et de compte ------------------------------- */

/* Masque visuellement un texte qui reste lu par les lecteurs d'ecran. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

select {
  min-height: 48px;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--t-border);
  border-radius: var(--t-radius-field);
  background: var(--t-surface);
  color: inherit;
  font: inherit;
}

select:focus-visible {
  outline: 3px solid var(--t-accent-text);
  outline-offset: 2px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.4rem;
  color: var(--t-muted);
  font-size: 0.85rem;
}

.field__hint {
  margin: 0.1rem 0 0;
  color: var(--t-muted);
  font-size: 0.85rem;
}

.button--danger {
  background: var(--t-danger);
  color: var(--t-on-danger);
  box-shadow: none;
}

.notice {
  display: grid;
  gap: 0.6rem;
  justify-items: start;
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--t-border);
  border-radius: var(--t-radius-field);
  background: var(--t-surface);
}

.notice p {
  margin: 0;
}

.notice--warm {
  border-color: var(--t-accent-border);
  background: var(--t-accent-bg);
  color: var(--t-accent-soft);
}

.notice--danger {
  border-color: var(--t-danger-border);
  background: var(--t-danger-bg);
  color: var(--t-danger);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  min-height: var(--t-touch);
}

.checkbox input {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.15rem;
  accent-color: var(--t-accent);
}

/* Pastille d'avatar : la couleur vient de `data-color`. */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--t-avatar-cobalt);
  color: var(--t-on-avatar);
  font-family: var(--t-font-title);
  font-weight: 800;
}

.avatar--large {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 1.8rem;
}

[data-color="orange"] { background: var(--t-avatar-orange); }
[data-color="rose"] { background: var(--t-avatar-rose); }
[data-color="vert"] { background: var(--t-avatar-vert); }
[data-color="turquoise"] { background: var(--t-avatar-turquoise); }
[data-color="violet"] { background: var(--t-avatar-violet); }

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.swatches legend {
  width: 100%;
}

.swatch {
  display: inline-grid;
  place-items: center;
  width: var(--t-touch);
  height: var(--t-touch);
  cursor: pointer;
}

.swatch input {
  position: absolute;
  opacity: 0;
}

.swatch__dot {
  width: 36px;
  height: 36px;
  border: 2px solid var(--t-border);
  border-radius: 12px;
}

.swatch input:checked + .swatch__dot {
  border: 4px solid var(--t-text);
}

.swatch input:focus-visible + .swatch__dot {
  outline: 3px solid var(--t-accent-text);
  outline-offset: 2px;
}

/* Choix en pastilles : de vrais boutons radio (clavier, lecteur d'ecran,
   formulaire sans script), dessines en boutons ; le choix fait se lit a sa
   bordure et a sa coche, jamais a la seule couleur. */
.choices {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choices legend {
  padding: 0;
  margin-bottom: 0.5rem;
  font-weight: 900;
}

.choices__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.choice {
  position: relative;
  display: inline-flex;
}

.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
}

.choice span,
.choice--link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 48px;
  padding: 0 1rem;
  border: 2px solid var(--t-border);
  border-radius: var(--t-radius-field);
  background: transparent;
  color: var(--t-text);
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
}

.choice input:checked + span {
  border-color: var(--t-accent);
  background: var(--t-accent-bg);
  color: var(--t-accent-text);
}

.choice input:checked + span::before {
  content: '✓';
}

.choice input:focus-visible + span {
  outline: 3px solid var(--t-accent-text);
  outline-offset: 2px;
}

.choice input:disabled + span {
  opacity: 0.5;
  cursor: not-allowed;
}

.choice--link::after {
  content: '→';
}

.create-hint {
  margin: 0;
  color: var(--t-muted);
  font-size: 0.9rem;
}
