/* ====================================
   Decanto Home Regions Frontend Styles
   ==================================== */

.decanto-home-regions {
    display: flex;
    flex-direction: column;
    gap: 60px;
}

/* ====================================
   Loading State
   ==================================== */

.region-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    background: #f9f9f9;
    border-radius: 8px;
}

.region-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: #666;
    font-family: 'HK Grotesk', sans-serif;
    font-size: 14px;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top-color: #D13A38;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.region-error {
    text-align: center;
    padding: 40px;
    color: #999;
    font-family: 'HK Grotesk', sans-serif;
    font-size: 14px;
}

/* ====================================
   Region Section
   ==================================== */

.decanto-home-region {
    width: 100%;
}

.decanto-home-region .region-title {
    font-family: 'Dinish', sans-serif;
    font-size: clamp(28px, 3vw, 42px);
    font-weight: 500;
    color: #242e50;
    text-transform: uppercase;
    margin: 0 0 30px 0;
    padding-bottom: 15px;
    border-bottom: 3px solid #D13A38;
}

.decanto-home-region .region-content {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* ====================================
   Cantine and Vini Sections
   ==================================== */

.region-cantine,
.region-vini {
    display: flex;
    flex-direction: column;
}

.region-cantine h3,
.region-vini h3 {
    font-family: 'HK Grotesk', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #242e50;
    margin: 0 0 20px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cantine-cards,
.vini-cards {
    flex-grow: 1;
    align-items: stretch;
}

.home-cantina-card,
.home-vino-card {
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ---- Ribbon Untold (home) ---- */

/* Fold: z-index 0 — verrà coperto dal link (z-index 1) nella parte interna alla card */
.home-vino-card .untold-fold {
    position: absolute;
    top: 36px;
    right: -9px;
    height: 20px;
    width: 20px;
    background: #161f38;
    transform: rotate(45deg);
    z-index: 0;
}

/* Il link copre il fold con il suo background bianco */
.home-vino-card .vino-card-link {
    position: relative;
    z-index: 1;
    background: #fff;
}

/* Label: z-index 2 — sopra tutto */
.home-vino-card .untold-badge {
    position: absolute;
    top: 20px;
    right: -14px;
    padding: 6px 14px 8px 14px;
    background: #242e50;
    color: #fff;
    font-family: 'HK Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    z-index: 2;
    line-height: 1;
    pointer-events: none;
    box-shadow: 4px 4px 15px rgba(36, 46, 80, 0.2);
}

.region-view-all {
    display: inline-flex;
    align-items: center;
    font-family: 'HK Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #D13A38;
    text-decoration: none;
    border: 2px solid #D13A38;
    border-radius: 4px;
    padding: 7px 18px;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.region-view-all:hover {
    color: #fff;
    background: #D13A38;
}

/* ====================================
   Cantina Card — immagine copertina 16:9
   ==================================== */

.home-cantina-card {
    background: #fff;
    border: 1px solid #242e50;
}

.cantina-card-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.cantina-card-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #1a1a2e;
    position: relative;
}

.cantina-card-thumbnail .cantina-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cantina-card-thumbnail .cantina-name-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Dinish', sans-serif;
    text-transform: uppercase;
    color: #FCE2C2;
    font-size: 18px;
    text-align: center;
    padding: 20px;
    line-height: 1.3;
}

.cantina-card-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 80px;
}

.cantina-card-content *,
.vino-card-content * {
    text-decoration: none !important;
    border-bottom: none !important;
}

.cantina-card-title {
    font-family: 'Dinish', sans-serif;
    font-size: 16px;
    color: #242e50;
    margin: 0 0 8px 0;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1.3;
}

.cantina-card-location {
    font-family: 'HK Grotesk', sans-serif;
    font-size: 12px;
    color: #666;
    margin: 0;
}

/* ====================================
   Vino Card — thumbnail 9:16
   ==================================== */

.home-vino-card {
    background: #fff;
    border: 1px solid #242e50;
}

.vino-card-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.vino-card-thumbnail {
    width: 100%;
    aspect-ratio: 3 / 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #FCE2C2;
    overflow: hidden;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
}

.vino-card-thumbnail img {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.vino-card-thumbnail .wine-svg-placeholder {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vino-card-thumbnail .wine-svg-placeholder svg {
    max-width: 100%;
    max-height: 100%;
}

.vino-card-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 100px;
}

.vino-card-cavatappi {
    display: flex;
    gap: 3px;
    justify-content: center;
    width: 100%;
    padding-top: 8px;
}

.vino-card-cavatappi .cavatappi-icon {
    width: 18px;
    height: 18px;
}

.vino-card-thumbnail .cavatappi-info-text {
    font-family: 'Dinish', sans-serif;
    font-size: 0.7rem;
    font-weight: 400;
    color: #D13A38;
    text-transform: uppercase;
    text-align: center;
    margin-top: 4px;
    line-height: 1;
}

.vino-card-cantina {
    font-family: 'Dinish', sans-serif;
    font-size: 12px;
    color: #242e50;
    text-transform: uppercase;
    margin: 0 0 5px 0;
}

.vino-card-title {
    font-family: 'Dinish', sans-serif;
    font-size: 15px;
    color: #242e50;
    margin: 0 0 8px 0;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1.3;
}

.vino-card-tipologia {
    font-family: 'HK Grotesk', sans-serif;
    font-size: 12px;
    color: #666;
    margin: auto 0 0 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.vino-color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ====================================
   Carousel
   ==================================== */

/* Wrapper: column flex so controls sit below the viewport */
.cantine-carousel-wrapper,
.vini-carousel-wrapper {
    display: flex;
    flex-direction: column;
    position: relative;
}

.carousel-viewport {
    overflow: hidden;
    width: 100%;
    min-width: 0;
}

/* Carousel track: flex row, slides widths set in px by JS */
.cantine-cards.in-carousel,
.vini-cards.in-carousel {
    display: flex !important;
    gap: 0 !important;
    will-change: transform;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

/* Gap between cards via slide padding (keeps JS geometry intact) */
.cantine-cards.in-carousel .carousel-slide,
.vini-cards.in-carousel .carousel-slide {
    padding-right: 16px;
}

.cantine-cards.in-carousel:active,
.vini-cards.in-carousel:active {
    cursor: grabbing;
}

/* Slide width set in pixels via inline style by JS */
.cantine-cards.in-carousel .carousel-slide,
.vini-cards.in-carousel .carousel-slide {
    flex: 0 0 auto;
    min-width: 0;
    box-sizing: border-box;
}

/* Cards inside carousel fill their slide */
.cantine-cards.in-carousel .home-cantina-card,
.vini-cards.in-carousel .home-vino-card {
    height: 100%;
}

/* Footer: view-all link left, arrow buttons right */
.carousel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

/* Controls: two buttons, no extra margin */
.carousel-controls {
    display: flex;
    gap: 8px;
}

/* Prev / Next circle buttons */
.carousel-btn {
    background: #242e50;
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0 0 2px 0;
    flex-shrink: 0;
}

.carousel-btn:hover {
    background: #D13A38;
}

.carousel-btn:disabled {
    background: #ccc;
    cursor: default;
}

/* ====================================
   Responsive Styles
   ==================================== */


@media (max-width: 768px) {
    .decanto-home-region .region-title {
        margin-bottom: 20px;
    }

    /* No arrows on mobile — swipe only */
    .carousel-controls {
        display: none;
    }
}

/* ====================================
   Desktop / Tablet: Grid layout (no carousel)
   ==================================== */

@media (min-width: 769px) {
    /* Let cards overflow their container naturally */
    .carousel-viewport {
        overflow: visible;
    }

    /* Switch track from flex-carousel to CSS grid */
    .cantine-cards.in-carousel,
    .vini-cards.in-carousel {
        display: grid !important;
        gap: 20px !important;
        cursor: default !important;
        user-select: auto;
        -webkit-user-select: auto;
        will-change: auto;
        transform: none !important;
    }

    /* Cantine: always 3 columns (matches MAX_CANTINE) */
    .cantine-cards.in-carousel {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Vini: 3 columns on tablet */
    .vini-cards.in-carousel {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Slides: let grid control sizing, remove carousel-specific padding */
    .cantine-cards.in-carousel .carousel-slide,
    .vini-cards.in-carousel .carousel-slide {
        width: auto !important;
        padding-right: 0;
    }

    /* Hide arrow controls on desktop */
    .carousel-controls {
        display: none !important;
    }
}

/* On full desktop: 5 columns for vini (matches MAX_VINI) */
@media (min-width: 1025px) {
    .vini-cards.in-carousel {
        grid-template-columns: repeat(5, 1fr);
    }
}
