/* === Mobile refinements ===
   Tightens layout, typography, spacing and touch targets for ≤760px.
   Loaded last so it overrides components.css safely.
*/

/* === Tablets and below (≤760px) === */
@media (max-width: 760px) {

  /* Tighten gutter and section rhythm */
  :root {
    --gutter: 1.125rem;
    --section-y: 3.75rem;
  }

  /* Topbar — compact */
  .topbar {
    padding: 0.875rem var(--gutter);
  }
  .topbar.is-scrolled {
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }
  .brand { font-size: 1.0625rem; gap: 0.5rem; }
  .brand .dot { width: 5px; height: 5px; }
  .topbar-actions { gap: 0.625rem; }
  .lang-toggle { font-size: 0.6875rem; }
  .lang-toggle button { padding: 0.375rem 0.25rem; min-width: 28px; }
  .menu-trigger { width: 44px; height: 44px; } /* WCAG touch target */

  /* Drawer */
  .drawer { padding: 5.5rem 1.25rem 1.25rem; gap: 1rem; }
  .drawer a { font-size: 1.625rem; line-height: 1.15; }
  .drawer .close { font-size: 0.75rem; }

  /* Hero */
  .hero {
    padding-top: 5.5rem;
    padding-bottom: 3.5rem;
  }
  .hero-grid { gap: 2rem; }
  .hero-eyebrow { margin-bottom: 1.25rem; }
  .hero-title {
    font-size: clamp(2.5rem, 12vw, 4.25rem) !important;
    line-height: 0.98;
    letter-spacing: -0.025em;
    margin-bottom: 1.25rem;
  }
  .hero-sub { font-size: 1rem; max-width: 100%; margin-bottom: 1rem; }
  .hero-text { font-size: 0.9375rem; max-width: 100%; margin-bottom: 1.75rem; line-height: 1.7; }

  /* Hero portrait — smaller on mobile so it doesn't eat the whole screen */
  .hero-portrait {
    aspect-ratio: 5/6;
    max-height: 60vh;
    margin: 0 auto;
    max-width: 480px;
    width: 100%;
  }
  .hero-portrait .badge {
    left: 1rem; bottom: 1rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.6875rem;
  }
  /* Hero actions — stack and full-width */
  .hero-actions { flex-direction: column; gap: 0.75rem; align-items: stretch; }
  .hero-actions .btn { justify-content: center; width: 100%; }

  /* Section padding */
  .section { padding-top: 3.5rem; padding-bottom: 3.5rem; }
  .section--tight { padding-top: 2.5rem; padding-bottom: 2.5rem; }

  /* Section heading stacks */
  .section-head {
    grid-template-columns: 1fr;
    gap: 1rem !important;
    margin-bottom: 2.25rem;
  }
  .section-head h2 { max-width: 100%; }

  /* Eyebrow */
  .eyebrow { font-size: 0.6875rem; letter-spacing: 0.18em; }

  /* Pillars — single column on small */
  .pillars { grid-template-columns: 1fr !important; }
  .pillar { padding: 1.75rem 1.25rem; min-height: auto; gap: 0.875rem; }
  .pillar h3 { font-size: 1.25rem; }
  .pillar p { font-size: 0.875rem; }

  /* Duo blocks stack */
  .duo { grid-template-columns: 1fr !important; gap: 2rem; }
  .duo--reverse > *:first-child { order: 0; }

  /* Eco-graphic — keep aspect tight */
  .eco-graphic { padding: 1.5rem; aspect-ratio: 1; }
  .eco-rings { max-width: 280px; }
  .eco-rings .core { font-size: 1.375rem; }
  .eco-rings .core small { font-size: 0.6875rem; letter-spacing: 0.16em; }

  /* Stats — 2 columns max on mobile */
  .stats { grid-template-columns: repeat(2, 1fr) !important; }
  .stat { padding: 1.25rem 1rem; }
  .stat .num { font-size: clamp(1.75rem, 8vw, 2.25rem); }
  .stat .label { font-size: 0.6875rem; letter-spacing: 0.14em; }

  /* Articles single column */
  .articles { grid-template-columns: 1fr !important; gap: 1rem; }
  .article-card { padding: 1.5rem; gap: 0.875rem; }
  .article-card h3 { font-size: 1.25rem; }

  /* Pullquote */
  .pullquote {
    font-size: clamp(1.25rem, 5vw, 1.625rem);
    padding-left: 1rem;
    line-height: 1.35;
  }

  /* Wise Hands card */
  .wh-card { grid-template-columns: 1fr !important; }
  .wh-card .wh-content { padding: 1.75rem 1.5rem; }
  .wh-card h2 { font-size: clamp(1.5rem, 6vw, 2rem); }
  .wh-card .wh-visual { min-height: 240px; }
  .wh-card .wh-visual svg, .wh-card .wh-visual img { width: 50%; max-width: 180px; }

  /* Newsletter */
  .newsletter {
    grid-template-columns: 1fr !important;
    padding: 2rem 1.5rem !important;
    gap: 1.5rem;
  }
  .newsletter form {
    flex-direction: column;
    background: transparent;
    border: 0;
    padding: 0;
    gap: 0.625rem;
  }
  .newsletter input {
    border: 1px solid var(--color-line-strong);
    background: var(--color-bg);
    border-radius: var(--r-pill);
    padding: 0.875rem 1.125rem;
    width: 100%;
    color: var(--color-ink);
  }
  .newsletter .btn { width: 100%; justify-content: center; }

  /* Marquee */
  .marquee { padding: 1rem 0; }
  .marquee-track { font-size: clamp(1.25rem, 6vw, 1.75rem); gap: 2.5rem; }
  .marquee-track span { gap: 2.5rem; }

  /* Footer */
  .footer { padding: 3rem 0 1.5rem; }
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 1.75rem;
    padding-bottom: 1.75rem;
  }
  .footer-grid > *:first-child { grid-column: 1 / -1; }
  .footer .signature { font-size: 1.5rem; max-width: 100%; }
  .footer h4 { margin-bottom: 0.75rem; }
  .footer ul { gap: 0.625rem; }
  .footer ul a { padding: 0.25rem 0; display: inline-block; } /* easier tap */
  .footer-base {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    font-size: 0.6875rem;
  }

  /* Long-form */
  .long-form { font-size: 1rem; }
  .long-form p { margin-bottom: 1rem; }
  .long-form h2 { font-size: clamp(1.5rem, 6vw, 2rem); }

  /* Areas list */
  .areas-list li {
    padding: 1rem 0;
    font-size: 1rem;
  }

  /* Forms (contato) */
  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  .field--full { grid-column: 1 / -1; }
  .field input, .field textarea, .field select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem; /* prevent iOS zoom on focus */
  }
  .field label {
    font-size: 0.8125rem;
    letter-spacing: 0.08em;
  }
  .form-actions { flex-direction: column; gap: 0.75rem; }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* Search field on blog */
  .search-field input { font-size: 1rem; padding: 0.875rem 1rem 0.875rem 3rem; }

  /* Useful links cards */
  .useful-links { grid-template-columns: 1fr !important; gap: 0.75rem; }
  .useful-link { padding: 1rem 1.25rem; }

  /* Photo grid (midia) */
  .photo-grid { grid-template-columns: 1fr !important; gap: 1rem; }

  /* Recent list */
  .recent-list { grid-template-columns: 1fr !important; }

  /* Weekly tile */
  .weekly { grid-template-columns: 1fr !important; }

  /* Article hero */
  .article-hero { padding-top: 6rem; padding-bottom: 1rem; }
  .article-hero h1 { font-size: clamp(1.75rem, 7vw, 2.5rem); line-height: 1.1; }

  /* Article body typography */
  .article-body { font-size: 1rem; line-height: 1.7; }
  .article-body p { margin-bottom: 1rem; }
  .article-body h2 { font-size: clamp(1.5rem, 6vw, 1.875rem); margin-top: 2.25rem; }
  .article-body h3 { font-size: 1.25rem; margin-top: 1.75rem; }
  .article-body p:first-of-type::first-letter {
    font-size: 3.25rem;
    line-height: 1;
    padding-right: 0.25rem;
  }

  /* CTAs in CTA-final blocks — full width and stacked */
  .container--narrow > div[style*="inline-flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .container--narrow > div[style*="inline-flex"] .btn {
    width: 100%;
    justify-content: center;
  }

  /* Larger touch targets for all .btn */
  .btn {
    padding: 0.875rem 1.25rem;
    min-height: 44px;
    font-size: 0.9375rem;
  }

  /* Disable horizontal section number markers (cluttered) */
  .section[data-num]::before { display: none; }

  /* Disable expensive aurora animation on small devices to save battery */
  .aurora::before { animation-duration: 40s; opacity: 0.4; }
  .aurora::after  { animation-duration: 50s; opacity: 0.4; }

  /* Keep grain but lighter */
  .grain { opacity: 0.06; }
}

