/* ============================================================
   CB Sant Gregori — Estils compartits
   Fonts auto-hostatjades + reset + header + footer + cookie banner
   ============================================================ */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300 600;
    font-display: block;
    src: url('fonts/inter.woff2') format('woff2');
}
@font-face {
    font-family: 'Oswald';
    font-style: normal;
    font-weight: 500 700;
    font-display: block;
    src: url('fonts/oswald.woff2') format('woff2');
}

/* --- VARIABLES --- */
:root {
    --bg-dark: #0A0A0A;
    --bg-card: #141414;
    --text-white: #F2F2F2;
    --text-gray: #A0A0A0;
    --accent: #552583;

    --font-display: 'Oswald', sans-serif;
    --font-body: 'Inter', sans-serif;

    --container-width: 1200px;
    --spacing-section: 100px;
}

/* --- RESET --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg-dark);
    color: var(--text-white);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; }

/* --- TIPOGRAFIA --- */
h1, h2, h3, h5 {
    font-family: var(--font-display);
    text-transform: uppercase;
    line-height: 1.1;
}

/* --- CONTAINER --- */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* --- HEADER & NAV --- */
header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 30px 0;
    z-index: 100;
}

.nav-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container { display: flex; align-items: center; }
.logo-img { height: 80px; width: auto; display: block; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-btn {
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 1px solid transparent;
}
.menu-btn:hover { border-color: white; }
.menu-btn.active { color: white; border-bottom: 1px solid var(--accent); }

.nav-link { font-size: 0.9rem; margin-left: 20px; color: var(--text-gray); }
.nav-link:hover { color: white; }
.nav-link.active { color: white; border-bottom: 1px solid var(--accent); }

/* Botons compartits (abans només existien inline a l'index.php) */
.btn {
    display: inline-block; padding: 15px 30px; font-family: var(--font-display);
    font-weight: 700; text-transform: uppercase; letter-spacing: 1px; border: none;
    cursor: pointer; transition: all 0.3s ease; font-size: 1rem; line-height: 1; text-align: center;
}
.btn-primary {
    background-color: var(--accent); color: var(--text-white);
    clip-path: polygon(0 0, 100% 0, 100% 85%, 95% 100%, 0 100%);
}
.btn-primary:hover { background-color: #fff; color: #000; transform: translateY(-2px); }

.btn-small {
    display: inline-block;
    padding: 10px 20px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
}

/* --- Desplegable del menú (EL CLUB) --- */
.nav-dropdown { position: relative; display: inline-flex; align-items: center; }
.nav-dropdown-toggle {
    display: inline-flex; align-items: center; gap: 5px;
    background: none; border: 0; border-bottom: 1px solid transparent;
    color: inherit; font-family: inherit; line-height: inherit;
}
.nav-caret { font-size: 0.7em; transition: transform 0.2s ease; }
.nav-dropdown:hover .nav-caret,
.nav-dropdown:focus-within .nav-caret { transform: rotate(180deg); }
.nav-submenu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 200px;
    padding: 6px;
    background: rgba(15, 15, 15, 0.98);
    border: 1px solid #222;
    border-top: 2px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
    z-index: 160;
}
.nav-dropdown:hover .nav-submenu,
.nav-dropdown:focus-within .nav-submenu { opacity: 1; visibility: visible; }
.nav-submenu a {
    display: block;
    padding: 11px 16px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-gray);
    border: none;
    border-radius: 6px;
    white-space: nowrap;
}
.nav-submenu a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.nav-submenu a[aria-current="page"] {
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}

/* --- FOOTER --- */
footer {
    padding: 80px 0 30px;
    border-top: 1px solid #222;
    font-size: 0.9rem;
    color: var(--text-gray);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
    margin-bottom: 60px;
}

.footer-col h5 {
    color: white;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.footer-col a { display: block; margin-bottom: 10px; }
.footer-col a:hover { color: var(--accent); }

.newsletter input {
    background: transparent;
    border: none;
    border-bottom: 1px solid #444;
    padding: 10px 0;
    width: 100%;
    color: white;
    outline: none;
}
.newsletter-form { display: flex; gap: 10px; margin-top: 10px; }
.newsletter-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-family: var(--font-display);
    text-transform: uppercase;
    font-weight: 700;
    transition: 0.3s;
}
.newsletter-btn:hover { background: white; color: black; }

