/* ═══════════════════════════════════════════════════════════════════════
   responsive.css — Anhelo mobile & tablet responsive layer
   Load AFTER styles.css (and all page-specific CSS files).
   Breakpoints: 768px (tablet), 480px (mobile), 375px (small mobile)
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── 1. BASE: prevent horizontal overflow everywhere ─────────────────── */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

*, *::before, *::after {
  max-width: 100%;
}

img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

/* ─── 2. HAMBURGER BUTTON ──────────────────────────────────────────────── */
/*
 * Base styles always applied — visibility toggled by media queries below.
 * Do NOT set display:none here; that is handled in section 8.
 */
.nav-hamburger {
  display: flex;               /* always flex-ready; section 8 hides on desktop */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: background 0.2s;
  flex-shrink: 0;
  z-index: 1100;
}
.nav-hamburger:hover {
  background: rgba(255,248,229,0.12);
}
.nav-hamburger-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-6, #fff8e5);
  border-radius: 2px;
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1),
              opacity 0.2s,
              width 0.25s;
}
/* Animated X state */
.nav-hamburger.is-open .nav-hamburger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-hamburger.is-open .nav-hamburger-bar:nth-child(2) {
  opacity: 0;
  width: 0;
}
.nav-hamburger.is-open .nav-hamburger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ─── 3. MOBILE MENU DRAWER ────────────────────────────────────────────── */
.nav-mobile-menu {
  display: none;
  position: fixed;
  top: 57px;
  left: 0;
  right: 0;
  z-index: 1050;
  background: transparent;
  padding: 0 24px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.38s cubic-bezier(0.4,0,0.2,1),
              padding 0.25s;
}
.nav-mobile-menu.is-open {
  max-height: 420px;
  padding: 20px 24px 28px;
}
.nav-mobile-link {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 0;
  font-family: var(--font-display, 'parabolica');
  font-style: italic;
  font-size: 22px;
  font-weight: 400;
  color: var(--color-6, #fff8e5);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,248,229,0.07);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.2s, padding-left 0.2s;
}
.nav-mobile-link:last-of-type {
  border-bottom: none;
}
.nav-mobile-link:hover {
  color: var(--color-4, #dbb90f);
  padding-left: 6px;
}
.nav-mobile-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,248,229,0.1);
}
.nav-mobile-actions .nav-login-btn,
.nav-mobile-actions .nav-register-btn {
  flex: 1;
  height: 44px;
  font-size: 15px;
  text-align: center;
  justify-content: center;
}

