/**
 * Fallbacks para dispositivos legados:
 * - iPad Air A1475 (Safari até iOS 15)
 * - iPhone X / Safari antigo
 * - Android antigo (Moto G5/G7, Chrome < 84)
 * Carregar DEPOIS de app.css / editorial-casa.css / ar.css.
 * Não remove recursos modernos: só preenche buracos.
 */

/* tipografia legível sem clamp() */
.brand-name { font-size: 1.05rem; }
.section-title { font-size: 1.55rem; }
.hero-fresh:not(.hero-inset) h1 { font-size: 2.1rem; }
.promo-banner .section-title { font-size: 1.7rem; }
.ar-brand-title { font-size: 1.05rem; }
body.theme-casa .casa-services-title { font-size: 1.55rem; }
body.theme-casa .ig-stories-title { font-size: 1.65rem; }
body.theme-casa .member-area .section-head .section-title { font-size: 1.75rem; }

@supports (font-size: clamp(1rem, 2vw, 2rem)) {
  .brand-name { font-size: clamp(0.95rem, 3.8vw, 1.15rem); }
  .section-title { font-size: clamp(1.35rem, 3vw, 1.75rem); }
  .hero-fresh:not(.hero-inset) h1 { font-size: clamp(2rem, 7vw, 3.4rem); }
  .promo-banner .section-title { font-size: clamp(1.55rem, 4vw, 2.1rem); }
  .ar-brand-title { font-size: clamp(0.95rem, 3.5vw, 1.15rem); }
  body.theme-casa .casa-services-title { font-size: clamp(1.45rem, 3vw, 1.9rem); }
  body.theme-casa .ig-stories-title { font-size: clamp(1.55rem, 3.4vw, 2.15rem); }
  body.theme-casa .member-area .section-head .section-title {
    font-size: clamp(1.55rem, 3.2vw, 2.2rem);
  }
}

/* margin-inline / padding-inline → left/right */
.container {
  margin-left: auto;
  margin-right: auto;
  width: 94%;
  max-width: 720px;
}
body.theme-casa .container {
  width: 94%;
  max-width: 1180px;
}
/* Não sobrescrever a largura do hero configurada no admin */
body.theme-casa .container.hero-inset-shell {
  width: min(var(--home-banner-width, 1120px), calc(100% - 1.5rem));
  max-width: 100%;
}
@media (min-width: 960px) {
  .container { max-width: 1080px; }
}
@supports (width: min(720px, 100%)) {
  .container { width: min(720px, calc(100% - 1.25rem)); }
  body.theme-casa .container { width: min(1180px, calc(100% - 1.5rem)); }
  body.theme-casa .container.hero-inset-shell {
    width: min(var(--home-banner-width, 1120px), calc(100% - 1.5rem));
    max-width: 100%;
  }
  @media (min-width: 960px) {
    .container { width: min(1080px, calc(100% - 2rem)); }
  }
}

body.theme-casa .lux-manifesto .container {
  padding-left: 0;
  padding-right: 0;
}

