/* ==========================================================================
   PART 1: RESET, CONFIGURACIÓ GENERAL I BARRA SUPERIOR FIXA
   ========================================================================== */

/* Reset bàsic de marges i tipografia */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* RETOC PER A LES ÀNCORES COIXÍ barra fixa */
html {
    scroll-margin-top: 54px; 
    scroll-behavior: smooth; 
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8fafc; 
    color: #0f172a;
    line-height: 1.4;
    padding-top: 44px; 
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 1. BARRA SUPERIOR FIXA DINÀMICA CLICABLE */
.top-fixed-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 44px; 
    background-color: #0f172a; 
    color: #ffffff;
    font-size: 15px; 
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 35px; 
    z-index: 2000;
    cursor: pointer;
}
.top-fixed-bar .sticky-title {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.top-fixed-bar.visible .sticky-title {
    opacity: 1;
    transform: translateX(0);
}

/* Missatge flotant discret */
.top-fixed-bar::after {
    content: "Prem la capçalera per pujar";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background-color: #0369a1;
    color: #ffffff;
    font-size: 14px; 
    font-weight: bold;
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid #0284c7;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
/* El missatge emergent només s'activarà en dispositius amb ratolí (ordinadors) */
@media (hover: hover) {
    .top-fixed-bar.visible:hover::after {
        opacity: 1;
    }
}

/* Botó de la Persiana */
.menu-trigger {
    background: #475569;
    color: white;
    border: none;
    padding: 6px 14px; 
    font-size: 13px; 
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: background-color 0.2s, opacity 0.3s ease;
    z-index: 2010;
}
.top-fixed-bar.visible .menu-trigger {
    opacity: 1;
    pointer-events: auto;
}
.menu-trigger:hover {
    background-color: #0369a1;
}

/* ESTRUCTURA DE LA PERSIANA PLEGABLE CORREGIDA */
.scrolling-persiana {
    position: fixed;
    top: -250px; 
    left: 0;
    width: 100%;
    background-color: #ffffff;
    padding: 12px 35px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    z-index: 1500;
    display: flex;
    justify-content: center;
    transition: top 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-bottom: 2px solid #e2e8f0; 
}
.scrolling-persiana.open {
    top: 44px !important; 
}
/* ==========================================================================
   PART 2: CAPÇALERA, NAV, BOTONS, COS, PEU DE PÀGINA I SECCIÓ MÒBIL
   ========================================================================== */

/* 2. BLOC DE LA CAPÇALERA ARRODONIT */
header {
    width: calc(100% - 40px);
    margin: 10px auto 0 auto; 
    background-color: #ffffff;
    padding: 5px 35px;
    border-bottom: 2px solid #e2e8f0; 
    display: flex;
    justify-content: space-between; 
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    border-radius: 24px; 
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.02);
    border: 1px solid #e2e8f0;
}
.brand-container {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 250px;
}
.brand-container a {
    text-decoration: none;
    color: inherit; 
    display: flex;
    align-items: center;
    gap: 15px;
}
.brand-logo {
    height: 80px;
    width: auto;
    display: block;
    transition: transform 0.2s ease-in-out;
}
.brand-logo:hover {
    transform: scale(1.04);
    cursor: pointer;
}
.brand-text h1 {
    font-size: 24px;
    color: #0369a1;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.header-contact-block {
    padding: 5px 15px;
    border-left: 2px solid #e2e8f0;
    min-width: 220px;
}
.header-contact-block .author-name {
    font-size: 16px;
    color: #475569;
    font-weight: bold;
    margin-bottom: 12px; 
}

.header-contact-block .author-link {
    color: #0369a1; 
    font-weight: bold;
    text-decoration: none;
    transition: color 0.2s ease;
}
.header-contact-block .author-link:hover {
    color: #0f172a !important;
    text-decoration: underline !important;
}

.header-contact-block .author-email {
    font-size: 16px;
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s ease;
}
.header-contact-block .author-email:hover {
    color: #0369a1;
    text-decoration: underline;
}

/* QUADRÍCULA DE BOTONS */
.header-menu-grid {
    display: grid;
    grid-template-columns: repeat(6, 85px); 
    gap: 5px; 
    overflow: visible;
    padding: 4px 0; 
    flex-shrink: 0;
}
header .header-menu-grid {
    grid-template-columns: repeat(3, 85px); 
}
.header-menu-grid a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    text-align: center;
    padding: 4px 2px;
    font-weight: 700;
    font-size: 11px; 
    line-height: 1.1;
    height: 52px;
    border-radius: 10px;
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}
.header-menu-grid a .icon { font-size: 18px; margin-bottom: 2px; }