/* ─── 4. TABLET (≤ 768px) ──────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* ── NAV ── */
  .nav {
    padding: 0 20px;
    height: 57px;
  }

  .nav-links {
    display: none;              /* replaced by hamburger */
  }

  /* .nav-hamburger is display:flex by default; desktop media query hides it */

  .nav-user .nav-user-info {
    display: none;              /* hide name/subtitle, keep avatar */
  }

  /* ── HERO ── */
  .hero-content {
    padding: 80px 24px 60px;
  }
  .hero-title {
    font-size: clamp(38px, 8vw, 58px);
    line-height: 1;
  }
  .hero-subtitle {
    font-size: 15px;
    max-width: 100%;
  }
  .btn {
    height: 48px;               /* bigger touch target */
    padding: 0 24px;
    font-size: 16px;
  }

  /* ── PROBLEMA I SOLUCIÓ ── */
  .problema-section {
    padding: 12px;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
  }
  .problema-inner {
    padding-bottom: 48px;
  }
  .problema-header {
    padding: 40px 24px 0;
    margin-bottom: 36px;
  }
  .problema-body {
    grid-template-columns: 1fr;
    gap: 32px;
    min-height: unset;
    padding: 0 24px;
  }
  .problema-stats {
    padding-left: 0;
    padding-right: 0;
    gap: 28px;
    order: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .problema-stats .prob-stat:last-child {
    grid-column: 1 / -1;        /* full width for odd stat */
  }
  .problema-img-wrap {
    order: 1;
    height: auto;
    padding: 0;
  }
  .problema-img {
    width: 100%;
    height: auto;
    border-radius: 12px;
  }
  .problema-sol {
    order: 3;
    padding: 0;
    align-items: center;
  }
  .prob-desc {
    max-width: 100%;
  }

  /* ── LLETRA SECTION (3-col grid → vertical cards) ── */
  .lletra-section {
    padding: 40px 20px 60px;
  }
  .ll-step2 {
    grid-template-columns: 1fr !important; /* override hover :has() */
    height: auto;
    gap: 12px;
    transition: none;
  }
  .ll-step2:has(.ll-col-card:nth-child(1):hover),
  .ll-step2:has(.ll-col-card:nth-child(2):hover),
  .ll-step2:has(.ll-col-card:nth-child(3):hover) {
    grid-template-columns: 1fr !important;
  }
  .ll-col-card {
    height: auto;
    min-height: 220px;
    flex-direction: row;
    border-radius: 14px;
  }
  .ll-col-body {
    flex: 1;
    padding: 18px 16px;
    justify-content: center;
  }
  .ll-col-title {
    font-size: 22px;
    white-space: normal;
  }
  .ll-col-desc {
    max-height: none !important;
    opacity: 1 !important;
  }
  .ll-col-img {
    width: 130px;
    height: 100%;
    min-height: 160px;
    margin: 8px 8px 8px 0;
    flex-shrink: 0;
  }

  /* ── ENVELOPES CAROUSEL ── */
  .sobre-section {
    padding: 60px 0;
  }
  .sobre-section .section-title,
  .sobre-section .section-subtitle {
    padding: 0 24px;
  }
  .carousel-track {
    padding: 24px 24px 24px;
    gap: 20px;
  }
  .envelope-card img,
  .envelope-card .envelope-img-wrap img {
    width: 200px;
    height: 152px;
  }
  .envelope-card .envelope-img-wrap {
    width: 200px;
    height: 152px;
  }

  /* ── CENITAL SECTION ── */
  .cenital-section {
    height: 260px;
  }

  /* ── PLANS ── */
  .plans-section {
    padding: 48px 20px 56px;
  }
  .plans-grid {
    grid-template-columns: 1fr;
    max-width: 480px;
    margin: 0 auto;
    gap: 14px;
  }
  .plan-features {
    margin-left: -14px;
    margin-right: -14px;
  }

  /* ── OPINIONS CAROUSEL ── */
  .opinions-section {
    padding: 60px 0;
  }
  .opinions-section .section-title {
    padding: 0 24px;
  }
  .opinions-track {
    padding: 56px 24px 32px;
    gap: 16px;
  }
  .opinion-card {
    width: 260px;
    height: auto;
    min-height: 260px;
  }

  /* ── FOOTER ── */
  .footer {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    padding: 40px 24px;
  }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* ── STAMP PAGES (pagament, adreca_enviament) ── */
  .stamp-card {
    padding: 28px 20px 32px;
  }
  .pag-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .order-summary {
    order: -1;
  }
  .pay-methods {
    grid-template-columns: repeat(3, 1fr);
  }

  /* ── SOBRE PAGE (envelope selection) ── */
  .sobre-main {
    padding-top: calc(57px + 32px);
    overflow-y: auto;
  }
  .sobre-nav-btns {
    padding: 0 24px 16px;
  }
  .envelope-img-wrap {
    width: clamp(180px, 42vw, 260px);
    height: clamp(126px, 29.5vw, 182px);
  }
  .carousel-track {
    padding: 12px 40px 24px;
    gap: 20px;
  }

  /* ── AUTH MODAL ── */
  .auth-image {
    display: none;
  }
  .auth-modal {
    max-width: 100%;
    border-radius: 16px;
  }
  .auth-form {
    padding: 32px 24px;
  }
  .auth-row-2 {
    grid-template-columns: 1fr;
  }

  /* ── GALERIA ── */
  .galeria-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
  .galeria-main {
    padding: 60px 16px 60px;
  }

  /* ── PREVIA ESCRIU ── */
  .previa-main {
    padding: calc(57px + 20px) 16px 40px;
  }
  .previa-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 10px;
  }
}

