/* ==========================================================================
   layout.css — estrutura da página
   Topbar · Header · Menu de categorias · Barra inferior mobile · Footer
   ========================================================================== */

/* --------------------------------------------------------------------------
   Barra de avisos
   -------------------------------------------------------------------------- */

.topbar {
  background: var(--grey-900);
  color: var(--grey-300);
  font-size: var(--fs-sm);        /* maior = mais visível */
  font-weight: var(--fw-medium);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-8);
  min-height: 40px;               /* barra um pouco mais alta, mais presente */
}

.topbar__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* A parte-âncora (portes grátis, prazo) a branco e negrito — salta à vista. */
.topbar__item strong {
  color: #fff;
  font-weight: var(--fw-bold);
}

.topbar__ico {
  display: inline-flex;
  color: var(--brand-300);
}

.topbar__ico svg {
  width: 16px;
  height: 16px;
}

/* O camião dos portes leva a cor quente da marca — é o que salta à vista,
   como o camião amarelo das lojas de referência. */
.topbar__ico--truck {
  color: var(--accent-500);
}

.topbar__ico--truck svg {
  width: 19px;
  height: 19px;
}

/* No telemóvel só cabe um aviso. */
.topbar__item:not(:first-child) {
  display: none;
}

@media (min-width: 768px) {
  .topbar__item:not(:first-child) {
    display: flex;
  }
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

/* Header e barra de categorias colam ao topo como um bloco só — assim o
   dropdown de categorias tem sempre uma posição previsível por baixo. */
.header-wrap {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg-surface);
}

.header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--header-h);
  padding-block: var(--sp-2);
}

/* Hambúrguer — abre o painel de categorias. Só no telemóvel: no desktop a
   barra de categorias por baixo já tem o seu próprio botão "Todos os produtos". */
.header__menu {
  order: 1;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-left: calc(var(--sp-2) * -1);
  border-radius: var(--r-sm);
  color: var(--text-strong);
  transition: background var(--dur) var(--ease);
}

.header__menu:hover {
  background: var(--grey-50);
}

.header__menu svg {
  width: 26px;
  height: 26px;
}

@media (min-width: 1024px) {
  .header__menu {
    display: none;
  }
}

.logo {
  order: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-strong);
  font-size: 1.5rem;
  font-weight: var(--fw-black);
  letter-spacing: -0.03em;
  line-height: 1;
}

.logo:hover {
  color: var(--text-strong);
}

.logo b {
  color: var(--brand-500);
  font-weight: inherit;
}

.logo__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.logo__img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  display: block;
}

/* Estado de recurso: se a imagem falhar, volta o ícone SVG na caixa azul. */
.logo__mark--box {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--brand-500);
  color: var(--text-inverse);
}

.logo__mark svg {
  width: 22px;
  height: 22px;
}

.logo__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* O descritivo só aparece quando há largura para ele. */
.logo small {
  display: none;
}

@media (min-width: 1024px) {
  .logo small {
    display: block;
    color: var(--text-muted);
    font-size: var(--fs-2xs);
    font-weight: var(--fw-medium);
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}

/* Campo de pesquisa. No telemóvel ocupa a 2ª linha do header, a toda a
   largura (estilo loja moderna). No desktop volta ao meio, entre logo e ações. */
.search {
  order: 4;
  position: relative;
  display: block;
  flex: 1 0 100%;
}

@media (min-width: 1024px) {
  .search {
    order: 3;
    flex: 1 1 auto;
    flex-basis: auto;
    max-width: 620px;
    margin-inline: auto;
  }
}

.search input {
  width: 100%;
  height: 46px;
  padding: 0 54px 0 var(--sp-4);
  background: var(--grey-50);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 16px;          /* 16px = o iOS não dá zoom ao focar o campo */
  outline: none;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.search input::placeholder {
  color: var(--text-muted);
}

.search input:focus {
  background: var(--bg-surface);
  border-color: var(--brand-400);
}

/* Botão de lupa: círculo escuro, como nas lojas de referência. */
.search__go {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-circle);
  background: var(--grey-900);
  color: #fff;
  transition: background var(--dur) var(--ease);
}

.search__go:hover {
  background: var(--brand-500);
}

.search__go svg {
  width: 19px;
  height: 19px;
}

.header__actions {
  order: 3;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-left: auto;
}

@media (min-width: 1024px) {
  .header__actions {
    order: 4;
  }
}

.header__action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  transition: color var(--dur) var(--ease);
}

.header__action:hover {
  color: var(--brand-500);
}

/* Ações que no telemóvel já vivem na barra inferior. */
.header__action--wide {
  display: none;
}

@media (min-width: 1024px) {
  .header__action--wide {
    display: flex;
  }
}

.header__action svg {
  width: 22px;
  height: 22px;
}

