@import '../utils/variables.css';

/* Page Services. Tout est préfixé .services-page / .sv-* pour ne pas
   écraser home.css (les anciens .container et .section-title globaux
   sont supprimés). */

.services-page {
    --s-red: var(--institutional-red, #c92525);
    --s-navy: #1e3a5f;
    --s-navy-deep: #0f2238;
    --s-surface: var(--pure-white, #ffffff);
    --s-soft: var(--bg-secondary, #f4f6f9);
    --s-ink: var(--deep-black, #111827);
    --s-muted: var(--text-secondary, #5b6472);
    --s-line: rgba(15, 34, 56, 0.12);
    --s-radius: clamp(14px, 1vw + 8px, 22px);
    --s-gap: clamp(1rem, 0.6rem + 1.6vw, 2rem);
    --s-section: clamp(3.25rem, 2rem + 5vw, 6.5rem);
    --s-pad: clamp(1.1rem, 0.6rem + 2.4vw, 2rem);
    --s-nav: 80px; /* hauteur de la navbar fixe */
    --s-heading: var(--font-heading, 'Playfair Display', Georgia, serif);

    color: var(--s-ink);
    overflow-x: clip;
}

[data-theme="dark"] .services-page {
    --s-surface: #0e1116;
    --s-soft: #161a21;
    --s-ink: #f3f4f6;
    --s-muted: #c4cad4;
    --s-line: rgba(255, 255, 255, 0.1);
}

.services-page *,
.services-page *::before,
.services-page *::after { box-sizing: border-box; }

.services-page svg { flex-shrink: 0; }
.services-page a:focus-visible { outline: 3px solid var(--s-red); outline-offset: 3px; border-radius: 6px; }

.sv-container {
    width: min(100% - 2 * var(--s-pad), 1200px);
    margin-inline: auto;
}

/* Bannière */
.sv-hero {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    padding: calc(var(--s-nav) + clamp(1.5rem, 5vw, 3.5rem)) 0 clamp(2.5rem, 6vw, 5rem);
    color: #fff;
    background: var(--s-navy-deep);
    overflow: hidden;
}

.sv-hero__bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(55% 70% at 80% 55%, rgba(201, 37, 37, 0.24), transparent 65%),
        radial-gradient(70% 90% at 0% 100%, rgba(30, 58, 95, 0.95), transparent 70%),
        linear-gradient(160deg, var(--s-navy-deep) 0%, var(--s-navy) 100%);
}

.sv-hero__bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1.5px);
    background-size: 28px 28px;
    mask-image: linear-gradient(180deg, #000, transparent 80%);
    -webkit-mask-image: linear-gradient(180deg, #000, transparent 80%);
}

.sv-hero__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(1.75rem, 5vw, 3rem);
    align-items: center;
}

.sv-hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1.25rem;
    padding: 0.45rem 1rem 0.45rem 0.85rem;
    font-size: 0.88rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.sv-hero__dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--s-red);
    box-shadow: 0 0 0 4px rgba(201, 37, 37, 0.3);
}

.sv-hero__title {
    margin: 0 0 1rem;
    font-family: var(--s-heading);
    font-size: clamp(2.1rem, 1.2rem + 4.5vw, 4.1rem);
    font-weight: 700;
    line-height: 1.06;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.sv-hero__subtitle {
    max-width: 52ch;
    margin: 0;
    font-size: clamp(1rem, 0.92rem + 0.4vw, 1.2rem);
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.86);
}

.sv-hero__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: clamp(1.5rem, 4vw, 2.25rem) 0 1.5rem;
    padding: 0;
    list-style: none;
}

.sv-hero__chips li {
    padding: 0.45rem 0.95rem;
    font-size: 0.88rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
}

.sv-hero__link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    font-weight: 600;
    color: #fff;
    text-decoration: underline;
    text-decoration-color: var(--s-red);
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

/* Façade animée */
.sv-hero__art { 
    width: min(100%, 560px); 
    margin: 0 auto; 
    /* 🎯 MOBILE : Affiché en premier (au-dessus du texte) */
    order: -1; 
    margin-bottom: 2rem;
}

.fx { display: block; width: 100%; height: auto; overflow: visible; }

.fx-shadow { fill: rgba(0, 0, 0, 0.28); }

.fx-steps rect {
    fill: rgba(255, 255, 255, 0.07);
    stroke: rgba(255, 255, 255, 0.35);
    stroke-width: 1.5;
}