.copyright {
    text-align: center;
    padding-top: 30px;
    border-top: 1px solid #1a1a1a;
    font-size: 0.8rem;
}

/* --- Fila de xarxes socials (footer) --- */
.footer-social {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}
.footer-social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    border: 1px solid #333;
    border-radius: 50%;
    color: var(--text-gray);
    transition: background .2s, border-color .2s, color .2s, transform .2s;
}
.footer-social a:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-2px);
}
.footer-social svg {
    width: 19px;
    height: 19px;
    fill: currentColor;
}

/* --- COOKIE BANNER --- */
.cookie-banner {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    background-color: rgba(10, 10, 10, 0.95);
    border-top: 1px solid #222;
    padding: 20px 0;
    z-index: 9999;
    transition: bottom 0.5s ease-out;
    backdrop-filter: blur(10px);
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
}
.cookie-banner.show { bottom: 0; }

.cookie-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.cookie-text p {
    margin: 0;
    font-size: 0.9rem;
    color: #ccc;
}

.cookie-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.btn-cookie {
    padding: 10px 20px;
    font-family: 'Oswald', sans-serif;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: 0.3s;
    border-radius: 2px;
}

.btn-fill {
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);
}
.btn-fill:hover { background: white; color: black; border-color: white; }

/* .btn-outline dins del cookie banner — més específic que .btn-outline de pàgines amb hero */
.cookie-banner .btn-outline {
    background: transparent;
    color: #ccc;
    border: 1px solid #444;
}
.cookie-banner .btn-outline:hover { border-color: white; color: white; }

.link-cookie {
    font-size: 0.8rem;
    text-decoration: underline;
    color: #888;
}
.link-cookie:hover { color: var(--accent); }

/* --- HAMBURGUESA MÒBIL --- */
.hamburger {
    display: none;
    background: none;
    border: 0;
    cursor: pointer;
    padding: 8px;
    width: 44px;
    height: 44px;
    position: relative;
    z-index: 200;
}
.hamburger span {
    display: block;
    width: 28px;
    height: 3px;
    background: var(--text-white);
    margin: 5px auto;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-radius: 2px;
}

/* X quan està obert */
body.menu-open .hamburger span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
body.menu-open .hamburger span:nth-child(2) {
    opacity: 0;
}
body.menu-open .hamburger span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* --- MEDIA MÒBIL — regles compartides --- */
@media (max-width: 768px) {
    .cookie-flex { flex-direction: column; text-align: center; }
    .cookie-buttons { flex-direction: column; width: 100%; }
    .btn-cookie { width: 100%; }

    /* Mostra la hamburguesa */
    .hamburger { display: block; }

    /* Menú mòbil: overlay fullscreen */
    .nav-right {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100vh;        /* fallback navegadors antics */
        height: 100dvh;       /* alçada real del viewport mòbil (sense el bug de la barra d'adreces) */
        background: rgba(10, 10, 10, 0.97);
        backdrop-filter: blur(10px);
        flex-direction: column;
        justify-content: flex-start;   /* ancorat a dalt: si no cap, es fa scroll en lloc de retallar-se */
        align-items: center;
        gap: 16px;                     /* compacte perquè els 9 ítems càpiguen a la pantalla */
        overflow-y: auto;              /* el menú pot fer scroll intern quan té més ítems que alçada */
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 150;
        padding: 64px 20px 28px;
    }
    body.menu-open .nav-right {
        transform: translateX(0);
    }

    /* Tipografia més gran als enllaços del menú mòbil */
    .nav-right .menu-btn {
        font-size: 1.15rem;
        font-family: var(--font-display);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 1.5px;
        border-bottom: none;
        padding: 6px 0;
    }
    .nav-right .menu-btn.active {
        color: var(--text-white);   /* text blanc llegible; el morat quedava fosc sobre negre */
        border-bottom: 2px solid var(--accent);
    }
    .nav-right .btn-small {
        padding: 14px 30px;
        font-size: 1rem;
        margin-top: 10px;
    }

    /* Desplegable dins del menú mòbil: subítems sempre visibles i centrats */
    .nav-dropdown { flex-direction: column; align-items: center; gap: 12px; }
    .nav-caret { display: none; }
    .nav-submenu {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        margin: 0;
        padding: 0;
        background: transparent;
        border: 0;
        box-shadow: none;
        min-width: 0;
    }
    .nav-submenu a {
        font-size: 1rem;
        padding: 0;
        color: var(--text-white);
        text-transform: uppercase;
        letter-spacing: 1px;
        border-radius: 0;
    }

    /* Bloca el scroll del body quan el menú està obert */
    body.menu-open {
        overflow: hidden;
    }

    /* Logo una mica més petit en mòbil */
    .logo-img { height: 60px; }
}

