/* =============================================
   RESPONSIVE.CSS — Projecte Share
   Mobile-first media queries for full site
   Breakpoints: 1024px | 900px | 768px | 640px | 480px | 400px
   ============================================= */

/* ──────────────────────────────────────────────
   PREVENT HORIZONTAL OVERFLOW
   ────────────────────────────────────────────── */
body { overflow-x: hidden; max-width: 100%; }
body.nav-open { overflow: hidden; }

/* ──────────────────────────────────────────────
   HAMBURGER TOGGLE BUTTON
   (hidden on desktop, shown on mobile)
   ────────────────────────────────────────────── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: 8px;
  position: relative;
  z-index: 1200;
  flex-shrink: 0;
  transition: background 0.2s;
}
.nav-toggle:hover { background: rgba(255,255,255,0.1); }
.nav.scrolled .nav-toggle:hover,
.nav.force-solid .nav-toggle:hover { background: rgba(0,0,0,0.06); }

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: #fff;
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1),
              opacity   0.25s ease,
              background 0.3s;
  transform-origin: center;
}
.nav.scrolled .nav-toggle span,
.nav.force-solid .nav-toggle span { background: var(--dark); }

/* X state when menu is open */
.nav.nav-open .nav-toggle span { background: #fff !important; }
.nav.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav.nav-open .nav-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ──────────────────────────────────────────────
   MOBILE NAV OVERLAY — ≤ 1024px
   ────────────────────────────────────────────── */
@media (max-width: 1024px) {

  .nav-toggle { display: flex; }

  /* ── FIX: when menu is open, remove glassmorphism from nav-inner.
     backdrop-filter on a parent creates a stacking context that causes
     the overlay to appear semi-transparent and the glass panel to bleed
     through. Disabling it makes the overlay fully opaque. ── */
  .nav.nav-open .nav-inner,
  .nav.nav-open.scrolled .nav-inner,
  .nav.nav-open.force-solid .nav-inner {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    padding: 10px 16px !important;
  }

  /* Re-position nav-links as a full-screen overlay */
  .nav-links {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    /* Fully opaque — no backdrop-filter to avoid compositor interference */
    background: rgb(14, 16, 18);
    flex-direction: column !important;
    align-items: center;
    justify-content: center;
    gap: 4px;
    z-index: 1100;
    list-style: none;
    margin: 0;
    padding: 72px 32px 40px;
    /* Hidden state */
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
  }

  .nav.nav-open .nav-links {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  /* Nav links items */
  .nav-links li {
    width: 100%;
    text-align: center;
  }

  .nav-links a {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    color: rgba(255, 255, 255, 0.85) !important;
    padding: 13px 32px !important;
    display: block !important;
    letter-spacing: 0.3px !important;
    text-transform: none !important;
    border-radius: 12px;
    transition: background 0.2s, color 0.2s !important;
    white-space: normal !important;
  }
  .nav-links a:hover {
    background: rgba(255,255,255,0.08) !important;
    color: #fff !important;
  }
  .nav-links a::after { display: none !important; }

  /* CTA buttons in mobile menu */
  .nav-links .nav-cta {
    display: inline-flex !important;
    font-size: 0.95rem !important;
    padding: 13px 40px !important;
    border-radius: 100px !important;
    margin-top: 12px !important;
  }
  .nav-links .nav-cta-outline {
    display: inline-flex !important;
    font-size: 0.95rem !important;
    border: 1.5px solid rgba(255,255,255,0.4) !important;
    color: rgba(255,255,255,0.85) !important;
    padding: 11px 40px !important;
    border-radius: 100px !important;
    background: transparent !important;
    backdrop-filter: none !important;
    margin-top: 6px !important;
  }

  /* Language switcher */
  .nav-links .nav-lang {
    justify-content: center;
    margin: 10px 0 0 0;
  }
}

/* ──────────────────────────────────────────────
   HERO SECTION
   ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero { min-height: 100svh; }
  .hero-dots { bottom: 72px; }
}

@media (max-width: 640px) {
  /* Stats bar: 2×2 grid */
  .hero-stats-inner { flex-wrap: wrap; }
  .hero-stat {
    flex: 1 1 50%;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .hero-stat:nth-child(odd)  { border-right: 1px solid rgba(255,255,255,0.08); }
  .hero-stat:nth-last-child(-n+2) { border-bottom: none; }
  .hero-dots { bottom: 76px; }
}

@media (max-width: 480px) {
  .hero-stat-num { font-size: 1.4rem; }
  .hero-stat { padding: 16px 0; }
  .hero-actions {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .btn-hero-primary,
  .btn-hero-secondary {
    width: 100%;
    justify-content: center;
  }
}

/* ──────────────────────────────────────────────
   INTRO STRIP (home)
   ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .intro-strip-inner {
    grid-template-columns: 1fr !important;
    gap: 48px;
  }
  .intro-visual { order: -1; }
  .intro-badge {
    bottom: -10px;
    right: 10px;
  }
}

@media (max-width: 640px) {
  .intro-strip { padding: 64px 5%; }
  .intro-photo-grid {
    grid-template-rows: 200px 140px;
  }
  .intro-badge { padding: 14px 18px; }
  .intro-badge-num { font-size: 1.5rem; }
}

/* ──────────────────────────────────────────────
   PROGRAMES BENTO GRID
   ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .bento-grid {
    grid-template-columns: 1fr 1fr;
  }
  .bento-wide { grid-column: 1 / -1; }
  .bento-card-photo { min-height: 300px; }
}

@media (max-width: 580px) {
  .bento-grid { grid-template-columns: 1fr; }
  .bento-wide { grid-column: 1; }
  .bento-card-photo { min-height: 260px; }
  .bento-card-solid { min-height: 160px; padding: 24px; }
}

/* ──────────────────────────────────────────────
   NOTICIES SECTION HEADER (home)
   ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .noticies .section-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 20px !important;
  }
  .noticies .section-header .btn-secondary {
    align-self: flex-start;
  }
}

/* ──────────────────────────────────────────────
   CTA VOLUNTARIAT
   ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .cta-inner {
    grid-template-columns: 1fr !important;
    gap: 48px;
  }
  .cta-voluntariat { padding: 80px 5%; }
}
@media (max-width: 480px) {
  .cta-voluntariat { padding: 64px 5%; }
}

/* ──────────────────────────────────────────────
   COL·LABORADORS
   ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .colabs-logos { gap: 24px; }
  .colab-logo img { max-height: 36px; }
}

/* ──────────────────────────────────────────────
   FOOTER
   ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 40px;
  }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 540px) {
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .footer-brand { grid-column: auto; }
  .footer-bottom {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  footer { padding: 48px 5% 28px; }
}

/* ──────────────────────────────────────────────
   SECTION PADDING
   ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .section { padding: 72px 5% !important; }
  .section-header { margin-bottom: 40px; }
  .noticies { padding: 72px 5% !important; }
}
@media (max-width: 480px) {
  .section { padding: 56px 5% !important; }
  .noticies { padding: 56px 5% !important; }
}

/* ──────────────────────────────────────────────
   PAGE HERO (interior pages)
   ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .page-hero {
    padding: 120px 5% 56px !important;
    min-height: 300px;
  }
}
@media (max-width: 480px) {
  .page-hero {
    padding: 100px 5% 48px !important;
    min-height: 260px;
  }
}

/* ──────────────────────────────────────────────
   INLINE PAGE STYLES — INNER PAGES
   (These override <style> blocks inside templates)
   ────────────────────────────────────────────── */

/* ─ programs-grid (qui-es-share) ─ */
@media (max-width: 900px) {
  .programs-grid { grid-template-columns: repeat(2,1fr) !important; }
}
@media (max-width: 580px) {
  .programs-grid { grid-template-columns: 1fr !important; }
}

/* ─ intro-2col (qui-es-share) ─ */
@media (max-width: 900px) {
  .intro-2col {
    grid-template-columns: 1fr !important;
    gap: 40px !important;
  }
}

/* ─ numbers-strip / numbers-inner (qui-es-share) ─ */
@media (max-width: 640px) {
  .numbers-inner {
    grid-template-columns: repeat(2,1fr) !important;
    gap: 28px !important;
  }
  .numbers-strip { padding: 48px 5%; }
}
@media (max-width: 360px) {
  .numbers-inner { grid-template-columns: 1fr !important; }
}

/* ─ exp-grid (qui-es-share, experiencies) ─ */
@media (max-width: 900px) {
  .exp-grid { grid-template-columns: repeat(2,1fr) !important; }
}
@media (max-width: 580px) {
  .exp-grid { grid-template-columns: 1fr !important; }
}

/* ─ colab-ways (com-collaborar) ─ */
@media (max-width: 900px) {
  .colab-ways { grid-template-columns: 1fr !important; }
}

/* ─ empresa-grid (com-collaborar) ─ */
@media (max-width: 900px) {
  .empresa-grid { grid-template-columns: 1fr !important; }
}

/* ─ rifa-banner (com-collaborar) ─ */
@media (max-width: 640px) {
  .rifa-banner {
    flex-direction: column !important;
    gap: 20px !important;
    padding: 32px 28px !important;
    text-align: center;
  }
}

/* ─ amount-grid (com-collaborar donation) ─ */
@media (max-width: 380px) {
  .amount-grid { grid-template-columns: repeat(2,1fr) !important; }
}

/* ─ donation-box (com-collaborar) ─ */
@media (max-width: 480px) {
  .donation-box { padding: 32px 24px !important; }
}

/* ─ steps (voluntari) ─ */
@media (max-width: 900px) {
  .steps { grid-template-columns: repeat(2,1fr) !important; }
  .step::after { display: none !important; }
}
@media (max-width: 480px) {
  .steps { grid-template-columns: 1fr !important; }
}

/* ─ testimonials-grid (voluntari) ─ */
@media (max-width: 900px) {
  .testimonials-grid { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 580px) {
  .testimonials-grid { grid-template-columns: 1fr !important; }
}

/* ─ posts-grid & post-featured (noticies) ─ */
@media (max-width: 900px) {
  .posts-grid { grid-template-columns: repeat(2,1fr) !important; }
  /* Featured post: no longer spans all 3 columns */
  .post-featured { grid-column: 1 / -1 !important; }
}
@media (max-width: 768px) {
  .posts-grid { grid-template-columns: 1fr !important; }
  .post-featured {
    grid-column: 1 / -1 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: auto !important;
  }
  .post-featured-img-inner { min-height: 200px !important; }
  .post-featured-body { padding: 24px !important; }
}
@media (max-width: 580px) {
  .posts-grid { grid-template-columns: 1fr !important; }
}

/* ─ Home news grid — all posts same size on mobile ─ */
@media (max-width: 768px) {
  .news-layout {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
  }
  .news-featured-wrap,
  .news-top-wrap,
  .news-bot1-wrap,
  .news-bot2-wrap {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
  }
  /* All cards same fixed height */
  .news-featured-wrap .noticia-featured,
  .news-top-wrap .noticia-small,
  .news-bot1-wrap .noticia-small,
  .news-bot2-wrap .noticia-small {
    height: 220px !important;
    min-height: 220px !important;
  }
}

/* ─ timeline simple (qui-es-share) ─ */
@media (max-width: 768px) {
  .timeline { padding-left: 36px !important; }
  .timeline::before { left: 6px !important; }
  .timeline-dot { left: -30px !important; }
  .timeline-item { margin-bottom: 28px !important; }
}


/* ─ posts-grid: override inline grid-column:span 2 on cards ─ */
@media (max-width: 900px) {
  .posts-grid .post-card { grid-column: auto !important; }
}
@media (max-width: 768px) {
  .posts-grid .post-card,
  .posts-grid .post-featured { grid-column: 1 / -1 !important; }
}

/* ─ Home news: override any inline span on news wrappers ─ */
@media (max-width: 768px) {
  .news-layout > * { grid-column: 1 / -1 !important; grid-row: auto !important; }
}

/* ─ Donations section — inline grid (1fr 1fr) override ─ */
@media (max-width: 900px) {
  /* The donation "impacte real" section uses an inline grid-template-columns */
  #donacio .section-inner > div {
    grid-template-columns: 1fr !important;
    gap: 40px !important;
  }
  /* program-impact-row: keep flex but allow amount to wrap */
  .program-impact-row { flex-wrap: wrap; gap: 12px; }
  .program-impact-amount { width: 100%; text-align: right; }
}
@media (max-width: 480px) {
  .program-impact-row { gap: 10px; }
  .program-impact-icon { width: 40px !important; height: 40px !important; font-size: 1.4rem !important; }
}

/* ─ Language popup grid: always 1 row (auto-flow column) ─ */
.lang-grid {
  grid-template-columns: unset !important;
  grid-auto-flow: column !important;
  grid-auto-columns: 1fr !important;
}

/* ─ quote-block (qui-es-share) ─ */
@media (max-width: 480px) {
  .quote-block { padding: 28px 28px !important; }
}

/* ─ single post ─ */
@media (max-width: 768px) {
  .single-post-header {
    padding: 110px 5% 56px !important;
  }
}

/* ──────────────────────────────────────────────
   BUTTONS — Touch-friendly on mobile
   ────────────────────────────────────────────── */
@media (max-width: 480px) {
  .btn-primary,
  .btn-red,
  .btn-outline,
  .btn-secondary {
    width: 100%;
    justify-content: center;
  }
  .hero-actions .btn-hero-primary,
  .hero-actions .btn-hero-secondary {
    padding: 14px 28px;
    font-size: 0.88rem;
  }
}

/* ──────────────────────────────────────────────
   MISC LAYOUT TWEAKS
   ────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Section desc max-width full on mobile */
  .section-desc { max-width: 100%; }
  .page-hero-desc { max-width: 100%; }
}

/* Tilt animation: disable on touch devices (no hover) */
@media (hover: none) {
  .tilt-img { animation: none !important; }
  .intro-float-1,
  .intro-float-2,
  .intro-float-3 { animation: none !important; }
}

/* ──────────────────────────────────────────────
   STORY TIMELINE INTERACTIVA (qui-es-share)
   ────────────────────────────────────────────── */
@media (max-width: 900px) {
  /* Línia: pegada a l'esquerra */
  .story-line-bg,
  .story-line-progress { left: 16px !important; }

  /* Nodes: centrats sobre la línia */
  .story-node { left: 10px !important; }

  /* Item: columna. !important necessari perquè l'inline <style> del template
     ve després al DOM i sobreescriu sense ell */
  .story-item {
    flex-direction: column !important;
    justify-content: center !important;
    gap: 10px !important;
    padding: 72px 20px 40px 68px !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
  }

  /* Info: no expandir en columna (flex:1 empeny la targeta fora de pantalla) */
  .story-info { max-width: 100%; flex: none !important; }

  /* Any: mida reduïda */
  .story-year {
    font-size: clamp(1.8rem, 8vw, 2.4rem);
    margin-bottom: 4px;
    letter-spacing: -1px;
  }

  .story-title { font-size: clamp(1.05rem, 4.5vw, 1.5rem); margin-bottom: 6px; }
  .story-sub   { font-size: 0.87rem; line-height: 1.55; }

  /* Targeta: amplada completa, no expandir */
  .story-card {
    max-width: 100%;
    flex: none !important;
    padding: 16px 16px;
    border-top-width: 3px;
  }
  .story-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
  .story-card p  { font-size: 0.85rem; line-height: 1.6; }
  .story-card-btn { padding: 9px 18px; font-size: 0.8rem; margin-top: 12px; }

  /* Intro: marge esquerre per a la línia */
  .story-intro { padding: 0 5% 0 52px; }
  .story-intro h2 { font-size: clamp(1.8rem, 7vw, 3rem); margin-bottom: 14px; }
  .story-intro p  { font-size: 0.95rem; }
}

@media (max-width: 600px) {
  .story-item {
    padding: 100px 16px 12px 62px !important;
    gap: 8px !important;
  }

  .story-year { font-size: clamp(1.6rem, 9vw, 2rem); }
  .story-title { font-size: clamp(1rem, 4.5vw, 1.25rem); }
  .story-sub  { font-size: 0.83rem; }

  .story-card { padding: 14px 14px !important; }
  .story-card h3 { font-size: 1rem; }
  .story-card p  { font-size: 0.83rem; }

  .story-intro { padding: 0 16px 0 46px; }
  .story-intro .stag { font-size: 0.68rem; }
}

@media (max-width: 400px) {
  .story-item { padding: 90px 14px 10px 56px !important; }
  .story-year { font-size: 1.6rem; }
  .story-intro { padding: 0 14px 0 42px; }
  .story-card { padding: 12px 12px !important; }
}
