/* ============================================================
   Variables & Reset
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg:       #080808;
    --fg:       #e9e6df;
    --muted:    #909088;
    --dim:      #333330;
    --gap:      6px;
    --max-w:    1520px;
    --pad-x:    clamp(20px, 4vw, 60px);
}

html {
    scroll-behavior: smooth;
}

html {
    background: var(--bg);
}

body {
    background: transparent;
    color: var(--fg);
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

img {
    display: block;
    max-width: 100%;
    -webkit-user-drag: none;
    pointer-events: none;
    user-select: none;
}

ul { list-style: none; }
button { cursor: pointer; }

/* ============================================================
   Header / Nav
   ============================================================ */
#header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 200;
    padding: 28px var(--pad-x);
    transition: padding 0.5s, background 0.5s, backdrop-filter 0.5s;
}

#header.scrolled {
    padding: 18px var(--pad-x);
    background: rgba(8, 8, 8, 0.88);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

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

.nav-logo {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1.5rem;
    letter-spacing: 0.08em;
    color: var(--fg);
}

.nav-links {
    display: flex;
    gap: 44px;
}

.nav-links a {
    color: var(--fg);
    text-decoration: none;
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.nav-links a:hover { opacity: 1; }

/* ============================================================
   Hero
   ============================================================ */
#hero {
    position: relative;
    height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hero-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.hero-pre {
    font-size: 0.68rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0;
    animation: fadeUp 1s ease 0.2s forwards;
}

#hero h1 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(3.6rem, 9vw, 9.5rem);
    letter-spacing: 0.02em;
    line-height: 0.95;
    background: linear-gradient(135deg, #d4c9a8 0%, #f0ece4 40%, #f0ece4 60%, #d4c9a8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0;
    transform: translateY(24px);
    animation: fadeUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.4s forwards;
}

.hero-sub {
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0;
    animation: fadeUp 1s ease 0.8s forwards;
}

.scroll-cue {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 60px;
    overflow: hidden;
    z-index: 3;
}

.scroll-cue span {
    display: block;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--muted));
    animation: scrollLine 2s ease-in-out infinite 1.5s;
}

@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scrollLine {
    0%   { transform: translateY(-100%); opacity: 1; }
    100% { transform: translateY(100%); opacity: 0; }
}

/* ============================================================
   Featured — Sunset Ebre
   ============================================================ */
#featured {
    padding: 100px 0 0;
}

.featured-header {
    text-align: center;
    padding: 0 var(--pad-x) 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.featured-eyebrow {
    font-size: 0.65rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--muted);
}

.featured-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(2.4rem, 5vw, 4.5rem);
    letter-spacing: 0.04em;
    line-height: 1;
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap);
    height: clamp(360px, 72vh, 820px);
}

.featured-item {
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.featured-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.featured-item img.loaded { opacity: 1; }

.featured-item:hover img { transform: scale(1.04); }

.featured-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.25) 0%, transparent 50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s;
}

.featured-item:hover::after { opacity: 1; }

.featured-caption {
    text-align: center;
    padding: 28px var(--pad-x) 0;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    color: var(--muted);
    font-style: italic;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    font-weight: 300;
}

/* ============================================================
   Featured — Far de l'Ebre (single image, natural framing)
   ============================================================ */
#featured-far-ebre {
    padding: 150px 0 0;
}

.featured-grid--far-ebre {
    display: flex;
    justify-content: center;
    align-items: center;
    width: min(100%, 1180px);
    height: auto;
    margin: 0 auto;
    padding: 0 var(--pad-x);
}

#featuredFarEbreGrid .featured-item {
    width: min(100%, 980px);
    height: clamp(420px, 72vh, 760px);
    cursor: pointer;
}

#featuredFarEbreGrid .featured-item img {
    width: auto;
    max-width: 100%;
    height: 100%;
    margin: 0 auto;
    object-fit: contain;
}

#featuredFarEbreGrid .featured-item:hover img {
    transform: none;
}

/* ============================================================
   Featured — Molins holandesos
   ============================================================ */
#featured-molins-holandesos {
    padding: 100px 0 0;
}

.featured-grid--molins-holandesos {
    grid-template-columns: 1fr 1fr;
    height: clamp(360px, 82vh, 900px);
}

#featuredMolinsHolandesosGrid .featured-item:nth-child(1) img {
    object-position: center 42%;
}

#featuredMolinsHolandesosGrid .featured-item:nth-child(2) img {
    object-position: center 50%;
}


/* ============================================================
   Featured — Castella (layout duo 50/50)
   ============================================================ */
#featured-castella {
    padding: 100px 0 0;
}

.featured-grid--castella {
    grid-template-columns: 1fr;
    height: clamp(420px, 88vh, 960px);
}

#featuredCastellaGrid .featured-item:nth-child(1) img {
    object-position: center 48%;
}

#featuredCastellaGrid .featured-item:nth-child(2) img {
    object-position: center 45%;
}

