/* RUN365 — база: подключается на КАЖДОЙ странице.
   В теме → wp_enqueue_style('r365-base') без условий.
   Содержит: утилиты, полосу лояльности, шапку, мега-меню, футер,
   шапку секции и карточку товара (она нужна и на главной, и в каталоге,
   и в блоке «с этим товаром покупают»).
   Требует run365-tokens.css. */

/* ============ утилиты ============ */

.r365-wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  width: 100%;
}

.r365-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-lab);
}

.r365-more {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 3px;
  white-space: nowrap;
}
.r365-more:hover { border-bottom-color: var(--text); }

.r365-ai-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 10px;
  font-weight: 700;
  width: 26px;
  height: 26px;
}

/* основная кнопка */
.r365-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 22px;
  border-radius: 24px;
  background: var(--btn);
  color: var(--btn-fg);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
}

/* ============ полоса лояльности ============ */

.r365-loyalty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 0 0 22px 22px;
  padding: 11px 20px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 500;
}
.r365-loyalty b { font-weight: 700; letter-spacing: .02em; }
.r365-loyalty__cta { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.r365-loyalty__short { display: none; }

/* ============ шапка ============ */

.r365-header {
  position: sticky;
  top: 0;
  /* выше липкой панели каталога (62), иначе она просвечивает
     сквозь раскрытое мега-меню на мобильном */
  z-index: 70;
  background: rgba(244, 244, 242, .92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid #dedcd6;
}

.r365-utility {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 18px;
  min-height: 34px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-mut);
  border-bottom: 1px solid #e6e4de;
}
.r365-utility a { color: var(--text-mut); }
.r365-utility a:hover { color: var(--text); }
.r365-utility__left { display: flex; flex-wrap: wrap; gap: 6px 26px; }
.r365-utility__right { display: flex; align-items: center; gap: 18px; }
.r365-utility__right span { color: var(--text); white-space: nowrap; }
.r365-online { display: flex; align-items: center; gap: 6px; }
.r365-online::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stock-lite);
}

.r365-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  row-gap: 12px;
  padding-top: 18px;
  padding-bottom: 18px;
}
.r365-logo { flex: none; display: block; }
.r365-logo img { height: 34px; width: auto; display: block; }

.r365-nav {
  display: flex;
  gap: 22px;
  min-width: 0;
  margin: 0;
  padding: 0;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.01em;
  transition: opacity .32s cubic-bezier(.4, 0, .2, 1);
}
.r365-nav > li { list-style: none; }
.r365-nav__link { display: block; padding: 6px 0; border-bottom: 2px solid transparent; }
.r365-nav > li:hover .r365-nav__link { border-bottom-color: var(--text); }
.r365-nav__link--sale { color: var(--accent-ink); }

.r365-spacer { flex: 1; }

/* Поиск свёрнут в кружок 44px и раскрывается до 272px по клику на лупу.
   Пока он открыт, навигация гаснет, а у кнопки консультанта схлопывается
   подпись — остаётся только значок AI. Ровно как в макете. */
.r365-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--rule-soft);
  border-radius: 20px;
  background: var(--surface);
  width: 44px;
  max-width: 100%;
  overflow: hidden;
  /* без этого форма — обычный флекс-элемент шапки и ужимается обратно,
     несмотря на width: 272px */
  flex: none;
  transition: width .32s cubic-bezier(.4, 0, .2, 1);
}
.r365-search.is-open { width: 272px; padding: 0 12px; }

.r365-search__toggle {
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.r365-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  opacity: 0;
  transition: opacity .2s ease;
}
.r365-search.is-open input { opacity: 1; }

/* Навигацию гасим только когда раскрытому поиску реально не хватает места.
   На широком десктопе между меню и поиском есть распорка — прятать пункты
   там незачем, это только сбивает с толку. */
@media (max-width: 1279px) {
  .r365-bar.is-search-open .r365-nav { opacity: 0; pointer-events: none; }
}

.r365-consultant {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--rule-soft);
  border-radius: 20px;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.r365-consultant:hover { border-color: var(--text); }
.r365-consultant__label {
  max-width: 120px;
  opacity: 1;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width .32s cubic-bezier(.4, 0, .2, 1), opacity .2s ease;
}
.r365-bar.is-search-open .r365-consultant__label { max-width: 0; opacity: 0; }

/* Когда подпись схлопнулась, оставшиеся padding 16px и gap 9px сдвигают
   значок влево от центра. Поэтому кнопка сжимается в ровный кружок. */