/* ─── 5. MOBILE (≤ 480px) ─────────────────────────────────────────────── */
@media (max-width: 480px) {

  /* ── NAV ── */
  .nav {
    padding: 0 16px;
  }
  .nav-logo {
    height: 28px;
  }

  /* ── HERO ── */
  .hero-content {
    padding: 72px 16px 48px;
  }
  .hero-title {
    font-size: clamp(34px, 9.5vw, 46px);
    line-height: 1;
    margin-bottom: 20px;
  }
  .hero-subtitle {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 28px;
  }
  .btn {
    width: 100%;
    max-width: 320px;
    justify-content: center;
    height: 50px;
    font-size: 16px;
  }

  /* ── PROBLEMA I SOLUCIÓ ── */
  .problema-section {
    padding: 8px;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
  }
  .problema-header {
    padding: 28px 16px 0;
    margin-bottom: 24px;
  }
  .problema-body {
    padding: 0 16px;
    gap: 24px;
  }
  .problema-stats {
    grid-template-columns: 1fr;   /* single column on small mobile */
  }
  .problema-stats .prob-stat:last-child {
    grid-column: 1;
  }
  .prob-num {
    font-size: clamp(30px, 8vw, 44px);
  }

  /* ── LLETRA ── */
  .lletra-section {
    padding: 32px 16px 48px;
  }
  .ll-col-card {
    min-height: 180px;
  }
  .ll-col-img {
    width: 110px;
    min-height: 140px;
  }
  .ll-col-title {
    font-size: 20px;
  }

  /* ── ENVELOPES CAROUSEL ── */
  .sobre-section {
    padding: 48px 0;
  }
  .carousel-track {
    padding: 20px 16px;
    gap: 14px;
  }
  .envelope-card img,
  .envelope-card .envelope-img-wrap img {
    width: 170px;
    height: 130px;
  }
  .envelope-card .envelope-img-wrap {
    width: 170px;
    height: 130px;
  }
  .envelope-label {
    font-size: 13px;
  }

  /* ── CENITAL ── */
  .cenital-section {
    height: 200px;
  }

  /* ── PLANS ── */
  .plans-section {
    padding: 36px 16px 44px;
  }
  .plan-card {
    padding: 20px 20px 16px;
    border-radius: 18px;
  }
  .plan-name {
    font-size: 30px;
  }
  .price-num {
    font-size: 42px;
  }
  .plan-features {
    margin-left: -6px;
    margin-right: -6px;
    border-radius: 12px;
  }
  .plans-grid {
    max-width: 100%;
  }

  /* ── OPINIONS ── */
  .opinions-track {
    padding: 48px 16px 24px;
    gap: 12px;
  }
  .opinion-card {
    width: 240px;
    padding: 52px 14px 20px;
  }

  /* ── FOOTER ── */
  .footer {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 36px 20px;
    gap: 20px;
  }
  .footer-social {
    justify-content: center;
  }
  .footer-bottom {
    align-items: center;
    text-align: center;
  }

  /* ── STAMP PAGES ── */
  .stamp-card {
    padding: 22px 16px 26px;
    --d: 10px;
  }
  .pag-title {
    font-size: clamp(1.6rem, 7vw, 2.4rem);
    margin-bottom: 18px;
  }
  .form-input {
    font-size: 16px; /* prevents iOS zoom */
  }
  .form-row {
    grid-template-columns: 1fr;   /* stack CP + Ciutat */
  }
  .btn-confirmar {
    font-size: 15px;
    padding: 16px;
  }
  .pay-methods {
    grid-template-columns: 1fr 1fr;
  }
  .pay-method:last-child {
    grid-column: span 2;
  }

  /* ── CONFIRMACIÓ PAGE ── */
  .conf-wrap {
    padding: 32px 18px 28px;
    --d: 9px;
  }
  .conf-title {
    font-size: clamp(1.3rem, 6vw, 1.8rem);
  }

  /* ── SOBRE PAGE ── */
  .sobre-main {
    padding-left: 12px;
    padding-right: 12px;
  }
  .sobre-nav-btns {
    padding: 0 16px 12px;
  }
  .nav-btn-page {
    font-size: 13px;
    padding: 0 14px;
    height: 42px;
  }

  /* ── GALERIA ── */
  .galeria-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* ── AUTH MODAL ── */
  .auth-form {
    padding: 28px 18px;
  }
  .auth-title {
    font-size: 26px;
    margin-bottom: 18px;
  }
  .auth-btn-primary,
  .auth-btn-google {
    height: 48px;
    font-size: 15px;
  }
  .auth-input {
    height: 46px;
    font-size: 16px; /* prevents iOS zoom */
  }

  /* ── ESCRIU PREVIA ── */
  .previa-header {
    align-items: center;
  }
  .previa-btn-nova {
    font-size: 15px;
    padding: 10px 16px;
  }

  /* ── SECTION COMMONS ── */
  .section {
    padding: 48px 16px;
  }
  .section-title {
    font-size: clamp(24px, 6vw, 34px);
    margin-bottom: 8px;
  }
  .section-subtitle {
    font-size: 16px;
    margin-bottom: 36px;
  }
}

