/* ============================================
   MOBILE OPTIMIZATION — Terraplanagem Pelo Brasil
   Loaded after style.min.css to override desktop-first rules.
   ============================================ */

/* --- TABLET (max-width: 900px) --- */
@media (max-width: 900px) {
  .header__nav {
    padding-inline: 1rem;
  }

  .header__logo {
    font-size: 1.1rem;
    max-width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hero__content {
    padding-block: 6rem 3rem;
  }

  .hero__title {
    font-size: clamp(2rem, 6vw, 3rem);
  }

  .hero__desc {
    font-size: 1rem;
  }

  .why-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .why-grid__desc {
    font-size: 0.95rem;
  }

  .services-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
  }

  .testimonials-grid {
    grid-template-columns: 1fr;
  }

  .location-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .location-map iframe {
    width: 100%;
    height: 300px;
  }

  .footer__grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer__bottom {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .about__text {
    columns: 1;
  }
}

/* --- MOBILE (max-width: 640px) --- */
@media (max-width: 640px) {
  :root {
    --section-pad: 3rem 0;
    --section-pad-lg: 3.5rem 0;
    --section-pad-sm: 2rem 0;
    --gap: 1.25rem;
  }

  body {
    font-size: 0.95rem;
    line-height: 1.65;
  }

  .container {
    padding-inline: 1rem;
  }

  /* HEADER MOBILE */
  .header__nav {
    height: 3.75rem;
    padding-inline: 0.75rem;
  }

  .header__logo {
    font-size: 0.95rem;
    max-width: 70%;
    letter-spacing: 0.02em;
  }

  .header__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .header__mobile {
    padding: 0.75rem 1rem 1.5rem;
  }

  .header__mobile a {
    padding: 0.875rem 0;
    font-size: 1.05rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* HERO MOBILE */
  .hero {
    min-height: 85vh;
  }

  .hero__content {
    padding-block: 5rem 2.5rem;
  }

  .hero__tagline {
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
  }

  .hero__title {
    font-size: 1.85rem;
    line-height: 1.15;
    margin-bottom: 1rem;
  }

  .hero__desc {
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 1.75rem;
  }

  .hero__cta {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .hero__cta .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
  }

  /* SECTION HEADERS */
  .section__title {
    font-size: clamp(1.4rem, 5vw, 1.8rem);
  }

  .section__subtitle {
    font-size: 0.85rem;
    letter-spacing: 0.1em;
  }

  .section__header {
    margin-bottom: 2rem;
  }

  /* BUTTONS */
  .btn {
    min-height: 48px;
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
  }

  /* CARDS */
  .services-grid,
  .diff-grid,
  .contact-grid,
  .testimonials-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .service-card__img-wrap {
    height: 10rem;
  }

  .service-card__body {
    padding: 1.25rem;
  }

  .service-card__title {
    font-size: 1.05rem;
  }

  .service-card__desc {
    font-size: 0.85rem;
  }

  .diff-card {
    padding: 1.5rem;
  }

  .diff-card__icon {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
  }

  .diff-card__title {
    font-size: 1rem;
  }

  .diff-card__desc {
    font-size: 0.85rem;
  }

  /* CONTACT CARDS */
  .contact-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .contact-card {
    padding: 1.25rem 1rem;
  }

  .contact-card__icon {
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 0.75rem;
  }

  .contact-card__title {
    font-size: 0.85rem;
  }

  .contact-card__link {
    font-size: 0.8rem;
    word-break: break-word;
  }

  /* TESTIMONIALS */
  .testimonial-card {
    padding: 1.5rem;
  }

  .testimonial-card__text {
    font-size: 0.9rem;
  }

  /* LOCATION / MAP */
  .location-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .location-map {
    border-radius: var(--radius-md);
  }

  .location-map iframe {
    width: 100%;
    height: 250px;
  }

  .location-list li {
    padding: 0.4rem 0;
    font-size: 0.9rem;
  }

  /* FOOTER */
  .footer {
    padding-top: 3rem;
  }

  .footer__grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .footer__logo {
    font-size: 1.1rem;
  }

  .footer__heading {
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }

  .footer__links a,
  .footer__links p {
    font-size: 0.85rem;
    min-height: 40px;
    display: flex;
    align-items: center;
  }

  .footer__bottom {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    padding: 1.25rem 0;
    font-size: 0.75rem;
  }

  /* WHATSAPP FAB */
  .whatsapp-fab {
    width: 3.25rem;
    height: 3.25rem;
    bottom: 1rem;
    right: 1rem;
  }

  .whatsapp-fab svg {
    width: 22px;
    height: 22px;
  }

  /* FORM (orçamento) */
  .form-group {
    margin-bottom: 1.25rem;
  }

  .form-input,
  .form-textarea,
  .form-select {
    padding: 0.75rem 0.875rem;
    font-size: 1rem;
    min-height: 48px;
  }

  .form-textarea {
    min-height: 120px;
  }

  /* ABOUT PAGE */
  .about__text {
    columns: 1;
  }

  .about__text p {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }

  /* INLINE STYLES OVERRIDE — many pages use inline grids */
  [style*="grid-template-columns: repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(auto-fill"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  [style*="display: grid"][style*="gap: 2rem"] {
    gap: 1.25rem !important;
  }

  /* Fix inline font sizes that are too big */
  [style*="font-size: 2.5rem"],
  [style*="font-size:2.5rem"] {
    font-size: 1.75rem !important;
  }

  [style*="font-size: 3rem"],
  [style*="font-size:3rem"] {
    font-size: 2rem !important;
  }

  [style*="font-size: 2.2rem"],
  [style*="font-size:2.2rem"] {
    font-size: 1.5rem !important;
  }

  [style*="font-size: 2rem"],
  [style*="font-size:2rem"] {
    font-size: 1.5rem !important;
  }

  [style*="font-size: 1.8rem"],
  [style*="font-size:1.8rem"] {
    font-size: 1.3rem !important;
  }

  /* Fix inline padding that is too generous */
  [style*="padding: 3rem"],
  [style*="padding:3rem"] {
    padding: 1.5rem !important;
  }

  [style*="padding: 4rem"],
  [style*="padding:4rem"] {
    padding: 2rem 1rem !important;
  }

  /* FAQ / details  */
  details {
    padding: 1rem;
    font-size: 0.9rem;
  }

  details summary {
    font-size: 0.95rem;
    line-height: 1.4;
    padding-right: 1.5rem;
  }

  /* Blog page specifics */
  #blog-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  /* Padding-top fix for non-hero pages on mobile */
  [style*="padding-top: 7rem"] {
    padding-top: 5rem !important;
  }

  [style*="padding-top:7rem"] {
    padding-top: 5rem !important;
  }
}

/* --- SMALL MOBILE (max-width: 380px) --- */
@media (max-width: 380px) {
  .header__logo {
    font-size: 0.8rem;
  }

  .hero__title {
    font-size: 1.6rem;
  }

  .hero__desc {
    font-size: 0.85rem;
  }

  .section__title {
    font-size: 1.3rem;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    font-size: 0.85rem;
    padding: 0.75rem 1.25rem;
  }
}

/* --- TOUCH & INTERACTION --- */
@media (hover: none) and (pointer: coarse) {
  .service-card:hover,
  .diff-card:hover,
  .testimonial-card:hover,
  .contact-card:hover {
    transform: none;
    box-shadow: var(--shadow-card);
  }

  .service-card:hover .service-card__img-wrap img {
    transform: none;
  }

  .btn:hover::after {
    opacity: 0;
  }

  .whatsapp-fab:hover {
    transform: none;
  }

  .service-card:active,
  .diff-card:active {
    transform: scale(0.98);
    transition: transform 0.1s;
  }
}

/* --- LANDSCAPE MOBILE --- */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    min-height: 100vh;
  }

  .hero__content {
    padding-block: 4.5rem 2rem;
  }

  .hero__title {
    font-size: 1.5rem;
  }

  .hero__desc {
    display: none;
  }
}

/* --- SAFE AREA (notch/island) --- */
@supports (padding: env(safe-area-inset-bottom)) {
  .whatsapp-fab {
    bottom: calc(1rem + env(safe-area-inset-bottom));
    right: calc(1rem + env(safe-area-inset-right));
  }

  .header {
    padding-top: env(safe-area-inset-top);
  }

  .footer__bottom {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}

/* --- REDUCE 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;
  }

  .whatsapp-fab {
    animation: none;
  }
}