.r365-consultant {
  transition: width .32s cubic-bezier(.4, 0, .2, 1), padding .32s cubic-bezier(.4, 0, .2, 1);
}
.r365-bar.is-search-open .r365-consultant {
  width: 40px;
  padding: 0;
  gap: 0;
  justify-content: center;
}
.r365-consultant .r365-ai-badge {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--accent-text);
  font-size: 9px;
}

.r365-account {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.r365-cart { display: flex; align-items: center; gap: 7px; }
.r365-cart__count {
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--btn);
  color: var(--btn-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

/* мега-меню: hover, без JS на десктопе */
.r365-mega {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: var(--surface);
  border-top: 1px solid #dedcd6;
  border-bottom: 1px solid #dedcd6;
  box-shadow: 0 24px 44px rgba(0, 0, 0, .1);
  display: none;
}
/* Мостик между пунктом меню и панелью.
   Панель висит под всей шапкой, а пункт кончается выше её низа — между
   ними 21px пустоты (нижний отступ .r365-bar). Курсор по дороге вниз
   выходил из :hover, и меню схлопывалось на полпути.
   Псевдоэлемент принадлежит самой панели, то есть потомку пункта, —
   пока курсор на нём, пункт считается наведённым. Высота привязана
   к отступу .r365-bar: поменяется он — поправить и здесь. */
.r365-mega::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 21px;
}

@media (min-width: 861px) {
  .r365-nav > li:hover .r365-mega { display: block; }
}
/* на мобильном раскрывается тапом — класс вешает JS */
.r365-nav > li.is-open .r365-mega { display: block; }
.r365-mega__inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 40px;
  padding-top: 34px;
  padding-bottom: 38px;
}
.r365-mega__col { display: flex; flex-direction: column; gap: 14px; }
.r365-mega__title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.r365-mega__list { display: flex; flex-direction: column; gap: 11px; }
.r365-mega__list a { font-size: 15px; color: var(--text-hover); }
.r365-mega__list a:hover { color: var(--accent-ink); }

/* ============ хлебные крошки: нужны и каталогу, и карточке товара ============ */

.r365-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-lab);
  padding-top: 26px;
}
.r365-crumbs a { color: var(--text-lab); }
.r365-crumbs a:hover { color: var(--text); }
.r365-crumbs__current { color: var(--text); }

/* ============ шапка секции ============ */

.r365-section { padding-top: var(--sec-gap); width: 100%; }
.r365-section--first { padding-top: 30px; }

.r365-section__head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 22px;
}
.r365-section__title {
  margin: 0;
  font-size: clamp(22px, 2.79vw, 38px);
  font-weight: 800;
  letter-spacing: -.04em;
}

/* ============ карточка товара ============
   Одна разметка на главную, каталог и апселлы.
   В теме → template-parts/product-card.php, вызывается из
   woocommerce/content-product.php. */

.r365-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.r365-card:hover { border-color: var(--text); }

.r365-card__media {
  position: relative;
  aspect-ratio: 355 / 250;
  background: var(--surface);
}
.r365-card__media > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
}

.r365-card__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--btn);
  color: var(--btn-fg);
  padding: 5px 9px;
  border-radius: 999px;
}

/* полоса размеров, проявляется по наведению на карточку */
.r365-card__sizes {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 9px 10px;
  background: rgba(255, 255, 255, .95);
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.r365-card:hover .r365-card__sizes { opacity: 1; }
.r365-card__size {
  height: 21px;
  padding: 0 7px;
  border-radius: 11px;
  background: #f2f0ea;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-hover);
  display: flex;
  align-items: center;
}

.r365-card__body {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-top: 1px solid var(--hairline);
}
.r365-card__brand { font-size: 10px; letter-spacing: .1em; }
.r365-card__name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.r365-card__spec { font-size: 11px; font-weight: 500; line-height: 1.4; color: var(--text-mut); }

.r365-card__prices {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding-top: 7px;
}
.r365-card__price { font-size: 17px; font-weight: 700; }
.r365-card__old {
  font-size: 12px;
  font-weight: 500;
  color: #a3a39b;
  text-decoration: line-through;
}
.r365-card__range { font-size: 11px; font-weight: 500; color: var(--text-mut); padding-top: 5px; }


/* ============ уведомления WooCommerce ============
   Плагин рисует их своей серо-зелёной плашкой с иконочным шрифтом.
   Перебиваем на наш стиль: карточка с чёрной полоской слева, как у блока
   статуса на карточке товара. Кнопка внутри — наша основная.
   Ссылка «Просмотр корзины» приходит от WooCommerce, свою не заводим. */

.woocommerce-notices-wrapper:empty { display: none; }
.r365-notices:has(.woocommerce-notices-wrapper:empty) { display: none; }
.r365-notices { padding-top: 22px; }

.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin: 0 0 20px;
  padding: 16px 20px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text);
  border-top: 0;
  border-radius: 4px 18px 18px 4px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--text);
}

