/* --------------------------------------------------------------------------
   Fondations : couleurs, typographie, éléments communs (reprises de Mon
   Association et de Ma Famille), avec un accent vert sapin à Mon ERP.

   Pensé pour le doigt d'abord : aucune cible tactile en dessous de 48 px.
   Largeur minimale visée : 320 px, sans défilement horizontal. Un ERP sert
   aussi beaucoup au bureau : la page s’élargit sur ordinateur (.application).
   -------------------------------------------------------------------------- */

:root {
    color-scheme: light;

    --fond: #f4f6f5;
    --fond-carte: #ffffff;
    --fond-doux: #ebefed;
    --texte: #212724;
    --texte-doux: #66706b;
    --bordure: #dfe5e2;
    --alerte: #c0392b;
    --alerte-fond: #fcebeb;
    --attention: #a86a0c;

    --accent: #2f5d50;
    --accent-fond: #e2efea;
    --accent-encre: #1c3d34;
    --accent-texte: #ffffff;

    --rayon: 16px;
    --rayon-grand: 24px;
    --espace: 16px;
    --cible: 48px;

    --ombre: 0 1px 2px rgba(30, 40, 60, .05), 0 6px 20px rgba(30, 40, 60, .06);

    --police: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

    --duree: 220ms;
    --courbe: cubic-bezier(.2, .8, .2, 1);
}

/* Le sombre dépend de `data-theme`, posé sur <html> avant le premier dessin,
   et non d'un `@media` : une règle média l'emporterait sur un choix
   (appris chez Ma Famille). */
:root[data-theme="sombre"] {
    color-scheme: dark;

    --fond: #131816;
    --fond-carte: #1c2320;
    --fond-doux: #25302b;
    --texte: #eef0f3;
    --texte-doux: #a2a9b2;
    --bordure: #2e3833;
    --alerte: #f08a7a;
    --alerte-fond: #3a1f1c;
    --attention: #e8b25c;

    --accent: #7fcbb4;
    --accent-fond: #173a30;
    --accent-encre: #bfe6da;
    --accent-texte: #07201a;

    --ombre: 0 1px 2px rgba(0, 0, 0, .3);
}

/* `hidden` doit toujours cacher, même sous un `display: flex`. */
[hidden] {
    display: none !important;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background: var(--fond);
    color: var(--texte);
    font: 16px/1.5 var(--police);
    -webkit-font-smoothing: antialiased;
    /* Encoches et barres système des téléphones. */
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
    -webkit-tap-highlight-color: transparent;
    /* Un mot très long (une adresse e-mail) ne pousse jamais la page de côté. */
    overflow-wrap: anywhere;
}

.application {
    max-width: 1120px;
    margin: 0 auto;
    padding: var(--espace);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 0 0 4px;
}

h2 {
    font-size: 1.1rem;
    margin: 0 0 var(--espace);
    font-weight: 650;
}

p {
    margin: 0 0 var(--espace);
}

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

.chargement {
    text-align: center;
    color: var(--texte-doux);
    margin-top: 40vh;
    animation: pulsation 1.2s ease-in-out infinite;
}

/* ------------------------------------------------------------- formulaires */

button {
    font: inherit;
    min-height: var(--cible);
    border-radius: 999px;
    border: none;
    cursor: pointer;
    background: var(--fond-carte);
    color: var(--texte);
    box-shadow: inset 0 0 0 1px var(--bordure);
    padding: 0 18px;
    transition: transform 120ms var(--courbe), background-color var(--duree) var(--courbe);
}

button:active {
    transform: scale(.97);
}

button:disabled {
    cursor: default;
    opacity: .5;
}

.bouton-principal {
    background: var(--accent);
    color: var(--accent-texte);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent);
    font-weight: 650;
    width: 100%;
}

.bouton-discret {
    background: none;
    box-shadow: none;
    color: var(--texte-doux);
    font-weight: 550;
}

.bouton-discret:hover {
    background: var(--fond-doux);
}

input,
select,
textarea {
    font: inherit;
    width: 100%;
    min-height: var(--cible);
    padding: 0 16px;
    border-radius: var(--rayon);
    border: 1.5px solid transparent;
    background: var(--fond-doux);
    color: var(--texte);
}

input::placeholder {
    color: var(--texte-doux);
    opacity: .8;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--fond-carte);
}

button:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
}

label {
    display: block;
    font-weight: 600;
    margin: 0 0 6px;
}

/* ------------------------------------------------------------------ divers */

.carte {
    background: var(--fond-carte);
    border-radius: var(--rayon-grand);
    padding: 18px;
    box-shadow: var(--ombre);
}

.message-erreur {
    color: var(--alerte);
    font-weight: 600;
    text-align: center;
    /* Hauteur réservée : l'apparition du message ne fait pas sauter le
       clavier sous le doigt. */
    min-height: 1.5em;
    margin: 12px 0 0;
}

@keyframes pulsation {
    50% { opacity: .45; }
}

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