/* ==========================================================================
   Doodle-Home — Feuille de styles
   Palette : dérivée du symbole international de protection civile (OIPC/ICDO)
     Orange → Pantone 151 C (#FF8200, H28°) décliné en pastel
     Bleu   → Pantone 286 C (#0032A0, H220°) décliné en pastel
   Breakpoints : mobile < 768px | tablette 768–1024px | bureau > 1024px
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Variables CSS
   -------------------------------------------------------------------------- */
:root {
    /* Palette ORPC Salève */
    /* Orange #ea8a2f décliné */
    --color-orange-light:  #fef3e8;   /* fond des blocs journée */
    --color-orange-mid:    #f5c88a;   /* en-têtes journée */
    --color-orange-dark:   #c06918;   /* CTA, ratio ≥ 4.5:1 sur blanc */
    /* Violet-bleu #52549b décliné */
    --color-blue-light:    #eeeef7;   /* survol créneaux */
    --color-blue-mid:      #b8b8d8;   /* bordures créneaux, sélection */
    --color-blue-dark:     #52549b;   /* focus, bordure sélection, liens */

    /* Neutres */
    --color-white:         #FFFFFF;
    --color-bg:            #f4f4fb;   /* fond de page, teinte violette douce */
    --color-surface:       #FFFFFF;
    --color-border:        #d0d0e8;
    --color-text:          #111118;   /* quasi-noir */
    --color-text-muted:    #4a4a7a;
    --color-error:         #C0392B;
    --color-error-bg:      #FDECEA;
    --color-error-border:  #E8A8A8;
    --color-success:       #1A7840;
    --color-success-bg:    #E8F5EE;

    /* Slot sélectionné — orange */
    --color-slot-selected-bg:     #f9cfa0;
    --color-slot-selected-border: #ea8a2f;
    --color-slot-selected-text:   #3d1f00;

    /* Typographie */
    --font-base: system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-size-base: 1rem;
    --line-height: 1.5;

    /* Espacements */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;

    /* Rayons de bordure */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Ombres */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.10);

    /* Taille minimale des éléments interactifs (mobile/tablette) */
    --min-touch-size: 44px;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-base);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--color-text);
    background-color: var(--color-bg);
    min-width: 320px;
    overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   3. Layout
   -------------------------------------------------------------------------- */
.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.main-content {
    flex: 1;
    padding: var(--space-xl) 0;
}

/* --------------------------------------------------------------------------
   4. En-tête & pied de page
   -------------------------------------------------------------------------- */
.site-header {
    background: #52549b;
    padding: var(--space-lg) var(--space-xl);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    margin: 0 calc(-1 * var(--space-md));
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.site-header__logo {
    height: 72px;
    width: auto;
    display: block;
}

.site-header h1 {
    font-size: clamp(1.2rem, 3vw, 1.75rem);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.site-footer {
    text-align: center;
    padding: var(--space-lg);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-xl);
}

/* --------------------------------------------------------------------------
   5. Alertes / messages système
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-size: 0.95rem;
}

.alert--error {
    background-color: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    color: var(--color-error);
}

.alert--inline {
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
}

/* --------------------------------------------------------------------------
   6. Fieldsets & champs
   -------------------------------------------------------------------------- */
.fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    background-color: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.fieldset__legend {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text);
    padding: 0 var(--space-sm);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}

.fieldset__hint {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--color-text-muted);
}

.field {
    margin-bottom: var(--space-md);
}

.field:last-child {
    margin-bottom: 0;
}

.field__label {
    display: block;
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: var(--space-xs);
    color: var(--color-text);
}

.required {
    color: var(--color-error);
    margin-left: 2px;
}

.field__input {
    display: block;
    width: 100%;
    max-width: 400px;
    padding: var(--space-sm) var(--space-md);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--color-text);
    background-color: var(--color-white);
    transition: border-color 0.15s, box-shadow 0.15s;
    min-height: 44px;
}

.field__input:focus {
    outline: none;
    border-color: var(--color-blue-dark);
    box-shadow: 0 0 0 3px rgba(82, 84, 155, 0.25);
}

.field--error .field__input {
    border-color: var(--color-error);
}

.field__error {
    display: block;
    margin-top: var(--space-xs);
    font-size: 0.875rem;
    color: var(--color-error);
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   7. Grille horaire
   -------------------------------------------------------------------------- */
.grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    margin-top: var(--space-md);
}

