/* =========================================================
   Home Editor — Public Rendering Styles
   ========================================================= */

.he-public-home {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  /* Size container so the responsive block rules below track the rendered
     width of the page, not the browser viewport. On the published site this
     wrapper is ~viewport-wide, so the breakpoints fire where they always did;
     in the editor canvas it's clamped to the device width (375 / 768 / …),
     so the "Dispositivo" toggle now actually restacks the blocks. */
  container: he-page / inline-size;
}

/* Layout blocks */
.he-layout-block {
  width: 100%;
}

/* Full-width: break out of the centered container */
.he-layout-block--full-width {
  position: relative;
  width: 100vw;
  left: 50%;
  margin-left: -50vw;
  border-radius: 0 !important;
}

.he-cols-grid {
  display: grid;
  gap: 16px;
}

.he-cols-grid--1 { grid-template-columns: 1fr; }
.he-cols-grid--2 { grid-template-columns: repeat(2, 1fr); }
.he-cols-grid--3 { grid-template-columns: repeat(3, 1fr); }
/* Custom column ratios come through as an inline `grid-template-columns`
   (set from the editor's drag-resize / "proporção das colunas"). */

@container he-page (max-width: 768px) {
  .he-cols-grid--3:not(.he-cols-grid--custom) { grid-template-columns: repeat(2, 1fr); }
  /* Custom 3-col layouts collapse to 2 tracks on tablet, overriding the inline style. */
  .he-cols-grid--custom.he-cols-grid--3 { grid-template-columns: repeat(2, 1fr) !important; }
}

@container he-page (max-width: 480px) {
  .he-cols-grid--2,
  .he-cols-grid--3 { grid-template-columns: 1fr; }
  /* Stack every multi-column layout on phones, even with a custom ratio. */
  .he-cols-grid--custom { grid-template-columns: 1fr !important; }
}

/* Image blocks */
.he-image-block img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Text blocks */
.he-text-block {
  line-height: 1.6;
}

.he-text-block h1 { font-size: 2rem; margin-bottom: 0.5em; }
.he-text-block h2 { font-size: 1.5rem; margin-bottom: 0.5em; }
.he-text-block h3 { font-size: 1.25rem; margin-bottom: 0.5em; }
.he-text-block h4 { font-size: 1.1rem; margin-bottom: 0.5em; }
.he-text-block p  { margin-bottom: 0.75em; }