/* ============================================================
   Featured — Côte d'Azur (layout duo 50/50)
   ============================================================ */
#featured-cote-dazur {
    padding: 100px 0 0;
}

.featured-grid--cote-dazur {
    grid-template-columns: 1fr 1fr;
    height: clamp(420px, 92vh, 1040px);
}

#featuredCoteGrid .featured-item:nth-child(1) img {
    object-fit: contain;
    object-position: center center;
    background: transparent;
}

#featuredCoteGrid .featured-item:nth-child(2) img {
    object-position: center 38%;
}

/* ============================================================
   Featured — Braga (layout duo 50/50)
   ============================================================ */
#featured-braga {
    padding: 100px 0 0;
}

.featured-grid--braga {
    grid-template-columns: 1fr 1fr;
    height: clamp(360px, 85vh, 920px);
}

#featuredBragaGrid .featured-item:nth-child(1) img {
    object-position: center 40%;
}

#featuredBragaGrid .featured-item:nth-child(2) img {
    object-position: center 45%;
}

/* ============================================================
   Featured — França / Mont Saint-Michel + Versalles (duo)
   ============================================================ */
#featured-franca {
    padding: 100px 0 0;
}

.featured-grid--franca {
    grid-template-columns: 1fr 1fr;
    width: min(100%, 1120px);
    margin: 0 auto;
    height: clamp(360px, 82vh, 900px);
}

#featuredMontGrid .featured-item:nth-child(1) img {
    object-position: 30% 38%;
}

/* ============================================================
   Featured — Gaztelugatxe (layout duo 50/50)
   ============================================================ */
#featured-gaztelugatxe {
    padding: 100px 0 0;
}

.featured-grid--gaztelugatxe {
    grid-template-columns: 1fr 1fr;
    height: clamp(360px, 82vh, 900px);
}

#featuredGaztelugatxeGrid .featured-item:nth-child(1) img {
    object-position: center 42%;
}

#featuredGaztelugatxeGrid .featured-item:nth-child(2) img {
    object-position: center 48%;
}

/* ============================================================
   Featured — Budapest (panoràmica + cúpula)
   ============================================================ */
#featured-budapest {
    padding: 100px 0 0;
}

.featured-grid--budapest {
    display: flex;
    justify-content: center;
    gap: var(--gap);
    height: clamp(400px, 75vh, 860px);
}

#featuredBudapestGrid .featured-item {
    flex: 0 0 auto;
    height: 100%;
    aspect-ratio: 3 / 4;
}

#featuredBudapestGrid .featured-item img {
    object-fit: cover;
    background: transparent;
}

/* ============================================================
   Featured — Castells d'Europa (layout 3 columnes)
   ============================================================ */
#featured-castells {
    padding: 100px 0 0;
}

.featured-grid--duo {
    grid-template-columns: 1fr 1fr;
    height: clamp(360px, 80vh, 860px);
}

#featuredCastellsGrid .featured-item:nth-child(1) img {
    object-position: 60% 25%;
}

#featuredCastellsGrid .featured-item:nth-child(2) img {
    object-position: center 32%;
}


/* ============================================================
   About
   ============================================================ */
#about {
    padding: 120px var(--pad-x);
    max-width: 660px;
    margin: 0 auto;
}

.about-inner {
    display: flex;
    flex-direction: column;
    gap: 36px;
}

.about-line {
    width: 40px;
    height: 1px;
    background: var(--dim);
}

#about h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(2rem, 4vw, 2.8rem);
    letter-spacing: 0.03em;
    line-height: 1.1;
}

#about p {
    font-size: 0.88rem;
    line-height: 2;
    color: var(--muted);
    letter-spacing: 0.025em;
}

/* ============================================================
   Contact
   ============================================================ */
#contact {
    padding: 80px var(--pad-x) 120px;
    text-align: center;
}

.contact-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.contact-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

#contact h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(2.4rem, 5vw, 4rem);
    letter-spacing: 0.02em;
    color: var(--muted);
}

.contact-link {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    font-weight: 300;
    color: var(--fg);
    text-decoration: none;
    position: relative;
    padding-bottom: 3px;
}

.contact-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--dim);
    transition: background 0.4s;
}

.contact-link:hover::after { background: var(--fg); }

/* ============================================================
   Footer
   ============================================================ */
footer {
    border-top: 1px solid rgba(255,255,255,0.04);
    padding: 28px var(--pad-x);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    flex-wrap: wrap;
    gap: 8px;
}

/* ============================================================
   Lightbox
   ============================================================ */
#lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(4, 4, 4, 0.97);
    align-items: center;
    justify-content: center;
}

#lightbox.active { display: flex; }

#lb-stage {
    max-width: 92vw;
    max-height: 92vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lb-img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.35s ease;
    user-select: none;
}

#lb-img.loaded { opacity: 1; }