/* иконочный шрифт плагина убираем, ставим свою метку */
.woocommerce-message::before,
.woocommerce-info::before,
.woocommerce-error::before {
  content: '';
  position: static;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--stock) no-repeat center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5.5 5.5L20 7'/%3E%3C/svg%3E");
  margin: 0;
  font-size: 0;
  color: transparent;
}
.woocommerce-info::before { background-color: var(--text); }
.woocommerce-error::before { background-color: var(--sale); }

/* текст занимает всё место, кнопка прижимается вправо */
.woocommerce-message > a.button,
.woocommerce-info > a.button,
.woocommerce-error > a.button {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 20px;
  border-radius: 20px;
  background: var(--btn);
  color: var(--btn-fg);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.woocommerce-message > a.button:hover,
.woocommerce-info > a.button:hover,
.woocommerce-error > a.button:hover { background: var(--text-hover); color: var(--btn-fg); }

.woocommerce-error { flex-direction: column; align-items: flex-start; }
.woocommerce-error li { list-style: none; }

@media (max-width: 560px) {
  .woocommerce-message > a.button,
  .woocommerce-info > a.button,
  .woocommerce-error > a.button { margin-left: 0; width: 100%; }
}

/* ============ футер ============ */

.r365-footer { margin-top: 70px; background: var(--ink); color: var(--ink-fg); }
.r365-footer__cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 40px;
  padding-top: 56px;
  padding-bottom: 40px;
}
.r365-footer__col { display: flex; flex-direction: column; gap: 12px; font-size: 15px; }
.r365-footer__col a { color: var(--ink-mut); }
.r365-footer__col a:hover { color: var(--ink-fg); }
.r365-footer__col .r365-label { color: var(--ink-lab); letter-spacing: .1em; }
.r365-footer__brand { gap: 18px; }
.r365-footer__brand img { height: 32px; width: auto; align-self: flex-start; filter: invert(1); }
.r365-footer__about { font-size: 15px; line-height: 1.55; color: var(--ink-mut); max-width: 300px; }
.r365-footer__phone { font-size: 14px; font-weight: 500; }

.r365-footer__legal { padding-bottom: 44px; }
.r365-footer__legal-inner {
  border-top: 1px solid var(--ink-line);
  padding-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-lab);
}
.r365-footer__legal-inner a { color: var(--ink-lab); }
.r365-footer__legal-links { display: flex; gap: 22px; }

/* ============ мобильный ============ */

@media (max-width: 860px) {
  :root { --sec-gap: 40px; }

  .r365-loyalty { padding: 8px 12px; font-size: 11px; }
  .r365-loyalty__long { display: none; }
  .r365-loyalty__short { display: inline; }

  .r365-utility,
  .r365-consultant,
  .r365-spacer { display: none; }

  .r365-bar { gap: 12px; }

  /* первая строка: логотип, поиск, корзина. Поиск прижат вправо */
  .r365-search,
  .r365-account { order: 2; }
  .r365-search { margin-left: auto; }
  .r365-search.is-open { width: 100%; margin-left: 0; }

  /* вход прячем: на телефоне он уводит с витрины, в макете его тоже нет */
  .r365-account > a:not(.r365-cart) { display: none; }

  /* вторая строка: разделы лентой с горизонтальной прокруткой */
  .r365-nav {
    order: 3;
    flex: 1 1 100%;
    gap: 18px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .r365-nav::-webkit-scrollbar { display: none; }
  .r365-nav > li { flex: none; }

  /* мега-меню разворачивается на всю ширину под шапкой */
  .r365-mega { max-height: 70vh; overflow-y: auto; }
  .r365-mega__inner {
    grid-template-columns: 1fr;
    gap: 22px;
    padding-top: 22px;
    padding-bottom: 26px;
  }
  .r365-mega__list { gap: 9px; }

  .r365-card__body { padding: 12px 13px 15px; }
  .r365-card__name,
  .r365-card__price { font-size: 14px; }
  .r365-card__sizes { display: none; }

  .r365-footer { margin-top: 40px; }
  .r365-footer__legal-inner { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
