/* ==========================================================================
   app.css — base, mise en page et composants communs.
   Chargé sur toutes les pages. Le studio ajoute studio.css par-dessus.
   ========================================================================== */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.1; font-weight: 700; }
p { margin: 0 0 var(--sp-4); }
a { color: inherit; text-decoration-color: var(--hot); text-underline-offset: 3px; }

/* Anneau de focus unique et toujours visible. Un outil de production se
   pilote aussi au clavier, en particulier quand on a les mains prises. */
:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 2px;
  border-radius: var(--r-sharp);
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--hot); color: #fff; }

/* Toute grandeur physique porte cette classe. Voir tokens.css. */
.mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.92em;
  letter-spacing: -0.01em;
}

.unit { color: var(--ink-faint); font-size: 0.85em; margin-left: 0.15em; }

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

/* ==========================================================================
   Marque
   ========================================================================== */

.wordmark {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 0.85;
  color: var(--hot);
  /* Ombre portée en dur plutôt qu'un calque dupliqué en position absolue :
     le calque dupliqué de l'ancienne version se coupait différemment du
     texte du dessus dès que la ligne passait à la ligne, produisant le
     doublon décalé visible sur les captures. */
  text-shadow: 3px 3px 0 var(--ink);
}
.wordmark--xl { font-size: var(--step-4); text-shadow: 5px 5px 0 var(--ink); }

.brand {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  text-decoration: none;
}
.brand__mark {
  font-family: var(--font-display);
  font-size: 1.35rem; line-height: 1;
  padding: 0.34em 0.5em 0.4em;
  background: var(--hot); color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--r-soft);
  box-shadow: var(--drop-1);
  transform: rotate(-2deg);
  letter-spacing: -0.02em;
}
.brand__tag {
  font-size: var(--step--2); font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* ==========================================================================
   En-tête d'application
   ========================================================================== */

.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--sp-4);
  height: var(--header-h);
  padding: 0 var(--sp-5);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--ink);
}
.appbar__spacer { flex: 1; }

.navlink {
  font-weight: 600; font-size: var(--step--1);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-pill);
  text-decoration: none;
  color: var(--ink-soft);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.navlink:hover { background: var(--paper-warm); color: var(--ink); }
.navlink[aria-current='page'] { background: var(--ink); color: var(--paper); }

/* ==========================================================================
   Boutons
   ========================================================================== */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  font: inherit; font-weight: 600;
  padding: var(--sp-2) var(--sp-4);
  min-height: 38px;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 2px solid var(--ink);
  border-radius: var(--r-soft);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--paper-warm); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--primary { --btn-bg: var(--hot); --btn-fg: #fff; }
.btn--primary:hover:not(:disabled) { --btn-bg: var(--hot-deep); }

.btn--ghost { --btn-bg: transparent; border-color: transparent; }
.btn--ghost:hover:not(:disabled) { background: var(--paper-warm); }

.btn--danger { --btn-bg: transparent; --btn-fg: var(--alert); border-color: var(--alert); }
.btn--danger:hover:not(:disabled) { --btn-bg: var(--alert); --btn-fg: #fff; }

.btn--block { width: 100%; }
.btn--sm { min-height: 30px; padding: var(--sp-1) var(--sp-3); font-size: var(--step--1); }

/* Le bouton d'appel des écrans d'identité : gros, incliné, ombre franche. */
.btn--loud {
  font-family: var(--font-display);
  font-size: var(--step-1);
  padding: var(--sp-3) var(--sp-5);
  --btn-bg: var(--hot); --btn-fg: #fff;
  border-width: 3px;
  border-radius: var(--r-bold);
  box-shadow: var(--drop-2);
  letter-spacing: -0.01em;
}
.btn--loud:hover:not(:disabled) { --btn-bg: var(--hot-deep); box-shadow: var(--drop-1); transform: translate(2px, 2px); }

/* ==========================================================================
   Champs
   ========================================================================== */

.field { display: block; margin-bottom: var(--sp-4); }

.field__label {
  display: block;
  font-size: var(--step--2); font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: var(--sp-2);
}

.field__hint { font-size: var(--step--2); color: var(--ink-faint); margin-top: var(--sp-2); }
.field__error { font-size: var(--step--2); color: var(--alert); margin-top: var(--sp-2); font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  font: inherit;
  padding: var(--sp-3);
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-soft);
  transition: border-color var(--fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--hot); }
.input[aria-invalid='true'] { border-color: var(--alert); }
.textarea { resize: vertical; min-height: 72px; line-height: 1.35; }

.input--mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Curseur : la piste porte une graduation, comme une réglette. */
.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: var(--paper-warm);
  border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent);
}
.range::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: var(--paper-warm);
  border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -7px;
  border-radius: 50%;
  background: var(--hot);
  border: 2px solid var(--ink);
}
.range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--hot); border: 2px solid var(--ink);
}
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--hot-wash); }