#lb-close {
    position: fixed;
    top: 24px;
    right: 32px;
    background: none;
    border: none;
    color: var(--fg);
    font-size: 2.2rem;
    line-height: 1;
    opacity: 0.45;
    transition: opacity 0.3s;
    z-index: 1001;
    padding: 4px 8px;
}

#lb-prev,
#lb-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--fg);
    font-size: 3rem;
    line-height: 1;
    opacity: 0.3;
    transition: opacity 0.3s;
    z-index: 1001;
    padding: 24px 20px;
    user-select: none;
}

#lb-prev { left: 16px; }
#lb-next { right: 16px; }

#lb-close:hover,
#lb-prev:hover,
#lb-next:hover { opacity: 1; }

#lb-counter {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    color: var(--muted);
    white-space: nowrap;
}

/* ============================================================
   Ambient overlay — dual crossfade
   ============================================================ */
#ambient-a,
#ambient-b {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    filter: saturate(1.15);
    transition: opacity 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#ambient-b { opacity: 0; }

/* ============================================================
   Eyebrow — decorative line
   ============================================================ */
.featured-eyebrow::before {
    content: '';
    display: block;
    width: 28px;
    height: 1px;
    background: var(--muted);
    margin: 0 auto 14px;
    opacity: 0.6;
}

/* ============================================================
   Castella — Don Quijote literary strip
   ============================================================ */
.castella-literary {
    position: relative;
    height: clamp(220px, 38vh, 460px);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: var(--gap);
}

.castella-literary__bg {
    position: absolute;
    inset: 0;
    background: url('Fotos/optimitzades/quijoe.jpg') center 40% / cover no-repeat;
    filter: brightness(0.28) sepia(0.4);
    transform: scale(1.04);
    transition: transform 8s ease;
}

.castella-literary:hover .castella-literary__bg {
    transform: scale(1.0);
}

.castella-quote {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    text-align: center;
    padding: 0 var(--pad-x);
    max-width: 680px;
}

.castella-quote p {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.2rem, 2.2vw, 2rem);
    font-style: italic;
    font-weight: 300;
    line-height: 1.65;
    color: var(--fg);
}

.castella-quote cite {
    font-size: 0.62rem;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    font-style: normal;
}

/* ============================================================
   Sunset Ebre — warm glow
   ============================================================ */
#featured {
    position: relative;
}

#featured::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to top, rgba(180, 70, 10, 0.08) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

#featured .featured-grid {
    position: relative;
    z-index: 1;
}

/* ============================================================
   Budapest — subtle frame
   ============================================================ */
#featured-budapest {
    position: relative;
}

/* ============================================================
   Responsive — Tablet (≤900px)
   ============================================================ */
@media (max-width: 900px) {

    .featured-grid--franca {
        grid-template-columns: 1fr 1fr;
        height: clamp(280px, 58vh, 560px);
    }

    #featuredMontGrid .featured-item:nth-child(2) img {
        object-fit: cover;
    }

    .featured-grid--budapest {
        height: clamp(280px, 52vh, 500px);
    }
}

/* ============================================================
   Responsive — Mobile (≤640px)
   ============================================================ */
@media (max-width: 640px) {
    /* Reset totes les altures personalitzades */
    .featured-grid,
    .featured-grid--castella,
    .featured-grid--cote-dazur,
    .featured-grid--braga,
    .featured-grid--franca,
    .featured-grid--gaztelugatxe,
    .featured-grid--molins-holandesos,
    .featured-grid--duo {
        grid-template-columns: 1fr;
        height: auto;
    }

    .featured-item { height: 72vw; }

    #featuredGaztelugatxeGrid .featured-item,
    #featuredMolinsHolandesosGrid .featured-item {
        height: auto;
    }

    #featuredGaztelugatxeGrid .featured-item img,
    #featuredMolinsHolandesosGrid .featured-item img {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    #featuredFarEbreGrid .featured-item {
        height: min(72vh, 540px);
    }

    /* Budapest — apila verticalment */
    .featured-grid--budapest {
        flex-direction: column;
        height: auto;
    }

    #featuredBudapestGrid .featured-item {
        width: 100%;
        height: auto;
        aspect-ratio: 3 / 4;
        flex: 0 0 auto;
    }

    #featuredBudapestGrid .featured-item img {
        width: 100%;
        height: 100%;
    }

    /* Castella */
    #featured-castella .featured-grid--castella { margin: 0; }

    .castella-literary {
        height: clamp(160px, 50vw, 260px);
    }

    .castella-quote p { font-size: 1.05rem; }

    /* Padding seccions */
    [id^="featured"] { padding-top: 64px; }

    /* Nav */
    .nav-links { display: none; }

    #lb-prev { left: 4px; }
    #lb-next { right: 4px; }

    #about { padding-top: 80px; padding-bottom: 80px; }

    .featured-title { font-size: clamp(1.8rem, 8vw, 3rem); }

    .hero-sub, .hero-pre { letter-spacing: 0.14em; }
}
