/* ============================================================
   CRIAVIART — RESPONSIVE GLOBAL
   Regra de ouro: só adicionar, nunca duplicar o que os CSS
   individuais (portfolio.css, loja.css, contacto.css) já fazem.
   Foco: corrigir somente lacunas e conflitos reais.
   ============================================================ */

/* ------------------------------------------------------------------
   PREVENÇÃO GLOBAL de overflow horizontal
   ------------------------------------------------------------------ */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

img {
  max-width: 100%;
  height: auto;
}

iframe {
  max-width: 100%;
}

h1, h2, h3, h4, h5, h6, p {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ------------------------------------------------------------------
   992px — Tablets
   ------------------------------------------------------------------ */
@media (max-width: 992px) {
  /* Trabalhos grid (index.html) */
  .trabalhos-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 16px;
  }

  /* Thinking layout (nossos valores) */
  .thinking-layout {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .thinking-copy {
    text-align: center;
  }

  .thinking-copy p {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  /* Valores grid fica em coluna única */
  .valores-grid {
    gap: 14px;
  }
}

/* ------------------------------------------------------------------
   768px — Mobile landscape / tablets pequenos
   Aqui os CSS individuais já tratam muito — apenas complementamos.
   ------------------------------------------------------------------ */
@media (max-width: 768px) {
  /* Trabalhos grid */
  .trabalhos-recentes {
    padding: 60px 0;
  }

  .trabalhos-grid {
    grid-template-columns: 1fr;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 16px;
  }

  /* Footer contacts em coluna */
  .footer-contact ul {
    flex-direction: column;
    gap: 16px;
    align-items: center;
  }

  /* CTA section (styles.css já tem, mas confirmar padding) */
  .cta-content {
    padding: 28px 18px;
    border-radius: 18px;
  }

  .cta-content h3 {
    font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  }

  /* Home CTA card */
  .home-cta-card {
    margin: 60px auto 30px;
    padding: 30px 18px;
    border-radius: 16px;
  }

  /* Sobre stats horizontal → vertical */
  .sobre-stats {
    flex-direction: column;
    gap: 18px;
    padding: 18px 16px;
  }
}

/* ------------------------------------------------------------------
   576px — Smartphones
   ------------------------------------------------------------------ */
@media (max-width: 576px) {
  /* Container lateral padding */
  .container {
    padding-left: 14px;
    padding-right: 14px;
  }

  /* Hero (index.html) — título e botões */
  .hero h1 {
    font-size: clamp(1.6rem, 7vw, 2rem);
  }

  .hero p {
    font-size: 0.9rem;
  }

  .hero-buttons {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .hero-buttons .btn {
    width: min(100%, 320px);
    text-align: center;
  }

  /* Section tags menores */
  .section-tag {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  /* Section headers */
  .section-header h2 {
    font-size: clamp(1.3rem, 5vw, 1.6rem);
  }

  /* Contact form — row → column (contacto.css já faz 768, aqui reforçamos) */
  .form-grid-new {
    grid-template-columns: 1fr;
  }

  /* Sobre info */
  .sobre-info h2 {
    font-size: 1.4rem;
  }

  .sobre-stats {
    padding: 14px 12px;
    border-radius: 12px;
    gap: 14px;
  }

  .stat-number {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.82rem;
  }

  /* Futuro cards */
  .futuro-card {
    padding: 26px 18px;
  }

  .futuro-card h4 {
    font-size: 1.15rem;
  }

  /* Parceiros */
  .parceiro-item {
    width: 130px;
    height: 80px;
    padding: 12px;
  }

  /* Toast position */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 20px;
  }

  body.loja-page .toast-container {
    bottom: 90px;
  }

  /* Cart mini — full width on very small screens */
  .cart-mini-dropdown {
    width: calc(100vw - 16px);
  }
}

/* ------------------------------------------------------------------
   480px — Smartphones pequenos
   ------------------------------------------------------------------ */
@media (max-width: 480px) {
  /* Hero */
  .hero h1 {
    font-size: clamp(1.45rem, 6.5vw, 1.8rem);
  }

  .hero-grid {
    padding: 1.4rem 1rem;
    border-radius: 16px;
  }

  /* Secções padding */
  .servicos,
  .futuros {
    padding: 55px 0;
  }

  /* Mission Vision cards */
  .mv-item {
    padding: 20px;
    min-height: auto;
  }

  .mv-number {
    width: 38px;
    height: 38px;
    font-size: 0.75rem;
    margin-bottom: 16px;
  }

  .mv-item h3 {
    font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  }

  /* Valor card — desfazer grid lateral */
  .valor-card {
    grid-template-columns: 48px 1fr;
    padding: 18px;
    gap: 14px;
    border-radius: 18px;
  }

  .valor-number {
    font-size: 1.6rem;
  }

  .valor-card h3 {
    font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  }

  .valor-card p {
    font-size: 0.86rem;
  }

  /* Thinking section */
  .thinking-copy h2 {
    font-size: clamp(1.5rem, 6.5vw, 2rem);
  }

  /* Home CTA */
  .home-cta-card {
    margin: 40px auto 24px;
    padding: 24px 14px;
    border-radius: 14px;
  }

  .home-cta-card h2 {
    font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  }

  /* Trabalhos card */
  .trabalho-info {
    padding: 14px 16px 18px;
  }

  .trabalho-info h3 {
    font-size: 0.98rem;
  }

  .trabalho-info p {
    font-size: 0.84rem;
  }

  /* FAQ */
  .faq-question {
    padding: 16px 14px;
    gap: 14px;
  }

  .faq-answer {
    padding: 0 14px 16px;
    font-size: 0.9rem;
  }

  /* Cart mini actions */
  .cart-mini-actions {
    grid-template-columns: 1fr;
  }

  .cart-mini-btn--primary {
    min-height: 50px;
  }

  /* Floating cart */
  .floating-cart {
    width: 54px;
    height: 54px;
    bottom: 20px;
    right: 18px;
  }

  .floating-cart i {
    font-size: 1.3rem;
  }
}

/* ------------------------------------------------------------------
   400px — Muito pequenos
   ------------------------------------------------------------------ */
@media (max-width: 400px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .hero h1 {
    font-size: 1.35rem;
  }

  .hero p {
    font-size: 0.84rem;
  }

  .btn,
  .btn-primary,
  .btn-outline,
  .btn-card {
    font-size: 0.78rem;
    padding: 10px 18px;
    letter-spacing: 0.4px;
  }

  /* Valor card — coluna única */
  .valor-card {
    grid-template-columns: 1fr;
  }

  /* Section header */
  .section-header h2 {
    font-size: clamp(1.15rem, 5vw, 1.4rem);
  }

  .section-header p {
    font-size: 0.84rem;
  }

  /* Servico card */
  .servico-card {
    padding: 24px 16px;
    border-radius: 16px;
  }

  .card-icon {
    width: 66px;
    height: 66px;
    font-size: 1.9rem;
  }

  /* Footer */
  .footer {
    padding: 16px 12px 28px;
  }

  .textfooter {
    font-size: 0.76rem;
    padding: 10px 8px;
  }

  .social-link {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  /* Toast */
  .toast {
    padding: 11px 14px;
    font-size: 0.84rem;
  }
}

/* ------------------------------------------------------------------
   360px — Telemóveis antigos / Galaxy S min
   ------------------------------------------------------------------ */
@media (max-width: 360px) {
  .container {
    padding-left: 10px;
    padding-right: 10px;
  }

  .hero {
    padding: 6rem 0 1.5rem;
  }

  .hero h1 {
    font-size: 1.2rem;
    letter-spacing: -0.02em;
  }

  .hero p {
    font-size: 0.8rem;
  }

  .hero-grid {
    padding: 1.2rem 0.75rem;
    border-radius: 14px;
  }

  .btn,
  .btn-primary,
  .btn-outline,
  .btn-card {
    font-size: 0.72rem;
    padding: 9px 16px;
    min-height: 38px;
    letter-spacing: 0.3px;
  }

  .section-header h2 {
    font-size: 1.1rem;
  }

  .home-cta-card {
    padding: 20px 12px;
    margin: 30px auto 20px;
    border-radius: 12px;
  }

  .home-cta-card h2 {
    font-size: 1rem;
  }

  .cta-content {
    padding: 20px 14px;
    border-radius: 14px;
  }

  .cta-content h3 {
    font-size: 1rem;
  }

  /* Footer */
  .footer h3 {
    font-size: 1rem;
  }

  .footer-contact ul li span {
    font-size: 0.82rem;
    white-space: normal;
  }

  .textfooter {
    font-size: 0.7rem;
  }

  /* Cart mini */
  .cart-mini-item-thumb {
    width: 60px;
    height: 60px;
  }

  .cart-mini-item-title {
    font-size: 0.84rem;
  }
}

/* ------------------------------------------------------------------
   320px — Ecrã mínimo absoluto
   ------------------------------------------------------------------ */
@media (max-width: 320px) {
  .container {
    padding-left: 8px;
    padding-right: 8px;
  }

  .nav-container {
    padding: 6px 10px;
  }

  .header-logo {
    height: 36px;
    width: 88px;
  }

  .hero {
    padding: 5.5rem 0 1.2rem;
  }

  .hero h1 {
    font-size: 1.05rem;
  }

  .hero p {
    font-size: 0.76rem;
  }

  .section-header h2 {
    font-size: 1rem;
  }

  .btn,
  .btn-primary,
  .btn-outline,
  .btn-card {
    font-size: 0.68rem;
    padding: 8px 14px;
    min-height: 36px;
  }

  .home-cta-card {
    padding: 18px 10px;
    border-radius: 10px;
  }

  .home-cta-card h2 {
    font-size: 0.95rem;
  }

  .cta-content {
    padding: 18px 12px;
    border-radius: 12px;
  }

  .textfooter {
    font-size: 0.65rem;
  }
}

/* Tamanho unico para os titulos principais do home no mobile. */
@media (max-width: 768px) {
  .hero-content {
    padding-top: 0.95rem;
  }

  .mission-vision {
    gap: 16px;
    width: 92%;
    margin-left: auto;
    margin-right: auto;
  }

  .services-offset-grid,
  .valores-grid {
    width: 92%;
    margin-left: auto;
    margin-right: auto;
  }

  .mv-item {
    min-height: 0;
    padding: 24px;
  }

  .mv-item::after {
    right: -24px;
    bottom: -24px;
    width: 72px;
    height: 72px;
    z-index: 0;
  }

  .mv-item > * {
    position: relative;
    z-index: 1;
  }

  .mv-item h3,
  .valor-card h3,
  .card-body h2 {
    font-size: 1.05rem;
    line-height: 1.25;
  }

  .mv-item h3 {
    margin-bottom: 12px;
  }

  .mv-item p,
  .valor-card p,
  .card-body p {
    font-size: 0.92rem;
    line-height: 1.55;
  }

  .card-body {
    padding: 30px 24px 24px;
  }

  .hero h1 {
    width: min(100%, 380px);
    margin-left: auto;
    margin-right: auto;
    font-size: clamp(1.35rem, 6vw, 1.75rem);
    line-height: 1.12;
    text-transform: none;
  }

  .hero p {
    width: min(90%, 380px);
    margin-left: auto;
    margin-right: auto;
  }

  .home-cta-card {
    width: 92%;
    padding: 24px 18px;
  }

  .home-cta-card span {
    font-size: 0.82rem;
  }

  .home-cta-card h2 {
    font-size: 0.5rem;
  }

  .home-cta-card p {
    font-size: 0.86rem;
  }

  .home-cta-card .btn-primary {
    font-size: 0.82rem;
  }

  .faq-list {
    width: 92%;
  }

  .faq-item {
    margin-bottom: 14px;
    border-radius: 14px;
  }

  .faq-question {
    padding: 18px 16px;
    gap: 12px;
  }

  .faq-question h3 {
    font-size: 0.92rem;
    line-height: 1.35;
  }

  .faq-question i {
    font-size: 1rem;
  }

  .faq-answer {
    padding: 0 16px 18px;
    font-size: 0.86rem;
    line-height: 1.55;
  }

  .sobre-info h2,
  .nossa-identidade .section-header h2,
  .services-offset-section .section-header h2,
  .trabalhos-recentes .section-header h2,
  .clientes-section .section-header h2,
  .parceiros-section .section-header h2,
  .faq-section .section-header h2,
  .thinking-copy h2 {
    font-size: 1.4rem;
    line-height: 1.25;
    text-transform: uppercase;
  }

  .home-cta-card h2 {
    font-size: 1.05rem;
    line-height: 1.25;
    text-transform: uppercase;
  }

  .cta-content h3 {
    font-size: 1.15rem;
    line-height: 1.25;
  }

  .cta-content p {
    font-size: 0.85rem;
    line-height: 1.5;
  }

  .cta-content .btn {
    font-size: 0.8rem;
  }
}
