/* ===========================
   PAGE HERO
=========================== */

.page-hero{

    min-height:75vh;
    min-height:75dvh;
    display:flex;
    justify-content:center;
    align-items:center;
    text-align:center;
    padding:120px 20px;
    position:relative;
    overflow:hidden;

    background:
        linear-gradient(
            rgba(0,0,0,.35),
            rgba(0,0,0,.35)
        ),
        url("../images/historiaHero.jpg");

    background-size:cover;
    background-position:center;

}

.page-hero-content{

    max-width:720px;

}

.page-hero h1{

    font-family:"Playfair Display";
    font-size:4.5rem;
    font-weight:300;
    color:white;
    margin:25px 0;

}

.page-description{

    color:white;
    font-size:1.2rem;
    line-height:1.8;
    max-width:650px;
    margin:auto;

}

/* ===========================
   STORY SECTIONS
=========================== */

/* padding de 170px: és la zona buida (sense text) on viuen les fulles */
.story-section{

    padding:170px 20px;
    background:white;
    position:relative;

}

/* Secció del mig (Xavi): fons crema, el mateix de la secció de
   preguntes freqüents, perquè les tres seccions s'alternin
   blanc / crema / blanc i es distingeixin bé */
.story-section:nth-of-type(2){

    background:var(--background);

}

/* La imatge "flota" a un costat i el text l'envolta: mentre hi ha imatge,
   el text va al costat; quan s'acaba la imatge, el text ocupa tota l'amplada.
   display:flow-root fa que el contenidor "abraci" la imatge flotant
   (si no, una imatge més alta que el text sortiria per sota de la secció). */

.story-container{

    max-width:1200px;
    margin:auto;

    display:flow-root;

    position:relative;
    z-index:1;

}

.story-header{

    text-align:left;

    margin-bottom:30px;

}

.story-header h2{

    font-family:"Playfair Display";
    font-size:3.2rem;
    margin:10px 0 0;

}

/* Per defecte la imatge flota a l'esquerra (Alba i Nosaltres).
   min(430px, 45%): fa 430px, però mai més del 45% de l'amplada,
   perquè en pantalles mitjanes quedi espai per al text */
.story-image{

    float:left;

    width:min(430px, 45%);

    margin:0 70px 40px 0;

    border-radius:40px;
    overflow:hidden;

    position:relative;
    z-index:1;

}

.story-image-large{

    width:min(500px, 48%);

}

/* Segona secció (Xavi): la imatge passa a la dreta.
   Només a ordinador: al mòbil la imatge no flota (vegeu MOBILE) */
@media (min-width:769px){

    .story-section:nth-of-type(2) .story-image{

        float:right;

        margin:0 0 40px 70px;

    }

}

.story-image img{

    width:100%;
    display:block;

    object-fit:cover;
    aspect-ratio:4/5;

    border-radius:40px;
    border:8px solid white;

    box-shadow:0 25px 70px rgba(0,0,0,.12);

    transition:
        transform .6s ease,
        box-shadow .6s ease;

}

.story-image:hover img{

    transform:scale(1.03);
    box-shadow:0 35px 90px rgba(0,0,0,.18);

}

.story-content p:last-child{

    margin-bottom:0;

}

.story-content p{

    font-size:1.12rem;
    line-height:1.95;
    color:#666;
    margin-bottom:24px;

}

/* Logo de tancament al final de "Nosaltres".
   display:block + margin auto el centra; height:auto manté la proporció */
.story-closing-logo{

    display:block;

    width:150px;
    height:auto;

    /* 150px d'aire a sobre: hi va l'última fulla (vegeu Nosaltres ::before) */
    margin:150px auto 0;

    position:relative;
    z-index:1;

}

/* ===========================
   STORY ANIMATIONS
=========================== */

.story-section{

    opacity:0;
    transform:translateY(60px);

    transition:
        opacity .8s ease,
        transform .8s ease;

}

.story-section.visible{

    opacity:1;
    transform:translateY(0);

}

/* ===========================
   BACK BUTTON
=========================== */

.back-home{

    position:fixed;
    top:30px;
    left:30px;
    z-index:1000;

    padding:12px 22px;

    background:rgba(255,255,255,.92);
    backdrop-filter:blur(12px);

    border-radius:999px;

    text-decoration:none;
    color:var(--green);

    font-family:"Poppins";
    font-weight:500;

    box-shadow:0 10px 30px rgba(0,0,0,.12);

    transition:all .3s ease;

}

.back-home:hover{

    transform:translateY(-2px);
    box-shadow:0 16px 40px rgba(0,0,0,.18);

}

/* ===========================
   BOTANICAL DECORATIONS
   Regla: cada fulla ha de cabre dins del padding de dalt o de baix
   de la secció (170px), que és on no hi ha mai text. Per això
   fan 140px i estan a 15px de la vora: 15 + 140 = 155 < 170.
=========================== */

.story-section::before{

    content:"";
    position:absolute;

    width:140px;
    height:140px;

    background-repeat:no-repeat;
    background-size:contain;

    opacity:.12;
    pointer-events:none;

}

/* 1a secció (Alba): branca a dalt a l'esquerra */

.story-section:nth-of-type(1)::before{

    background-image:url("../images/decorations/leaf-bottom.png");

    top:15px;
    left:30px;

    opacity:.42;

}

/* 2a secció (Xavi): branca a dalt a l'esquerra */

.story-section:nth-of-type(2)::before{

    background-image:url("../images/decorations/leaf-top.png");

    top:15px;
    left:30px;

    opacity:.42;

}

