/* ========================================
   base.css — Reset, tipografía, utilidades
   ======================================== */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--body-font);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-color);
    background-color: var(--bg-color);
    padding-top: var(--nav-h);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-slow), color var(--transition-slow);
}

h1, h2, h3, h4 {
    font-family: var(--heading-font);
    font-weight: 700;
    line-height: 1.12;
    color: var(--primary-dark);
    text-wrap: balance;
}

p { text-wrap: pretty; }

img, picture, svg, video {
    display: block;
    max-width: 100%;
}

/* el atributo height="" no debe fijar la altura cuando el CSS cambia el ancho */
img { height: auto; }

a {
    color: var(--primary-color);
    text-decoration: none;
}

button {
    font: inherit;
    border: none;
    background: none;
    cursor: pointer;
}

ul[class], ol[class] { list-style: none; }

::selection {
    background: var(--secondary-color);
    color: #fff;
}

:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 3px;
    border-radius: 4px;
}

#main-content {
    transition: opacity 0.22s var(--animation-smooth);
    /* mantiene el footer por debajo del pliegue hasta que el contenido se inyecta
       (evita el "flash" del footer sobre el main vacío en el primer paint) */
    min-height: calc(100svh - var(--nav-h));
}

/* ---------- Layout helpers ---------- */
.container {
    width: min(var(--container), 100% - var(--gutter) * 2);
    margin-inline: auto;
}

.container-narrow {
    width: min(720px, 100% - var(--gutter) * 2);
    margin-inline: auto;
}

.section { padding-block: var(--space-section); }
.section-tint { background: var(--accent-color); }

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

/* En móvil el título + enlace "Veure tots →" no caben en una fila (320–390px):
   se apilan para que el CTA no se recorte. */
@media (max-width: 600px) {
    .section-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

.section-title { font-size: var(--text-display); }

.eyebrow {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--secondary-color);
    margin-bottom: 0.6rem;
}

.lead {
    font-size: var(--text-lead);
    color: var(--text-muted);
    max-width: 56ch;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Fotos de producto ---------- */
.photo {
    background: var(--photo-bg);
    overflow: hidden;
}

.photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- Scroll reveal (fallback IntersectionObserver) ----------
   Solo se ocultan elementos si JS está activo (html.js);
   sin JS la página es 100% visible. */
html.js:not(.fx-off) .reveal {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity 0.7s var(--animation-smooth), transform 0.7s var(--animation-smooth);
}

html.js:not(.fx-off) .reveal.visible {
    opacity: 1;
    transform: none;
}

html.js:not(.fx-off) .reveal-stagger > * {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity 0.7s var(--animation-smooth), transform 0.7s var(--animation-smooth);
}

html.js:not(.fx-off) .reveal-stagger.visible > * {
    opacity: 1;
    transform: none;
}

html.js:not(.fx-off) .reveal-stagger.visible > :nth-child(2) { transition-delay: 90ms; }
html.js:not(.fx-off) .reveal-stagger.visible > :nth-child(3) { transition-delay: 180ms; }
html.js:not(.fx-off) .reveal-stagger.visible > :nth-child(4) { transition-delay: 270ms; }
html.js:not(.fx-off) .reveal-stagger.visible > :nth-child(5) { transition-delay: 360ms; }
html.js:not(.fx-off) .reveal-stagger.visible > :nth-child(n+6) { transition-delay: 440ms; }

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
