/**
 * Missão 13 — Mobile-first SUN (app shell)
 * Bottom nav, FAB, topbar compacta, header enxuto, hero empilhado.
 */

:root {
  --sun-bottom-nav-h: 64px;
  --sun-fab-size: 54px;
  --sun-mobile-chrome: calc(var(--sun-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

/* —— Topbar: uma mensagem rotativa no mobile —— */
@media (max-width: 767px) {
  .sun-topbar__inner {
    min-height: 36px;
    justify-content: center;
    padding: 0 1rem;
  }
  .sun-topbar__benefits {
    flex-wrap: nowrap;
    justify-content: center;
    padding: 0.4rem 0;
    width: 100%;
    gap: 0;
  }
  .sun-topbar__benefits li {
    display: none;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-size: 12px;
    line-height: 1.2;
  }
  .sun-topbar__benefits li.is-visible {
    display: inline-flex;
  }
  .sun-topbar__wa {
    display: none !important;
  }

  /* Header: logo + carrinho (busca/favoritos/conta no bottom nav / sheet) */
  .sun-header__row {
    grid-template-columns: 1fr auto;
    min-height: 60px;
    padding: 0.4rem 0;
    gap: 0.5rem;
  }
  .sun-search-wrap,
  .sun-search {
    display: none !important;
  }
  .sun-header__actions .sun-util:not(.sun-util--cart):not(.sun-util--mobile-search),
  .sun-header__menu-btn {
    display: none !important;
  }
  .sun-util--mobile-search {
    display: inline-flex !important;
  }
  .sun-util span {
    display: none !important;
  }
  .sun-util {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
  }
  .sun-logo__tag {
    display: none;
  }
  .sun-logo__name {
    font-size: 1.15rem;
  }
  .sun-logo__mark {
    width: 40px;
    height: 40px;
  }

  /* Hero: imagem + conteúdo empilhados (sem vazio) */
  .sun-hero {
    min-height: 0;
  }
  .sun-hero-slide.is-active {
    position: relative;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .sun-hero__photo {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 5 / 4;
    max-height: 48vh;
    object-fit: cover;
    object-position: center 28%;
  }
  .sun-hero__shade {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    height: auto;
    aspect-ratio: 5 / 4;
    max-height: 48vh;
    background: linear-gradient(
      180deg,
      rgba(8, 43, 58, 0.15) 0%,
      rgba(8, 43, 58, 0.05) 55%,
      rgba(8, 43, 58, 0.55) 100%
    );
  }
  .sun-hero__inner {
    min-height: 0;
    padding: 1.15rem 0 3.75rem;
    align-items: start;
    gap: 0;
  }
  .sun-hero h1,
  .sun-hero__h {
    font-size: clamp(1.55rem, 7vw, 2rem);
    max-width: none;
    margin-bottom: 0.65rem;
  }
  .sun-hero__eyebrow {
    margin-bottom: 0.5rem;
  }
  .sun-hero__lead {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    max-width: none;
  }
  .sun-hero__pillars {
    display: none;
  }
  .sun-hero__cta {
    flex-direction: column;
    align-items: stretch;
  }
  .sun-hero__cta .sun-btn {
    width: 100%;
    justify-content: center;
  }
  .sun-hero__cta .sun-btn--ghost {
    display: none;
  }
  .sun-hero-controls {
    bottom: 0.65rem;
  }

  /* Espaço para bottom nav */
  body.sun-store {
    padding-bottom: calc(var(--sun-mobile-chrome) + 12px);
  }

  /* Footer / seções */
  .sun-section {
    padding-left: 0;
    padding-right: 0;
  }
  .sun-cat-grid {
    gap: 0.75rem;
  }
  .sun-cat-card__desc {
    font-size: 0.8rem;
  }
}

/* Desktop: chrome mobile oculto */
@media (min-width: 768px) {
  .sun-bottom-nav,
  .sun-wa-fab,
  .sun-sheet,
  .sun-util--mobile-search {
    display: none !important;
  }
}

/* —— Bottom navigation —— */
.sun-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: calc(var(--sun-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 0.25rem env(safe-area-inset-bottom, 0px);
  background: #ffffff;
  border-top: 1px solid rgba(8, 43, 58, 0.1);
  box-shadow: 0 -4px 20px rgba(8, 43, 58, 0.08);
  align-items: stretch;
  justify-content: space-around;
}
@media (max-width: 767px) {
  .sun-bottom-nav {
    display: flex;
  }
}
html.sun-dark .sun-bottom-nav {
  background: #0c3344;
  border-top-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
}
.sun-bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.4rem 0.15rem;
  border: 0;
  background: transparent;
  color: #526570;
  text-decoration: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  position: relative;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
html.sun-dark .sun-bottom-nav__item {
  color: rgba(255, 255, 255, 0.55);
}
.sun-bottom-nav__item svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}
.sun-bottom-nav__item.is-active,
.sun-bottom-nav__item[aria-current="page"] {
  color: #082B3A;
}
html.sun-dark .sun-bottom-nav__item.is-active,
html.sun-dark .sun-bottom-nav__item[aria-current="page"] {
  color: #FFCB45;
}
.sun-bottom-nav__item.is-active svg {
  color: #167A50;
}
html.sun-dark .sun-bottom-nav__item.is-active svg {
  color: #FFCB45;
}
.sun-bottom-nav__badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 22px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #FFCB45;
  color: #082B3A;
  font-size: 9px;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* —— Categories sheet —— */
.sun-sheet {
  position: fixed;
  inset: 0;
  z-index: 55;
}
.sun-sheet.hidden {
  display: none !important;
}
.sun-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 43, 58, 0.45);
}
.sun-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(78vh, 640px);
  background: var(--sun-surface, #fff);
  color: var(--sun-text, #082B3A);
  border-radius: 20px 20px 0 0;
  padding: 0.5rem 1rem calc(1rem + var(--sun-mobile-chrome));
  overflow: auto;
  box-shadow: 0 -8px 32px rgba(8, 43, 58, 0.18);
  animation: sun-sheet-up 0.28s ease;
}
@keyframes sun-sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .sun-sheet__panel { animation: none; }
}
.sun-sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--sun-border, #d0d8dc);
  margin: 0.35rem auto 0.75rem;
}
.sun-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.sun-sheet__head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}
.sun-sheet__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}
.sun-sheet__list a,
.sun-sheet__btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.85rem 0.75rem;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
}
.sun-sheet__list a:hover,
.sun-sheet__list a:focus-visible,
.sun-sheet__btn:hover,
.sun-sheet__btn:focus-visible {
  background: var(--sun-surface-muted, #F5F8F7);
  outline: none;
}

/* —— WhatsApp FAB —— */
.sun-wa-fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(var(--sun-mobile-chrome) + 16px);
  z-index: 46;
  width: var(--sun-fab-size);
  height: var(--sun-fab-size);
  border-radius: 999px;
  background: #25D366;
  color: #fff;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
@media (max-width: 767px) {
  .sun-wa-fab {
    display: flex;
  }
}
.sun-wa-fab svg {
  width: 26px;
  height: 26px;
}
.sun-wa-fab:hover,
.sun-wa-fab:focus-visible {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.5);
  outline: 2px solid #082B3A;
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .sun-wa-fab { transition: none; }
}

/* Esconder chrome em checkout / drawers críticos */
body.sun-checkout-open .sun-bottom-nav,
body.sun-checkout-open .sun-wa-fab,
body.sun-cart-open .sun-wa-fab {
  display: none !important;
}
body.sun-checkout-open {
  padding-bottom: 0 !important;
}

/* Cart drawer CTA acima do safe area no mobile */
@media (max-width: 767px) {
  .sun-drawer {
    width: 100%;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }
  .sun-drawer__foot {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .sun-checkout {
    width: 100%;
    max-height: none;
    height: 100%;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  #product-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .sun-product-card .sun-btn {
    min-height: 44px;
    font-size: 0.8rem;
  }
}

/* Overflow guard */
html, body.sun-store {
  overflow-x: hidden;
  max-width: 100vw;
}
