:root {
    --main-green: #318C57;
    --main-orange: #F7931E;
    --main-brown: #7B2D2D;
    --main-bg: #f9f9f6;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.hero {
    position: relative;
    min-height: calc(100 * var(--vh, 1vh));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--main-bg);
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('../img/accueil/hero.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    filter: blur(18px) saturate(1.02);
    transform: scale(1.04);
    transition: filter 1600ms cubic-bezier(.2,.9,.3,1), transform 1600ms cubic-bezier(.2,.9,.3,1);
    will-change: filter, transform;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-color: rgba(255,255,255,0.45);
    z-index: 1;
}

.hero-inner {
    position: relative;
    z-index: 2;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.white-overlay {
    position: absolute;
    inset: 0;
    background: var(--main-bg);
    z-index: 3;
    pointer-events: none;
    opacity: 1;
    filter: blur(18px);
    transition: opacity 3000ms cubic-bezier(.2,.9,.3,1), filter 3000ms cubic-bezier(.2,.9,.3,1);
    will-change: opacity, filter;
}

body.animate-ready .hero::before {
    filter: blur(0px) saturate(1);
    transform: scale(1);
}

body.animate-ready .white-overlay {
    opacity: 0;
    filter: blur(18px);
}

.text-box {
    --side-padding: clamp(12px, 3vw, 48px);
    --vertical-padding: clamp(20px, 3.5vw, 56px);
    --border-w: clamp(2px, 0.4vw, 3px);
    --box-gap: 48px;
    position: relative;
    max-width: 920px;
    width: calc(100% - 20px);
    background: rgba(255,255,255,0.9);
    border: var(--border-w) solid var(--main-green);
    padding: var(--vertical-padding) var(--side-padding);
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(0,0,0,0.12);
    transform: translateY(28px);
    opacity: 0;
    transition: transform 1200ms cubic-bezier(.2,.9,.3,1), opacity 1200ms ease;
    will-change: transform, opacity;
    display: flex;
    flex-direction: column;

    overflow: visible;
    max-height: calc((var(--vh, 1vh) * 100) - var(--box-gap) - 60px);
}

.text-box.show {
    transform: translateY(0);
    opacity: 1;
}

.avatar {
    --avatar-size: clamp(64px, 9vw, 120px);
    --avatar-border: clamp(3px, 0.6vw, 4px);
    position: absolute;
    top: calc(var(--avatar-size) * -0.45);
    left: calc(var(--side-padding) - var(--border-w));
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: 50%;
    border: var(--avatar-border) solid var(--main-orange);
    object-fit: cover;
    background-color: #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    transform-origin: center;
    opacity: 0;
    will-change: transform, opacity, box-shadow;

    z-index: 6;
}

.avatar.reveal {
    opacity: 1;
    animation: portrait-entry 1400ms cubic-bezier(.18,.9,.25,1) both;
}

@keyframes portrait-entry {
    0% {
        transform: translateY(60px) rotate(-22deg) scale(0.5);
        opacity: 0;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }
    45% {
        transform: translateY(-14px) rotate(12deg) scale(1.12);
        opacity: 1;
        box-shadow: 0 20px 50px rgba(0,0,0,0.14);
    }
    70% {
        transform: translateY(8px) rotate(-6deg) scale(0.96);
    }
    100% {
        transform: translateY(0) rotate(0deg) scale(1);
        box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    }
}

.text-content {
    margin-left: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc((var(--vh, 1vh) * 100) - var(--box-gap) - var(--vertical-padding) - 60px);
}

.text-content h1 {
    margin: 20px 0 20px 0;
    color: var(--main-brown);
    font-size: clamp(1.4rem, 4vw, 2rem);
    line-height: 1.1;
    font-weight: 700;
}

.text-content p {
    margin-top: 20px;
    color: #333;
    font-size: clamp(0.9rem, 2.8vw, 1rem);
    line-height: 1.55;
    text-align: justify;
    padding-inline: clamp(4px, 1.5vw, 12px);
    hyphens: auto;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 420px) {
    .text-box {
        width: calc(100% - 24px);
        padding: clamp(12px, 4vw, 20px);
        border-radius: 10px;
    }

    .text-content h1 {
        font-size: 1.25rem;
        margin: 12px 0;
    }

    .text-content p {
        margin-top: 12px;
        font-size: 0.88rem;
        line-height: 1.45;
    }

    .avatar {
        --avatar-size: clamp(56px, 11vw, 84px);
        top: calc(var(--avatar-size) * -0.42);
        left: calc(var(--side-padding) - var(--border-w));
    }
}

@media (max-height: 540px) {
    .text-box {
        --box-gap: 28px;
        max-height: calc((var(--vh, 1vh) * 100) - var(--box-gap));
    }

    .text-content {
        max-height: calc((var(--vh, 1vh) * 100) - var(--box-gap) - (var(--vertical-padding) * 0.9));
    }
}

body.preload .white-overlay,
body.preload .hero::before,
body.preload .text-box,
body.preload .avatar {
    transition: none !important;
    animation: none !important;
}
