/* Oasi Crescita — sezione animata "dalla talea alla pianta" */

/* ---------- modalità scorrimento: la sezione resta ferma mentre si scende ---------- */
.oc-scroll { position: relative; }
/* Altezza = una schermata per tappa, più le due pause (inizio e fine) sulla prima e
   sull'ultima immagine: così nessuna delle due si vede solo per un istante. */
.oc-scroll.oc-con-scroll {
    height: calc((var(--oc-tappe, 4) + var(--oc-attese, .5)) * var(--oc-passo, 95vh));
}
/* La sezione non deve mai essere più alta della finestra: uno sticky più alto del
   viewport si "attacca" solo quando arriva al suo fondo, e sembra che scorra via. */
.oc-scroll.oc-con-scroll > .oc {
    position: sticky; top: 0;
    height: 100vh; min-height: 0; max-height: 100vh; overflow: hidden;
}
@supports (height: 100svh) {
    .oc-scroll.oc-con-scroll > .oc { height: 100svh; max-height: 100svh; }
}

/* Ultimo ripiego: la sezione viene spostata nel body e tenuta fissa a schermo. */
.oc.oc-agganciata {
    position: fixed !important; top: 0; left: 0; right: auto; bottom: auto;
    height: 100vh !important; max-height: 100vh !important; margin: 0 !important; z-index: 1;
}
.oc.oc-agganciata[hidden] { display: none !important; }
.oc-segnaposto { display: block; }

.oc {
    --oc-verde: #0b4a2f;
    --oc-verde-chiaro: #7ac943;
    --oc-crema: #f6f4ed;
    --oc-altezza: 86vh;
    position: relative;
    min-height: var(--oc-altezza);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    isolation: isolate;
    background: #06251a;
    color: #fff;
}
.oc *, .oc *::before, .oc *::after { box-sizing: border-box; }

/* ---------- sfondi ---------- */
.oc-sfondi { position: absolute; inset: 0; z-index: 0; }
.oc-sfondo {
    position: absolute; inset: 0;
    background-size: cover; background-position: center;
    opacity: 0; transform: scale(1.12);
    transition: opacity 1.4s ease, transform 9s linear;
    will-change: opacity, transform;
}
.oc-sfondo.attivo { opacity: 1; transform: scale(1); }
.oc-velo {
    position: absolute; inset: 0;
    /* il velo è più scuro dove ora sta il testo (metà schermata, a sinistra) */
    background:
        radial-gradient(110% 85% at 18% 55%, rgba(6, 37, 26, .92) 0%, rgba(6, 37, 26, .6) 45%, rgba(6, 37, 26, .22) 72%),
        linear-gradient(to top, rgba(4, 26, 18, .9) 0%, rgba(4, 26, 18, .5) 55%, rgba(4, 26, 18, .2) 100%);
}

/* ---------- contenuto ---------- */
.oc-contenuto {
    position: relative; z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(240px, .9fr);
    /* il testo si legge al centro della schermata, la pianta resta piantata in basso */
    align-items: center;
    gap: 1rem;
    width: min(1240px, 100%);
    margin: 0 auto;
    padding: clamp(2rem, 6vh, 5rem) clamp(1.1rem, 4vw, 3rem) 0;
    flex: 1;
}
@media (max-width: 860px) {
    .oc-contenuto { grid-template-columns: 1fr; align-items: start; padding-top: 2.2rem; }
    /* su telefono il testo sta sopra la pianta: al centro della sua riga, non stirato */
    .oc-testi { align-self: start; min-height: 13rem; }
}

