/**
 * UI Kit — кастомные классы темы expertsportal
 * 
 * Этот файл содержит СКОЛЬНЫЕ классы для атомов UI Kit, которые не могут быть
 * реализованы через theme.json (бейджи, теги, утилиты).
 * 
 * ⚠️ Дизайн-токены (цвета, шрифты, spacing, border-radius) берутся ТОЛЬКО из 
 *    theme.json через var(--wp--preset--...).
 * ⚠️ :root содержит ТОЛЬКО layout-токены (contentSize, wideSize) из theme.json.
 * 
 * См. docs/03-ui-kit.md и docs/09-styles-and-css.md
 */

/* ==========================================================================
   1. Layout токены (из theme.json settings.layout)
   ========================================================================== */

:root {
  /* Ширина контента из theme.json → settings.layout.contentSize */
  --wp----custom--layout--content-size: 1200px;
  /* Широкая ширина из theme.json → settings.layout.wideSize */
  --wp----custom--layout--wide-size: 1400px;
  /* Кастомный тип reading из theme.json → settings.layout.customTypes[0].contentSize */
  --wp----custom--layout--reading-size: 720px;

  /* Font weights (дубликат для консистентности с editor.css) */
  --wp--preset--font-weight--regular: 400;
  --wp--preset--font-weight--medium:  500;
  --wp--preset--font-weight--bold:    700;
}

/* ==========================================================================
   2. Теги / чипы (Tags)
   ========================================================================== */

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wp--preset--spacing--space-2);

  min-height: 40px;
  padding: var(--wp--preset--spacing--space-2) var(--wp--preset--spacing--space-5);

  background-color: var(--wp--preset--color--surface-muted);
  border: 0;
  border-radius: var(--wp--custom--radius--pill);
  color: var(--wp--preset--color--text-primary);

  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--body);
  font-weight: var(--wp--preset--font-weight--regular);
  line-height: var(--wp--preset--line-height--normal);

  cursor: pointer;
  transition:
    background-color 200ms cubic-bezier(0.2, 0, 0, 1),
    color            200ms cubic-bezier(0.2, 0, 0, 1),
    box-shadow       120ms cubic-bezier(0,   0, 0.2, 1);
  user-select: none;
}

@media (hover: none) {
  .tag { min-height: 44px; }
}

.tag:hover {
  background-color: #E9EAEC;
}

.tag:active {
  transform: scale(0.98);
}

.tag:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(168, 102, 238, 0.35);
}

.tag[aria-pressed="true"],
.tag.is-active {
  background-color: var(--wp--preset--color--accent-soft);
}

.tag[aria-pressed="true"]:hover,
.tag.is-active:hover {
  background-color: #DABCF6;
}

.tag[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==========================================================================
   2. Кнопки (Button variations)
   ========================================================================== */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wp--preset--spacing--space-2);

  min-height: 44px;
  padding: var(--wp--preset--spacing--space-3) var(--wp--preset--spacing--space-6);

  border: 0;
  border-radius: var(--wp--custom--radius--pill);
  cursor: pointer;

  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--body);
  font-weight: var(--wp--preset--font-weight--medium);
  line-height: var(--wp--preset--line-height--tight);

  transition:
    background-color 200ms cubic-bezier(0.2, 0, 0, 1),
    color            200ms cubic-bezier(0.2, 0, 0, 1),
    transform        120ms cubic-bezier(0,   0, 0.2, 1),
    box-shadow       120ms cubic-bezier(0,   0, 0.2, 1);
}

/* Primary */
.button--primary {
  background-color: var(--wp--preset--color--accent);
  color: var(--wp--preset--color--text-inverse);
}

.button--primary:hover {
  background-color: var(--wp--preset--color--accent-strong);
}

.button--primary:active {
  transform: scale(0.98);
}

/* Secondary (outline) */
.button--secondary {
  background-color: transparent;
  color: var(--wp--preset--color--accent-strong);
  box-shadow: inset 0 0 0 2px var(--wp--preset--color--accent);
}

.button--secondary:hover {
  background-color: var(--wp--preset--color--accent-soft);
}