.fx-col { transform-box: fill-box; transform-origin: 50% 100%; }

.fx-col__shaft { fill: url(#fx-shaft); stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.5; }
.fx-col__cap,
.fx-col__base { fill: rgba(255, 255, 255, 0.15); stroke: rgba(255, 255, 255, 0.6); stroke-width: 1.5; }
.fx-col__flute { stroke: rgba(255, 255, 255, 0.17); stroke-width: 1.5; }
.fx-col__glow { fill: url(#fx-glow); opacity: 0; }

.fx-entab { fill: rgba(255, 255, 255, 0.12); stroke: rgba(255, 255, 255, 0.6); stroke-width: 1.5; }
.fx-entab-line { stroke: rgba(255, 255, 255, 0.25); stroke-width: 1.5; }

.fx-ped-fill { fill: rgba(255, 255, 255, 0.06); }

.fx-ped {
    fill: none;
    stroke: #fff;
    stroke-width: 2.4;
    stroke-linejoin: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    filter: drop-shadow(0 0 10px rgba(201, 37, 37, 0.6));
}

.fx-oculus { fill: none; stroke: #ff9a9a; stroke-width: 2; transform-box: fill-box; transform-origin: center; }
.fx-oculus--in { fill: #ff9a9a; stroke: none; }

@media (prefers-reduced-motion: no-preference) {
    .fx-shadow { opacity: 0; animation: sv-fade 0.8s ease 0.1s forwards; }

    .fx-steps rect { opacity: 0; animation: sv-step 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
    .fx-steps rect:nth-child(1) { animation-delay: 0.15s; }
    .fx-steps rect:nth-child(2) { animation-delay: 0.3s; }
    .fx-steps rect:nth-child(3) { animation-delay: 0.45s; }

    .fx-col {
        transform: scaleY(0);
        animation: sv-rise 1s cubic-bezier(0.22, 1, 0.36, 1) calc(0.8s + var(--i) * 0.35s) forwards;
    }

    .fx-entab,
    .fx-entab-line { opacity: 0; animation: sv-fade 0.7s ease 2.3s forwards; }

    /* 🎯 MODIFICATION : Animation en boucle infinie au lieu de "forwards" */
    .fx-ped { 
        stroke-dashoffset: 1; 
        animation: sv-draw-loop 6s ease-in-out 2.5s infinite; 
    }
    
    .fx-ped-fill { opacity: 0; animation: sv-fade 0.9s ease 3.4s forwards; }
    .fx-oculus { opacity: 0; transform: scale(0.2); animation: sv-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 3.7s forwards; }

    /* après la construction, une colonne puis la suivante s'éclairent en boucle */
    .fx-col__glow { animation: sv-glow 8s ease-in-out calc(4.4s + var(--i) * 2s) infinite; }
    .sv-hero__chips li { animation: sv-chip 8s ease-in-out calc(4.4s + var(--i) * 2s) infinite; }

    .sv-hero__text > * { opacity: 0; animation: sv-in 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
    .sv-hero__text > :nth-child(1) { animation-delay: 0.05s; }
    .sv-hero__text > :nth-child(2) { animation-delay: 0.15s; }
    .sv-hero__text > :nth-child(3) { animation-delay: 0.25s; }
    .sv-hero__text > :nth-child(4) { animation-delay: 0.35s; }
    .sv-hero__text > :nth-child(5) { animation-delay: 0.45s; }
}

@keyframes sv-fade { to { opacity: 1; } }
@keyframes sv-draw { to { stroke-dashoffset: 0; } }
@keyframes sv-rise { to { transform: scaleY(1); } }
@keyframes sv-pop  { to { opacity: 1; transform: scale(1); } }
@keyframes sv-step { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes sv-in   { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

/* 🎯 NOUVELLE KEYFRAME : Dessin en boucle infinie */
@keyframes sv-draw-loop {
    0%   { stroke-dashoffset: 1; opacity: 0; }
    8%   { opacity: 1; }
    45%  { stroke-dashoffset: 0; opacity: 1; } /* Fin du dessin */
    85%  { stroke-dashoffset: 0; opacity: 1; } /* Pause pour qu'on puisse bien voir le résultat */
    100% { stroke-dashoffset: 1; opacity: 0; } /* S'efface doucement et recommence */
}

@keyframes sv-glow {
    0%   { opacity: 0; }
    6%   { opacity: 1; }
    22%  { opacity: 1; }
    30%, 100% { opacity: 0; }
}

@keyframes sv-chip {
    0%   { background-color: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); }
    6%   { background-color: var(--s-red); border-color: var(--s-red); }
    22%  { background-color: var(--s-red); border-color: var(--s-red); }
    30%, 100% { background-color: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); }
}

@media (min-width: 960px) {
    .sv-hero { min-height: clamp(600px, 92svh, 860px); }
    .sv-hero__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .sv-hero__art { 
        margin-inline: auto 0; 
        /* 🎯 DESKTOP : Ordre normal (texte à gauche, art à droite) */
        order: 0; 
        margin-bottom: 0;
    }
}

@media (min-width: 1600px) {
    .sv-container { width: min(100% - 6rem, 1320px); }
}

/* Éléments communs */
.sv-section { padding: var(--s-section) 0; }
.sv-section--plain { background: var(--s-surface); }
.sv-section--soft  { background: var(--s-soft); }

.sv-head { margin-bottom: clamp(1.75rem, 1rem + 3vw, 3.5rem); }
.sv-head--center { text-align: center; }

.sv-head__title {
    margin: 0 0 0.5rem;
    font-family: var(--s-heading);
    font-size: clamp(1.6rem, 1.1rem + 2vw, 2.6rem);
    font-weight: 700;
    line-height: 1.15;
    color: var(--s-ink);
    text-wrap: balance;
}

.sv-head__title::after {
    content: '';
    display: block;
    width: 64px; height: 4px;
    margin-top: 0.9rem;
    background: linear-gradient(90deg, var(--s-red), var(--s-navy));
    border-radius: 4px;
}

.sv-head--center .sv-head__title::after { margin-inline: auto; }

.sv-head__text { margin: 1rem 0 0; font-size: clamp(1rem, 0.95rem + 0.3vw, 1.1rem); color: var(--s-muted); }

.sv-checklist { display: grid; gap: 0.55rem; margin: 0; padding: 0; list-style: none; }

.sv-checklist li {
    position: relative;
    padding-left: 1.7rem;
    font-size: 0.93rem;
    line-height: 1.5;
    color: var(--s-muted);
}

.sv-checklist li::before {
    content: '';
    position: absolute;
    left: 0; top: 0.2em;
    width: 1.05rem; height: 1.05rem;
    background: var(--s-red);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
}

.services-page .sv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 48px;
    text-align: center;
}

/* Les quatre piliers */
.piliers {
    display: grid;
    gap: var(--s-gap);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.pilier {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: clamp(1.4rem, 1rem + 1.4vw, 2.25rem);
    overflow: hidden;
    background: var(--s-soft);
    border: 1px solid var(--s-line);
    border-radius: var(--s-radius);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease, border-color 0.4s ease;
}

.pilier::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--s-red), var(--s-navy));
}

.pilier__icon {
    display: grid;
    place-items: center;
    width: 64px; height: 64px;
    margin-bottom: 1.25rem;
    color: #fff;
    background: linear-gradient(135deg, var(--s-red), var(--s-navy));
    border-radius: 18px;
    box-shadow: 0 10px 22px -10px rgba(201, 37, 37, 0.6);
}

.pilier__title {
    margin: 0 0 0.75rem;
    font-family: var(--s-heading);
    font-size: clamp(1.2rem, 1.1rem + 0.5vw, 1.4rem);
    line-height: 1.25;
    color: var(--s-ink);
}

.pilier__desc { margin: 0 0 1.25rem; font-size: 0.95rem; line-height: 1.7; color: var(--s-muted); }
.pilier .sv-checklist { margin-top: auto; padding-top: 1.25rem; border-top: 1px solid var(--s-line); }

@media (hover: hover) {
    .pilier:hover {
        transform: translateY(-8px);
        border-color: rgba(201, 37, 37, 0.4);
        box-shadow: 0 26px 50px -24px rgba(15, 34, 56, 0.35);
    }
}

/* Détail des prestations */
.prestations {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: minmax(0, 1fr);
}

.prestation {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.1rem;
    background: var(--s-surface);
    border: 1px solid var(--s-line);
    border-radius: var(--s-radius);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.35s ease, box-shadow 0.35s ease;
}

.prestation__icon {
    display: grid;
    place-items: center;
    width: 48px; height: 48px;
    color: var(--s-red);
    background: rgba(201, 37, 37, 0.1);
    border-radius: 14px;
    transition: background 0.3s ease, color 0.3s ease;
}

.prestation__body { flex: 1; min-width: 0; }

.prestation__title {
    margin: 0 0 0.35rem;
    font-family: var(--s-heading);
    font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
    line-height: 1.3;
    color: var(--s-ink);
    overflow-wrap: anywhere;
}

.prestation__desc { margin: 0; font-size: 0.92rem; line-height: 1.6; color: var(--s-muted); }

@media (hover: hover) {
    .prestation:hover {
        transform: translateY(-4px);
        border-color: rgba(201, 37, 37, 0.4);
        box-shadow: 0 18px 36px -20px rgba(15, 34, 56, 0.3);
    }
    .prestation:hover .prestation__icon { color: #fff; background: linear-gradient(135deg, var(--s-red), var(--s-navy)); }
}

@media (min-width: 640px) {
    .prestations { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-gap); }
    .prestation { padding: 1.5rem; gap: 1.1rem; }
    .prestation__icon { width: 54px; height: 54px; }
}

@media (min-width: 1100px) {
    .prestation { padding: 1.75rem; }
}

/* Pourquoi nous choisir */
.pourquoi {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(1.75rem, 1rem + 4vw, 4rem);
    align-items: start;
}

.pourquoi__text { margin: 1.25rem 0 0; font-size: clamp(1rem, 0.95rem + 0.3vw, 1.1rem); line-height: 1.75; color: var(--s-muted); }

.pourquoi__list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--s-line); }

.atout {
    display: flex;
    gap: 1rem;
    padding: clamp(1.1rem, 0.8rem + 1vw, 1.6rem) 0;
    border-bottom: 1px solid var(--s-line);
}

.atout__icon {
    display: grid;
    place-items: center;
    width: 48px; height: 48px;
    color: var(--s-red);
    background: rgba(201, 37, 37, 0.1);
    border-radius: 14px;
}

.atout__title { margin: 0 0 0.35rem; font-family: var(--s-heading); font-size: clamp(1.1rem, 1.05rem + 0.3vw, 1.3rem); color: var(--s-ink); }
.atout__desc  { margin: 0; font-size: 0.95rem; line-height: 1.7; color: var(--s-muted); }

@media (min-width: 900px) {
    .pourquoi { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }
    .pourquoi__intro { position: sticky; top: calc(var(--s-nav) + 1.5rem); }
}

/* Appel à l'action */
.sv-cta {
    position: relative;
    padding: var(--s-section) 0;
    color: #fff;
    text-align: center;
    background:
        radial-gradient(60% 120% at 50% 0%, rgba(201, 37, 37, 0.25), transparent 70%),
        linear-gradient(135deg, var(--s-navy-deep), var(--s-navy));
    overflow: hidden;
}

.sv-cta::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--s-red), #fff, var(--s-red));
}

.sv-cta__inner { max-width: 760px; }

.sv-cta__title { margin: 0 0 1rem; font-family: var(--s-heading); font-size: clamp(1.6rem, 1.1rem + 2.2vw, 2.6rem); line-height: 1.15; text-wrap: balance; }
.sv-cta__text  { margin: 0 0 2rem; font-size: clamp(1rem, 0.95rem + 0.3vw, 1.1rem); line-height: 1.7; color: rgba(255, 255, 255, 0.82); }

.sv-cta__buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.9rem; }

@media (max-width: 559px) {
    .sv-cta__buttons { flex-direction: column; }
    .sv-cta__buttons .sv-btn { width: 100%; }
}

/* Cas particuliers */
@media (max-height: 500px) and (orientation: landscape) {
    .sv-hero { min-height: 0; padding-top: calc(var(--s-nav) + 1rem); padding-bottom: 1.5rem; }
    .sv-hero__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .sv-hero__art { width: min(100%, 320px); }
}

@media (prefers-reduced-motion: reduce) {
    .services-page *, .services-page *::before, .services-page *::after { transition-duration: 0.01ms !important; }
}

@media print {
    .sv-hero { color: #000; background: none; padding: 1rem 0; min-height: 0; }
    .sv-hero__bg, .sv-hero__art, .sv-cta__buttons { display: none; }
    .sv-section, .sv-cta { padding: 1.5rem 0; background: none; color: #000; }
    .pilier, .prestation { break-inside: avoid; box-shadow: none; }
}