/* 3a secció (Nosaltres): branqueta de tancament arraconada a la dreta,
   a l'espai buit entre l'última frase i el logo (més amunt que el logo).
   Càlcul (ordinador): el logo fa 150px d'ample → 137px d'alt, i acaba
   on comença el padding de baix (170px). El seu cantó de dalt és, doncs,
   a 170 + 137 = 307px del final de la secció. Deixem 15px d'aire:
   bottom = 307 + 15 = 322px. La fulla (120px) cap dins dels 150px de
   margin-top del logo, així que no toca mai el text. */

.story-section:nth-of-type(3)::before{

    background-image:url("../images/decorations/leaf-small.png");

    width:120px;
    height:120px;

    bottom:322px;
    right:30px;

    transform:scaleX(-1);

    opacity:.38;

}

/* Segona fulla de cada secció (::after), a l'altre cantó, per tancar-la visualment */

.story-section::after{

    content:"";
    position:absolute;

    background-repeat:no-repeat;
    background-size:contain;

    pointer-events:none;

}

/* 1a secció (Alba): tancament a baix a la dreta */

.story-section:nth-of-type(1)::after{

    background-image:url("../images/decorations/leaf-bottom.png");

    width:140px;
    height:140px;

    transform:scaleX(-1);

    bottom:15px;
    right:30px;

    opacity:.28;

}

/* 2a secció (Xavi): tancament a baix a la dreta */

.story-section:nth-of-type(2)::after{

    background-image:url("../images/decorations/leaf-top.png");

    width:140px;
    height:140px;

    transform:scaleX(-1);

    bottom:15px;
    right:30px;

    opacity:.28;

}

/* 3a secció (Nosaltres): ara també amb una branqueta a dalt a l'esquerra, com a obertura */

.story-section:nth-of-type(3)::after{

    background-image:url("../images/decorations/leaf-small.png");

    width:120px;
    height:120px;

    top:20px;
    left:20px;

    opacity:.26;

}

/* ===========================
   MOBILE
=========================== */

@media (max-width:768px){

    /* Al mòbil la foto (apaïsada) es retalla per omplir una caixa vertical
       i la parella quedava just sota els textos. Per separar-los:
       - hero més alt: la foto s'escala amb l'alçada, i la parella (que és
         a dos terços cap avall) baixa i es fa més gran;
       - textos col·locats just per sobre dels caps: els alineem a baix
         (align-items:flex-end) i el padding-bottom els fa pujar fins a 40px
         per sobre de la parella. Com que la foto ocupa tot l'alt del hero,
         els caps són sempre al 64,5% de l'alçada, és a dir, a 35,5% del
         final. padding-bottom = 35,5% de l'alçada + 40px d'aire.
         Així l'aire és el mateix encara que el text ocupi més o menys línies;
       - background-position 62%: desplaça el retall cap a la dreta perquè
         la parella quedi ben a la vista. */
    .page-hero{

        min-height:620px;
        min-height:max(80dvh, 620px);

        align-items:flex-end;

        padding:100px 24px calc(620px * .355 + 40px);
        padding-bottom:calc(max(80dvh, 620px) * .355 + 40px);

        background-position:62% center;

    }

    .page-hero h1{

        font-size:2.8rem;
        line-height:1.15;

    }

    .page-description{

        font-size:1rem;

    }

    .back-home{

        top:20px;
        left:20px;

        padding:10px 18px;

        font-size:.95rem;

    }

    /* Dalt 130px per a les fulles d'obertura (12 + 110 = 122 < 130) */
    .story-section{

        padding:130px 20px 210px;

    }

    /* A "Nosaltres" la fulla de tancament va al costat del logo, no a baix:
       no cal tant espai buit al final */
    .story-section:nth-of-type(3){

        padding-bottom:100px;

    }

    .story-container{

        display:flex;
        flex-direction:column;

        gap:25px;

    }

    .story-header{

        order:1;

        text-align:center;

        margin-bottom:0;

    }

    .story-header h2{

        font-size:2.7rem;

    }

    .story-image{

        order:2;

        float:none;

        width:100%;

        max-width:340px;

        margin:20px auto 45px;

    }

    .story-image-large{

        width:100%;

        max-width:380px;

    }

    .story-content{

        order:3;

        max-width:700px;

    }

    .story-content p{

        font-size:1.05rem;
        line-height:1.9;

    }

    .story-closing-logo{

        width:120px;

        margin-top:120px;

    }

    .story-section:nth-of-type(1)::before{

        width:110px;
        height:110px;

        top:12px;
        left:10px;

        opacity:.28;

    }

    .story-section:nth-of-type(2)::before{

        width:110px;
        height:110px;

        top:12px;
        left:10px;

        opacity:.28;

    }

    /* Igual que a l'ordinador: a la dreta i més amunt que el logo.
       Al mòbil el logo fa 120px d'ample → 110px d'alt, i el padding de
       baix és 100px: cantó de dalt del logo = 100 + 110 = 210px del final.
       Amb 15px d'aire: bottom = 225px. La fulla (90px) cap dins dels
       120px de margin-top del logo. */
    .story-section:nth-of-type(3)::before{

        width:90px;
        height:90px;

        bottom:225px;
        right:10px;

        opacity:.3;

    }

    .story-section:nth-of-type(1)::after{

        width:150px;
        height:150px;

        bottom:16px;
        right:10px;

        opacity:.2;

    }

    .story-section:nth-of-type(2)::after{

        width:150px;
        height:150px;

        bottom:16px;
        right:10px;

        opacity:.2;

    }

    .story-section:nth-of-type(3)::after{

        width:110px;
        height:110px;

        top:12px;
        left:10px;

        opacity:.18;

    }

}
