/* ============================================================
   3DCORE — адаптив и правки поверх статической копии
   Подключается на всех страницах через /assets/site.css
   ============================================================ */

/* ---------- 0. Базовые предохранители от «не влезает» ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
}

img,
svg,
video,
iframe,
canvas,
picture {
  max-width: 100%;
  height: auto;
}

iframe {
  max-width: 100%;
}

/* длинные слова, артикулы, e-mail, ссылки — не ломают вёрстку */
body,
p,
li,
td,
th,
h1,
h2,
h3,
h4,
h5,
h6,
a,
span,
div {
  overflow-wrap: anywhere;
  word-break: break-word;
}

pre,
code,
kbd,
samp {
  max-width: 100%;
}

pre {
  overflow-x: auto;
  white-space: pre;
}

/* таблицы: на мобиле скроллятся горизонтально, а не рвут страницу */
table {
  max-width: 100%;
}

.table-scroll,
.entry-content .wp-block-table,
.entry-content table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.entry-content .wp-block-table > table,
.entry-content .table-scroll > table {
  display: table;
  min-width: 100%;
}

/* ничего не должно выезжать за экран */
.ct-container,
.ct-container-full,
.wp-block-group,
.entry-content > * {
  max-width: 100%;
}

/* ---------- 1. Крупный/средний десктоп ---------- */
@media (max-width: 1440px) {
  :root {
    --theme-container-edge-spacing: min(88vw, 1320px);
  }
}

/* ---------- 2. Планшет ---------- */
@media (max-width: 999.98px) {
  :root {
    --theme-container-edge-spacing: 92vw;
    --theme-content-vertical-spacing: 40px;
  }

  h1,
  h1.entry-title,
  .product_title {
    font-size: clamp(24px, 5.2vw, 40px) !important;
    line-height: 1.2 !important;
  }

  h2 {
    font-size: clamp(20px, 4.4vw, 32px) !important;
    line-height: 1.25 !important;
  }

  h3 {
    font-size: clamp(18px, 3.6vw, 26px) !important;
  }

  /* hero-блоки: не режем текст по высоте */
  [class*='hero'],
  [class*='banner'] {
    min-height: auto !important;
    height: auto !important;
  }
}

/* ---------- 3. Мобильные ---------- */
@media (max-width: 782px) {
  :root {
    --theme-container-edge-spacing: calc(100vw - 32px);
    --theme-content-vertical-spacing: 32px;
  }

  body {
    font-size: 15px;
  }

  /* отступы контента */
  .entry-content > *,
  .wp-block-group > * {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* карточки товаров: 2 в ряд на телефоне, крупнее на планшете */
  .pcard-body {
    padding: 12px !important;
  }

  .pcard-name {
    font-size: 14px !important;
    line-height: 1.35 !important;
  }

  .pcard-price {
    font-size: 16px !important;
  }

  /* длинные кнопки не вылезают */
  .ct-button,
  .wp-block-button__link,
  button,
  input[type='submit'] {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  /* фиксированные ширины в инлайн-стилях контента — обнуляем */
  .entry-content [style*='width:'],
  .entry-content [style*='min-width:'] {
    max-width: 100% !important;
  }

  .entry-content [style*='display:grid'] {
    grid-template-columns: 1fr !important;
  }

  /* таблицы характеристик в 2 колонки — в одну */
  .entry-content table td,
  .entry-content table th {
    padding: 8px 10px !important;
    font-size: 14px !important;
  }
}

@media (max-width: 479.98px) {
  :root {
    --theme-container-edge-spacing: calc(100vw - 24px);
  }

  body {
    font-size: 14.5px;
  }

  h1,
  h1.entry-title {
    font-size: clamp(22px, 7vw, 30px) !important;
  }

  h2 {
    font-size: clamp(19px, 6vw, 25px) !important;
  }

  /* цены в карточках — не переносим некрасиво */
  .woocommerce-Price-amount {
    white-space: nowrap;
  }
}

/* ---------- 4. Логотип 3DCORE ---------- */
body #header .site-logo-container {
  height: auto;
}

#header [data-device='desktop'] .site-logo-container img.default-logo {
  display: block;
  width: clamp(216px, 17.6vw, 248px);
  height: auto;
  max-width: 100%;
}

