/* Reset i base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', 'Times New Roman', 'Palatino', serif;
    background: #e8ddd0;
    color: #2a2218;
    line-height: 1.7;
    min-height: 100vh;
}

/* ---------- CAPÇALERA ---------- */
header {
    background: #dac9b4;
    background-image: 
        radial-gradient(ellipse at 20% 80%, rgba(180, 150, 110, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(140, 110, 80, 0.10) 0%, transparent 50%);
    padding: 1.8rem 2rem 1.2rem 2rem;
    border-bottom: 3px solid #b8a084;
    box-shadow: 0 4px 20px rgba(80, 60, 40, 0.12);
    position: relative;
}

/* Afegir textura de pergamí amb pseudo-element */
header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    opacity: 0.3;
}

.capcalera-contenidor {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 2.5rem;
    position: relative;
    z-index: 1;
}

.capcalera-text {
    flex: 1;
    min-width: 0;
}

h1 {
    font-size: 2.8rem;
    font-weight: 700;
    color: #2a1f14;
    letter-spacing: -0.02em;
    font-family: 'Georgia', 'Times New Roman', serif;
    text-shadow: 1px 1px 0 rgba(255, 240, 220, 0.3);
    margin-bottom: 0.15rem;
}

h1 .eye-icon {
    display: inline-block;
    transform: scale(1.1);
}

.subtitol {
    font-size: 1.05rem;
    color: #4d3d2e;
    font-weight: 400;
    font-style: italic;
    letter-spacing: 0.02em;
    border-left: 2px solid #b09078;
    padding-left: 1rem;
    margin: 0.2rem 0 0.3rem 0;
}

.subtitol #comptador {
    font-weight: 700;
    color: #6a4f3a;
    font-style: normal;
}

.lema {
    font-size: 0.9rem;
    color: #5a4738;
    font-style: italic;
    letter-spacing: 0.01em;
    margin-top: 0.3rem;
    padding-left: 1rem;
    border-left: 2px solid #b09078;
    opacity: 0.85;
    font-family: 'Palatino', 'Georgia', serif;
}

/* ---------- IMATGE DEL PERGAMÍ ---------- */
.capcalera-imatge {
    flex: 0 0 auto;
    max-width: 420px;
    width: 100%;
}

.capcalera-imatge img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    box-shadow: 
        0 8px 32px rgba(60, 40, 20, 0.25),
        inset 0 0 60px rgba(180, 150, 110, 0.15);
    border: 1px solid #b8a084;
    transition: box-shadow 0.3s ease;
    filter: saturate(1.05) contrast(1.02);
}

.capcalera-imatge img:hover {
    box-shadow: 
        0 12px 48px rgba(60, 40, 20, 0.32),
        inset 0 0 60px rgba(180, 150, 110, 0.20);
}

/* ---------- MAIN ---------- */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.8rem 2rem 3rem 2rem;
}

/* ---------- NÚVOL D'ETIQUETES ---------- */
#nuvoldetiquetes {
    background: rgba(240, 232, 220, 0.70);
    backdrop-filter: blur(4px);
    border-radius: 16px;
    padding: 2rem 2rem 1.5rem 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid #d0c0b0;
    box-shadow: 0 2px 12px rgba(80, 60, 40, 0.08);
    min-height: 120px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.25rem 0.5rem;
}

.etiqueta {
    display: inline-block;
    padding: 4px 16px;
    margin: 4px 4px;
    background: #dccfc0;
    color: #2a1f14;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 500;
    user-select: none;
    border: 1px solid #c8b8a8;
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 1px 3px rgba(60, 40, 20, 0.06);
    font-family: 'Georgia', 'Times New Roman', serif;
}

.etiqueta:hover {
    background: #c8b8a4;
    transform: scale(1.04);
    box-shadow: 0 4px 14px rgba(60, 40, 20, 0.12);
    border-color: #b09880;
}

.etiqueta.seleccionada {
    background: #3d2e1e;
    color: #f0e4d6;
    border-color: #3d2e1e;
    box-shadow: 0 4px 16px rgba(60, 40, 20, 0.30);
}

/* ---------- FILTRES ACTIUS ---------- */
#filtresactius {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 0 1.5rem 0;
    min-height: 2.5rem;
    align-items: center;
}

#filtresactius > span:first-child {
    color: #6a5a4a;
    font-size: 0.9rem;
    font-style: italic;
}

.filtre-actiu {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #3d2e1e;
    color: #f0e4d6;
    padding: 4px 12px 4px 16px;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #5a4a3a;
}

.filtre-actiu:hover {
    background: #5a4a3a;
    transform: scale(1.04);
}

.filtre-actiu .eliminar {
    font-size: 1.1rem;
    font-weight: 300;
    line-height: 1;
    opacity: 0.7;
    margin-left: 0.2rem;
}

.filtre-actiu .eliminar:hover {
    opacity: 1;
}

#netejar-filtres {
    background: transparent;
    border: 1px solid #b8a898;
    color: #4d3d2e;
    padding: 4px 14px;
    border-radius: 24px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-family: 'Georgia', serif;
}

#netejar-filtres:hover {
    background: #d0c0b0;
    border-color: #9a8a7a;
}

/* ---------- RESULTATS - FITXES ---------- */
#resultats {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: stretch;
    gap: 1.5rem;
    padding: 0.5rem 0 2rem 0;
}