/* inset → top/right/bottom/left (Safari < 14.1) */
.hero-banner-track,
.hero-banner-slide,
.hero-fresh-bg,
.hero-fresh-bg picture,
.hero-fresh-bg picture img,
.hero-banner-hit,
.promo-banner-media,
.casa-spotlight-stage,
.casa-spotlight-slide,
.casa-spotlight-slide picture,
.casa-spotlight-slide picture img,
.casa-spotlight-overlay,
.ig-story-card picture,
.ig-story-card picture img,
.atelier-strip-media picture,
.atelier-strip-media img,
.ar-app,
.ar-camera,
.ar-canvas,
.ar-vignette,
.ar-sparkles {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.product-badge,
.badge {
  top: 0.65rem;
  right: 0.65rem;
}

/* Hero 50/50 no A1475: altura vem do admin (vars / #home-banner-display-size). */
body.theme-casa .hero-inset .hero-banner-slide {
  min-height: 0;
  max-height: none;
}
body.theme-casa .hero-inset .hero-banner-slide.is-active {
  min-height: 0;
}
@media (min-width: 760px) {
  body.theme-casa .hero-inset .hero-banner-slide.is-active {
    min-height: var(--home-banner-height, 18rem);
  }
  body.theme-casa .hero-inset .hero-fresh-bg {
    height: 100%;
    min-height: 0;
    padding-bottom: 0;
  }
}

/* Badge Natural Aventura: trava 500×500 → selo pequeno + texto visível */
body.theme-casa .hero-inset .hero-line-logo,
body.theme-casa .hero-inset picture.hero-line-logo,
html.is-legacy-ios body.theme-casa .hero-inset .hero-line-logo,
html.is-legacy-ios body.theme-casa .hero-inset picture.hero-line-logo,
html.is-legacy-device body.theme-casa .hero-inset .hero-line-logo,
html.is-legacy-device body.theme-casa .hero-inset picture.hero-line-logo {
  width: 4.25rem !important;
  max-width: 4.25rem !important;
  height: 4.25rem !important;
  max-height: 4.25rem !important;
  flex: 0 0 4.25rem !important;
}
body.theme-casa .hero-inset picture.hero-line-logo img,
body.theme-casa .hero-inset .hero-line-logo img,
html.is-legacy-ios body.theme-casa .hero-inset picture.hero-line-logo img,
html.is-legacy-device body.theme-casa .hero-inset picture.hero-line-logo img {
  width: 4.25rem !important;
  max-width: 4.25rem !important;
  height: 4.25rem !important;
  max-height: 4.25rem !important;
}
html.is-legacy-ios body.theme-casa .hero-inset .hero-banner-slide.is-aventura .hero-fresh-content h1,
html.is-legacy-device body.theme-casa .hero-inset .hero-banner-slide.is-aventura .hero-fresh-content h1 {
  display: block !important;
  font-size: 1.35rem !important;
  line-height: 1.15 !important;
  color: #ebb800 !important;
  max-width: 16ch;
}
html.is-legacy-ios body.theme-casa .hero-inset .hero-banner-slide.is-aventura .hero-fresh-text,
html.is-legacy-device body.theme-casa .hero-inset .hero-banner-slide.is-aventura .hero-fresh-text {
  display: block !important;
  font-size: 0.9rem !important;
  color: #ffffff !important;
}

/* Editorial: coluna única legível no tablet legado */
html.is-legacy-ios body.theme-casa .lux-manifesto .container,
html.is-legacy-device body.theme-casa .lux-manifesto .container {
  display: block !important;
  max-width: 42rem;
}
html.is-legacy-ios body.theme-casa .lux-manifesto-kicker,
html.is-legacy-device body.theme-casa .lux-manifesto-kicker {
  color: #d17a6d !important;
  font-size: 0.78rem !important;
  font-weight: 700 !important;
}
html.is-legacy-ios body.theme-casa .lux-manifesto h2,
html.is-legacy-device body.theme-casa .lux-manifesto h2 {
  font-size: 1.75rem !important;
  font-weight: 700 !important;
  color: #000000 !important;
  max-width: 18ch;
}
html.is-legacy-ios body.theme-casa .lux-manifesto p,
html.is-legacy-device body.theme-casa .lux-manifesto p {
  color: #000000 !important;
  font-size: 1.02rem !important;
  text-align: left !important;
}

/* Coleções: garante palco/imagem mesmo sem clamp/inset */
body.theme-casa .casa-spotlight-banner,
body.theme-casa .casa-spotlight-content {
  min-height: 15rem;
}
body.theme-casa .casa-spotlight-stage,
body.theme-casa .casa-spotlight-slide,
body.theme-casa .casa-spotlight-slide picture,
body.theme-casa .casa-spotlight-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
body.theme-casa .casa-spotlight-slide picture img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Natural Stories: altura sem aspect-ratio */
body.theme-casa .ig-story-card {
  height: 0;
  padding-bottom: 125%;
}
body.theme-casa .ig-story-card picture,
body.theme-casa .ig-story-card img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
@supports (aspect-ratio: 1 / 1) {
  body.theme-casa .ig-story-card {
    height: auto;
    padding-bottom: 0;
    aspect-ratio: 4 / 5;
  }
}

/* Featured rail: flex evita scrollWidth=0 em grid antigo */
html.is-legacy-device body.theme-casa .casa-featured-track {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-overflow-scrolling: touch;
}
html.is-legacy-device body.theme-casa .casa-featured-slide {
  -webkit-flex: 0 0 47%;
  flex: 0 0 47%;
  max-width: 47%;
}
@media (min-width: 760px) {
  html.is-legacy-device body.theme-casa .casa-featured-slide {
    -webkit-flex: 0 0 31%;
    flex: 0 0 31%;
    max-width: 31%;
  }
}

/* Carrossel Nossas linhas — fallbacks de largura/centro */
body.theme-casa .casa-services-rail {
  --services-card-w: 78%;
}
body.theme-casa .casa-services-track {
  grid-auto-columns: 78%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scroll-padding-left: 11%;
  scroll-padding-right: 11%;
}
@media (min-width: 760px) {
  body.theme-casa .casa-services-rail { --services-card-w: 52%; }
  body.theme-casa .casa-services-track {
    grid-auto-columns: 52%;
    scroll-padding-left: 24%;
    scroll-padding-right: 24%;
  }
}
@media (min-width: 1100px) {
  body.theme-casa .casa-services-rail { --services-card-w: 38%; }
  body.theme-casa .casa-services-track {
    grid-auto-columns: 38%;
    scroll-padding-left: 31%;
    scroll-padding-right: 31%;
  }
}

/* iOS legado: flex + % fixo (scrollLeft/offsetLeft mais confiáveis que grid) */
html.is-legacy-ios body.theme-casa .casa-services-track,
html.is-legacy-device body.theme-casa .casa-services-track {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  grid-auto-columns: unset;
  overflow-x: auto;
}
html.is-legacy-ios body.theme-casa .casa-services-track [data-services-slide],
html.is-legacy-device body.theme-casa .casa-services-track [data-services-slide] {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 78%;
  flex: 0 0 78%;
  max-width: 78%;
  width: 78%;
  margin-right: 1rem;
  -webkit-scroll-snap-align: center;
  scroll-snap-align: center;
}
@media (min-width: 760px) {
  html.is-legacy-ios body.theme-casa .casa-services-track [data-services-slide],
  html.is-legacy-device body.theme-casa .casa-services-track [data-services-slide] {
    -webkit-flex: 0 0 52%;
    flex: 0 0 52%;
    max-width: 52%;
    width: 52%;
  }
}
@media (min-width: 1100px) {
  html.is-legacy-ios body.theme-casa .casa-services-track [data-services-slide],
  html.is-legacy-device body.theme-casa .casa-services-track [data-services-slide] {
    -webkit-flex: 0 0 38%;
    flex: 0 0 38%;
    max-width: 38%;
    width: 38%;
  }
}
@supports (width: min(78vw, 20.5rem)) {
  body.theme-casa .casa-services-rail {
    --services-card-w: min(78vw, 20.5rem);
  }
  body.theme-casa .casa-services-track {
    grid-auto-columns: var(--services-card-w);
    scroll-padding-left: max(0px, calc((100% - var(--services-card-w)) / 2));
    scroll-padding-right: max(0px, calc((100% - var(--services-card-w)) / 2));
  }
  @media (min-width: 760px) {
    body.theme-casa .casa-services-rail { --services-card-w: min(52%, 24rem); }
  }
  @media (min-width: 1100px) {
    body.theme-casa .casa-services-rail { --services-card-w: min(38%, 26rem); }
  }
}

body.theme-casa .casa-services-rail {
  margin-left: -0.15rem;
  margin-right: -0.15rem;
}

/* aspect-ratio fallback — fora do tema casa */
body:not(.theme-casa) .product-media,
.product-detail-media-wrap,
.related-card a {
  position: relative;
  display: block;
  height: 0;
  padding-bottom: 100%;
  overflow: hidden;
}
body:not(.theme-casa) .product-media > img,
.product-detail-media-wrap > img,
.product-detail-media > img,
.related-grid img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
@supports (aspect-ratio: 1) {
  body:not(.theme-casa) .product-media,
  .product-detail-media-wrap {
    height: auto;
    padding-bottom: 0;
    aspect-ratio: 1;
  }
  body:not(.theme-casa) .product-media > img,
  .product-detail-media-wrap > img,
  .product-detail-media > img,
  .related-grid img {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
  }
}

.ig-phone {
  height: 0;
  padding-bottom: 177.78%;
  position: relative;
  width: 100%;
  max-width: 320px;
}
.ig-phone canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
@supports (aspect-ratio: 9 / 16) {
  .ig-phone {
    height: auto;
    padding-bottom: 0;
    aspect-ratio: 9 / 16;
  }
  .ig-phone canvas {
    position: static;
  }
}

/* Flex gap ausente → margens nos filhos */
.app-top-inner > * { margin: 0 0.2rem; }
.brand > * { margin-right: 0.55rem; }
.brand > *:last-child { margin-right: 0; }
.top-actions > * { margin-left: 0.35rem; }
.site-nav a { margin-right: 0.35rem; margin-bottom: 0.35rem; }
.actions > * { margin: 0.3rem 0.35rem 0.3rem 0; }
.tags > * { margin: 0.2rem 0.35rem 0.2rem 0; }
.footer-links > * { margin: 0.25rem 0.45rem 0.25rem 0; }
.partners-list > * { margin: 0.25rem 0.35rem 0.25rem 0; }
.ar-dock > * { margin: 0.2rem; }
.ar-top > * { margin: 0 0.25rem; }
.hero-banner-controls > * { margin: 0 0.25rem; }
.hero-banner-dots > * { margin: 0 0.15rem; }
.footer-newsletter-row > * { margin: 0.25rem 0.35rem 0.25rem 0; }
.admin-actions > * { margin: 0.25rem 0.35rem 0.25rem 0; }
.ig-thumbs > * { margin: 0 0.35rem 0.35rem 0; }

body.theme-casa .casa-topbar-right > * { margin-left: 0.35rem; }
body.theme-casa .casa-social > * { margin-left: 0.35rem; }
body.theme-casa .casa-header-main-inner > * { margin-right: 0.35rem; }
body.theme-casa .casa-services-controls > * { margin: 0 0.35rem; }
body.theme-casa .member-page-actions > * { margin: 0.25rem 0.45rem 0.25rem 0; }
body.theme-casa .app-tabbar .tab { margin: 0 0.15rem; }

@supports (gap: 1rem) and (selector(:focus-visible)) {
  .brand > *,
  .top-actions > *,
  .site-nav a,
  .actions > *,
  .tags > *,
  .footer-links > *,
  .partners-list > *,
  .ar-dock > *,
  .ar-top > *,
  .hero-banner-controls > *,
  .hero-banner-dots > *,
  .footer-newsletter-row > *,
  .admin-actions > *,
  .ig-thumbs > *,
  body.theme-casa .casa-topbar-right > *,
  body.theme-casa .casa-social > *,
  body.theme-casa .casa-header-main-inner > *,
  body.theme-casa .casa-services-controls > *,
  body.theme-casa .member-page-actions > *,
  body.theme-casa .app-tabbar .tab {
    margin: 0;
  }
}

/* Alvos de toque generosos */
.btn,
.top-action,
.site-nav a,
.app-tabbar .tab,
.line-card,
.product-ar-chip,
.ar-btn,
.hero-banner-nav,
.hero-banner-dot,
.casa-services-nav,
.member-page-actions .btn {
  min-height: 44px;
}
.site-nav a {
  padding: 0.65rem 0.9rem;
}
.hero-banner-dot {
  min-width: 14px;
  min-height: 14px;
}
.hero-banner-nav,
.casa-services-nav {
  min-width: 44px;
  width: 44px;
  height: 44px;
}

/* iPad Air / tablets 768–1024 */
@media (min-width: 768px) and (max-width: 1024px) {
  body { font-size: 16px; }
  .container { max-width: 940px; }
  .product-grid { grid-template-columns: repeat(3, 1fr) !important; }
  body.theme-casa .casa-line-page .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .line-grid { grid-template-columns: repeat(3, 1fr) !important; }
  .hero-fresh { min-height: 520px; }
  .app-tabbar .tab-label { font-size: 0.78rem; }
  .product-detail { grid-template-columns: 1fr 1fr; }
  .ar-phone,
  .ig-phone { max-width: 360px; }
  body.theme-casa .member-shortcut-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Header: marca circular compacta (A1475 portrait ~768 CSS px) */
  body.theme-casa .casa-header .brand img.brand-logo--mark,
  body.theme-casa .casa-header .brand-logo--mark,
  body.theme-casa .casa-header .brand picture.brand-logo--mark,
  body.theme-casa .casa-header .brand picture.brand-logo--mark img {
    width: 2.75rem !important;
    height: 2.75rem !important;
    max-width: 2.75rem !important;
    max-height: 2.75rem !important;
    flex: 0 0 2.75rem !important;
  }
}

@media (min-width: 768px) and (max-width: 900px) and (orientation: portrait) {
  .product-grid { grid-template-columns: repeat(2, 1fr) !important; }
  body.theme-casa .casa-line-page .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .hero-fresh-content { padding-bottom: 4rem; }

  /* iPad Air A1475 portrait: trava a marca para não competir com o lockup */
  body.theme-casa .casa-header .brand img.brand-logo--mark,
  body.theme-casa .casa-header .brand-logo--mark,
  body.theme-casa .casa-header .brand picture.brand-logo--mark,
  body.theme-casa .casa-header .brand picture.brand-logo--mark img {
    width: 2.5rem !important;
    height: 2.5rem !important;
    max-width: 2.5rem !important;
    max-height: 2.5rem !important;
    flex: 0 0 2.5rem !important;
  }
  body.theme-casa .casa-header .brand--lockup {
    gap: 0.45rem;
  }
  body.theme-casa .casa-header .brand-lockup-name {
    font-size: 1.15rem !important;
  }
  body.theme-casa .casa-header .brand-lockup-tag {
    font-size: 0.7rem !important;
  }
}

/* Safari legado: reforço absoluto da marca (sem depender de clamp/aspect-ratio) */
html.is-legacy-ios body.theme-casa .casa-header .brand img.brand-logo--mark,
html.is-legacy-ios body.theme-casa .casa-header .brand-logo--mark,
html.is-legacy-ios body.theme-casa .casa-header .brand picture.brand-logo--mark,
html.is-legacy-ios body.theme-casa .casa-header .brand picture.brand-logo--mark img,
html.is-legacy-device body.theme-casa .casa-header .brand img.brand-logo--mark,
html.is-legacy-device body.theme-casa .casa-header .brand-logo--mark,
html.is-legacy-device body.theme-casa .casa-header .brand picture.brand-logo--mark,
html.is-legacy-device body.theme-casa .casa-header .brand picture.brand-logo--mark img {
  width: 2.5rem !important;
  height: 2.5rem !important;
  max-width: 2.5rem !important;
  max-height: 2.5rem !important;
  flex: 0 0 2.5rem !important;
}

/* Phones estreitos (Moto G5) */
@media (max-width: 400px) {
  body.theme-casa .casa-services-track {
    grid-auto-columns: 82%;
    scroll-padding-left: 9%;
    scroll-padding-right: 9%;
  }
  body.theme-casa .member-shortcut-grid {
    grid-template-columns: 1fr;
  }
  .app-tabbar .tab-label { font-size: 0.68rem; }
}

/* Menos animação / blur em legado */
html.is-legacy-ios .hero-banner-slide.is-active .hero-fresh-bg img,
html.is-legacy-android .hero-banner-slide.is-active .hero-fresh-bg img,
html.is-legacy-device .hero-banner-slide.is-active .hero-fresh-bg img {
  -webkit-transform: none;
  transform: none;
  -webkit-transition: none;
  transition: none;
}
html.is-legacy-device .animate-rise {
  -webkit-animation: none;
  animation: none;
  opacity: 1;
  -webkit-transform: none;
  transform: none;
}
html.is-legacy-device .product-card:hover,
html.is-legacy-device .product-card:hover img,
html.is-legacy-device .line-card:hover,
html.is-legacy-device .casa-service-card:hover,
html.is-legacy-device .casa-service-card.is-active {
  -webkit-transform: none;
  transform: none;
}

html.is-legacy-device .backdrop-blur,
html.is-legacy-device .app-top,
html.is-legacy-device .casa-header,
html.is-legacy-device .app-tabbar {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

html.is-legacy-device {
  scroll-behavior: auto;
}

html.is-legacy-android .hero-inset .hero-banner-slide {
  max-height: none;
}

.admin-img-hint,
.admin-img-tip {
  display: block;
}