@media (min-width: 1000px) {
  #header [data-device='desktop'] [data-row='middle'] {
    --height: 136px;
  }

  #header [data-device='desktop'] [data-row='middle'] > .ct-container {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    grid-template-rows: 90px 46px;
    align-items: center;
  }

  #header [data-device='desktop'] [data-column='start'] {
    grid-area: 1 / 1;
  }

  #header [data-device='desktop'] [data-column='end'],
  #header [data-device='desktop'] [data-column='end'] > [data-items] {
    display: contents;
  }

  #header [data-device='desktop'] .dp3-header-phones {
    grid-area: 1 / 2;
  }

  #header [data-device='desktop'] .ct-header-search {
    grid-area: 1 / 3;
    width: 44px;
    min-height: 44px;
  }

  #header [data-device='desktop'] .ct-header-cart {
    grid-area: 1 / 4;
  }

  #header [data-device='desktop'] [data-id='menu'] {
    grid-area: 2 / 1 / 3 / -1;
    display: flex;
    justify-content: center;
    align-self: stretch;
    margin: 0;
  }

  #header [data-device='desktop'] [data-id='menu'] > .menu > li > a {
    display: flex;
    align-items: center;
    min-height: 46px;
  }

  #header [data-device='desktop'] [data-id='menu'] > .menu > li > a[hreflang] {
    font-size: 12px;
    font-weight: 700;
  }

  #header [data-device='desktop'] .dp3-header-phones,
  #header [data-device='desktop'] [data-id='menu'] > .menu > li > a,
  #header [data-device='desktop'] .ct-cart-item {
    white-space: nowrap;
  }
}

@media (max-width: 999.98px) {
  #header [data-device='mobile'] [data-row='middle'] {
    --height: 80px;
  }

  #header [data-device='mobile'] [data-row='middle'] > .ct-container {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
  }

  #header [data-device='mobile'] [data-column='end'] [data-items] {
    gap: clamp(2px, calc(2vw - 6px), 12px);
  }

  #header [data-device='mobile'] [data-items] > [data-id] {
    margin-inline: 0;
  }

  #header [data-device='mobile'] .site-logo-container img.default-logo {
    display: block;
    width: clamp(104px, calc(80vw - 144px), 195.2px);
    height: auto;
    max-width: 100%;
  }
}

body.fs1-page .fs1-nav .fs1-logo img {
  width: clamp(89.6px, 28vw, 141.6px);
  height: auto;
}

/* ---------- 5. Мелкие косметические правки ---------- */
/* горизонтальный скролл внутри блоков «сравнение» */
.entry-content .wp-block-table {
  border-radius: 10px;
}

.entry-content :is(td, th) {
  vertical-align: top;
  word-break: normal;
  overflow-wrap: break-word;
}

@media (max-width: 782px) {
  .entry-content :is(p, li, blockquote)[style*='text-align:justify'],
  .entry-content :is(p, li, blockquote)[style*='text-align: justify'],
  .entry-content .has-text-align-justify {
    text-align: start !important;
  }

  .single-product .woocommerce-tabs .tabs {
    flex-wrap: wrap;
  }

  .woocommerce-product-gallery .flexy-pills > ol {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-inline: 0;
  }

  .woocommerce-product-gallery .flexy-pills > ol > li {
    width: auto;
    padding: 8px 0 0;
  }
}

@media (max-width: 480px) {
  body.fs1-page .fs1-ticket-price {
    grid-column: 1 / -1;
  }

  body.fs1-page .fs1-ticket-price .fs1-price {
    flex-wrap: wrap;
  }
}

/* футер: телефонные ссылки не рвутся посередине */
a[href^='tel:'] {
  white-space: nowrap;
}

/* липкая мобильная панель не перекрывает контент */
@media (max-width: 782px) {
  body {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mbb,
  .m-sticky-buy {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* карта и iframe в контактах */
.entry-content iframe[src*='google.com/maps'] {
  width: 100% !important;
  height: 320px !important;
  border-radius: 12px;
}

@media (max-width: 782px) {
  .entry-content iframe[src*='google.com/maps'] {
    height: 260px !important;
  }
}

/* фокус для доступности */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #e31e24;
  outline-offset: 2px;
}