/* ---------- testi ---------- */
.oc-testi { position: relative; align-self: stretch; display: flex; align-items: center; min-height: 16rem; }
.oc-testo {
    /* le tappe sono sovrapposte e occupano tutta la colonna: il contenuto sta al centro */
    position: absolute; inset: 0; width: 100%;
    display: flex; flex-direction: column; justify-content: center;
    opacity: 0; visibility: hidden; transform: translateY(18px);
    transition: opacity .6s ease, transform .6s ease, visibility 0s linear .6s;
}
.oc-testo.attivo { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

.oc-tappa-numero { display: flex; align-items: center; gap: .6rem; margin: 0 0 .7rem; }
.oc-numero {
    font-size: .8rem; font-weight: 700; letter-spacing: .12em;
    background: var(--oc-verde-chiaro); color: #06251a;
    border-radius: 999px; padding: .2rem .6rem; line-height: 1.4;
}
.oc-etichetta { font-size: .78rem; letter-spacing: .22em; text-transform: uppercase; opacity: .85; }

.oc-titolo {
    margin: 0; color: #fff;
    font-size: clamp(1.45rem, 3.1vw, 2.9rem);
    line-height: 1.12; font-weight: 800; letter-spacing: -.01em;
    text-wrap: balance;
}
.oc-parola {
    display: inline-block;
    opacity: 0; transform: translateY(.5em) rotate(1.5deg); filter: blur(4px);
}
.oc-testo.attivo .oc-parola {
    animation: oc-parola .62s cubic-bezier(.2, .8, .25, 1) forwards;
    animation-delay: calc(var(--n) * 55ms + 120ms);
}
@keyframes oc-parola {
    to { opacity: 1; transform: none; filter: blur(0); }
}

.oc-sottotitolo {
    margin: .9rem 0 0; max-width: 46ch;
    font-size: clamp(.95rem, 1.2vw, 1.1rem); line-height: 1.55; opacity: 0;
    color: rgba(255, 255, 255, .9);
}
.oc-testo.attivo .oc-sottotitolo { animation: oc-sale .7s ease .5s forwards; }
@keyframes oc-sale { from { opacity: 0; transform: translateY(12px); } to { opacity: .92; transform: none; } }

/* ---------- la pianta che cresce ---------- */
.oc-piante {
    position: relative; align-self: end;
    height: clamp(260px, 52vh, 560px);
    display: flex; align-items: flex-end; justify-content: center;
}
.oc-con-scroll .oc-pianta { transition: none; }
.oc-con-scroll .oc-pianta.attiva { animation: none; }
.oc-pianta {
    position: absolute; bottom: 0; left: 50%;
    max-height: 100%; width: auto; max-width: 100%;
    transform-origin: bottom center;
    transform: translateX(-50%) scale(.42);
    opacity: 0; filter: drop-shadow(0 26px 34px rgba(0, 0, 0, .45));
    transition: opacity .8s ease, transform 1.1s cubic-bezier(.22, .9, .25, 1);
    will-change: transform, opacity;
}
/* la tappa attiva: la pianta "spunta" dal terreno e ondeggia piano */
.oc-pianta.attiva {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    animation: oc-ondeggia 7s ease-in-out 1.1s infinite alternate;
}
/* le tappe già passate restano un attimo, più piccole e sfocate, come un ricordo */
.oc-pianta.passata { opacity: 0; transform: translateX(-50%) scale(1.06) translateY(-8px); filter: blur(6px); }
@keyframes oc-ondeggia {
    from { transform: translateX(-50%) scale(1) rotate(-.8deg); }
    to { transform: translateX(-50%) scale(1) rotate(.8deg); }
}

/* terreno: la linea su cui poggia il pane di terra */
.oc-terreno {
    position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
    width: min(520px, 92%); height: 90px; z-index: -1;
    background: radial-gradient(60% 60% at 50% 40%, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, 0) 70%);
}
/* alone di luce che cresce con la pianta */
.oc-luce {
    position: absolute; left: 50%; bottom: 8%; transform: translate(-50%, 0);
    width: min(420px, 80%); aspect-ratio: 1; border-radius: 50%; z-index: -2;
    background: radial-gradient(circle, rgba(122, 201, 67, .30) 0%, rgba(122, 201, 67, 0) 65%);
    animation: oc-respira 6s ease-in-out infinite alternate;
}
@keyframes oc-respira { from { opacity: .55; transform: translate(-50%, 0) scale(.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1.06); } }