/* ─── Product card (single) ─────────────────────────────── */
.he-product-card {
  background: var(--surface-container-lowest, #ffffff);
  border-radius: var(--r-lg, 1rem);
  overflow: hidden;
  box-shadow: 0 2px 32px rgba(160, 82, 45, 0.08), 0 1px 4px rgba(160, 82, 45, 0.04);
  transition: box-shadow 0.25s, transform 0.25s;
  display: flex;
  flex-direction: column;
}

.he-product-card:hover {
  box-shadow: 0 8px 32px rgba(160, 82, 45, 0.15), 0 2px 8px rgba(160, 82, 45, 0.06);
  transform: translateY(-3px);
}

.he-product-card__img-link {
  display: block;
  overflow: hidden;
  background: var(--surface-container, #efeeea);
}

.he-product-card img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.he-product-card:hover img {
  transform: scale(1.04);
}

.he-product-card__body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ─── Product grid ───────────────────────────────────────── */
.he-product-grid {
  display: grid;
  gap: 20px;
}

.he-product-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.he-product-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.he-product-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }

@container he-page (max-width: 768px) {
  .he-product-grid--cols-3,
  .he-product-grid--cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@container he-page (max-width: 480px) {
  .he-product-grid--cols-2,
  .he-product-grid--cols-3,
  .he-product-grid--cols-4 { grid-template-columns: 1fr; }
}

.he-product-grid__card {
  background: var(--surface-container-lowest, #ffffff);
  border-radius: var(--r-lg, 1rem);
  min-width: 0;  /* grid item: don't let image/text min-content blow the track past 1fr */
  overflow: hidden;
  box-shadow: 0 2px 32px rgba(160, 82, 45, 0.08), 0 1px 4px rgba(160, 82, 45, 0.04);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.25s, transform 0.25s;
}

.he-product-grid__card:hover {
  box-shadow: 0 8px 32px rgba(160, 82, 45, 0.15), 0 2px 8px rgba(160, 82, 45, 0.06);
  transform: translateY(-3px);
}

.he-product-grid__card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  background: var(--surface-container, #efeeea);
  transition: transform 0.35s ease;
}

.he-product-grid__card:hover img {
  transform: scale(1.04);
}

.he-product-grid__placeholder {
  width: 100%;
  height: 220px;
  background: var(--surface-container, #efeeea);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--outline, #87736b);
  font-size: 32px;
}

.he-product-grid__info {
  padding: 14px 18px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.he-product-grid__footer {
  padding: 0 18px 16px;
}

.he-product-grid__empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--outline, #888);
  font-family: var(--font-body, system-ui, sans-serif);
}

/* ─── Shared product card internals ──────────────────────── */

/* Category tag */
.he-product-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary, #823b18);
  margin-bottom: 7px;
}

.he-product-tag::before {
  content: '';
  display: block;
  width: 16px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

/* Product name */
.he-product-card__name,
.he-product-grid__name {
  font-family: var(--font-display, 'Libre Caslon Text', Georgia, serif);
  font-size: 17px;
  font-weight: 400;
  color: var(--on-surface, #1b1c1a);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

/* Price block */
.he-product-card__price,
.he-product-grid__price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 14px;
}

.he-price-prefix {
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 12px;
  font-weight: 400;
  color: var(--on-surface-variant, #54433c);
  padding-bottom: 2px;
}

.he-price-amount {
  font-family: var(--font-display, 'Libre Caslon Text', Georgia, serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--on-surface, #1b1c1a);
  letter-spacing: -0.02em;
  line-height: 1;
}

.he-price--original {
  text-decoration: line-through;
  color: var(--outline, #87736b);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 13px;
}

.he-price--promo {
  font-family: var(--font-display, 'Libre Caslon Text', Georgia, serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--primary, #823b18);
  letter-spacing: -0.02em;
  line-height: 1;
}

/* ─── Color swatches ─────────────────────────────────────── */
.he-color-swatches {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.he-color-swatch {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  border: 1.5px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
  display: block;
  transition: transform 0.15s, border-color 0.15s;
}

.he-color-swatch:hover {
  transform: scale(1.08);
  border-color: rgba(0,0,0,0.2);
}

.he-color-swatch img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.he-color-swatch--text {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-container, #efeeea);
  color: var(--on-surface-variant, #54433c);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
  overflow: hidden;
  word-break: break-word;
}

/* Button block */
.he-button-block {
  padding: 4px 0;
}

.he-button-block a,
.he-button-block button {
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  font-family: inherit;
}

.he-button-block a:hover,
.he-button-block button:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

/* Separator block */
.he-separator-block hr {
  border: none;
  margin: 0;
}

/* Video block */
.he-video-block {
  width: 100%;
}

.he-video-wrapper iframe {
  border: none;
}

/* Carousel */
.he-carousel {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #333;
  -webkit-user-select: none;
  user-select: none;
}

.he-carousel-track {
  display: flex;
  height: 100%;
  will-change: transform;
  transition: transform 0.45s cubic-bezier(.25,.46,.45,.94);
}

.he-slide {
  min-width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  position: relative;
}

.he-carousel-prev,
.he-carousel-next {
  transition: background 0.2s;
}

.he-carousel-prev:hover,
.he-carousel-next:hover {
  background: rgba(0, 0, 0, 0.65) !important;
}

.he-dot {
  transition: all 0.25s;
  border: none;
  cursor: pointer;
  padding: 0;
}

@container he-page (max-width: 480px) {
  .he-carousel-prev,
  .he-carousel-next {
    display: none !important;
  }
}

/* HTML embed */
.he-html-embed {
  width: 100%;
}

/* Buy button */
.he-btn-buy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 20px;
  border-radius: var(--r-lg, 1rem);
  border: none;
  background: var(--primary, #823b18);
  color: var(--on-primary, #ffffff);
  font-family: var(--font-body, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.22s, transform 0.18s, box-shadow 0.22s;
  margin-top: auto;
  box-sizing: border-box;
}

.he-btn-buy:hover {
  background: var(--primary-container, #a0522d);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(130, 59, 24, 0.32);
  color: var(--on-primary, #ffffff);
}

/* =========================================================
   Condições de exibição — visibilidade por dispositivo.
   Emitidas como classes pelo servidor (home_editor/rendering.py);
   os breakpoints acompanham os de he-cols-grid (tablet ≤768, mobile ≤480).
   ========================================================= */
@container he-page (min-width: 769px) {
  .he-hide-desktop { display: none !important; }
}
@container he-page (min-width: 481px) and (max-width: 768px) {
  .he-hide-tablet { display: none !important; }
}
@container he-page (max-width: 480px) {
  .he-hide-mobile { display: none !important; }
}
