/* Base : couleurs, reset, mise en page generale (coque, navigation). */

:root {
  color-scheme: light dark;

  --fond: #f5f4ee;
  --surface: #ffffff;
  --surface-2: #eeece3;
  --texte: #1d2722;
  --doux: #58645d;
  --bord: #e2dfd2;

  --accent: #2f7a5a;
  --accent-fort: #25634a;
  --accent-sur: #ffffff;
  --accent-fond: #e1f0e7;

  --ok: #1f7a46;
  --ok-fond: #e0f1e6;
  --bientot: #8f5300;
  --bientot-fond: #fcefd2;
  --perime: #b3261e;
  --perime-fond: #fbe5e2;
  --inconnu: #56625b;
  --inconnu-fond: #eceae2;

  --bandeau-fond: #1f4d3a;
  --bandeau-texte: #ffffff;
  --urgence: #b3261e;

  --ombre: 0 1px 2px rgba(25, 45, 35, 0.06), 0 6px 18px rgba(25, 45, 35, 0.07);
  --ombre-forte: 0 10px 40px rgba(15, 30, 22, 0.22);
  --rayon: 18px;
  --police: -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --largeur-lecture: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #121714;
    --surface: #1b2420;
    --surface-2: #242e29;
    --texte: #e9efe9;
    --doux: #a2afa7;
    --bord: #2e3b34;

    --accent: #5ab88d;
    --accent-fort: #7fcfa8;
    --accent-sur: #0d1f17;
    --accent-fond: #1d3329;

    --ok: #72d39b;
    --ok-fond: #1b3427;
    --bientot: #f2bd62;
    --bientot-fond: #3a2f17;
    --perime: #ff8f86;
    --perime-fond: #402120;
    --inconnu: #a2afa7;
    --inconnu-fond: #28312c;

    --bandeau-fond: #2b4d3d;
    --bandeau-texte: #eef6f0;
    --urgence: #c9352c;

    --ombre: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
    --ombre-forte: 0 10px 40px rgba(0, 0, 0, 0.55);
  }
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  background: var(--fond);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* Une fois connecte, l'appli occupe tout l'ecran et c'est la zone centrale qui defile */
html.appli,
html.appli body {
  height: 100%;
  overflow: hidden;
}

img {
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

p {
  margin: 0;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

.cache {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.texte-doux {
  color: var(--doux);
}

.sans-js {
  padding: 24px;
  text-align: center;
}

/* ---------- ecran d'ouverture / hors ligne ---------- */

.demarrage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: var(--doux);
}

.demarrage img {
  border-radius: 18px;
}

.hors-ligne h1 {
  color: var(--texte);
  font-size: 1.6rem;
}

.hors-ligne p {
  max-width: 24rem;
}

.hors-ligne__urgence {
  color: var(--texte);
}

/* ---------- coque : contenu + navigation ---------- */

.coque {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    'contenu'
    'nav';
}

.contenu {
  grid-area: contenu;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.vue {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  outline: none;
  padding-top: calc(env(safe-area-inset-top, 0px) + 20px);
  padding-bottom: 32px;
  padding-left: max(16px, env(safe-area-inset-left, 0px), calc((100% - var(--largeur-lecture)) / 2));
  padding-right: max(16px, env(safe-area-inset-right, 0px), calc((100% - var(--largeur-lecture)) / 2));
}

.vue--plein {
  overflow: hidden;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
}

/* Navigation : barre d'onglets en bas (mobile) */

.nav {
  grid-area: nav;
  background: var(--surface);
  border-top: 1px solid var(--bord);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.nav__marque {
  display: none;
}

.nav__liste {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav__lien {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 58px;
  padding: 6px 4px;
  color: var(--doux);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: color 150ms ease-out, background-color 150ms ease-out;
}

.nav__lien:active {
  background: var(--surface-2);
}

.nav__lien[aria-current='page'] {
  color: var(--accent);
}

.nav__icone {
  width: 26px;
  height: 26px;
}

.nav__lien--ajout .nav__icone {
  box-sizing: content-box;
  padding: 4px;
  margin-bottom: -2px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-sur);
  width: 22px;
  height: 22px;
}

/* Grand ecran : barre laterale */

@media (min-width: 900px) {
  .coque {
    grid-template-columns: 17rem minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: 'nav contenu';
  }

  .nav {
    border-top: 0;
    border-right: 1px solid var(--bord);
    padding: 28px 14px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    overflow-y: auto;
  }

  .nav__marque {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
    font-weight: 750;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
  }

  .nav__marque img {
    border-radius: 10px;
  }

  .nav__liste {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .nav__lien {
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    font-size: 1rem;
  }

  .nav__lien[aria-current='page'] {
    background: var(--accent-fond);
  }

  .nav__lien--ajout .nav__icone {
    padding: 3px;
    width: 20px;
    height: 20px;
    margin: 0;
  }

  .vue {
    padding-top: 36px;
    padding-bottom: 48px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .nav__lien:hover {
    background: var(--surface-2);
  }
}

/* Mouvement reduit : plus de transitions ni d'animations decoratives */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .rond-attente {
    animation: tourner 2.4s linear infinite !important;
  }
}