/* ─── 6. SMALL MOBILE (≤ 375px) ─────────────────────────────────────────── */
@media (max-width: 375px) {

  .nav-logo {
    height: 25px;
  }
  .hero-title {
    font-size: 32px;
  }
  .hero-subtitle {
    font-size: 13px;
  }
  .btn {
    font-size: 15px;
    height: 48px;
  }

  .envelope-card img,
  .envelope-card .envelope-img-wrap img {
    width: 148px;
    height: 113px;
  }
  .envelope-card .envelope-img-wrap {
    width: 148px;
    height: 113px;
  }

  .opinion-card {
    width: 210px;
  }

  .galeria-grid {
    gap: 8px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .plans-grid {
    gap: 10px;
  }

  .sobre-nav-btns {
    gap: 8px;
  }
  .nav-btn-page {
    padding: 0 12px;
    font-size: 12px;
    gap: 6px;
  }
  .nav-btn-page svg {
    width: 15px;
    height: 15px;
  }
}

/* ─── 7. TABLET LANDSCAPE / MEDIUM (769px – 1024px) ─────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {

  .nav {
    padding: 0 28px;
  }
  .nav-links {
    gap: 20px;
  }
  .nav-btn {
    font-size: 17px;
  }

  .hero-title {
    font-size: clamp(46px, 6.5vw, 66px);
  }

  .problema-body {
    grid-template-columns: 1fr 400px 1fr;
    min-height: 500px;
  }
  .problema-img-wrap {
    height: 500px;
  }
  .problema-img {
    width: 400px;
  }
  .problema-stats {
    padding-left: 32px;
    padding-right: 16px;
  }
  .problema-sol {
    padding: 0 16px 0 16px;
  }

  .ll-step2 {
    height: 380px;
  }
  .ll-col-title {
    font-size: 24px;
  }

  .plans-section {
    padding: 60px 32px;
  }
  .plans-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    max-width: 720px;
  }
  .plans-grid .plan-card:last-child {
    grid-column: 1 / -1;         /* plus plan full-width */
  }

  .footer {
    padding: 48px 32px;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
  }
  .footer-bottom {
    flex-direction: row;
  }
}

/* ─── 8. MOBILE MENU VISIBILITY CONTROL ─────────────────────────────────── */
/*
 * Desktop (≥769px): hide hamburger and drawer.
 * Mobile (≤768px):  hamburger visible (display:flex already set in base);
 *                   drawer uses display:block but height controlled by max-height.
 */
@media (min-width: 769px) {
  .nav-hamburger {
    display: none !important;
  }
  .nav-mobile-menu {
    display: none !important;
  }
}

@media (max-width: 768px) {
  /* Drawer is block but collapses to height 0 until .is-open is added by JS */
  .nav-mobile-menu {
    display: block;
  }
  /* Hamburger inherits display:flex from base styles — nothing extra needed */
}

/* ─── 9. TOUCH IMPROVEMENTS ─────────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* On touch devices, always show lletra desc (no hover) */
  .ll-col-desc {
    max-height: none !important;
    opacity: 1 !important;
    transition: none !important;
  }
  .ll-col-num {
    color: rgba(87, 54, 14, 0.08) !important;
    transition: none !important;
  }
  /* Bigger touch targets */
  .nav-btn,
  .btn,
  .btn-confirmar,
  .auth-btn-primary,
  .auth-btn-google,
  .nav-btn-page,
  .previa-btn-nova,
  .previa-btn-cta {
    min-height: 44px;
  }
  /* Carousels should be easily swipeable */
  .carousel-track,
  .opinions-track {
    cursor: auto;
  }
  .carousel-track:active,
  .opinions-track:active {
    cursor: auto;
  }
  /* Galeria hover overlay → always slightly visible */
  .galeria-card__overlay {
    opacity: 0;
  }
}

/* ─── 10. REDUCED MOTION ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
