/* =============================================
   STACK CAROUSEL — Frontend CSS
   Reproduit fidèlement le design stack-immobilier.ch
   ============================================= */

/* ── Carousel wrapper ───────────────────────── */
.stack-carousel-wrap {
    overflow: hidden;
    position: relative;
    width: 100%;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    padding: 25px 0;
}
.stack-carousel-wrap:active {
    cursor: grabbing;
}

.stack-carousel__track {
    display: flex;
    gap: 20px;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    padding: 0 20px;
}

.stack-carousel__item {
    flex: 0 0 calc(25% - 15px);
    min-width: calc(25% - 15px);
}

@media (max-width: 1100px) {
    .stack-carousel__item { flex: 0 0 calc(33.33% - 14px); min-width: calc(33.33% - 14px); }
}
@media (max-width: 768px) {
    .stack-carousel__item { flex: 0 0 calc(80% - 10px); min-width: calc(80% - 10px); }
    .stack-carousel__track { padding: 0 10px; }
}
@media (max-width: 480px) {
    .stack-carousel__item { flex: 0 0 85%; min-width: 85%; }
}

/* ── Card ───────────────────────────────────── */
.stack-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 3/4;
    cursor: pointer;
    display: block;
    transition: transform 0.3s ease;
}

.stack-card:hover {
    /* Pas d'ombre ni de translateY — ombre coupée dans le carrousel */
}

.stack-card__img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.6s ease;
}
.stack-card:hover .stack-card__img {
    transform: scale(1.04);
}

/* Gradient overlay — projets disponibles : opacité au repos plus marquée */
.stack-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(0,0,0,0.45) 0%,
        rgba(0,0,0,0.05) 40%,
        rgba(0,0,0,0.05) 55%,
        rgba(0,0,0,0.65) 100%
    );
    border-radius: 16px;
    opacity: 0.7;
    transition: opacity 0.35s ease;
}

/* Hover overlay — projets disponibles : assombrir davantage */
.stack-card:not(.stack-card--vendu):hover .stack-card__overlay {
    opacity: 0.95;
}

/* Vendu overlay — plus sombre au repos (comportement inchangé) */
.stack-card--vendu .stack-card__overlay {
    background: rgba(0,0,0,0.55);
    border-radius: 16px;
    opacity: 1;
    transition: opacity 0.35s ease;
}

/* Hover overlay — projets vendus : s'éclaircit */
.stack-card--vendu:hover .stack-card__overlay {
    opacity: 0.2;
}

/* Content */
.stack-card__content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px 24px;
    color: #fff;
}

