/* Gros Week-end — styles. Mobile d'abord, clair et sombre. */

:root {
  color-scheme: light;
  --fond: #f5f1e8;
  --surface: #fffdf8;
  --encre: #1e2622;
  --encre-2: #5b655f;
  --ligne: #e4ddcf;
  --accent: #2f6b4f;
  --accent-encre: #ffffff;
  --accent-doux: #dcebe2;
  --libre: #2e8a52;
  --libre-fond: #eaf5ee;
  --gele: #3f5a85;
  --gele-fond: #e3e9f4;
  --alerte: #a95a17;
  --alerte-fond: #f8ead9;
  --ombre: 0 1px 2px rgb(30 38 34 / 6%), 0 4px 16px rgb(30 38 34 / 6%);

  --rayon: 16px;
  --nav-h: 64px;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --fond: #121614;
    --surface: #1b211e;
    --encre: #ecefe9;
    --encre-2: #a3aca6;
    --ligne: #2b332f;
    --accent: #6fbf91;
    --accent-encre: #0f1a14;
    --accent-doux: #1f3329;
    --libre: #5cc98a;
    --libre-fond: #15291e;
    --gele: #9db6e0;
    --gele-fond: #1e2736;
    --alerte: #e3a062;
    --alerte-fond: #33261a;
    --ombre: 0 1px 2px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }

/* Le style du navigateur pour [hidden] est faible : tout display (grid, flex)
   l'écrase. Sans cette règle, le voile et le message restent affichés. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--encre);
  font: 16px/1.45 var(--police);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }

h1, h2, h3, p { margin: 0; }

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

/* --- Mise en page ------------------------------------------------------- */

#ecran {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px
           calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 24px);
  display: grid;
  /* minmax(0, …) : un long nom d'activité (nowrap) ne peut pas élargir la colonne. */
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  outline: none;
}

.entete { display: grid; gap: 2px; padding: 8px 4px 4px; }
.surtitre { color: var(--encre-2); font-size: 0.875rem; font-weight: 600; letter-spacing: 0.02em; }
h1 { font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 1rem; }
.intro { color: var(--encre-2); margin-top: 6px; }

.carte {
  background: var(--surface);
  border: 1px solid var(--ligne);
  border-radius: var(--rayon);
  padding: 16px;
  box-shadow: var(--ombre);
}
.carte > h2 { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; }
.carte > h2 small { color: var(--encre-2); font-weight: 500; font-size: 0.8125rem; }

/* --- Écran 1 : temps libre et capacité ----------------------------------- */

.libre-total {
  background: var(--libre-fond);
  border-color: color-mix(in srgb, var(--libre) 30%, transparent);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 14px;
  align-items: center;
}
.libre-total svg { grid-row: span 2; width: 44px; height: 44px; color: var(--libre); }
.grand-chiffre { font-size: 2.25rem; font-weight: 750; line-height: 1; color: var(--libre); letter-spacing: -0.02em; }
.libre-total p { color: var(--encre-2); font-size: 0.9375rem; }
.libre-total .alerte-texte { grid-column: 1 / -1; margin-top: 8px; color: var(--alerte); font-weight: 600; }

.periodes { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.periode-entete { display: flex; justify-content: space-between; gap: 8px; font-size: 0.9375rem; margin-bottom: 6px; }
.periode-entete span:last-child { color: var(--encre-2); font-variant-numeric: tabular-nums; }
.periode-entete .depasse { color: var(--alerte); font-weight: 600; }

.barre {
  position: relative;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--libre-fond) 0 6px,
              color-mix(in srgb, var(--libre) 22%, var(--libre-fond)) 6px 8px);
}
.barre > span { position: absolute; inset-block: 0; left: 0; }
.barre .capacite { background: var(--accent-doux); }
.barre .utilise { background: var(--accent); border-radius: 7px 0 0 7px; }
.barre .surplus { background: var(--alerte); }

.legende { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; font-size: 0.8125rem; color: var(--encre-2); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legende .l-utilise { background: var(--accent); }
.legende .l-capacite { background: var(--accent-doux); }
.legende .l-libre { background: var(--libre-fond); border: 1.5px dashed var(--libre); }

.apercu { list-style: none; margin: 0; padding: 0; }
.apercu li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--ligne); }
.apercu li:first-child { border-top: 0; padding-top: 0; }
.apercu .nom { flex: 1; min-width: 0; }
.apercu .nom strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apercu .nom small { color: var(--encre-2); font-size: 0.8125rem; }
.apercu .plus { color: var(--encre-2); font-size: 0.875rem; justify-content: center; }

