/* =========================================
   LA GRAELLA DE LES OBRES (TARGETES)
   ========================================= */
.cataleg-main {
    width: 100%;
    padding: 10px 8vw;
    padding-bottom: 40px;
    box-sizing: border-box;
    flex: 1;
}

.galeria-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 60px 40px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.obra-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-align: left;
    cursor: pointer; /* Indica que es pot clicar */
}

.obra-img-wrapper {
    background-color: #f5f5f5;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    box-sizing: border-box;
    margin-bottom: 20px;
    overflow: hidden;
}

.obra-img-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: transform 0.4s ease;
}

.obra-card:hover .obra-img-wrapper img {
    transform: scale(1.03);
}

.obra-info {
    font-family: var(--font-sans);
    font-size: 14px;
    color: #1a1a1a;
    line-height: 1.5;
}

.obra-coleccio {
    font-size: 13px;
    text-transform: uppercase;
    margin: 0 0 0 0;
}

.obra-titol {
    font-size: 13px;
    font-weight: 700;
    margin: 0 0 15px 0;
}

.obra-detalls {
    margin-bottom: 20px;
}

.obra-detalls p {
    font-size: 12px;
    margin: 0 0 0 0;
    color: #000;
    font-weight: 300;
    white-space: pre-line; /* Manté els salts de línia si n'hi ha */
    line-height: 1.2;
}

.obra-ref {
    font-size: 12px;
    margin: 0 0 0 0;
    font-weight: 300;
    margin: 0;
    color: #888;
}

/* =========================================
   EL VISOR DE DETALLS (PANTALLA COMPLETA)
   ========================================= */
.visor-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: #ffffff; /* Fons completament blanc com a la imatge */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

.visor-modal.hidden {
    opacity: 0;
    visibility: hidden;
}

.visor-close {
    position: absolute;
    top: 20px;
    right: 40px;
    background: none;
    border: none;
    font-size: 50px;
    color: #000;
    font-weight: 300;
    cursor: pointer;
    z-index: 10000;
    transition: transform 0.3s;
}

.visor-close:hover {
    transform: scale(1.1);
}

.visor-layout {
    display: flex;
    width: 90%;
    max-width: 1400px;
    height: 80vh;
    align-items: center;
    gap: 80px;
}

/* --- VISOR: ESQUERRA (IMATGE I FLECHAS) --- */
.visor-left {
    flex: 1.5;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.visor-img-container {
    width: 100%;
    height: 90%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.visor-img-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

/* Fletxes de navegació */
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: #000;
    cursor: pointer;
    padding: 20px;
    transition: color 0.3s;
}

.slider-btn:hover { color: var(--text-name); }
.prev-btn { left: -50px; }
.next-btn { right: -50px; }

/* Puntets de navegació a sota */
.slider-dots {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: #ccc;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s;
}

.dot.active {
    background-color: #000;
    width: 8px;
    height: 8px;

}

/* --- VISOR: DRETA (TEXTOS) --- */
.visor-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: left;
    text-align: left;
}

.visor-right h2 {
    font-size: 16px;
    font-weight: 800; 
    margin: 0 0 20px 0;
    color: #000;
}

.visor-right h3 {
    font-size: 16px;
    font-weight: 300;
    text-transform: uppercase;
    color: #000;
    margin: 0 0 0 0;
    letter-spacing: 1px;
}

.visor-tech p {
    font-size: 16px;
    font-weight: 300;
    line-height: 1.8;
    color: #444;
    margin: 0 0 -10px 0;
}

.text-gris { color: #888 !important; }
.text-estat { font-style: italic; margin-top: 15px !important; color: #000 !important; }

.btn-consulta {
    display: inline-block;
    margin-top: 40px;
    padding: 12px 24px;
    border: 1px solid #ccc;
    background: transparent;
    color: #555;
    text-decoration: none;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: fit-content;
    transition: all 0.3s ease;
}

.btn-consulta:hover {
    border-color: #000;
    color: #000;
}

.titol-seccio {
    font-size: 20px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #000000;
    margin-top: 40px;
    margin-bottom: 10px;
    text-align: center;
}

/* =========================================
   RESPONSIVE (Mòbils - Optimitzat per iPhone)
   ========================================= */
@media (max-width: 768px) {
    #visor-coleccio {
        font-size: 12px !important; /* Canvia aquest 13 per la mida que vulguis */
        margin-bottom: 2px !important; /* Per ajustar l'espai si queda massa separat */
    }
    
    /* Si també vols fer més petit el títol de l'obra per compensar: */
    #visor-titol {
        font-size: 12px !important;
        margin-bottom: 15px !important;
    }
    #visor-descripcio, #visor-mides, #visor-pes, #visor-ref {
        font-size: 12px !important;
    }
    
    .galeria-grid { 
        grid-template-columns: repeat(1, 1fr); 
        gap: 30px 15px; 
    }
    .obra-img-wrapper { padding: 15px; }
    .obra-titol { font-size: 12px; margin-bottom: 8px; }
    .obra-coleccio { font-size: 12px; }
    .obra-detalls p, .obra-ref { font-size: 11px; }
    
    .visor-modal {
        align-items: flex-start; 
        height: 100%; 
    }

    .visor-layout {
        display: block; 
        max-width: 1400px;
        width: 100%;
        height: 100%; 
        margin: 0;
        padding: 70px 20px 80px 20px; 
        overflow-y: auto; 
        -webkit-overflow-scrolling: touch; 
        box-sizing: border-box;
    }

    .visor-left {
        width: 100%;
        height: 45vh; 
        min-height: 320px;
        margin-bottom: 20px; 
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding-bottom: 40px; 
        box-sizing: border-box;
    }

    .visor-img-container {
        width: 100%;
        height: 100%; /* La foto ocupa todo menos el espacio de las flechas */
    }

    .visor-right {
        width: 100%;
        text-align: left;
        padding-bottom: 50px; 
    }

    .visor-right h2 { font-size: 24px; margin-top: 10px; }
    .visor-right h3 { font-size: 14px; margin-bottom: 20px; }
    .btn-consulta { margin-top: 20px; } 

    .visor-close {
        position: fixed;
        top: 15px;
        right: 15px;
        font-size: 45px;
        background: rgba(255, 255, 255, 0.95); 
        border-radius: 50%;
        width: 45px; 
        height: 45px;
        display: flex; 
        align-items: center; 
        justify-content: center;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        z-index: 10001;
    }

    /* --- FLECHAS DISCRETAS DEBAJO DE LA FOTO --- */
    .slider-btn {
        position: absolute;
        top: auto; /* Anulamos que estén en el medio de la pantalla */
        bottom: 0px; /* Las pegamos abajo del todo (en el espacio en blanco) */
        transform: none;
        font-size: 22px; /* Más pequeñas y refinadas */
        background: transparent; /* Quitamos el fondo gris */
        color: #999; /* Color gris muy suave */
        padding: 5px 20px;
        z-index: 10;
    }
    .prev-btn { left: 10%; }
    .next-btn { right: 10%; }

    .slider-dots {
        position: absolute;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        margin: 0;
    }
}