.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; font-size: var(--step--1); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__box {
  width: 20px; height: 20px; flex: none;
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 5px;
  background: var(--surface);
  font-size: 13px; line-height: 1; color: #fff;
}
.switch input:checked + .switch__box { background: var(--hot); border-color: var(--ink); }
.switch input:focus-visible + .switch__box { outline: 2px solid var(--hot); outline-offset: 2px; }

/* ==========================================================================
   Cartes et surfaces
   ========================================================================== */

.card {
  background: var(--surface);
  border: 2.5px solid var(--ink);
  border-radius: var(--r-bold);
  padding: var(--sp-5);
  box-shadow: var(--drop-2);
}

.panel {
  background: var(--surface);
  border: var(--line-faint);
  border-radius: var(--r-soft);
  padding: var(--sp-4);
}

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--step--2); font-weight: 700;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--paper-warm);
  color: var(--ink-soft);
}
.chip--hot   { background: var(--hot-wash); color: var(--hot-deep); }
.chip--go    { background: color-mix(in srgb, var(--go) 16%, transparent); color: var(--go); }
.chip--warn  { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }
.chip--alert { background: color-mix(in srgb, var(--alert) 14%, transparent); color: var(--alert); }

/* ==========================================================================
   Messages
   ========================================================================== */

.notice {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-soft);
  border-left: 4px solid var(--ink-faint);
  background: var(--surface-2);
  font-size: var(--step--1);
  margin-bottom: var(--sp-4);
}
.notice--error { border-left-color: var(--alert); background: color-mix(in srgb, var(--alert) 8%, var(--surface)); }
.notice--warn  { border-left-color: var(--gold);  background: color-mix(in srgb, var(--gold) 10%, var(--surface)); }
.notice--ok    { border-left-color: var(--go);    background: color-mix(in srgb, var(--go) 8%, var(--surface)); }
.notice--info  { border-left-color: var(--glass); background: color-mix(in srgb, var(--glass) 8%, var(--surface)); }

/* Notifications éphémères */
.toasts {
  position: fixed; inset-block-end: var(--sp-5); inset-inline-end: var(--sp-5);
  z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2);
  max-width: min(420px, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--ink); color: var(--paper);
  border-radius: var(--r-soft);
  box-shadow: var(--lift);
  font-size: var(--step--1);
  animation: toast-in var(--base) var(--ease);
}
.toast--error { background: var(--alert); color: #fff; }
.toast--ok    { background: var(--go); color: #fff; }
.toast--warn  { background: var(--gold); color: #17141A; }
.toast__close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.1em; opacity: 0.7; }
.toast__close:hover { opacity: 1; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================================
   Boîtes de dialogue
   ========================================================================== */

dialog.modal {
  padding: 0; border: none; background: transparent;
  max-width: min(560px, calc(100vw - 2rem));
}
dialog.modal::backdrop { background: rgb(23 20 26 / 0.55); backdrop-filter: blur(2px); }
.modal__body {
  background: var(--surface); color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: var(--r-bold);
  padding: var(--sp-5);
  box-shadow: var(--drop-3);
}
.modal__title { font-family: var(--font-display); font-size: var(--step-2); margin-bottom: var(--sp-3); }
.modal__actions { display: flex; gap: var(--sp-3); justify-content: flex-end; margin-top: var(--sp-5); }

/* ==========================================================================
   Tableaux — administration et historique
   ========================================================================== */

.table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.table th {
  text-align: left; font-size: var(--step--2); font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}
.table td { padding: var(--sp-3); border-bottom: var(--line-faint); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table__scroll { overflow-x: auto; }

/* ==========================================================================
   Grilles de galerie
   ========================================================================== */

.shell { max-width: 1240px; margin: 0 auto; padding: var(--sp-6) var(--sp-5) var(--sp-8); }
.shell--narrow { max-width: 760px; }

.section-head {
  display: flex; align-items: baseline; gap: var(--sp-4);
  margin: var(--sp-7) 0 var(--sp-4);
  flex-wrap: wrap;
}
.section-head:first-child { margin-top: 0; }
.section-head__title {
  font-family: var(--font-display);
  font-size: var(--step-2);
  letter-spacing: -0.01em;
}
.section-head__count { font-size: var(--step--1); color: var(--ink-faint); }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: var(--sp-5);
}

/* La carte reprend l'inclinaison et l'ombre de la marque : c'est un objet
   fabriqué, pas une ligne de tableur. L'inclinaison se redresse au survol,
   ce qui donne le retour d'interaction sans animation gratuite. */
.design-card {
  display: block; text-align: left; width: 100%;
  padding: var(--sp-3);
  background: var(--surface);
  border: 2.5px solid var(--ink);
  border-radius: var(--r-soft);
  box-shadow: var(--drop-2);
  cursor: pointer;
  font: inherit; color: inherit;
  transition: transform var(--base) var(--ease), box-shadow var(--base) var(--ease);
}
.design-card:nth-child(odd)  { transform: rotate(-1deg); }
.design-card:nth-child(even) { transform: rotate(0.8deg); }
.design-card:hover, .design-card:focus-visible {
  transform: rotate(0deg) translateY(-3px);
  box-shadow: var(--drop-3);
}

.design-card__thumb {
  aspect-ratio: 16 / 10;
  display: grid; place-items: center;
  border-radius: var(--r-sharp);
  border: 2px solid var(--ink);
  background: var(--ink);
  background-image: radial-gradient(color-mix(in srgb, var(--paper) 18%, transparent) 1px, transparent 1.3px);
  background-size: 10px 10px;
  overflow: hidden;
  padding: var(--sp-2);
}
.design-card__word {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 4.6vw, 1.6rem);
  color: var(--hot);
  text-shadow: 1.5px 1.5px 0 #000;
  text-align: center;
  overflow-wrap: anywhere;
  line-height: 1;
}
.design-card__meta {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--sp-2); margin-top: var(--sp-3);
}
.design-card__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.design-card__dims { font-size: var(--step--2); color: var(--ink-faint); white-space: nowrap; }

/* ==========================================================================
   État vide — une invitation, pas un constat
   ========================================================================== */

.empty {
  border: 2px dashed var(--ink-faint);
  border-radius: var(--r-bold);
  padding: var(--sp-7) var(--sp-5);
  text-align: center;
  color: var(--ink-soft);
}
.empty__title { font-family: var(--font-display); font-size: var(--step-1); color: var(--ink); margin-bottom: var(--sp-2); }

/* ==========================================================================
   Écrans d'identité (connexion, invitation)
   ========================================================================== */

.gate {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
}

/* Le semis d'arrière-plan reprend le motif de l'outil : des points régulés,
   comme un remplissage de strass. Il est masqué en dégradé vers les bords et
   ne passe jamais sous le contenu de manière lisible. */
.gate::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(var(--ink) 1.2px, transparent 1.4px);
  background-size: 18px 18px;
  opacity: 0.16;
  -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 12%, transparent 72%);
  mask-image: radial-gradient(ellipse at 50% 45%, #000 12%, transparent 72%);
  pointer-events: none;
}