/* Pour les cartes vendues : le badge est dans le flux du top content */
.stack-card--vendu .stack-card__top {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stack-card__top {}

.stack-card__titre {
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.25;
    margin: 0 0 6px 0;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.stack-card__lieu {
    font-size: 0.85rem;
    font-weight: 400;
    margin: 0;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.stack-card__bottom {
    display: flex;
    gap: 20px;
}

.stack-card__stat {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.9);
    font-weight: 400;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ── Badge VENDU ────────────────────────────── */
/* Le badge est positionné dans le flux du contenu (non absolu)
   pour que le titre et la localité apparaissent SOUS lui */
.stack-badge-vendu {
    display: inline-block;
    align-self: flex-start;
    background: #E03B2E;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 4px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    margin-bottom: 10px;
    position: relative; /* pas absolute */
    z-index: 10;
}

/* ── Grid (page Projets) ────────────────────── */
.stack-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin: 30px 0;
}

.stack-grid .stack-card {
    aspect-ratio: 3/4;
}

/* ── Animation : fade from bottom en cascade ─────────────── */
@keyframes stackFadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .stack-grid .stack-card,
    .stack-carousel__item {
        opacity: 0;
        animation: stackFadeInUp 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    }

    /* Cascade : chaque vignette a un délai de +90ms par rapport à la précédente.
       On couvre jusqu'à 24 vignettes (6 lignes en grille 4 colonnes), au-delà on plafonne. */
    .stack-grid .stack-card:nth-child(1),
    .stack-carousel__item:nth-child(1)  { animation-delay: 0.00s; }
    .stack-grid .stack-card:nth-child(2),
    .stack-carousel__item:nth-child(2)  { animation-delay: 0.09s; }
    .stack-grid .stack-card:nth-child(3),
    .stack-carousel__item:nth-child(3)  { animation-delay: 0.18s; }
    .stack-grid .stack-card:nth-child(4),
    .stack-carousel__item:nth-child(4)  { animation-delay: 0.27s; }
    .stack-grid .stack-card:nth-child(5),
    .stack-carousel__item:nth-child(5)  { animation-delay: 0.36s; }
    .stack-grid .stack-card:nth-child(6),
    .stack-carousel__item:nth-child(6)  { animation-delay: 0.45s; }
    .stack-grid .stack-card:nth-child(7),
    .stack-carousel__item:nth-child(7)  { animation-delay: 0.54s; }
    .stack-grid .stack-card:nth-child(8),
    .stack-carousel__item:nth-child(8)  { animation-delay: 0.63s; }
    .stack-grid .stack-card:nth-child(9),
    .stack-carousel__item:nth-child(9)  { animation-delay: 0.72s; }
    .stack-grid .stack-card:nth-child(10),
    .stack-carousel__item:nth-child(10) { animation-delay: 0.81s; }
    .stack-grid .stack-card:nth-child(11),
    .stack-carousel__item:nth-child(11) { animation-delay: 0.90s; }
    .stack-grid .stack-card:nth-child(12),
    .stack-carousel__item:nth-child(12) { animation-delay: 0.99s; }
    .stack-grid .stack-card:nth-child(13),
    .stack-carousel__item:nth-child(13) { animation-delay: 1.08s; }
    .stack-grid .stack-card:nth-child(14),
    .stack-carousel__item:nth-child(14) { animation-delay: 1.17s; }
    .stack-grid .stack-card:nth-child(15),
    .stack-carousel__item:nth-child(15) { animation-delay: 1.26s; }
    .stack-grid .stack-card:nth-child(16),
    .stack-carousel__item:nth-child(16) { animation-delay: 1.35s; }
    .stack-grid .stack-card:nth-child(17),
    .stack-carousel__item:nth-child(17) { animation-delay: 1.44s; }
    .stack-grid .stack-card:nth-child(18),
    .stack-carousel__item:nth-child(18) { animation-delay: 1.53s; }
    .stack-grid .stack-card:nth-child(19),
    .stack-carousel__item:nth-child(19) { animation-delay: 1.62s; }
    .stack-grid .stack-card:nth-child(20),
    .stack-carousel__item:nth-child(20) { animation-delay: 1.71s; }
    .stack-grid .stack-card:nth-child(21),
    .stack-carousel__item:nth-child(21) { animation-delay: 1.80s; }
    .stack-grid .stack-card:nth-child(22),
    .stack-carousel__item:nth-child(22) { animation-delay: 1.89s; }
    .stack-grid .stack-card:nth-child(23),
    .stack-carousel__item:nth-child(23) { animation-delay: 1.98s; }
    .stack-grid .stack-card:nth-child(24),
    .stack-carousel__item:nth-child(24) { animation-delay: 2.07s; }
    .stack-grid .stack-card:nth-child(n+25),
    .stack-carousel__item:nth-child(n+25) { animation-delay: 2.16s; }
}

.stack-section-title {
    font-size: 1.8rem;
    font-weight: 600;
    text-align: center;
    margin: 60px 0 10px;
}

@media (max-width: 1100px) {
    .stack-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .stack-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
@media (max-width: 480px) {
    .stack-grid { grid-template-columns: 1fr; }
}

/* ── Modal ──────────────────────────────────── */
.stack-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 2147483647 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    isolation: isolate;
}

.stack-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.stack-modal__backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 0;
    background: rgba(0,0,0,0.70);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.stack-modal__box {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    max-width: 820px;
    width: 100%;
    height: min(560px, 85vh);
    max-height: 85vh;
    display: flex;
    flex-direction: row;
    box-shadow: 0 30px 80px rgba(0,0,0,0.4);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stack-modal.is-open .stack-modal__box {
    transform: translateY(0) scale(1);
}

.stack-modal__img-wrap {
    position: relative;
    flex: 0 0 48%;
    height: 100%;
    overflow: hidden;
}

.stack-modal__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.stack-modal__badge {
    position: absolute;
    top: 14px;
    left: 14px;
    background: #E03B2E;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 4px 10px;
    border-radius: 4px;
    text-transform: uppercase;
}

.stack-modal__body {
    flex: 1;
    padding: 36px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stack-modal__titre {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: #111;
    line-height: 1.2;
}

.stack-modal__lieu {
    font-size: 0.9rem;
    color: #888;
    margin: 0 0 16px;
}

.stack-modal__desc {
    font-size: 0.9rem;
    color: #444;
    line-height: 1.6;
    margin: 0 0 24px;
}

.stack-modal__stats {
    display: flex;
    gap: 24px;
    margin-bottom: 28px;
    padding: 18px;
    background: #f7f7f7;
    border-radius: 12px;
}

.stack-modal__stat-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stack-modal__stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #aaa;
    font-weight: 600;
}

.stack-modal__stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #111;
}

.stack-modal__btn {
    display: inline-block;
    background: #E03B2E;
    color: #fff !important;
    text-decoration: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.2s ease;
    text-align: center;
}

.stack-modal__btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
    color: #fff !important;
}

.stack-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 10;
    background: rgba(0,0,0,0.12);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    color: #fff;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.stack-modal__close:hover {
    background: rgba(0,0,0,0.3);
}

@media (max-width: 640px) {
    .stack-modal__box {
        flex-direction: column;
        height: auto;
        max-height: 92vh;
        overflow-y: auto;
    }
    .stack-modal__img-wrap {
        flex: 0 0 240px;
        height: 240px;
        width: 100%;
    }
    .stack-modal__body { padding: 24px 20px; }
}