/* Ghost */
.button--ghost {
  background-color: transparent;
  color: var(--wp--preset--color--text-primary);
}

.button--ghost:hover {
  min-height: 40px;
  padding: var(--wp--preset--spacing--space-2) var(--wp--preset--spacing--space-5);

  background-color: var(--wp--preset--color--surface-muted);
}

/* Состояния */
.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(168, 102, 238, 0.35);
}

.button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==========================================================================
   3. Поля ввода (Input)
   ========================================================================== */

.input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: var(--wp--preset--spacing--space-3) var(--wp--preset--spacing--space-4);

  background-color: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
  border-radius: var(--wp--custom--radius--sm);
  color: var(--wp--preset--color--text-primary);

  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--body);
  line-height: var(--wp--preset--line-height--normal);

  transition:
    border-color 200ms cubic-bezier(0.2, 0, 0, 1),
    box-shadow   200ms cubic-bezier(0.2, 0, 0, 1);
}

.input::placeholder {
  color: var(--wp--preset--color--text-muted);
}

.input:hover {
  border-color: var(--wp--preset--color--text-muted);
}

.input:focus-visible {
  outline: none;
  border-color: var(--wp--preset--color--accent);
  box-shadow: 0 0 0 3px rgba(168, 102, 238, 0.35);
}

.input[aria-invalid="true"] {
  border-color: var(--wp--preset--color--danger);
}

.input[disabled] {
  background-color: var(--wp--preset--color--surface-muted);
  opacity: 0.7;
  cursor: not-allowed;
}

/* ==========================================================================
   4. Аватары
   ========================================================================== */

.avatar {
  border-radius: var(--wp--custom--radius--full);
  object-fit: cover;
  display: inline-block;
}

.avatar-sm {
  width: 40px;
  height: 40px;
}

.avatar-md {
  width: 64px;
  height: 64px;
}

.avatar-lg {
  width: clamp(96px, 18vw, 130px);
  height: clamp(96px, 18vw, 130px);
}

/* ==========================================================================
   5. Разделители
   ========================================================================== */

.divider {
  width: 100%;
  height: 2px;
  background-color: var(--wp--preset--color--divider);
  border-radius: var(--wp--custom--radius--line);
  border: 0;
}

/* ==========================================================================
   6. Маркер секции
   ========================================================================== */

.section-marker {
  display: inline-block;
  width: 5px;
  height: 26px;
  background-color: var(--wp--preset--color--accent);
  border-radius: var(--wp--custom--radius--line);
}

/* ==========================================================================
   7. Иконки
   ========================================================================== */

.icon {
  display: inline-block;
  flex-shrink: 0;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-md {
  width: 24px;
  height: 24px;
}

.icon-lg {
  width: 32px;
  height: 32px;
  color: var(--wp--preset--color--accent);
}

.icon-xl {
  width: 45px;
  height: 45px;
}

/* ==========================================================================
   8. Бейджи
   ========================================================================== */

.badge {
  display: inline-block;
  padding: var(--wp--preset--spacing--space-1) var(--wp--preset--spacing--space-3);
  border-radius: var(--wp--custom--radius--sm);
  font-size: var(--wp--preset--font-size--caption);
  font-weight: var(--wp--preset--font-weight--bold);
  line-height: 1;
}

.badge--urgent {
  background-color: var(--wp--preset--color--danger);
  color: var(--wp--preset--color--text-inverse);
}

.badge--category {
  background-color: var(--wp--preset--color--accent);
  color: var(--wp--preset--color--text-inverse);
}

.badge--partner {
  background-color: var(--wp--preset--color--success);
  color: var(--wp--preset--color--text-inverse);
}

/* ==========================================================================
   9. Текстовые пресеты
   ========================================================================== */

.text-display {
  font-family: var(--wp--preset--font-family--heading);
  font-size: var(--wp--preset--font-size--display);
  font-weight: var(--wp--preset--font-weight--bold);
  line-height: var(--wp--preset--line-height--tight);
  letter-spacing: -0.01em;
  border-radius: var(--wp--custom--radius--pill);
  color: var(--wp--preset--color--text-primary);
}

.text-title {
  font-family: var(--wp--preset--font-family--heading);
  font-size: var(--wp--preset--font-size--title);
  font-weight: var(--wp--preset--font-weight--bold);
  line-height: var(--wp--preset--line-height--snug);
  color: var(--wp--preset--color--text-primary);
}

.text-subtitle {
  font-family: var(--wp--preset--font-family--heading);
  font-size: var(--wp--preset--font-size--body);
  font-weight: var(--wp--preset--font-weight--bold);
  line-height: var(--wp--preset--line-height--normal);
  color: var(--wp--preset--color--text-primary);
}

.text-body {

  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--body);
  font-weight: var(--wp--preset--font-weight--regular);
  line-height: var(--wp--preset--line-height--normal);
  color: var(--wp--preset--color--text-muted);

  cursor: pointer;
  transition:
    background-color 200ms cubic-bezier(0.2, 0, 0, 1),
    color            200ms cubic-bezier(0.2, 0, 0, 1),
    box-shadow       120ms cubic-bezier(0,   0, 0.2, 1);
  user-select: none;
}