.gate__card {
  position: relative; z-index: 1;
  width: min(420px, 100%);
  background: var(--surface);
  border: 3px solid var(--ink);
  border-radius: var(--r-bold);
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  box-shadow: var(--drop-3);
}
.gate__badge {
  position: absolute; top: -13px; left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  font-size: var(--step--2); font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: var(--sp-1) var(--sp-3);
  background: var(--hot); color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.gate__title { text-align: center; margin: var(--sp-3) 0 var(--sp-2); }
.gate__sub { text-align: center; color: var(--ink-soft); font-size: var(--step--1); margin-bottom: var(--sp-5); }
.gate__foot { text-align: center; font-size: var(--step--2); color: var(--ink-faint); margin-top: var(--sp-4); }

/* ==========================================================================
   Adaptation aux petits écrans
   ========================================================================== */

/* La barre supérieure porte huit éléments : à 400 px de large, tout empiler
   mangerait le tiers de l'écran. Elle défile horizontalement, la marque et
   l'état d'enregistrement restant toujours visibles. */
@media (max-width: 900px) {
  .appbar {
    padding: 0 var(--sp-3);
    gap: var(--sp-2);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .appbar::-webkit-scrollbar { display: none; }
  .appbar > * { flex: none; }
  .appbar__spacer { flex: 1 0 var(--sp-2); }

  .brand__tag { display: none; }
  .brand__mark { font-size: 1.1rem; }

  .appbar__nav { display: flex; gap: var(--sp-1); }
  .navlink { padding: var(--sp-2); font-size: var(--step--2); }

  .shell { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: var(--sp-4); }

  /* Les cartes se redressent : l'inclinaison rogne la largeur utile, et sur
     un petit écran chaque millimètre compte. */
  .design-card:nth-child(odd),
  .design-card:nth-child(even) { transform: none; }

  .card { padding: var(--sp-4); box-shadow: var(--drop-1); }
  .gate__card { padding: var(--sp-5) var(--sp-4) var(--sp-4); box-shadow: var(--drop-2); }

  .table th, .table td { padding: var(--sp-2); }

  /* Les notifications occupent toute la largeur, hors des zones de gestes. */
  .toasts {
    inset-inline: var(--sp-3);
    inset-block-end: var(--sp-3);
    max-width: none;
  }
}

@media (max-width: 560px) {
  /* 16 px sur les champs : en dessous, iOS zoome tout seul à la mise au point
     et l'utilisateur se retrouve avec une page décadrée. */
  .input, .select, .textarea { font-size: 16px; padding: var(--sp-3) var(--sp-3); }

  /* Cibles tactiles : 44 px est le minimum confortable au doigt. */
  .btn { min-height: 44px; }
  .btn--sm { min-height: 36px; }

  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: var(--sp-3); }
  .wordmark--xl { text-shadow: 3px 3px 0 var(--ink); }
  .modal__actions { flex-direction: column-reverse; }
  .modal__actions .btn { width: 100%; }
}