/* === Very narrow phones (≤380px) === */
@media (max-width: 380px) {
  :root {
    --gutter: 1rem;
  }
  .brand span:not(.dot) { font-size: 1rem; }
  .lang-toggle .sep { display: none; }
  .hero-title { font-size: clamp(2.25rem, 11vw, 3.5rem) !important; }
  .pillar { padding: 1.5rem 1rem; }
  .article-card { padding: 1.25rem; }
  .stat .num { font-size: 1.625rem; }
}

/* === Ultra narrow safety net (≤360px, e.g. iPhone SE in PWA) === */
@media (max-width: 360px) {
  /* Allow manifesto lines to wrap if they would overflow the viewport.
     Prefers breaking at word boundary; word-break as fallback. */
  .hero-title .split-line > span {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: keep-all;
  }
  .hero-title { font-size: clamp(2rem, 10vw, 3rem) !important; }
  .footer-grid { gap: 1rem; }
}

/* === Hide footer ".desktop-only" markers if ever there are === */
@media (max-width: 760px) {
  .desktop-only { display: none !important; }
}

/* === Prevent horizontal overflow === */
html, body { overflow-x: hidden; }

/* === Improve tap delay === */
a, button, input[type="submit"] {
  touch-action: manipulation;
}

/* === Better focus on touch === */
@media (hover: none) {
  .btn:active { transform: scale(0.98); }
  .pillar:active { background: var(--color-bg-elev-2); }
  .article-card:active { transform: translateY(-2px); }
}