.text-meta {
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--body);
  font-weight: var(--wp--preset--font-weight--regular);
  line-height: var(--wp--preset--line-height--normal);
  color: var(--wp--preset--color--text-primary);
}

.text-name {
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--title);
  font-weight: var(--wp--preset--font-weight--regular);
  line-height: var(--wp--preset--line-height--normal);
  color: var(--wp--preset--color--text-strong);
}

.text-link {
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--body);
  font-weight: var(--wp--preset--font-weight--regular);
  line-height: var(--wp--preset--line-height--normal);
  color: var(--wp--preset--color--accent-strong);
  text-decoration: none;
  transition: color 200ms cubic-bezier(0.2, 0, 0, 1);
}

.text-link:hover {
  color: var(--wp--preset--color--accent);
  text-decoration: underline;
}

/* ==========================================================================
   10. Utility-классы для изображений
   ========================================================================== */

img,
picture,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

.media-fluid {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--wp--custom--radius--md);
}

.hero-image {
  width: 100%;
  aspect-ratio: 680 / 378;
  object-fit: cover;
  border-radius: var(--wp--custom--radius--lg);
}

.news-card__media {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--wp--custom--radius--md);
  display: block;
}

.news-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   11. Брейкпоинты — Mobile-First (min-width, от мобилки к десктопу)
   ========================================================================== */

/*
 * Единая система брейкпойнтов для всего проекта.
 * Базовые стили = мобилка (0–767px). Далее — только min-width.
 *
 *   sm:    480px   — landscape-телефоны
 *   md:    768px   — tablet portrait (iPad Mini, Air, Pro, горизонт. телефоны)
 *   lg:    1024px  — tablet landscape / малый десктоп
 *   xl:    1280px  — стандартный десктоп (1200px контейнер + стрелки слайдера)
 *   2xl:   1440px  — широкий десктоп
 */

:root {
  --bp-sm:  480px;
  --bp-md:  768px;
  --bp-lg:  1024px;
  --bp-xl:  1280px;
  --bp-2xl: 1440px;
}

/* (пустые блоки — документация, не удалять) */
@media (min-width: 480px)  { /* sm */ }
@media (min-width: 768px)  { /* md — tablet */ }
@media (min-width: 1024px) { /* lg */ }
@media (min-width: 1280px) { /* xl */ }
@media (min-width: 1440px) { /* 2xl */ }

/* ==========================================================================
   12. Скрытие/показ блоков (mobile-first)
   ========================================================================== */

/* По умолчанию (мобилка): скрываем десктопные элементы, показываем мобильные */
.hidden-mobile  { display: none; }   /* скрыт на мобилке, покажется на ≥ tablet */
.hidden-tablet  { display: block; }  /* видно на мобилке, скроется на tablet */
.hidden-desktop { display: block; }  /* видно на мобилке, скроется на десктопе */

@media (min-width: 768px) {
  .hidden-mobile  { display: block; }
  .hidden-tablet  { display: none; }
}

@media (min-width: 1024px) {
  .hidden-mobile  { display: block; }
  .hidden-desktop { display: none; }
}