img {
    -webkit-user-drag: none;  /* Bloqueja l'arrossegament a Safari/Chrome */
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-select: none;        /* Evita que es pugui seleccionar com si fos text */
    -webkit-user-select: none;
    -ms-user-select: none;
}

/* =========================================
   TEXTOS DEL VISOR (ESTIL A MIDA)
   ========================================= */

/* Bloc 1: Títol i Col·lecció */
#visor-coleccio {
    font-size: 14px;
    font-weight: 400;
    color: #000;
    margin: 0 0 0 0; /* Molt poc espai amb el títol de sota */
}

#visor-coleccio strong {
    font-weight: 700;

}

#visor-titol {
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 15px 0;
}

/* Bloc 2: Tècnica i Mides */
#visor-descripcio {
    font-size: 13px;
    font-weight: 300;
    color: #000;
    margin: 0 0 -5px 0; 
    white-space: pre-line; /* Manté els salts de línia si n'hi ha */
    line-height: 1.2;
}

#visor-mides {
    font-size: 13px;
    font-weight: 300;
    color: #000;
    margin: 0 0 0 0; 
}

#visor-pes {
    font-size: 13px;
    font-weight: 300;
    color: #000;
    margin: -10px 0 0 0; 
}
/* Bloc 3: Referència */
#visor-ref {
    font-size: 13px;
    font-weight: 300;
    color: #888; /* Gris clar igual que la foto */
    margin: 0;
}

#visor-img {
    cursor: zoom-in;
    transition: all 0.3s ease;
}

/* Quan s'activa el zoom */
#obra-modal.mode-zoom #visor-img {
    cursor: zoom-out;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain;
    background-color: rgba(250, 250, 250, 0.98);
    z-index: 1000;
    padding: 60px;
    box-sizing: border-box;
}

/* Amaguem la info (Assegura't que el div de la dreta on hi ha el text es diu .visor-info o l'id corresponent) */
#obra-modal.mode-zoom .visor-info {
    opacity: 0;
    pointer-events: none;
}

/* =========================================
   REPOSICIONAMENT DELS BOTONS EN MODE ZOOM
   ========================================= */

/* Fletxes als extrems laterals i centrades verticalment */
#obra-modal.mode-zoom #slider-prev,
#obra-modal.mode-zoom #slider-next {
    position: fixed !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 1001 !important;
    /* Opcional: Pots fer-les una mica més grans perquè destaquen més */
    transform: translateY(-50%) scale(1.2) !important; 
}

#obra-modal.mode-zoom #slider-prev {
    left: 40px !important; /* Marge des de l'esquerra de la pantalla */
}

#obra-modal.mode-zoom #slider-next {
    right: 40px !important; /* Marge des de la dreta de la pantalla */
}

/* Creu de tancar fixada a dalt a la dreta */
#obra-modal.mode-zoom #visor-close {
    position: fixed !important;
    top: 30px !important;
    right: 40px !important;
    z-index: 1001 !important;
}

/* Puntets inferiors centrats a baix de tot */
#obra-modal.mode-zoom #slider-dots {
    position: fixed !important;
    bottom: 30px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 1001 !important;
    width: auto !important;
}

/* =========================================
   MODE ZOOM: RESPONSIVE PER A MÒBILS
   ========================================= */
@media (max-width: 768px) {
    /* 1. Traiem el padding exagerat perquè la foto aprofiti tota la pantalla */
    #obra-modal.mode-zoom #visor-img {
        padding: 10px !important; 
    }

    /* 2. Movem la "X" a la cantonada superior i li posem un filet de fons 
          perquè es llegeixi bé encara que la foto sigui fosca */
    #obra-modal.mode-zoom #visor-close {
        top: 15px !important;
        right: 15px !important;
        background-color: rgba(255, 255, 255, 0.7) !important;
        border-radius: 50% !important;
        padding: 5px !important;
    }

    /* 3. Amaguem les fletxes per netejar la pantalla. 
          Ja tens l'esdeveniment tàctil (swipe) per passar de foto! */
    #obra-modal.mode-zoom #slider-prev,
    #obra-modal.mode-zoom #slider-next {
        display: none !important; 
    }

    /* 4. Baixem els puntets una mica més perquè no tapin l'obra */
    #obra-modal.mode-zoom #slider-dots {
        bottom: 15px !important;
    }
}