/* ---------- stelo di avanzamento / navigazione ---------- */
.oc-stelo { position: relative; z-index: 3; width: min(1240px, 100%); margin: 0 auto; padding: 0 clamp(1.1rem, 4vw, 3rem) clamp(1.2rem, 3vh, 2rem); }
.oc-stelo-binario { position: relative; height: 3px; background: rgba(255, 255, 255, .22); border-radius: 999px; overflow: hidden; }
.oc-stelo-linea {
    position: absolute; inset: 0 auto 0 0; width: 0;
    background: linear-gradient(90deg, #2f8f4e, var(--oc-verde-chiaro));
    border-radius: 999px; transition: width .8s cubic-bezier(.3, .8, .3, 1);
}
.oc-nodi { display: flex; justify-content: space-between; list-style: none; margin: 0; padding: .55rem 0 0; }
.oc-nodo {
    display: flex; align-items: center; gap: .45rem; background: none; border: 0; padding: .2rem 0;
    color: rgba(255, 255, 255, .7); font: inherit; font-size: .76rem; letter-spacing: .06em;
    text-transform: uppercase; cursor: pointer; transition: color .3s;
}
.oc-nodo:hover, .oc-nodo:focus-visible { color: #fff; }
.oc-foglia {
    width: 11px; height: 11px; border-radius: 50% 0 50% 50%; transform: rotate(45deg);
    background: rgba(255, 255, 255, .45); transition: background .3s, box-shadow .3s, transform .4s;
}
.oc-nodo.attivo { color: #fff; }
.oc-nodo.attivo .oc-foglia { background: var(--oc-verde-chiaro); box-shadow: 0 0 0 5px rgba(122, 201, 67, .22); transform: rotate(45deg) scale(1.2); }
.oc-nodo.fatto .oc-foglia { background: #2f8f4e; }
@media (max-width: 700px) { .oc-nodo-testo { display: none; } .oc-nodi { justify-content: space-around; } }

/* ---------- comandi ---------- */
.oc-comandi { position: absolute; top: clamp(1rem, 3vh, 2rem); right: clamp(1.1rem, 4vw, 3rem); z-index: 4; display: flex; gap: .4rem; }
.oc-freccia, .oc-pausa {
    width: 2.5rem; height: 2.5rem; border-radius: 50%; cursor: pointer;
    border: 1px solid rgba(255, 255, 255, .45); background: rgba(6, 37, 26, .45); color: #fff;
    font-size: 1.4rem; line-height: 1; display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(6px); transition: background .25s, color .25s, border-color .25s;
}
.oc-freccia:hover, .oc-pausa:hover { background: #fff; color: var(--oc-verde); border-color: #fff; }
.oc-pausa-icona { width: 12px; height: 12px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.oc.in-pausa .oc-pausa-icona { width: 0; height: 0; border: 7px solid transparent; border-left: 11px solid currentColor; margin-left: 4px; }

/* ---------- accessibilità: niente animazioni se non gradite ---------- */
@media (prefers-reduced-motion: reduce) {
    .oc-sfondo, .oc-pianta, .oc-testo, .oc-parola, .oc-stelo-linea { transition: none !important; animation: none !important; }
    .oc-parola { opacity: 1; transform: none; filter: none; }
    .oc-pianta.attiva { transform: translateX(-50%) scale(1); }
    .oc-sottotitolo { opacity: .92; }
    .oc-luce { animation: none; }
}

/* ---------- invito a scorrere ---------- */
.oc-invito {
    position: absolute; left: 50%; bottom: clamp(4.5rem, 12vh, 7rem); transform: translateX(-50%);
    z-index: 3; display: flex; flex-direction: column; align-items: center; gap: .4rem;
    color: rgba(255, 255, 255, .8); font-size: .7rem; letter-spacing: .28em; text-transform: uppercase;
    transition: opacity .5s ease;
}
.oc-invito-freccia { width: 1px; height: 34px; background: linear-gradient(to bottom, rgba(255,255,255,.9), rgba(255,255,255,0)); position: relative; overflow: hidden; }
.oc-invito-freccia::after {
    content: ''; position: absolute; left: -2px; top: 0; width: 5px; height: 5px; border-radius: 50%;
    background: var(--oc-verde-chiaro); animation: oc-goccia 1.9s ease-in-out infinite;
}
@keyframes oc-goccia { 0% { top: -6px; opacity: 0; } 25% { opacity: 1; } 100% { top: 34px; opacity: 0; } }
.oc.finito .oc-invito { opacity: 0; }

/* in modalità scorrimento le frecce laterali non servono */
.oc-con-scroll .oc-comandi { display: none; }

@media (prefers-reduced-motion: reduce) {
    /* Lo scorrimento resta: è la persona a comandarlo. Si togliono solo gli effetti. */
    .oc-invito { display: none; }
}

/* ---------- ripiego quando position:sticky non funziona (antenati con overflow/transform) ---------- */
.oc-scroll.oc-fisso > .oc { position: absolute; top: 0; left: 0; }
.oc-scroll.oc-senza-corsa { height: auto !important; }
.oc-scroll.oc-senza-corsa > .oc { position: relative !important; height: auto; min-height: var(--oc-altezza); }

/* ---------- la pianta gira in prospettiva nel passaggio ---------- */
.oc-piante { perspective: 1200px; perspective-origin: 50% 80%; }
.oc-pianta { transform-origin: 50% 100%; backface-visibility: hidden; will-change: transform, opacity; }

/* ---------- pannello di controllo con ?oc_debug=1 ---------- */
.oc-debug {
    position: fixed; left: 10px; bottom: 10px; z-index: 99999;
    background: rgba(12, 22, 16, .92); color: #d7f5e0; font: 12px/1.45 ui-monospace, monospace;
    padding: .7rem .85rem; border-radius: .5rem; white-space: pre; pointer-events: none;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