.header__action span {
  display: none;
}

@media (min-width: 1024px) {
  .header__action span {
    display: block;
  }
}

/* Contador do carrinho */
.header__action {
  position: relative;
}

.count-bubble {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding-inline: 4px;
  border-radius: var(--r-pill);
  background: var(--accent-500);
  color: var(--text-inverse);
  font-size: 10px;
  font-weight: var(--fw-bold);
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Barra de categorias (desktop)
   -------------------------------------------------------------------------- */

.mainnav {
  display: none;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 1024px) {
  .mainnav {
    display: block;
  }
}

.mainnav__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 48px;
}

.mainnav__toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 34px;
  padding-inline: var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--brand-500);
  color: var(--text-inverse);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.mainnav__toggle svg {
  width: 16px;
  height: 16px;
}

.mainnav__links {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  overflow-x: auto;
  scrollbar-width: none;
}

.mainnav__links::-webkit-scrollbar {
  display: none;
}

.mainnav__links a {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.mainnav__links a:hover {
  background: var(--brand-50);
  color: var(--brand-600);
}

/* --------------------------------------------------------------------------
   Painel de categorias
   Desktop → dropdown por baixo da barra. Mobile → gaveta a subir do fundo.
   É o MESMO elemento nos dois casos; muda só a apresentação.
   -------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgba(18, 22, 28, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}

.overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  max-height: 82vh;
  padding: var(--sp-5) var(--sp-4)
           calc(var(--sp-5) + env(safe-area-inset-bottom, 0px));
  background: var(--bg-surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--sh-lg);
  overflow-y: auto;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform var(--dur) var(--ease), visibility var(--dur) var(--ease);
}

.panel.is-open {
  transform: translateY(0);
  visibility: visible;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.panel__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
}

.panel__close svg {
  width: 22px;
  height: 22px;
}

.panel__list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
}

.panel__list a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-strong);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
}

.panel__list a:hover {
  border-color: var(--brand-300);
  background: var(--brand-50);
  color: var(--brand-700);
}

.panel__list img {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

@media (min-width: 1024px) {
  /* No desktop deixa de ser gaveta e passa a dropdown. Fica `fixed` e o JS
     acerta o `top` com a posição real da barra de navegação — mais fiável do
     que somar alturas à mão, que se desalinha com a barra de avisos. */
  .panel {
    position: fixed;
    top: 0;
    left: 50%;
    right: auto;
    bottom: auto;
    width: min(var(--container), calc(100vw - var(--sp-8)));
    max-height: none;
    margin-top: var(--sp-2);
    padding: var(--sp-6);
    border-radius: var(--r-md);
    transform: translate(-50%, -8px);
    opacity: 0;
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
                visibility var(--dur) var(--ease);
  }
  .panel.is-open {
    transform: translate(-50%, 0);
    opacity: 1;
  }
  .panel__list {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-3);
  }
  .panel__close {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Pesquisa em ecrã inteiro (mobile)
   -------------------------------------------------------------------------- */

/* Aqui a pesquisa TEM de aparecer no telemóvel — anula o `display:none`
   que esconde a caixa do header. */
.searchpanel .search {
  display: block;
  max-width: none;
  margin: 0;
}

.searchpanel__hint {
  margin-top: var(--sp-4);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* --------------------------------------------------------------------------
   Resultados de pesquisa
   -------------------------------------------------------------------------- */

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
}

@media (min-width: 600px) {
  .results-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .results-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1200px) {
  .results-grid { grid-template-columns: repeat(5, 1fr); }
}

.results-empty {
  padding: var(--sp-12) var(--sp-4);
  text-align: center;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  margin-top: var(--sp-12);
  background: var(--grey-900);
  color: var(--grey-300);
  font-size: var(--fs-sm);
}

/* --- Footer minimalista ------------------------------------------------- */
.footer__mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-5);
  padding-block: var(--sp-8);
  text-align: center;
}
.footer__mini .logo,
.footer__mini .logo:hover {
  order: 0;
  margin: 0;
  color: var(--grey-0);
  font-size: 1.35rem;
}
.footer__mini .logo b { color: inherit; }
.footer__mini .logo small { display: none; }