/* ==========================================================================
   13. Touch-friendly элементы
   ========================================================================== */

.is-touchable {
  min-height: 44px;
  min-width: 44px;
}

/* ==========================================================================
   14. Focus-visible универсальный шаблон
   ========================================================================== */

.is-focusable:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(168, 102, 238, 0.35);
  border-radius: inherit;
}

/* ==========================================================================
   15. Prefers-reduced-motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   16. Тени (Shadows) — демонстрационные классы
   ========================================================================== */
/* Значения из theme.json → settings.shadow.presets */

.uikit-shadow-xs {
	box-shadow: 0 1px 2px 0 rgba(26, 27, 29, 0.04);
}

.uikit-shadow-sm {
	box-shadow: 0 2px 8px 0 rgba(26, 27, 29, 0.06);
}

.uikit-shadow-md {
	box-shadow: 0 8px 24px -4px rgba(26, 27, 29, 0.10);
}

.uikit-shadow-lg {
	box-shadow: 0 16px 40px -8px rgba(26, 27, 29, 0.16);
}

.uikit-shadow-xl {
	box-shadow: 0 24px 60px -12px rgba(26, 27, 29, 0.22);
}

.uikit-shadow-focus {
	box-shadow: 0 0 0 4px rgba(168, 102, 238, 0.5);
}

/* ==========================================================================
   17. Gutenberg Layout Types (theme.json)
   ========================================================================== */

/* Content layout — стандартная ширина контента (1200px из theme.json) */
.is-layout-constrained {
  max-width: var(--wp----custom--layout--content-size) !important;
  margin-inline: auto !important;
}

/* Wide layout — широкая ширина (1400px из theme.json) */
.is-layout-wide {
  max-width: var(--wp----custom--layout--wide-size) !important;
  margin-inline: auto !important;
}

/* Reading layout — оптимальная ширина для чтения статей (720px из theme.json customTypes) */
.is-layout-reading {
  max-width: var(--wp----custom--layout--reading-size) !important;
  margin-inline: auto !important;
}

/* Использование: добавить Group с layout.type="constrained/wide/reading" в Gutenberg */

/* ==========================================================================
   17. Site Logo (custom-logo) — Mobile-First
   ========================================================================== */

.wp-block-site-logo {
  line-height: 0;
}

.wp-block-site-logo img {
  height: auto;
  width: auto;
  // Mobile: логотип меньше
  max-width: 210px;
  max-height: 72px;
  object-fit: contain;
}

.wp-block-site-logo a {
  display: block;
  line-height: 0;
}

// Tablet (≥768px)
@media (min-width: 768px) {
  .wp-block-site-logo img {
    max-width: 360px;
    max-height: 144px;
  }
}

// Desktop (≥1024px)
@media (min-width: 1024px) {
  .wp-block-site-logo img {
    max-width: 420px;
    max-height: 180px;
  }
}

/* ==========================================================================
   18. Разделитель в хедере (header separator)
   ========================================================================== */

/* Сброс стандартных отступов Gutenberg у разделителя в хедере */
header .header-separator,
.header-separator.wp-block-separator {
  margin-top: var(--wp--preset--spacing--space-0) !important;
  margin-bottom: var(--wp--preset--spacing--space-0) !important;
}

/* ==========================================================================
   19. Sticky header — фиксированная шапка
   ========================================================================== */

/* Убираем отступы у wp-site-blocks для первого элемента (header) */
.wp-site-blocks > :first-child {
  margin-block-start: 0 !important;
}

/* Фиксируем шапку у верхнего края экрана при прокрутке */
/* Основной селектор — применяем sticky к wrapper */
header.wp-block-template-part,
body .wp-block-template-part:has(.header-sticky) {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 999 !important;
  background-color: var(--wp--preset--color--surface) !important;
}

/* Учитываем WordPress admin bar при прокрутке */
.admin-bar header.wp-block-template-part,
.admin-bar body .wp-block-template-part:has(.header-sticky) {
  top: 32px !important;
}

@media (max-width: 782px) {
  .admin-bar header.wp-block-template-part,
  .admin-bar body .wp-block-template-part:has(.header-sticky) {
    top: 46px !important;
  }
}