/* ============================================================
   NOTÍCIES — targetes (home + llistat) i bloc de portada
   ============================================================ */
.latest-news { padding: var(--spacing-section) 0; }
.news-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 40px;
    border-bottom: 1px solid #333;
    padding-bottom: 20px;
}
.news-head h2 { font-size: clamp(2rem, 4vw, 3rem); }
.news-seeall {
    display: inline-flex; align-items: center;
    padding: 10px 20px; border-radius: 999px;
    background: var(--accent); color: #fff;
    font-family: var(--font-display); text-transform: uppercase; letter-spacing: .5px;
    font-size: .9rem; white-space: nowrap;
    transition: filter .2s ease;
}
.news-seeall:hover { filter: brightness(1.18); }

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
}

.news-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid #222;
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.3s ease, border-color 0.3s ease;
}
.news-card:hover { transform: translateY(-6px); border-color: var(--accent); }

.news-card-img { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: #0e0e0e; }
.news-card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.news-card:hover .news-card-img img { transform: scale(1.05); }

.news-card-img--ph { display: flex; align-items: center; justify-content: center; }
.news-card-img--ph .news-ph-logo {
    width: 90px; height: auto; object-fit: contain; opacity: 0.35;
    transition: opacity 0.3s ease;
}
.news-card:hover .news-card-img--ph .news-ph-logo { opacity: 0.5; transform: none; }

.news-badge {
    position: absolute; top: 12px; left: 12px;
    background: rgba(85, 37, 131, 0.92);
    color: #fff; font-family: var(--font-display);
    font-size: 0.7rem; letter-spacing: 1px; text-transform: uppercase;
    padding: 5px 10px; border-radius: 100px;
}

.news-card-body { padding: 22px; display: flex; flex-direction: column; flex: 1; }
.news-date { color: var(--accent); font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 1px; text-transform: uppercase; }
.news-title { font-size: 1.4rem; margin: 8px 0 12px; line-height: 1.15; }
.news-resum {
    color: var(--text-gray); font-size: 0.95rem; margin-bottom: 18px;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.news-more { margin-top: auto; color: var(--text-white); font-family: var(--font-display); font-size: 0.85rem; letter-spacing: 1px; text-transform: uppercase; }
.news-card:hover .news-more { color: var(--accent); }

@media (max-width: 600px) {
    .news-head { flex-direction: column; align-items: flex-start; gap: 10px; }
    .news-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   BOTIGA — targetes de producte (catàleg)
   ============================================================ */
.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 28px;
}
.shop-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid #222;
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.3s ease, border-color 0.3s ease;
}
.shop-card:hover { transform: translateY(-6px); border-color: var(--accent); }
.shop-card-img { position: relative; aspect-ratio: 1; overflow: hidden; background: #0e0e0e; }
.shop-card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.shop-card:hover .shop-card-img img { transform: scale(1.05); }
.shop-card-img--ph { display: flex; align-items: center; justify-content: center; }
.shop-card-img--ph .shop-ph-logo { width: 90px; height: auto; object-fit: contain; opacity: 0.35; }
.shop-badge {
    position: absolute; top: 12px; left: 12px;
    background: rgba(85, 37, 131, 0.92); color: #fff;
    font-family: var(--font-display); font-size: 0.7rem; letter-spacing: 1px; text-transform: uppercase;
    padding: 5px 10px; border-radius: 100px;
}
.shop-badge--out { background: rgba(20,20,20,0.9); border: 1px solid #444; }
.shop-card-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.shop-name { font-size: 1.2rem; line-height: 1.2; }
.shop-price { margin-top: auto; font-family: var(--font-display); font-size: 1.3rem; color: var(--accent); }

@media (max-width: 600px) {
    .shop-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
}

/* ============================================================
   BOTIGA — cistella i checkout
   ============================================================ */
.cart-table { border-top: 1px solid #222; margin-bottom: 20px; }
.cart-row {
    display: grid; grid-template-columns: 1fr auto auto; gap: 20px; align-items: center;
    padding: 18px 0; border-bottom: 1px solid #222;
}
.cart-prod { display: flex; align-items: center; gap: 16px; }
.cart-prod img, .cart-thumb-ph { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: #0e0e0e; }
.cart-thumb-ph { display: flex; align-items: center; justify-content: center; }
.cart-thumb-ph img { width: 40px; height: 40px; opacity: 0.4; }
.cart-name { display: block; font-weight: 600; color: var(--text-white); }
.cart-unit { display: block; color: var(--text-gray); font-size: 0.88rem; }
.cart-warn { display: block; color: #e0a23c; font-size: 0.82rem; margin-top: 2px; }
.cart-qty input {
    width: 70px; padding: 8px 10px; background: #141414; border: 1px solid #2a2a2a;
    border-radius: 6px; color: var(--text-white); font-size: 1rem; text-align: center;
}
.cart-sub { font-family: var(--font-display); font-size: 1.1rem; min-width: 90px; text-align: right; }
.cart-actions { margin-bottom: 30px; text-align: right; }
.btn-cart-update {
    background: transparent; border: 1px solid #333; color: var(--text-gray);
    padding: 10px 18px; border-radius: 6px; cursor: pointer; font-family: var(--font-body); font-size: 0.9rem;
}
.btn-cart-update:hover { border-color: var(--accent); color: var(--text-white); }
.cart-foot {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px;
    border-top: 2px solid #333; padding-top: 24px;
}
.cart-total { font-size: 1.4rem; }
.cart-total strong { color: var(--accent); font-family: var(--font-display); font-size: 1.7rem; }
.cart-foot-btns { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.btn-cart-continue { color: var(--text-gray); }
.btn-cart-continue:hover { color: var(--text-white); }

/* Botó "Afegir a la cistella" + selector de quantitat */
.product-buy { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.product-qty-wrap { display: flex; flex-direction: column; }
.product-qty-lbl { color: var(--text-gray); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.product-qty {
    width: 84px; padding: 15px 12px; background: #141414; border: 1px solid #2a2a2a;
    border-radius: 6px; color: var(--text-white); font-size: 1.05rem; text-align: center;
}
.btn-cart { display: inline-flex; align-items: center; gap: 10px; padding-right: 38px; }
.btn-cart svg { width: 20px; height: 20px; fill: currentColor; }

@media (max-width: 600px) {
    .cart-row { grid-template-columns: 1fr auto; }
    .cart-sub { grid-column: 2; }
    .cart-qty { grid-column: 2; }
}

/* ============================================================
   Icona de cistella al menú (només apareix si hi ha articles)
   ============================================================ */
.cart-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    flex: 0 0 auto;
}
.cart-link svg { width: 26px; height: 26px; fill: #F2F2F2; transition: fill 0.3s ease; }
.cart-link:hover svg { fill: var(--accent); }
.cart-count {
    position: absolute;
    top: 3px; right: 3px;
    display: flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 4px;
    background: #e23b3b;          /* badge vermell */
    color: #fff;
    border-radius: 100px;
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--bg-dark);  /* anell per separar-lo de la icona */
    pointer-events: none;
}