.fitxa {
    flex: 0 0 calc(33.333% - 1.5rem);
    min-width: 280px;
    max-width: 100%;
    background: #f6f0e8;
    border-radius: 14px;
    padding: 1.5rem 1.5rem 1.25rem 1.5rem;
    box-shadow: 0 2px 12px rgba(60, 40, 20, 0.07);
    transition: all 0.3s ease;
    border: 1px solid #e0d4c8;
    display: flex;
    flex-direction: column;
}

.fitxa:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(60, 40, 20, 0.13);
    border-color: #c8b8a8;
    background: #faf4ec;
}

.fitxa .titol-fitxa {
    font-size: 1.15rem;
    font-weight: 700;
    color: #2a1f14;
    margin-bottom: 0.3rem;
    line-height: 1.3;
    font-family: 'Georgia', 'Times New Roman', serif;
}

.fitxa .subtitol-fitxa {
    font-size: 0.9rem;
    color: #5a4a3a;
    margin-bottom: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    font-style: italic;
}

.fitxa .resum-fitxa {
    font-size: 0.9rem;
    color: #2a2218;
    line-height: 1.7;
    flex: 1;
    overflow: hidden;
}

.fitxa .resum-fitxa p {
    margin-bottom: 0.6rem;
}

.fitxa .resum-fitxa p:last-child {
    margin-bottom: 0;
}

.fitxa .resum-fitxa img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0.5rem 0;
    display: block;
    border: 1px solid #ddd0c0;
}

.fitxa .enllac-fitxa {
    display: inline-block;
    margin-top: 0.75rem;
    color: #7a5a3a;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    border-top: 1px solid #e0d4c8;
    padding-top: 0.75rem;
    transition: color 0.2s;
    font-family: 'Georgia', serif;
}

.fitxa .enllac-fitxa:hover {
    color: #3d2e1e;
    text-decoration: underline;
}

.fitxa .etiquetes-fitxa {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.5rem;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid #e8ddd0;
}

.fitxa .etiqueta-mini {
    font-size: 0.7rem;
    background: #e8ddd0;
    color: #4d3d2e;
    padding: 2px 10px;
    border-radius: 16px;
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0.02em;
    font-family: 'Georgia', serif;
}

.fitxa .referencia-fitxa {
    font-size: 0.6rem;
    color: #b0a090;
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px solid #f0e8e0;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.02em;
}

/* ---------- SENSE RESULTATS ---------- */
.sense-resultats {
    width: 100%;
    text-align: center;
    padding: 4rem 2rem;
    color: #8a7a6a;
    font-size: 1.1rem;
    font-style: italic;
}

/* ---------- LOADER ---------- */
#loader {
    text-align: center;
    padding: 2rem;
    color: #8a7a6a;
    font-size: 0.9rem;
    width: 100%;
    font-style: italic;
}

/* ---------- FOOTER ---------- */
footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem 1.5rem 2rem;
    border-top: 2px solid #d0c0b0;
    text-align: center;
    color: #6a5a4a;
    font-size: 0.85rem;
    font-family: 'Georgia', serif;
}

footer p {
    margin-bottom: 0.25rem;
}

footer .footer-lema {
    font-style: italic;
    color: #5a4a3a;
    font-size: 0.9rem;
    opacity: 0.8;
}

footer .footer-ref {
    font-size: 0.75rem;
    color: #9a8a7a;
    margin-top: 0.5rem;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.05em;
}

/* ---------- RESPONSIVE ---------- */
/* Tablets i pantalles mitjanes */
@media (max-width: 900px) {
    .fitxa {
        flex: 0 0 calc(50% - 1.5rem);
    }
    
    .capcalera-contenidor {
        gap: 1.5rem;
    }
    
    .capcalera-imatge {
        max-width: 320px;
    }
    
    h1 {
        font-size: 2.2rem;
    }
}

/* Mòbils: la imatge va a sobre */
@media (max-width: 700px) {
    header {
        padding: 1.2rem 1.2rem 0.8rem 1.2rem;
    }
    
    .capcalera-contenidor {
        flex-direction: column;
        gap: 0.8rem;
        align-items: stretch;
    }
    
    .capcalera-text {
        order: 2;
        text-align: center;
    }
    
    .capcalera-imatge {
        order: 1;
        max-width: 100%;
        margin: 0 auto;
    }
    
    .capcalera-imatge img {
        max-height: 120px;
        width: auto;
        margin: 0 auto;
        border-radius: 10px;
    }
    
    h1 {
        font-size: 1.9rem;
        text-align: center;
    }
    
    .subtitol {
        font-size: 0.9rem;
        text-align: center;
        border-left: none;
        padding-left: 0;
        border-top: 1px solid #b09078;
        padding-top: 0.5rem;
    }
    
    .lema {
        font-size: 0.8rem;
        text-align: center;
        border-left: none;
        padding-left: 0;
        margin-top: 0.4rem;
    }
    
    main {
        padding: 1.2rem 1rem 2rem 1rem;
    }
    
    #nuvoldetiquetes {
        padding: 1.2rem 1rem 0.8rem 1rem;
    }
    
    .fitxa {
        flex: 0 0 100%;
        min-width: unset;
    }
}

/* Mòbils molt petits */
@media (max-width: 400px) {
    header {
        padding: 1rem 0.8rem 0.6rem 0.8rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .capcalera-imatge img {
        max-height: 80px;
    }
    
    .subtitol {
        font-size: 0.8rem;
    }
    
    .lema {
        font-size: 0.7rem;
    }
    
    .etiqueta {
        font-size: 0.75rem;
        padding: 3px 10px;
    }
}