.footer__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-3) var(--sp-4);
  max-width: 100%;
}
.footer__nav a {
  color: var(--grey-300);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  transition: color var(--dur) var(--ease);
}
.footer__nav a:hover { color: #fff; }

.footer__mini .footer__contact {
  display: flex;
  justify-content: center;
  gap: var(--sp-2) var(--sp-5);
  margin: 0;
}
.footer__mini .footer__contact a {
  display: inline;
  color: var(--grey-400);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.footer__mini .footer__contact a:hover { color: #fff; }

.footer__base {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  width: 100%;
  padding-top: var(--sp-5);
  border-top: 1px solid var(--grey-800);
  color: var(--grey-500);
  font-size: var(--fs-2xs);
}
.footer__pay-txt { color: var(--grey-500); letter-spacing: 0.02em; }

.footer__fine {
  max-width: 52ch;
  margin-top: var(--sp-2);
  color: var(--grey-600);
  font-size: var(--fs-2xs);
  line-height: var(--lh-normal);
  text-align: center;
}
/* Campos legais por preencher: discretos (não gritam), mas com sublinhado
   pontilhado que assinala "falta preencher" sem estragar o rodapé. */
.footer__fine .ph {
  color: var(--grey-500);
  border-bottom: 1px dotted var(--grey-700);
}

.footer__grid {
  display: grid;
  gap: var(--sp-8);
  padding-block: var(--sp-10);
}

@media (min-width: 768px) {
  .footer__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .footer__grid {
    grid-template-columns: 1.4fr repeat(3, 1fr);
    gap: var(--sp-10);
  }
}

.footer h3 {
  margin-bottom: var(--sp-4);
  color: var(--grey-0);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.footer li + li {
  margin-top: var(--sp-2);
}

.footer a:hover {
  color: var(--brand-300);
}

.footer__about p {
  max-width: 42ch;
  line-height: var(--lh-normal);
}

/* O logótipo é escuro por omissão; no rodapé preto tem de inverter. */
.footer .logo,
.footer .logo:hover {
  margin-bottom: var(--sp-4);
  color: var(--grey-0);
}

/* O "Ar" do logo é quase-preto (cor de acção); no rodapé escuro tinha de herdar
   o branco, senão desaparecia. */
.footer .logo b {
  color: inherit;
}

.footer .logo small {
  display: block;
  color: var(--grey-500);
}

.footer__contact {
  margin-top: var(--sp-4);
}

.footer__contact a {
  display: block;
  color: var(--grey-0);
  font-weight: var(--fw-semibold);
}

.footer__bottom {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding-block: var(--sp-5);
  border-top: 1px solid var(--grey-800);
  color: var(--grey-500);
  font-size: var(--fs-xs);
}

@media (min-width: 768px) {
  .footer__bottom {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.payments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* --- Faixa de confiança do rodapé -------------------------------------- */
.footer__trust {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4) var(--sp-5);
  padding-block: var(--sp-6);
  border-top: 1px solid var(--grey-800);
}
@media (min-width: 768px) {
  .footer__trust { grid-template-columns: repeat(4, 1fr); }
}
.ftrust {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}
.ftrust__ico {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-circle);
  background: rgba(255, 255, 255, 0.08);
  color: var(--brand-300);
}
.ftrust__ico svg { width: 18px; height: 18px; }
.ftrust b { display: block; color: var(--grey-0); font-size: var(--fs-sm); }
.ftrust small { display: block; margin-top: 2px; color: var(--grey-500); font-size: var(--fs-2xs); }

/* --- Selos de pagamento ------------------------------------------------- */
.footer__pay {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding-block: var(--sp-5);
  border-top: 1px solid var(--grey-800);
}
.footer__pay-label {
  color: var(--grey-400);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.payments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
/* Selos de pagamento: pastilhas brancas uniformes. Onde há ficheiro de
   logótipo (MB WAY, Multibanco…) mostra-se o logo real; onde não há, fica o
   texto — mas todos na mesma pastilha branca, para ficarem coerentes. */
.pay-seal {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  height: 34px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.pay-seal b {
  color: var(--grey-900);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.seal-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 5px 8px;
  object-fit: contain;
  background: #fff;
}

/* --- Resolução de litígios --------------------------------------------- */
.footer__ral a { color: var(--grey-300); text-decoration: underline; }
.footer__ral a:hover { color: var(--brand-300); }

/* --- Identidade legal --------------------------------------------------- */
.footer__legal {
  padding-block: var(--sp-5) var(--sp-8);
  border-top: 1px solid var(--grey-800);
  color: var(--grey-500);
  font-size: var(--fs-2xs);
  line-height: var(--lh-normal);
}
.footer__legal p + p { margin-top: var(--sp-2); }
.footer__legal b { color: var(--grey-300); }
/* Marca visualmente os campos legais por preencher — não passar assim para produção. */
.footer__legal .ph {
  color: var(--warning);
  border-bottom: 1px dashed var(--warning);
}

/* --------------------------------------------------------------------------
   Modo de filtragem
   Ao pesquisar ou escolher uma categoria, as secções da homepage saem de cena
   e fica só a grelha de resultados.
   -------------------------------------------------------------------------- */

body.is-filtering .home-only {
  display: none;
}

.results__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.results__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-black);
  letter-spacing: -0.02em;
}

.results__count {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
