/* Fitberg homepage — category tiles + H1 aligned to maxwidth-theme grid */

/* H1 in the same content column as .maxwidth-theme blocks */
body.front_page .fitberg-home-h1 {
  width: 100%;
  max-width: calc(
    var(--theme-page-width, 1296px) + 2 * var(--theme-page-width-padding, 32px)
  );
  margin: 24px auto 12px;
  padding-left: var(--theme-page-width-padding, 32px);
  padding-right: var(--theme-page-width-padding, 32px);
  box-sizing: border-box;
  font-size: clamp(1.25rem, 1.8vw, 1.65rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--white_text_black, #222);
}

@media (max-width: 600px) {
  body.front_page .fitberg-home-h1 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 1.2rem;
  }
}

/* Keep home stock on the same grid padding */
body.front_page .fitberg-home-stock.maxwidth-theme {
  box-sizing: border-box;
}

.sections-tile.tile-template {
  --fitberg-tile-pad: 14px 12px 16px;
  --fitberg-tile-img: 118px;
  --fitberg-tile-gap: 10px;
  --fitberg-tile-bg: var(--card_bg_black, #fafafa);
  --fitberg-tile-border: var(--stroke_black, #ebebeb);
  --fitberg-tile-text: var(--white_text_black, #2a2a2e);
  --fitberg-tile-muted: var(--secondary, #8a8a8f);
  --fitberg-tile-radius: 10px;
  --fitberg-accent: #ea0000;
}

.sections-tile.tile-template > .maxwidth-theme > .grid-list,
.sections-tile.tile-template .grid-list {
  --gap: 10px;
  row-gap: 14px;
  align-items: stretch;
  overflow: visible !important;
  padding: 4px 2px 14px;
}

.sections-tile.tile-template .sections-tile__group-heading {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 6px 0 0;
}

.sections-tile.tile-template .sections-tile__group-heading:first-child {
  margin-top: 0;
}

.sections-tile.tile-template .fitberg-sections-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 4px;
  padding: 0 2px;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--fitberg-tile-text) !important;
  letter-spacing: 0.01em;
  text-decoration: none;
  background: none !important;
}

.sections-tile.tile-template a.fitberg-sections-group-title:hover,
.sections-tile.tile-template a.fitberg-sections-group-title:focus {
  color: var(--fitberg-accent) !important;
  background: none !important;
  box-shadow: none !important;
}

.sections-tile.tile-template .fitberg-sections-group-title::before {
  content: "";
  flex: 0 0 3px;
  align-self: stretch;
  min-height: 1em;
  border-radius: 2px;
  background: var(--fitberg-accent);
}

/* Equal-size category buttons */
.sections-tile.tile-template,
.sections-tile.tile-template > .maxwidth-theme {
  overflow: visible;
}

.sections-tile.tile-template .grid-list > .grid-list__item:not(.sections-tile__group-heading) {
  min-width: 0;
  height: auto !important;
  display: flex;
  align-self: stretch;
}

.sections-tile.tile-template .sections-tile__item,
.sections-tile.tile-template .sections-tile__item.fitberg-home-tile,
.sections-tile.tile-template .sections-tile__item.height-100 {
  padding: var(--fitberg-tile-pad) !important;
  background-color: var(--fitberg-tile-bg) !important;
  border: 1px solid var(--fitberg-tile-border) !important;
  border-radius: var(--fitberg-tile-radius) !important;
  box-shadow: 0 0 0 1px transparent;
  width: 100%;
  height: 100% !important;
  min-height: 198px;
  display: flex !important;
  flex-direction: column;
  position: relative;
  z-index: 1;
  overflow: visible;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.sections-tile.tile-template .sections-tile__item:hover,
.sections-tile.tile-template .sections-tile__item.fitberg-home-tile:hover {
  background-color: var(--fitberg-tile-bg) !important;
  border-color: var(--fitberg-tile-border) !important;
  transform: translateY(-5px);
  z-index: 3;
  box-shadow:
    0 0 0 1px rgba(34, 34, 40, 0.06),
    0 8px 22px rgba(34, 34, 40, 0.16) !important;
}

/* Keep rest background; do not flatten the tile lift shadow */
@media (any-hover: hover) {
  body.front_page .shadow-no-border-hovered:hover,
  body.front_page .shadow-no-border-hovered--with-picture:hover {
    background-color: var(--card_bg_black, #fff) !important;
    border-color: var(--stroke_black, #ebebeb) !important;
  }

  body.front_page .sections-tile.tile-template .sections-tile__item:hover,
  body.front_page .sections-tile.tile-template .sections-tile__item.shadow-no-border-hovered:hover {
    background-color: var(--fitberg-tile-bg) !important;
    transform: translateY(-5px);
    box-shadow:
      0 0 0 1px rgba(34, 34, 40, 0.06),
      0 8px 22px rgba(34, 34, 40, 0.16) !important;
  }
}

/* Image on top, text below */
.sections-tile.tile-template .sections-tile__item-link,
.sections-tile.tile-template .sections-tile__item-link.fitberg-home-tile-link {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: center !important;
  gap: var(--fitberg-tile-gap) !important;
  height: 100% !important;
  min-height: 0;
  text-align: center;
  color: var(--fitberg-tile-text) !important;
}

.sections-tile.tile-template a.dark_link {
  color: var(--fitberg-tile-text) !important;
}

.sections-tile.tile-template .fitberg-home-tile-body,
.sections-tile.tile-template .sections-tile__item-link > .flexbox.gap--6 {
  flex: 0 1 auto;
  width: 100%;
  min-width: 0;
  display: flex !important;
  flex-direction: column !important;
  align-items: center;
  justify-content: flex-start;
  gap: 2px !important;
  order: 2;
}

.sections-tile.tile-template .sections-tile__item-text {
  font-size: 14.5px !important;
  line-height: 1.3 !important;
  font-weight: 600 !important;
  color: var(--fitberg-tile-text) !important;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
  min-height: calc(1.3em * 2);
}

/* Hide product count («N товара») under category titles */
.sections-tile.tile-template .fitberg-home-tile-sub,
.sections-tile.tile-template .sections-tile__item-link .font_12.secondary-color,
.sections-tile.tile-template .sections-tile__item-link > .flexbox.gap--6 > .font_12 {
  display: none !important;
}

.sections-tile.tile-template .sections-tile__item-arrow {
  display: none !important;
}

.sections-tile.tile-template .line-block--justify-between {
  justify-content: center !important;
}

.sections-tile.tile-template .sections-tile__item-inner {
  flex: 0 0 auto;
  order: 1;
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.sections-tile.tile-template .sections-tile__item-image-wrapper,
.sections-tile.tile-template .sections-tile__item-image-wrapper--PICTURES,
.sections-tile.tile-template .sections-tile__item-image-wrapper--TRANSPARENT_PICTURES,
.sections-tile.tile-template .sections-tile__item-image-wrapper--ICONS,
.sections-tile.tile-template .sections-tile__item-image-wrapper--PICTURES.sections-tile__item-image-wrapper--items-medium,
.sections-tile.tile-template .sections-tile__item-image-wrapper--PICTURES.sections-tile__item-image-wrapper--items-small,
.sections-tile.tile-template .fitberg-home-tile .sections-tile__item-image-wrapper {
  --section-image-size: var(--fitberg-tile-img) !important;
  flex: 0 0 var(--fitberg-tile-img) !important;
  flex-basis: var(--fitberg-tile-img) !important;
  width: var(--fitberg-tile-img) !important;
  height: var(--fitberg-tile-img) !important;
  min-width: var(--fitberg-tile-img) !important;
  min-height: var(--fitberg-tile-img) !important;
  max-width: var(--fitberg-tile-img) !important;
  max-height: var(--fitberg-tile-img) !important;
  aspect-ratio: 1 !important;
  border-radius: 8px !important;
  overflow: hidden;
  background: transparent;
  padding: 0 !important;
  box-sizing: border-box;
  position: relative;
  order: 1;
  margin: 0 auto;
}

.sections-tile.tile-template .sections-tile__item-image-wrapper.rounded,
.sections-tile.tile-template .sections-tile__item-image-wrapper--PICTURES.rounded {
  border-radius: 8px !important;
}

.sections-tile.tile-template .sections-tile__item-image.img,
.sections-tile.tile-template .sections-tile__item-image.fit-image,
.sections-tile.tile-template .sections-tile__item-image.absolute,
.sections-tile.tile-template img.sections-tile__item-image {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center !important;
  border-radius: 0 !important;
}

@media (max-width: 991px) {
  .sections-tile.tile-template {
    --fitberg-tile-img: 96px;
    --fitberg-tile-pad: 12px 10px 14px;
    --fitberg-tile-gap: 8px;
  }

  .sections-tile.tile-template .fitberg-sections-group-title {
    font-size: 16px;
  }

  .sections-tile.tile-template .sections-tile__item-text {
    font-size: 13.5px !important;
  }
}

@media (max-width: 600px) {
  .sections-tile.tile-template {
    --fitberg-tile-img: 72px;
    --fitberg-tile-pad: 10px 6px 12px;
    --fitberg-tile-gap: 6px;
  }

  .sections-tile.tile-template > .maxwidth-theme > .grid-list,
  .sections-tile.tile-template .grid-list {
    --gap: 8px;
    --items-count: 2 !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    row-gap: 10px;
  }

  .sections-tile.tile-template .fitberg-sections-group-title {
    font-size: 15px;
  }

  .sections-tile.tile-template .sections-tile__item-text {
    font-size: 13px !important;
  }
}

/* Dark / prefers-color-scheme safety for titles */
html.theme-dark .sections-tile.tile-template .fitberg-sections-group-title,
body.theme-dark .sections-tile.tile-template .fitberg-sections-group-title,
.theme-dark .sections-tile.tile-template .fitberg-sections-group-title {
  color: #ffffff !important;
}

@media (prefers-color-scheme: dark) {
  body.theme-default .sections-tile.tile-template .fitberg-sections-group-title {
    color: #ffffff !important;
  }

  body.theme-default .sections-tile.tile-template .sections-tile__item,
  body.theme-default .sections-tile.tile-template .sections-tile__item.fitberg-home-tile {
    background-color: #2a2a31 !important;
    border-color: #3f3f45 !important;
  }

  body.theme-default .sections-tile.tile-template .sections-tile__item-text,
  body.theme-default .sections-tile.tile-template .sections-tile__item-link,
  body.theme-default .sections-tile.tile-template a.dark_link {
    color: #e8eaed !important;
  }

  body.theme-default .sections-tile.tile-template .fitberg-home-tile-sub,
  body.theme-default .sections-tile.tile-template .sections-tile__item-link .font_12.secondary-color {
    color: #a8adb3 !important;
  }

  body.theme-default .fitberg-home-h1 {
    color: #ffffff !important;
  }
}