.header-menu-grid a.color-categoria { 
    background-color: #e0f2fe; 
    color: #0369a1;
}
.header-menu-grid a.color-categoria:hover,
.header-menu-grid a.color-categoria:focus-visible { 
    background-color: #bae6fd; 
    transform: translateY(-2px); 
    box-shadow: 0 4px 10px rgba(3, 105, 161, 0.08); 
    outline: 3px solid #0369a1;
    outline-offset: -3px;
}
.header-menu-grid a.color-inici { 
    background-color: #0369a1; 
    color: #ffffff; 
}
.header-menu-grid a.color-inici:hover,
.header-menu-grid a.color-inici:focus-visible { 
    background-color: #025a87; 
    transform: translateY(-2px); 
    box-shadow: 0 4px 10px rgba(3, 105, 161, 0.2); 
    outline: 3px solid #0f172a;
    outline-offset: -3px;
}

/* MARCAT DE BOTÓ ACTUAL A LA QUADRÍCULA */
.header-menu-grid a.pagina-actual {
    background-color: #0369a1 !important;
    color: #ffffff !important;
    cursor: default !important;
    transform: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* 3. BARRA DE NAVEGACIÓ SEPARADA ESTÀTICA */
nav {
    width: calc(100% - 40px); 
    margin: 15px auto 0 auto;
    background-color: #0f172a;
    padding: 6px 25px; 
    border-radius: 20px; 
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
    border: 1px solid #1e293b;
}
nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    gap: 5px; 
}
nav ul li a {
    display: block;
    color: #ffffff;
    text-decoration: none;
    padding: 10px 20px;
    font-size: 18px;
    border-radius: 12px; 
    transition: background-color 0.2s ease, color 0.2s ease;
}
nav ul li a:hover,
nav ul li a:focus-visible { 
    background-color: #1e293b; 
    color: #38bdf8;
    outline: 2px solid #38bdf8; 
}

/* 4. EL COS DE LA PÀGINA */
.main-content {
    width: 95%; 
    max-width: 1200px;
    margin: 15px auto 25px auto; 
    padding: 35px;
    background-color: #ffffff; 
    border-radius: 20px; 
    border: 1px solid #e2e8f0; 
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.02);
    flex: 1; 
}
.main-content h2 {
    font-size: 32px;
    color: #0369a1;
    border-bottom: 2px solid #e0f2fe; 
    padding-bottom: 8px;
    margin-bottom: 30px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* 5. PEU DE PÀGINA */
footer {
    width: 100%;
    background-color: #0f172a;
    padding: 12px 20px;
    margin-top: auto;
    border-top: 1px solid #1e293b;
    display: flex; 
    align-items: center;
    justify-content: center;
}
.footer-content {
    display: flex; 
    align-items: center; 
    justify-content: center; 
    flex-wrap: wrap; 
    gap: 15px; 
    color: #94a3b8; 
    font-size: 14px; 
    text-align: center;  
    width: 100%; 
    margin: 0;
}

/* TRANSICIÓ DE SEGURETAT PER AL BOTÓ DE RETORN */
#footerBackToTop {
    color: #ffffff !important; 
    text-decoration: none !important; 
    font-weight: bold !important; 
    background-color: #0369a1; 
    border: 1px solid #0284c7; 
    padding: 4px 14px; 
    border-radius: 20px; 
    font-size: 13px; 
    display: inline-flex; 
    align-items: center; 
    gap: 4px; 
    box-shadow: 0 2px 6px rgba(3, 105, 161, 0.2);
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease !important;
}

