/* =============================================================
   CASO STUDIO — Timeline + Milestone blocks
   Brand: #007df9 / #0a5cd0 (gradient blu)
   ============================================================= */

:root {
    --cs-blue: #007df9;
    --cs-blue-dark: #0a5cd0;
    --cs-navy: #0a2540;
    --cs-body: #44546f;
    --cs-azure: #e2f2ff;
    --cs-border: rgba(0, 30, 80, .06);
}


/* ---------- Hero header del caso studio ---------- */
.caso-studio-hero {
    position: relative;
    padding: 100px 20px 80px;
    text-align: center;
    background: linear-gradient(135deg, var(--cs-blue) 0%, var(--cs-blue-dark) 100%);
    color: #fff;
    overflow: hidden;
}
.caso-studio-hero::before {
    content: '';
    position: absolute;
    top: -200px; right: -200px;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(255, 255, 255, .15) 0%, transparent 70%);
    pointer-events: none;
}
.caso-studio-hero::after {
    content: '';
    position: absolute;
    bottom: -200px; left: -200px;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(255, 255, 255, .08) 0%, transparent 70%);
    pointer-events: none;
}
.caso-studio-hero__inner {
    position: relative;
    max-width: 820px;
    margin: 0 auto;
}
.caso-studio-hero__eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .16em;
    padding: 7px 16px;
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 999px;
    margin-bottom: 22px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.caso-studio-hero__title {
    font-size: 3.4rem;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.025em;
    margin: 0 0 18px;
    text-shadow: 0 4px 16px rgba(0, 0, 0, .12);
}
.caso-studio-hero__subtitle {
    font-size: 1.15rem;
    line-height: 1.55;
    opacity: .92;
    max-width: 620px;
    margin: 0 auto;
}


/* ---------- Timeline container + lines ---------- */
.caso-studio-timeline {
    position: relative;
    padding: 80px 0 60px;
    max-width: 1100px;
    margin: 0 auto;
}

/* Track (static background line) */
.caso-studio-timeline__line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(
        180deg,
        rgba(0, 125, 249, .06),
        rgba(0, 125, 249, .14) 50%,
        rgba(0, 125, 249, .06)
    );
    transform: translateX(-50%);
    border-radius: 999px;
    pointer-events: none;
}

/* Progress (fills as you scroll, controlled by JS) */
.caso-studio-timeline__progress {
    position: absolute;
    left: 50%;
    top: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--cs-blue), var(--cs-blue-dark));
    transform: translateX(-50%);
    border-radius: 999px;
    height: 0%;
    transition: height .25s ease-out;
    box-shadow: 0 0 14px rgba(0, 125, 249, .45);
    pointer-events: none;
}


/* ---------- Single milestone ---------- */
.milestone {
    position: relative;
    margin: 96px 0;
    padding: 0;
    opacity: 0;
    transform: translateY(40px);
    transition:
        opacity .8s cubic-bezier(.22, 1, .36, 1),
        transform .8s cubic-bezier(.22, 1, .36, 1);
}
.milestone.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Number bubble (centered above the card) */
.milestone__number {
    position: absolute;
    left: 50%;
    top: -36px;
    transform: translateX(-50%);
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cs-blue) 0%, var(--cs-blue-dark) 100%);
    color: #fff;
    font-weight: 800;
    font-size: 1.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow:
        0 4px 12px rgba(0, 125, 249, .38),
        0 14px 36px rgba(0, 30, 80, .18),
        inset 0 1px 0 rgba(255, 255, 255, .3);
}

/* Pulse ring around the bubble */
.milestone__number::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--cs-blue);
    opacity: 0;
    animation: cs-pulse 2.6s ease-out infinite;
    pointer-events: none;
}
@keyframes cs-pulse {
    0% { opacity: .5; transform: scale(.88); }
    100% { opacity: 0; transform: scale(1.7); }
}


/* Card */
.milestone__card {
    background: #fff;
    border-radius: 24px;
    border: 1px solid var(--cs-border);
    padding: 48px 44px 44px;
    box-shadow:
        0 1px 2px rgba(0, 30, 80, .04),
        0 8px 24px rgba(0, 30, 80, .06);
    transition:
        box-shadow .35s ease,
        transform .35s ease,
        border-color .35s ease;
    position: relative;
    overflow: hidden;
}

/* Gradient border che fade-in su tutto il perimetro all'hover (mask trick) */
.milestone__card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 24px;
    padding: 2px;
    background: linear-gradient(135deg, var(--cs-blue) 0%, var(--cs-blue-dark) 100%);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: 0;
    transition: opacity .4s ease;
    pointer-events: none;
}

.milestone__card:hover {
    transform: translateY(-4px);
    border-color: transparent;
    box-shadow:
        0 1px 2px rgba(0, 30, 80, .04),
        0 24px 56px rgba(0, 125, 249, .15);
}
.milestone__card:hover::before {
    opacity: 1;
}


/* Inner two-column grid: text + media */
.milestone__inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: center;
}

