/* =========================================================
   Posts carousel — scroll orizzontale con snap CSS + frecce
   Palette: --color-primary #27667B, --color-dark #143D60,
            --color-medium #A0C878, --color-light #DDEB9D
   ========================================================= */

.posts-carousel {
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    position: relative;
}

/* Header con titolo + frecce navigazione */
.posts-carousel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 1rem 0;
}

.posts-carousel-title {
    font-size: 1.75rem;
    color: var(--color-dark);
    margin: 0;
}

.posts-carousel-nav {
    display: flex;
    gap: 0.5rem;
}

.posts-carousel-arrow {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    background: var(--color-white);
    color: var(--color-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    padding: 0;
}

.posts-carousel-arrow:hover:not(:disabled),
.posts-carousel-arrow:focus-visible:not(:disabled) {
    background: var(--color-primary);
    color: var(--color-white);
    transform: translateY(-1px);
    outline: none;
}

.posts-carousel-arrow:disabled {
    opacity: 0.35;
    cursor: default;
}

.posts-carousel-arrow svg {
    display: block;
}

/* Track scrollabile con snap CSS */
.posts-carousel-track {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 0.5rem 0.25rem 1.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.posts-carousel-track::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Edge */
}

.posts-carousel-track:focus-visible {
    outline: 2px dashed var(--color-primary);
    outline-offset: 4px;
}

/* Card articolo */
.carousel-post {
    flex: 0 0 auto;
    width: calc((100% - 3rem) / 3); /* 3 card visibili desktop, gap 1.5rem × 2 */
    scroll-snap-align: start;
    background: var(--color-white);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(20, 61, 96, 0.08);
    border: 1px solid var(--color-light);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    overflow: hidden;
}

.carousel-post:hover,
.carousel-post:focus-within {
    transform: translateY(-4px);
    box-shadow: 0 6px 18px rgba(20, 61, 96, 0.15);
    border-color: var(--color-medium);
}

.carousel-thumbnail {
    width: 100%;
    height: 260px;
    overflow: hidden;
}

.carousel-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.carousel-title {
    font-size: 1.35rem;
    margin: 0 0 0.75rem;
    line-height: 1.25;
}

.carousel-title a {
    color: var(--color-dark);
    text-decoration: none;
    transition: color 0.2s ease;
}

.carousel-title a:hover {
    color: var(--color-primary);
}

.carousel-excerpt {
    color: var(--color-text);
    line-height: 1.6;
    margin-bottom: 1.25rem;
    flex: 1;
}

.carousel-meta {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: auto;
}

.carousel-meta .post-date {
    white-space: nowrap;
}

.carousel-meta .post-category {
    font-weight: 600;
    color: var(--color-primary);
}

/* Overlay cliccabile */
.carousel-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    text-decoration: none;
    color: inherit;
}

.carousel-title a,
.carousel-content a {
    position: relative;
    z-index: 2;
}

/* Progress bar sottile (indica quanto è stato scrollato) */
.posts-carousel-progress {
    width: 100%;
    height: 3px;
    background: var(--color-light);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.posts-carousel-progress-bar {
    height: 100%;
    width: 33%;
    margin-left: 0;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width 0.15s ease-out, margin-left 0.15s ease-out;
}

/* Responsive: 2 card su tablet, 1.15 card su mobile (mostra un accenno della successiva) */
@media screen and (max-width: 1024px) {
    .carousel-post {
        width: calc((100% - 1.5rem) / 2);
    }
    .carousel-thumbnail {
        height: 220px;
    }
}

@media screen and (max-width: 640px) {
    .posts-carousel {
        padding: 0 1rem;
    }
    .posts-carousel-title {
        font-size: 1.4rem;
    }
    .posts-carousel-arrow {
        width: 38px;
        height: 38px;
    }
    .carousel-post {
        width: 85%; /* mostra ~15% della card successiva, invita a swipare */
    }
    .carousel-thumbnail {
        height: 180px;
    }
    .carousel-content {
        padding: 1.25rem;
    }
}
