/**
 * Base Styles
 * Базовые стили для HTML-элементов с использованием дизайн-токенов
 */

/* ================================================
   HTML & BODY
   ================================================ */

html {
  font-size: 16px; /* Базовый размер для rem */
  scroll-behavior: smooth;
}

/* Отключение smooth scroll для пользователей с prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-secondary);
}

/* ================================================
   ТИПОГРАФИКА
   ================================================ */

/* Заголовки */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

h1 {
  font-size: var(--font-size-5xl);
  letter-spacing: var(--letter-spacing-tight);
}

h2 {
  font-size: var(--font-size-4xl);
  letter-spacing: var(--letter-spacing-tight);
}

h3 {
  font-size: var(--font-size-3xl);
}

h4 {
  font-size: var(--font-size-2xl);
}

h5 {
  font-size: var(--font-size-xl);
}

h6 {
  font-size: var(--font-size-lg);
}

/* Адаптивная типографика для заголовков на мобильных */
@media (max-width: 768px) {
  h1 {
    font-size: var(--font-size-4xl);
  }

  h2 {
    font-size: var(--font-size-3xl);
  }

  h3 {
    font-size: var(--font-size-2xl);
  }
}

/* Параграфы */
p {
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
}

p:last-child {
  margin-bottom: 0;
}

/* Текстовые элементы */
strong,
b {
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.highlight strong,
.highlight b {
  color: inherit;
}

em,
i {
  font-style: italic;
}

small {
  font-size: var(--font-size-sm);
}

/* ================================================
   ССЫЛКИ
   ================================================ */

a {
  color: var(--color-primary-600);
  text-decoration: none;
  transition: var(--transition-colors);
}

a:hover {
  color: var(--color-primary-700);
  text-decoration: underline;
}

a:focus {
  outline: none;
}

a:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
  border-radius: var(--border-radius-sm);
}

/* Внешние ссылки с иконкой (опционально) */
a[target='_blank']:not(.button)::after {
  content: ' ↗';
  font-size: var(--font-size-sm);
  opacity: var(--opacity-60);
}

/* ================================================
   СПИСКИ
   ================================================ */

/* Стили уже сброшены в reset.css, добавляем только spacing */
ul,
ol {
  margin-bottom: var(--space-4);
}

ul:last-child,
ol:last-child {
  margin-bottom: 0;
}

li {
  margin-bottom: var(--space-2);
}

li:last-child {
  margin-bottom: 0;
}

/* Для контентных списков (не навигации) можно добавить маркеры */
article ul:not([class]),
.content ul:not([class]) {
  list-style: disc;
  padding-left: var(--space-6);
}

article ol:not([class]),
.content ol:not([class]) {
  list-style: decimal;
  padding-left: var(--space-6);
}

/* ================================================
   ИЗОБРАЖЕНИЯ
   ================================================ */

img {
  height: auto;
  font-style: italic; /* Alt text стиль */
  background-repeat: no-repeat;
  background-size: cover;
  shape-margin: 1rem;
}

/* ================================================
   ФОРМЫ
   ================================================ */

input,
textarea,
select {
  display: block;
  width: 100%;
  padding: var(--space-3);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  border: var(--border-width-thin) solid var(--color-border-medium);
  border-radius: var(--border-radius-md);
  transition: var(--transition-colors);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
  opacity: var(--opacity-60);
}

/* ================================================
   LAYOUT UTILITIES
   ================================================ */

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

/* Container узкий (для текстового контента) */
.container--narrow {
  max-width: var(--container-max-width-narrow);
}

/* Container широкий */
.container--wide {
  max-width: var(--container-max-width-wide);
}

/* ================================================
   ACCESSIBILITY UTILITIES
   ================================================ */

/* Visually hidden (но доступно для screen readers) */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border-width: 0 !important;
}

/* Skip to main content link */
.skip-to-main {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  z-index: var(--z-tooltip);
  padding: var(--space-3) var(--space-6);
  background-color: var(--color-primary-600);
  color: var(--color-text-on-primary);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--border-radius-md);
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--transition-base) var(--ease-out);
}

.skip-to-main:focus {
  transform: translateY(0);
}

/* Focus visible для всех интерактивных элементов */
:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

/* ================================================
   ОБЩИЕ UTILITY КЛАССЫ
   ================================================ */

/* Text alignment */
.text-left {
  text-align: left;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

/* Font weights */
.font-normal {
  font-weight: var(--font-weight-normal);
}

.font-medium {
  font-weight: var(--font-weight-medium);
}

.font-semibold {
  font-weight: var(--font-weight-semibold);
}

.font-bold {
  font-weight: var(--font-weight-bold);
}

/* Text colors */
.text-primary {
  color: var(--color-text-primary);
}

.text-secondary {
  color: var(--color-text-secondary);
}

.text-muted {
  color: var(--color-text-muted);
}

/* ================================================
   PRINT STYLES
   ================================================ */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: ' (' attr(href) ')';
  }

  abbr[title]::after {
    content: ' (' attr(title) ')';
  }

  /* Не показывать ссылки для якорей и JS */
  a[href^='#']::after,
  a[href^='javascript:']::after {
    content: '';
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  img {
    max-width: 100% !important;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}
