/* ==========================================================================
   PAGE D'ACCUEIL (app/views/accueil.php) - styles dédiés
   - Mobile d'abord ; points de rupture alignés sur style.css :
     481px (au-delà de 480px), 769px (au-delà de 768px), 1024px (au-delà de 1023px)
   - Couleurs : variables de root.css + jetons locaux --home-* (suivent body.dark / body.light)
   - Fichier chargé sur toutes les pages : chaque règle cible une classe .home-*
   ========================================================================== */

/* ***** JETONS LOCAUX (thème automatique, puis thème forcé par themeMode.js) ***** */
body {
    --home-border: light-dark(#e5e7eb, #374151);
    --home-soft-accent: light-dark(#fff3f1, #2b1c19);
    --home-success-text: light-dark(#1e8449, #6ee7a0);
    --home-warning-bg: light-dark(#fef3c7, #4d3800);
    --home-warning-text: light-dark(#92400e, #fcd34d);
    --home-danger-bg: light-dark(#fee2e2, #4d1f1f);
    --home-danger-text: light-dark(#b91c1c, #fca5a5);
    --home-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

body.light {
    --home-border: #e5e7eb;
    --home-soft-accent: #fff3f1;
    --home-success-text: #1e8449;
    --home-warning-bg: #fef3c7;
    --home-warning-text: #92400e;
    --home-danger-bg: #fee2e2;
    --home-danger-text: #b91c1c;
    --home-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

body.dark {
    --home-border: #374151;
    --home-soft-accent: #2b1c19;
    --home-success-text: #6ee7a0;
    --home-warning-bg: #4d3800;
    --home-warning-text: #fcd34d;
    --home-danger-bg: #4d1f1f;
    --home-danger-text: #fca5a5;
    --home-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* Texte réservé aux lecteurs d'écran */
.home-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ***** BOUTONS DE L'ACCUEIL ***** */
a.home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 3rem;
    padding: 0.8rem 1.5rem;
    border: 2px solid transparent;
    border-radius: 2rem;
    font-family: var(--font-titles-and-button);
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;

    i {
        font-size: 1.1rem;
        line-height: 0;
    }

    &:hover {
        text-decoration: none;
        transform: translateY(-2px);
    }

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

a.home-btn-primary {
    background: var(--button-color);
    color: #fff;
    box-shadow: 0 6px 18px rgba(255, 91, 76, 0.3);

    &:hover {
        background: var(--button-color-hover);
        color: #fff;
        box-shadow: 0 8px 22px rgba(255, 91, 76, 0.4);
    }
}

a.home-btn-outline {
    background: var(--background-primary);
    color: var(--primary-color);
    border-color: var(--primary-color);

    &:hover {
        background: var(--primary-color);
        color: #fff;
    }
}

/* Boutons discrets (Se connecter, Voir la démo) : écrase le dégradé global des <button> */
button.home-btn-text {
    background: transparent;
    color: var(--text-primary);
    padding: 0.55rem 0.9rem;
    font-size: 1.05rem;
    box-shadow: none;

    i {
        color: var(--primary-color);
        font-size: 1rem;
        line-height: 0;
    }

    &:hover:not(:disabled) {
        background: var(--home-soft-accent);
        color: var(--primary-color);
        box-shadow: none;
    }
}

/* ***** HERO VISITEUR ***** */
.hero.home-hero {
    padding-left: 1rem;
    padding-right: 1rem;
}

.hero .boxHero.home-hero-box {
    gap: 1.1rem;
    padding: 1.75rem 1.1rem;
    border-radius: 1rem;
    text-align: center;
}

.hero .home-hero-box .home-hero-title {
    margin-left: 0;
    font-size: clamp(2.2rem, 9vw, 4.6rem);
    line-height: 1.12;
}

.hero .home-hero-box .home-hero-subtitle {
    max-width: 640px;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.home-hero-actions {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin: 0 auto;
}

.home-hero-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 0.75rem;
}

.home-reassurance {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;

    li {
        font-size: 0.95rem;
        font-weight: 500;
        line-height: 1.4;
        text-align: center;
        color: var(--text-secondary);
    }

    i {
        display: inline-block;
        margin-right: 0.35rem;
        vertical-align: -0.1em;
        color: var(--home-success-text);
        font-size: 1rem;
        line-height: 1;
    }
}

/* ***** ACCUEIL CONNECTÉ : INDICATEUR DE LIMITE FREE ***** */
/* Au-dessus de l'illustration décorative (z-index 3) qui peut chevaucher l'en-tête sur mobile */
.ingredients-manager .ingredients-header .home-count-group {
    position: relative;
    z-index: 4;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

.home-free-limit {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--home-border);
    border-radius: 20px;
    background: var(--background-secondary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;

    &.is-full {
        background: var(--home-warning-bg);
        border-color: var(--warning-color);
        color: var(--home-warning-text);
    }

    &.is-over {
        background: var(--home-danger-bg);
        border-color: var(--danger-color);
        color: var(--home-danger-text);
    }
}

/* ***** ACCUEIL CONNECTÉ : CARTE PREMIUM COMPACTE (comptes Free) ***** */
/* Même largeur que le gestionnaire d'ingrédients lorsque la carte est affichée */
.hero .boxHero > .ingredients-manager:has(+ .home-premium-card) {
    align-self: stretch;
}

.home-premium-card {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
        "icon body"
        "cta cta";
    align-items: start;
    gap: 0.85rem 1rem;
    margin-top: -1rem;
    padding: 1.25rem;
    border: 1px solid var(--home-border);
    border-left: 4px solid var(--secondary-color);
    border-radius: 12px;
    background: var(--background-primaryOpacity);
    backdrop-filter: blur(0.5rem);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.home-premium-card-icon {
    grid-area: icon;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: var(--button-color);

    i {
        color: #fff;
        font-size: 1.25rem;
        line-height: 0;
    }
}

.home-premium-card-body {
    grid-area: body;
    min-width: 0;
}

p.home-premium-card-title {
    margin: 0 0 0.2rem;
    font-family: var(--font-titles-and-button);
    font-size: 1.3rem;
    line-height: 1.2;
    color: var(--text-primary);
}

p.home-premium-card-text {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

p.home-premium-card-note {
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

a.home-premium-card-cta {
    grid-area: cta;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.75rem 1.25rem;
    border-radius: 2rem;
    background: var(--button-color);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(255, 91, 76, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;

    i {
        color: #fff;
        font-size: 1rem;
        line-height: 0;
    }

    &:hover {
        background: var(--button-color-hover);
        color: #fff;
        text-decoration: none;
        transform: translateY(-2px);
    }

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

/* ***** SECTIONS DE L'ACCUEIL VISITEUR ***** */
.home-section {
    padding: 3rem 1rem;
}

.home-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.home-container-narrow {
    max-width: 820px;
}

p.home-section-intro {
    max-width: 680px;
    margin: 0.75rem auto 0;
    text-align: center;
    font-size: 1.05rem;
    color: var(--text-secondary);
}

/* Recettes populaires : réutilise les cartes .recipes-main .recipes .recipeBox de style.css */
.home-popular .home-popular-list {
    margin-top: 2rem;

    .recipes .recipeBox {
        overflow: hidden;

        picture {
            display: block;
            width: calc(100% + 2rem);
            margin: 0 -1rem;
        }

        img {
            display: block;
            width: 100%;
            height: auto;
            aspect-ratio: 3 / 2;
            object-fit: cover;
        }

        h3 {
            font-size: 1.2rem;
            text-align: center;
        }
    }
}

p.home-popular-more {
    margin-top: 2rem;
    text-align: center;
}

/* Étiquette "Premium" dans le carrousel « Comment ça marche ? » */
.features .home-premium-tag {
    display: inline-flex;
    align-items: center;
    margin: -0.5rem 0 0.75rem;
    padding: 0.2rem 0.7rem;
    border-radius: 2rem;
    background: var(--button-color);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ***** COMPARATIF FREE / PREMIUM ***** */
.home-compare-wrapper {
    margin-top: 2rem;
    overflow-x: auto;
    border: 1px solid var(--home-border);
    border-radius: 1rem;
    background: var(--background-primary);
    box-shadow: var(--home-shadow);
}

.home-compare {
    width: 100%;
    border-collapse: collapse;

    th,
    td {
        padding: 0.7rem 0.5rem;
        border-bottom: 1px solid var(--home-border);
        font-size: 0.9rem;
        line-height: 1.35;
        color: var(--text-primary);
        text-align: center;
        vertical-align: middle;
    }

    thead th {
        font-family: var(--font-titles-and-button);
        font-size: 1.15rem;
        font-weight: 600;
        background: var(--background-secondary);

        &:first-child {
            font-family: var(--font-body);
            font-size: 0.85rem;
            color: var(--text-secondary);
        }

        small {
            display: block;
            margin-top: 0.15rem;
            font-family: var(--font-body);
            font-size: 0.75rem;
            font-weight: 500;
            color: var(--text-secondary);
        }
    }

    thead th:first-child,
    tbody th {
        text-align: left;
    }

    tbody th {
        width: 52%;
        font-weight: 500;
    }

    tbody tr:last-child th,
    tbody tr:last-child td {
        border-bottom: 0;
    }

    .home-compare-premium {
        background: var(--home-soft-accent);
    }

    thead .home-compare-premium {
        color: var(--primary-color);
    }

    i {
        font-size: 1.15rem;
        line-height: 0;
    }

    .home-compare-yes {
        color: var(--home-success-text);
    }

    .home-compare-no {
        color: var(--text-secondary);
        opacity: 0.55;
    }
}

/* ***** FORMULES PREMIUM ***** */
.home-pricing h3.home-plans-title {
    margin-top: 3rem;
    font-size: clamp(1.6rem, 5vw, 2.4rem);
}

/* Une colonne centrée jusqu'à 1023px, trois colonnes au-delà */
.home-plans {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.75rem;
    max-width: 560px;
    margin: 2rem auto 0;
}

.home-plan {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    padding: 2rem 1.25rem 1.5rem;
    border: 1px solid var(--home-border);
    border-radius: 1rem;
    background: var(--background-primary);
    box-shadow: var(--home-shadow);
    text-align: center;

    /* Formule mise en avant : affichée en premier en une colonne */
    &.home-plan-featured {
        order: -1;
        border: 2px solid var(--primary-color);
        box-shadow: 0 14px 36px rgba(255, 91, 76, 0.18);
    }

    p {
        margin: 0;
    }

    a.home-btn.home-plan-cta {
        width: 100%;
        margin-top: auto;
    }
}

p.home-plan-badge {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    width: max-content;
    max-width: calc(100% - 1.5rem);
    padding: 0.35rem 0.9rem;
    border-radius: 2rem;
    background: var(--button-color);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
}

.home-plan h4.home-plan-name {
    margin: 0;
    font-size: 1.7rem;
    color: var(--text-primary);
}

p.home-plan-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

strong.home-plan-amount {
    font-family: var(--font-titles-and-button);
    font-size: 2.6rem;
    line-height: 1;
    color: var(--primary-color);
}

small.home-plan-period {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

p.home-plan-detail {
    font-size: 0.92rem;
    color: var(--text-primary);
}

p.home-plan-trial {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--home-success-text);

    i {
        display: inline-block;
        margin-right: 0.3rem;
        vertical-align: -0.1em;
        font-size: 0.95rem;
        line-height: 1;
    }
}

p.home-plan-note {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

p.home-plans-free {
    margin-top: 2rem;
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);

    a {
        font-family: var(--font-body);
        font-size: 1rem;
        font-weight: 600;
        text-decoration: underline;
    }
}

/* ***** FAQ ***** */
.home-faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2rem;
}

.home-faq-item {
    border: 1px solid var(--home-border);
    border-radius: 0.85rem;
    background: var(--background-primary);
    overflow: hidden;

    summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 1rem 1.15rem;
        list-style: none;
        cursor: pointer;
        font-family: var(--font-titles-and-button);
        font-size: 1.2rem;
        font-weight: 600;
        line-height: 1.3;
        color: var(--text-primary);
        transition: color 0.2s ease;

        &::-webkit-details-marker {
            display: none;
        }

        &::after {
            content: '+';
            flex-shrink: 0;
            font-family: var(--font-body);
            font-size: 1.5rem;
            line-height: 1;
            color: var(--primary-color);
            transition: transform 0.2s ease;
        }

        &:hover {
            color: var(--primary-color);
        }

        &:focus-visible {
            outline: 2px solid var(--primary-color);
            outline-offset: -2px;
        }
    }

    &[open] summary::after {
        transform: rotate(45deg);
    }

    p {
        margin: 0;
        padding: 0 1.15rem 1.15rem;
        font-size: 0.98rem;
        color: var(--text-secondary);
    }
}

/* ***** BANDEAU FINAL ***** */
.home-final {
    padding-bottom: 4rem;
}

.home-final-box {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    padding: 2.25rem 1.25rem;
    border: 2px solid var(--primary-color);
    border-radius: 1.25rem;
    background: var(--background-primary);
    box-shadow: var(--home-shadow);
    text-align: center;

    h2 {
        font-size: clamp(2rem, 6vw, 3.2rem);
        line-height: 1.15;
    }

    > p {
        max-width: 600px;
        font-size: 1.05rem;
        color: var(--text-secondary);
    }
}

/* ***** RESPONSIVE (mobile d'abord) ***** */
/* Au-delà de 480px */
@media (min-width: 481px) {
    a.home-btn {
        width: auto;
    }

    .home-hero-actions {
        max-width: none;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
    }

    .home-reassurance {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem 1.5rem;
    }
}

/* Au-delà de 768px */
@media (min-width: 769px) {
    .hero .boxHero.home-hero-box {
        padding: 2.5rem 2rem;
    }

    .hero .home-hero-box .home-hero-subtitle {
        font-size: 1.15rem;
    }

    .home-free-limit {
        font-size: 0.85rem;
    }

    .home-premium-card {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: "icon body cta";
        align-items: center;
        gap: 1.25rem;
        padding: 1.25rem 1.5rem;
    }

    a.home-premium-card-cta {
        width: auto;
        white-space: nowrap;
    }

    .home-section {
        padding: 4rem 2rem;
    }

    .home-compare {
        th,
        td {
            padding: 0.85rem 1.25rem;
            font-size: 1rem;
        }

        thead th {
            font-size: 1.3rem;
        }

        thead th:first-child {
            font-size: 0.9rem;
        }

        tbody th {
            width: 50%;
        }
    }

    .home-faq-item summary {
        font-size: 1.3rem;
    }

    .home-final-box {
        padding: 3rem 2.5rem;
    }
}

/* Au-delà de 1023px */
@media (min-width: 1024px) {
    /* En-tête du gestionnaire en ligne (style.css) : compteurs alignés à droite */
    .ingredients-manager .ingredients-header .home-count-group {
        justify-content: flex-end;
    }

    .home-plans {
        max-width: none;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1.75rem;
        align-items: stretch;
    }

    .home-plan {
        padding: 2.25rem 1.75rem 1.75rem;
    }

    /* Ordre naturel Mensuel / Annuel / À vie, l'annuel au centre et surélevé */
    .home-plan.home-plan-featured {
        order: 0;
        transform: translateY(-0.5rem);
    }

    /* Notes de même hauteur (3 lignes) : boutons alignés d'une carte à l'autre */
    p.home-plan-note {
        min-height: 4.2em;
    }
}

/* Animations réduites */
@media (prefers-reduced-motion: reduce) {
    a.home-btn,
    a.home-premium-card-cta,
    .home-faq-item summary::after {
        transition: none;
    }

    a.home-btn:hover,
    a.home-premium-card-cta:hover {
        transform: none;
    }
}