/* Layout variant: image on the LEFT (text right) */
.milestone--right .milestone__content { order: 2; }
.milestone--right .milestone__media   { order: 1; }


/* Content */
.milestone__title {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -.02em;
    color: var(--cs-navy);
    margin: 0 0 16px;
}
.milestone__desc {
    font-size: 1rem;
    color: var(--cs-body);
    line-height: 1.65;
    margin: 0;
}
.milestone__desc p { margin: 0 0 12px; }
.milestone__desc p:last-child { margin-bottom: 0; }

/* Highlight inline pill — use .milestone-highlight via WYSIWYG source mode */
.milestone__desc .milestone-highlight,
.milestone__desc mark {
    display: inline-block;
    padding: 2px 10px;
    background: linear-gradient(135deg, var(--cs-blue), var(--cs-blue-dark));
    color: #fff !important;
    font-weight: 600;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 125, 249, .25);
}

/* Em / italic */
.milestone__desc em { color: var(--cs-navy); font-style: italic; }


/* Media */
.milestone__media {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    background: var(--cs-azure);
    aspect-ratio: 4 / 3;
    box-shadow:
        0 2px 6px rgba(0, 30, 80, .06),
        0 14px 32px rgba(0, 30, 80, .10);
}
.milestone__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .7s cubic-bezier(.22, 1, .36, 1);
}
.milestone__card:hover .milestone__media img {
    transform: scale(1.05);
}

/* Badge floating on the media (glass effect) */
.milestone__badge {
    position: absolute;
    bottom: 14px;
    right: 14px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--cs-navy);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 7px 14px;
    border-radius: 999px;
    box-shadow:
        0 2px 8px rgba(0, 30, 80, .15),
        0 0 0 1px rgba(0, 125, 249, .15);
}


/* ---------- Responsive ---------- */
@media (max-width: 880px) {
    .caso-studio-hero { padding: 70px 20px 60px; }
    .caso-studio-hero__title { font-size: 2.2rem; }
    .caso-studio-hero__subtitle { font-size: 1rem; }

    /* Line moves to the left, milestones offset right */
    .caso-studio-timeline { padding: 60px 16px 40px; }
    .caso-studio-timeline__line,
    .caso-studio-timeline__progress {
        left: 32px;
    }

    .milestone {
        margin: 80px 0;
        padding-left: 70px;
        padding-right: 0;
    }
    .milestone__number {
        left: 32px;
        top: -32px;
        width: 56px;
        height: 56px;
        font-size: 1.3rem;
    }

    .milestone__inner {
        grid-template-columns: 1fr;
        gap: 28px;
    }
    .milestone--right .milestone__content { order: 1; }
    .milestone--right .milestone__media   { order: 2; }

    .milestone__card { padding: 40px 26px 26px; border-radius: 20px; }
    .milestone__title { font-size: 1.35rem; }
}

@media (max-width: 480px) {
    .milestone { padding-left: 56px; }
    .caso-studio-timeline__line,
    .caso-studio-timeline__progress { left: 24px; }
    .milestone__number { left: 24px; width: 48px; height: 48px; font-size: 1.15rem; top: -28px; }
}



/* Editor-only: rende visibile lo slot InnerBlocks quando vuoto */
.editor-styles-wrapper .caso-studio-timeline {
    min-height: 220px;
    border: 2px dashed rgba(0, 125, 249, .25);
    border-radius: 16px;
    background: rgba(228, 242, 255, .35);
}

.editor-styles-wrapper .caso-studio-timeline > .block-editor-inner-blocks,
.editor-styles-wrapper .caso-studio-timeline .block-editor-block-list__layout {
    min-height: 180px;
    padding: 20px;
}

.editor-styles-wrapper .caso-studio-timeline .block-list-appender {
    margin: 20px auto;
}

/* Editor: forza opacity 1 e annulla il translate, altrimenti i milestone
   restano invisibili (il JS frontend con IntersectionObserver non gira qui) */
.editor-styles-wrapper .milestone {
    opacity: 1 !important;
    transform: none !important;
    min-height: 140px;
}

.editor-styles-wrapper .milestone__card {
    min-height: 100px;
    position: relative;
}

/* Hint quando il milestone non ha titolo */
.editor-styles-wrapper .milestone__content:not(:has(.milestone__title))::after {
    content: '✎ Compila numero, titolo, descrizione e immagine nella sidebar →';
    display: block;
    text-align: center;
    color: rgba(0, 125, 249, .7);
    font-style: italic;
    font-size: .95rem;
    padding: 20px;
}

/* Placeholder per l'area immagine vuota */
.editor-styles-wrapper .milestone__inner:not(:has(.milestone__media))::after {
    content: '🖼 Immagine non ancora caricata';
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 125, 249, .08);
    border: 2px dashed rgba(0, 125, 249, .2);
    border-radius: 18px;
    color: rgba(0, 125, 249, .6);
    aspect-ratio: 4 / 3;
    font-size: .9rem;
}