.priorite { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--encre-2); }
.priorite[data-p="1"] { background: #c4462f; }
.priorite[data-p="2"] { background: #d08a2b; }
.priorite[data-p="3"] { background: #6b9e7f; }
.priorite[data-p="4"], .priorite[data-p="5"] { background: #9aa39e; }

.etiquette {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem; font-weight: 650; padding: 2px 8px; border-radius: 999px;
  background: var(--fond); color: var(--encre-2); border: 1px solid var(--ligne);
  white-space: nowrap;
}
.etiquette svg { width: 12px; height: 12px; }
.etiquette.gele { background: var(--gele-fond); color: var(--gele); border-color: transparent; }
.etiquette.forcee { background: var(--alerte-fond); color: var(--alerte); border-color: transparent; }

.avatars { display: flex; flex: none; }
.avatars span {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.75rem; font-weight: 700;
  border: 2px solid var(--surface);
  margin-left: -6px;
}
.avatars span:first-child { margin-left: 0; }
.avatars [data-i="1"] { background: #d7e6f7; color: #24476f; }
.avatars [data-i="2"] { background: #f6dfe6; color: #7a2a44; }

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

.bouton-principal, .bouton-secondaire {
  min-height: 48px;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.bouton-principal { background: var(--accent); color: var(--accent-encre); border: 0; }
.bouton-principal:active, .bouton-secondaire:active { transform: scale(0.98); }
.bouton-principal:hover { filter: brightness(1.05); }
.bouton-secondaire { background: var(--surface); border: 1.5px solid var(--ligne); }
.bouton-secondaire:hover { border-color: var(--encre-2); }
.bouton-principal svg, .bouton-secondaire svg { width: 18px; height: 18px; }

.batir {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  width: 100%;
  font-size: 1.0625rem;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* --- Écran 2 : horaire -------------------------------------------------- */

.onglets {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px; border-radius: 14px; background: var(--ligne);
}
.onglets button {
  border: 0; background: transparent; border-radius: 10px;
  padding: 10px; font-weight: 600; color: var(--encre-2);
}
.onglets button[aria-selected="true"] { background: var(--surface); color: var(--encre); box-shadow: var(--ombre); }
.onglets small { display: block; font-weight: 500; font-size: 0.75rem; }

.resume-jour { color: var(--encre-2); font-size: 0.9375rem; padding: 0 4px; }
.resume-jour strong { color: var(--libre); }

.ligne-temps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.bloc { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; }
.bloc-heure { white-space: nowrap; font-size: 0.8125rem; font-weight: 600; color: var(--encre-2); padding-top: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.bloc-corps {
  min-height: max(56px, calc(var(--min) * 0.9px));
  border-radius: 14px; padding: 12px 14px;
  display: grid; align-content: start; gap: 4px;
}

.bloc-activite .bloc-corps {
  background: var(--surface);
  border: 1px solid var(--ligne);
  border-left: 4px solid var(--accent);
  box-shadow: var(--ombre);
}
.bloc-activite.gele .bloc-corps { border-left-color: var(--gele); }
.bloc-activite.forcee .bloc-corps { border-left-color: var(--alerte); }
.bloc-titre { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 650; }
.bloc-detail, .bloc-tampons { font-size: 0.8125rem; color: var(--encre-2); }
.bloc-pied { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }

.bloc-libre .bloc-corps {
  border: 2px dashed var(--libre);
  background: var(--libre-fond);
  color: var(--libre);
  align-content: center;
}
.bloc-libre .bloc-heure { color: var(--libre); }
.bloc-libre strong { font-size: 0.9375rem; }
.bloc-libre span { font-size: 0.8125rem; opacity: 0.9; }

/* --- Écran 3 : reportées ------------------------------------------------ */

.reportees { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.reportee { display: grid; gap: 12px; }
.reportee-entete { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.reportee-entete h2 { font-size: 1.0625rem; }
.reportee-entete p { color: var(--encre-2); font-size: 0.8125rem; margin-top: 2px; }

.raison {
  background: var(--fond);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.9375rem;
  display: grid; gap: 4px;
}
.raison b { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--encre-2); display: flex; align-items: center; gap: 6px; }
.raison b svg { width: 14px; height: 14px; color: var(--accent); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions button { padding-inline: 10px; font-size: 0.9375rem; }
@media (max-width: 360px) { .actions { grid-template-columns: 1fr; } }

.vide { text-align: center; padding: 32px 16px; display: grid; gap: 8px; justify-items: center; }
.vide svg { width: 56px; height: 56px; color: var(--libre); }
.vide p { color: var(--encre-2); }

/* --- Navigation --------------------------------------------------------- */

.navigation {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--ligne);
}
.navigation a {
  position: relative;
  display: grid; justify-items: center; align-content: center; gap: 2px;
  color: var(--encre-2); text-decoration: none; font-size: 0.75rem; font-weight: 600;
}
.navigation svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.navigation a[aria-current="page"] { color: var(--accent); }
.pastille {
  position: absolute; top: 8px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--alerte); color: #fff; font-size: 0.6875rem; line-height: 18px; text-align: center;
}

/* --- Superpositions ----------------------------------------------------- */

.chargement {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--fond) 80%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.chargement-boite { background: var(--surface); border-radius: var(--rayon); padding: 24px 28px; box-shadow: var(--ombre); display: grid; gap: 14px; justify-items: center; text-align: center; }
.roue { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--accent-doux); border-top-color: var(--accent); animation: tourne 0.8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

.toast {
  position: fixed; z-index: 30;
  left: 16px; right: 16px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  max-width: 448px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  background: var(--encre); color: var(--fond);
  font-size: 0.9375rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
}
.toast span { flex: 1; }
.toast button { background: none; border: 0; color: var(--accent-doux); font-weight: 700; padding: 6px; }
@media (prefers-color-scheme: dark) { .toast button { color: var(--accent-encre); } }

.mise-a-jour {
  position: fixed; z-index: 25;
  left: 16px; right: 16px;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  max-width: 448px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 16px; border-radius: 14px;
  background: var(--accent); color: var(--accent-encre);
  font-weight: 650;
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
}
.mise-a-jour button {
  min-height: 40px; padding: 8px 14px; border: 0; border-radius: 10px;
  background: var(--accent-encre); color: var(--accent); font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}
