/*
 * TASK-08-14 — Page de préférences email (notification.niubrand.me).
 *
 * Règles reprises de docs/design/prototype-human-editorial/globals.css :
 *   :root l.6-24 · body l.34-42 · button:focus-visible l.52-58
 *   .account-settings-sheet l.1250-1266, l.2139-2141, ≤ 920px l.9903-9907
 *   .account-settings-sheet h2 l.1298-1306 (porté sur le h1 de la page)
 *   .account-settings-sheet > header l.2142-2152 · .profile-kicker l.2397-2406
 *   .settings-toggle l.2220-2245 · panneau l.11856-11953 · ≤ 700px l.12140-12160
 *   .app-stage :where(…) l.12313-12323 (la feuille est rendue sous .app-stage,
 *   PrototypeApp.tsx l.560, sans portail)
 * rem du prototype = 16 px (navigateur, aucune taille racine) : idem ici.
 *
 * ⚠️ Écarts voulus (une page n'est pas une feuille) :
 *  - la feuille latérale devient la colonne de la page : même largeur
 *    (min(500px, 100%)), même fond, même rembourrage, centrée ; ni fond
 *    d'arrière-plan, ni animation, ni bouton Fermer (aucune application à
 *    rejoindre). ≤ 920 px : pleine largeur, sans l'arrondi de feuille du bas ;
 *  - colonne Push éteinte et désactivée (le push n'existe pas encore), comme
 *    l'écran mobile de TASK-08-05 ;
 *  - ajouts sans modèle au prototype : message d'erreur et « Réessayer »
 *    (repris de l'écran mobile), encart « lien non valide ».
 */

:root {
  --forest: #0d2b23;
  --emerald: #1e5b4b;
  --soft-mint: #dcefe7;
  --off-white: #f6f3ee;
  --warm-white: #fffdf9;
  --charcoal: #232c29;
  --muted: #56615c;
  --border: rgba(13, 43, 35, 0.16);
  --font-title: 'Geist', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Manrope', 'Avenir Next', 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  /* `.app-stage` : fond --off-white. */
  background: var(--off-white);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--charcoal);
  background: var(--off-white);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
}

button:focus-visible {
  outline: 3px solid rgba(77, 186, 154, 0.38);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.icone {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── La feuille, devenue colonne de page ─────────────────────────────────── */
.account-settings-sheet {
  position: relative;
  width: min(500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 34px;
  padding-top: max(34px, calc(22px + env(safe-area-inset-top)));
  padding-bottom: max(34px, calc(22px + env(safe-area-inset-bottom)));
  background: var(--warm-white);
  /* Ombre de la feuille (-20px 0 60px), rendue des deux côtés de la colonne. */
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.15);
}

.account-settings-sheet > header {
  padding-right: 48px;
}

.account-settings-sheet h1 {
  margin: 8px 0;
  color: var(--forest);
  font: 600 38px/1.02 var(--font-title);
  letter-spacing: -0.045em;
}

.account-settings-sheet > header p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* `.profile-kicker` puis `.app-stage :where(.profile-kicker)` (13px/1.4, plus tardive). */
.profile-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* ~~Valeur du prototype, telle quelle : --soft-mint sur --warm-white.~~ → révisé le
     2026-09-25 (TASK-09-28, arbitrage du propriétaire) : --soft-mint est presque illisible
     sur --warm-white ; le surtitre sur fond clair prend --emerald, comme `.overline`. */
  color: var(--emerald);
  font-size: 0.8125rem;
  line-height: 1.4;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.11em;
}

/* ── Le panneau ──────────────────────────────────────────────────────────── */
.notification-preferences-panel {
  display: grid;
  gap: 12px;
}

.preference-channel-head,
.preference-event-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 72px;
  align-items: center;
  gap: 10px;
}

.preference-channel-head {
  min-height: 36px;
  padding: 0 14px;
  color: var(--muted);
  font-size: 0.75rem;
}

.preference-channel-head b {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.75rem;
}

.preference-event-list {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.preference-event-list article {
  min-height: 78px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--warm-white);
}

.preference-event-list article:last-child {
  border-bottom: 0;
}

.preference-event-list article > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preference-event-list article b {
  color: var(--forest);
  font-size: 0.875rem;
}

.preference-event-list article small {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.settings-toggle {
  width: 48px;
  height: 29px;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  /* GAP token — piste éteinte : #c9cfcc (valeur du prototype, aucun token). */
  background: #c9cfcc;
  cursor: pointer;
  transition: 0.2s ease;
}

.settings-toggle span {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  /* GAP token — pouce : white (valeur du prototype, aucun token). */
  background: white;
  box-shadow: 0 2px 6px rgba(13, 43, 35, 0.15);
  transition: transform 0.2s ease;
}

.settings-toggle.active {
  background: var(--emerald);
}

.settings-toggle.active span {
  transform: translateX(19px);
}

.preference-event-list .settings-toggle {
  position: relative;
  justify-self: center;
}

/* Ajout (§10) : zone tactile portée à 45 px de haut, invisible. */
.preference-event-list .settings-toggle::after {
  content: '';
  position: absolute;
  inset: -8px 0;
}

.preference-event-list .settings-toggle:disabled {
  cursor: default;
}

.channel-unavailable {
  justify-self: center;
  color: var(--muted);
  font-size: 1rem;
}

.preference-event-list .settings-toggle.locked {
  cursor: not-allowed;
  opacity: 0.82;
}

.preference-event-list .settings-toggle.locked svg {
  position: absolute;
  left: 5px;
  color: var(--forest);
}

.critical-email-note {
  padding: 15px;
  border-radius: 15px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: var(--emerald);
  background: var(--soft-mint);
}

/* `.app-stage :where(p)` : 15px/1.55 — le titre de la note en hérite l'interligne. */
.critical-email-note p {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.critical-email-note b,
.critical-email-note span {
  display: block;
}

.critical-email-note b {
  color: var(--forest);
  font-size: 0.875rem;
}

.critical-email-note span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

/* ── Ajouts sans modèle au prototype ─────────────────────────────────────── */
/* Erreur et « Réessayer » : repris de l'écran mobile (TASK-08-05). */
.preferences-feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.preferences-feedback span {
  flex: 1;
  min-width: 0;
}

.preferences-feedback button {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--emerald);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

/* Encart « lien non valide » : la forme de la note du chemin critique. */
.link-refused {
  margin-top: 22px;
}

/* Sans icône (noscript) : le texte prend toute la largeur. */
noscript .link-refused p {
  grid-column: 1 / -1;
}

/* ── ≤ 920 px : la feuille occupe toute la largeur ───────────────────────── */
@media (max-width: 920px) {
  .account-settings-sheet {
    width: 100%;
    padding-right: max(19px, env(safe-area-inset-right));
    padding-left: max(19px, env(safe-area-inset-left));
    box-shadow: none;
  }
}

/* ── ≤ 700 px : colonnes de canaux resserrées ────────────────────────────── */
@media (max-width: 700px) {
  .preference-channel-head,
  .preference-event-list article {
    grid-template-columns: minmax(0, 1fr) 54px 54px;
    gap: 6px;
  }

  .preference-channel-head {
    padding-inline: 10px;
  }

  .preference-channel-head b {
    font-size: 0;
  }

  .preference-channel-head b svg {
    width: 18px;
    height: 18px;
  }

  .preference-event-list article {
    padding: 13px 10px;
  }

  .preference-event-list .settings-toggle {
    width: 46px;
  }
}