.grid__day {
    background-color: var(--color-orange-light);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.grid__day-header {
    background: linear-gradient(90deg, #52549b 0%, #7072b8 100%);
    padding: var(--space-sm) var(--space-md);
    font-weight: 600;
    font-size: 0.95rem;
    color: #ffffff;
    text-transform: capitalize;
}

.grid__slots {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: var(--space-md);
}

/* --------------------------------------------------------------------------
   8. Créneaux horaires (boutons de sélection)
   -------------------------------------------------------------------------- */
.time-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--color-blue-mid);
    border-radius: var(--radius-sm);
    background-color: var(--color-white);
    color: var(--color-text);
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
    user-select: none;
    min-width: 90px;
    white-space: nowrap;
}

.time-slot:hover {
    background-color: var(--color-blue-light);
    border-color: var(--color-blue-dark);
}

.time-slot:focus-visible {
    outline: 3px solid var(--color-blue-dark);
    outline-offset: 2px;
}

.time-slot.selected,
.time-slot[aria-pressed="true"] {
    background-color: var(--color-slot-selected-bg);
    border-color: var(--color-slot-selected-border);
    color: var(--color-slot-selected-text);
    font-weight: 700;
}

.time-slot.selected:hover {
    background-color: var(--color-blue-dark);
    color: var(--color-white);
}

/* --------------------------------------------------------------------------
   9. Boutons d'action
   -------------------------------------------------------------------------- */
.form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: var(--space-md);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-xl);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    min-height: 44px;
}

.btn--primary {
    background-color: #ea8a2f;
    border-color: #ea8a2f;
    color: var(--color-white);
}

.btn--primary:hover {
    background-color: #c06918;
    border-color: #c06918;
    box-shadow: var(--shadow-md);
}

.btn--primary:focus-visible {
    outline: 3px solid #ea8a2f;
    outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   10. Page de confirmation
   -------------------------------------------------------------------------- */
.confirmation {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-2xl) var(--space-xl);
    background-color: var(--color-success-bg);
    border: 1px solid var(--color-success);
    border-radius: var(--radius-lg);
    gap: var(--space-md);
}

.confirmation__icon {
    font-size: 3rem;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-success);
    color: white;
    border-radius: 50%;
    font-weight: 700;
}

.confirmation__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-success);
}

.confirmation__message {
    color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   11. Responsive — tablette (768px – 1024px)
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
    .page-wrapper {
        padding: 0 var(--space-xl);
    }

    .grid {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .grid__day {
        flex: 1 1 calc(50% - var(--space-md));
        min-width: 260px;
    }
}

/* --------------------------------------------------------------------------
   12. Responsive — bureau (> 1024px)
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
    .page-wrapper {
        padding: 0 var(--space-2xl);
    }

    .grid__day {
        flex: 1 1 calc(33.333% - var(--space-lg));
        min-width: 240px;
    }

    /* Sur bureau, les éléments interactifs n'ont pas de contrainte minimale de 44px */
    .time-slot {
        min-height: auto;
    }

    .btn {
        min-height: auto;
    }

    .field__input {
        min-height: auto;
    }
}

/* --------------------------------------------------------------------------
   13. Mobile (< 768px) — tailles minimales 44×44px
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
    .site-header {
        padding: var(--space-md);
    }

    .fieldset {
        padding: var(--space-md);
    }

    .field__input {
        max-width: 100%;
        min-height: var(--min-touch-size);
        font-size: 1rem; /* Évite le zoom sur iOS */
    }

    .time-slot {
        min-height: var(--min-touch-size);
        min-width: var(--min-touch-size);
        flex: 1 1 calc(50% - var(--space-sm));
        font-size: 0.8rem;
        padding: var(--space-sm);
    }

    .btn {
        min-height: var(--min-touch-size);
        width: 100%;
    }

    .form-actions {
        justify-content: stretch;
    }

    .grid__slots {
        gap: var(--space-xs);
    }
}

/* --------------------------------------------------------------------------
   14. Bloc d'introduction (texte config + logo)
   -------------------------------------------------------------------------- */
.intro-block {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid #52549b;
    border-radius: var(--radius-md);
    padding: var(--space-lg) var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
    color: var(--color-text);
    line-height: 1.7;
    font-size: 0.97rem;
}

.intro-block h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #52549b;
    margin-bottom: var(--space-sm);
}

.intro-block h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #52549b;
    margin-bottom: var(--space-xs);
}

.intro-block p {
    margin-bottom: var(--space-sm);
}

.intro-block p:last-child {
    margin-bottom: 0;
}

.intro-block ul {
    padding-left: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.intro-block li {
    margin-bottom: var(--space-xs);
}

.intro-block strong { font-weight: 700; }
.intro-block em     { font-style: italic; }
