/*
 * Base — reset + typography + fundamental styles
 * 
 * Порядок:
 * 1. Reset (обнуление браузерных стилей)
 * 2. Base HTML elements
 * 3. Typography scale
 * 4. Links
 * 5. Layout utilities
 */

/* ============================================================
   1. RESET
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    /* Плавный скролл для якорных ссылок */
    scroll-behavior: smooth;
    
    /* Предотвращаем скачок при появлении скроллбара */
    overflow-y: scroll;
    
    /* Улучшаем рендер текста */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-main);
    background-color: var(--bg-base);
    
    /* Плавный переход при смене темы */
    transition: background-color var(--transition-normal),
                color var(--transition-normal);
    
    /* Улучшенный рендер шрифтов */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Убираем стили списков */
ul, ol {
    list-style: none;
}

/* Картинки не вылезают за контейнер */
img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Формы наследуют шрифт */
input, button, textarea, select {
    font: inherit;
}

/* Убираем outline по умолчанию, добавим свой */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Скрываем outline при клике мышью (только для клавиатуры) */
:focus:not(:focus-visible) {
    outline: none;
}


/* ============================================================
   2. BASE HTML ELEMENTS
   ============================================================ */

/* Горизонтальная линия */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* Цитаты */
blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-style: italic;
}

/* Код инлайн */
code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--bg-surface-alt);
    padding: 2px 6px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

/* Код блок */
pre {
    font-family: var(--font-mono);
    font-size: 14px;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

pre code {
    background: none;
    border: none;
    padding: 0;
}

/* Таблицы базовые */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-hint);
    background: var(--bg-surface-alt);
}


/* ============================================================
   3. TYPOGRAPHY SCALE
   ============================================================ */

/* Hero — используется редко, для главных заголовков */
.t-hero {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

h1, .t-h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h2, .t-h2 {
    font-size: clamp(1.25rem, 3vw, 1.375rem);
    font-weight: 600;
    line-height: 1.3;
}

h3, .t-h3 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

h4, .t-h4 {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
}

/* Spacing для заголовков в контенте */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-main);
}

/* Мелкий текст */
small, .t-small {
    font-size: 0.8125rem;
    color: var(--text-hint);
}

/* Моно текст (спеки, данные) */
.t-mono {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

/* Лейбл (категории, метки) */
.t-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-hint);
}


/* ============================================================
   4. LINKS
   ============================================================ */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
}


/* ============================================================
   5. LAYOUT
   ============================================================ */

/* Контейнер для контента */
.container {
    width: 100%;
    max-width: var(--wide-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Узкий контейнер для текстового контента */
.container-narrow {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Основная область контента */
.site-content {
    min-height: calc(100vh - var(--header-height) - 200px);
    padding-bottom: 4rem;
}

/* Visually hidden (для accessibility, скринридеры видят) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}