/* Adaptació a telèfons mòbils */
@media (max-width: 900px) {
    header { 
        flex-direction: column; 
        align-items: center; 
        padding: 20px; 
        text-align: center;
    }
    .brand-container {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
    }
    .header-contact-block { 
        border-left: none; 
        border-top: 1px solid #e2e8f0; 
        padding: 14px 0 0 0; 
        width: 100%; 
    }
    header .header-menu-grid { 
        width: 100%; 
        grid-template-columns: repeat(3, 1fr); 
        grid-template-rows: repeat(2, 65px); 
    }
    .scrolling-persiana { 
        top: -250px; 
        padding: 15px 10px; 
    }
    .scrolling-persiana.open {
        top: 44px; 
    }
    .scrolling-persiana .header-menu-grid { 
        width: 100%; 
        grid-template-columns: repeat(3, 1fr); 
        grid-template-rows: repeat(2, 65px);
        gap: 6px;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 44px !important; 
    }
    header, .main-content { 
        width: 100% !important; 
        margin-top: 0 !important; 
        border-radius: 0 !important; 
        border-left: none !important; 
        border-right: none !important; 
    }
    
    /* Amaguem completament el menú horitzontal estàtic amb submenús a mòbils */
    nav { 
        display: none !important; 
    }

    /* Forcem que la barra superior negra es quedi totalment fixa i visible a mòbils */
    .top-fixed-bar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    .top-fixed-bar .sticky-title {
        opacity: 1 !important;
        transform: translateX(0) !important;
    }
    .top-fixed-bar .menu-trigger {
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Desactivació total del cartell flotant en pantalles mòbils */
    .top-fixed-bar::after {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    /* Reduïm el padding lateral de la barra perquè els elements s'oxigenin cap a les vores */
    .top-fixed-bar {
        padding: 0 12px !important; /* Passa de 35px a 12px a les vores */
    }

    /* Text del títol per a què no quedi completament enganxat a l'esquerra */
    .top-fixed-bar .sticky-title {
        margin-left: 4px;
    }
}

/* CLASSE PER AL BOTÓ DE LA PÀGINA ACTUAL AL NAV */
.pagina-actual {
    cursor: default;     
}
nav ul li a.pagina-actual {
    background-color: #0369a1 !important; 
    color: #ffffff !important;            
    font-weight: 700 !important;          
    outline: none !important;             
    box-shadow: none !important;          
}

/* Estils submenús ordinador */
nav {
    position: relative;
    z-index: 1000; 
}
nav ul li {
    position: relative; 
}
nav ul li .submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%; 
    transform: translateX(-50%); 
    background-color: #ffffff;
    width: max-content; 
    min-width: 170px; 
    list-style: none;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.1); 
    border-radius: 12px;
    padding: 6px 0;
    border: 1px solid #e2e8f0;
}
nav ul li .submenu li a {
    color: #334155 !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    padding: 10px 16px !important;
    border-radius: 0 !important;
    text-align: left !important;
    background-color: transparent !important;
}
nav ul li .submenu li a:hover {
    background-color: #f1f5f9 !important;
    color: #0369a1 !important;
}
nav ul li:hover .submenu {
    display: block;
}

/* ==========================================================================
   BOTÓ FLOTANT UNIVERSAL PER PUJAR (ORDRE NET COHESIONAT)
   ========================================================================== */
#btn-anar-dalt-universal {
    display: none; 
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    z-index: 999999 !important; /* Per sobre de tot el text fluid */
    
    /* Mida i forma del cercle */
    width: 62px !important;
    height: 62px !important;
    border-radius: 50% !important;
    
    /* Colors de la teva web */
    background-color: #0369a1 !important; 
    color: #ffffff !important;
    border: none !important;
    outline: none !important;
    cursor: pointer !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3) !important;
    
    /* Centrat en columna per a les dues línies */
    flex-direction: column !important; 
    align-items: center !important; 
    justify-content: center !important; 
    line-height: 1.1 !important; 
    text-align: center !important; 
    padding: 0 !important;
    transition: background-color 0.2s, transform 0.2s !important;
}

#btn-anar-dalt-universal:hover {
    background-color: #0f172a !important; 
    transform: scale(1.08) !important;
}

#btn-anar-dalt-universal .fletxa {
    font-size: 16px !important; 
    margin-bottom: 1px !important;
    display: block !important;
}

#btn-anar-dalt-universal .text-puja {
    font-size: 13px !important; 
    font-weight: bold !important; 
    text-transform: uppercase !important; 
    letter-spacing: 0.5px !important;
    display: block !important;
}

@media (max-width: 768px) {
    #btn-anar-dalt-universal {
        bottom: 25px !important;
        right: 25px !important;
        width: 52px !important;
        height: 52px !important;
    }
    #btn-anar-dalt-universal .fletxa { font-size: 14px !important; }
    #btn-anar-dalt-universal .text-puja { font-size: 11px !important; }
}
