/* ============================================================
   BASE.CSS — Технический фундамент для всех проектов студии
   ============================================================
   Что здесь есть:
   - CSS-переменные (объявления; значения переопределяются в проекте)
   - Reset / normalize
   - Container
   - Базовая типографика
   - Утилиты кнопок
   - Утилиты spacing/layout

   Что НЕЛЬЗЯ делать:
   - Не менять этот файл под конкретный проект
   - Не хардкодить сюда конкретные цвета/шрифты — они переопределяются
     в :root проекта (STYLE SPEC из HTML)
   ============================================================ */


/* === 1. CSS-ПЕРЕМЕННЫЕ (дефолты, переопределяются в проекте) === */

:root {
  /* Цвета — переопределяются в HTML проекта из STYLE SPEC */
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-bg: #ffffff;
  --color-bg-alt: #f8fafc;
  --color-bg-dark: #0f172a;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-inverse: #ffffff;
  --color-border: #e2e8f0;

  /* Шрифты — переопределяются в HTML проекта из STYLE SPEC */
  --font-heading: 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Размеры шрифтов (шкала фиксированная, не переопределяется) */
  --fs-h1: clamp(2rem, 5vw, 3.5rem);
  --fs-h2: clamp(1.5rem, 3.5vw, 2.5rem);
  --fs-h3: clamp(1.25rem, 2.5vw, 1.75rem);
  --fs-h4: 1.25rem;
  --fs-body: 1rem;
  --fs-small: 0.875rem;

  /* Line-height */
  --lh-tight: 1.15;
  --lh-normal: 1.5;
  --lh-relaxed: 1.7;

  /* Spacing scale (шкала из RULE 7 промпта — не переопределяется) */
  --sp-1: 0.5rem;    /* 8px  */
  --sp-2: 1rem;      /* 16px */
  --sp-3: 1.5rem;    /* 24px */
  --sp-4: 2rem;      /* 32px */
  --sp-5: 3rem;      /* 48px */
  --sp-6: 4rem;      /* 64px */
  --sp-7: 6rem;      /* 96px */

  /* Контейнер */
  --container-max: 1200px;
  --container-narrow: 800px;
  --container-padding: var(--sp-3);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 999px;

  /* Transition */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
}


/* === 2. RESET === */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

ul,
ol {
  list-style: none;
}

/* Убираем bounce-скролл на iOS для .no-scroll состояний */
html:has(body.no-scroll) {
  overflow: hidden;
}


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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: var(--lh-tight);
  font-weight: 700;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }

p {
  line-height: var(--lh-normal);
}

.lead {
  font-size: 1.125rem;
  line-height: var(--lh-relaxed);
  color: var(--color-text-muted);
}

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


/* === 4. КОНТЕЙНЕР === */

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

.container--narrow {
  max-width: var(--container-narrow);
}

.container--wide {
  max-width: 1440px;
}


/* === 5. СЕКЦИИ (базовые отступы) === */

.section {
  padding-top: var(--sp-7);
  padding-bottom: var(--sp-7);
}

.section--tight {
  padding-top: var(--sp-5);
  padding-bottom: var(--sp-5);
}

.section--dark {
  background: var(--color-bg-dark);
  color: var(--color-text-inverse);
}

.section--alt {
  background: var(--color-bg-alt);
}

.section--full-bleed {
  padding-left: 0;
  padding-right: 0;
}


/* === 6. КНОПКИ === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: 0.875rem 1.75rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--fs-body);
  line-height: 1;
  min-height: 44px;              /* тач-таргет */
  transition: transform var(--transition-fast),
              background var(--transition-base),
              opacity var(--transition-base);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.btn--primary:hover {
  background: var(--color-accent-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--ghost:hover {
  border-color: var(--color-text);
}

.btn--large {
  padding: 1.125rem 2.25rem;
  font-size: 1.0625rem;
}

.btn--block {
  display: flex;
  width: 100%;
}


/* === 7. УТИЛИТЫ === */

/* Flex */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* Gap */
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

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

/* Visually hidden (a11y) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* === 8. ФОКУС (a11y) === */

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


/* === 9. МЕДИА-ЗАПРОСЫ (базовые правила) === */

/* На мобильных — уменьшенные секции */
@media (max-width: 768px) {
  .section {
    padding-top: var(--sp-5);
    padding-bottom: var(--sp-5);
  }

  .section--tight {
    padding-top: var(--sp-4);
    padding-bottom: var(--sp-4);
  }

  :root {
    --container-padding: var(--sp-2);
  }
}

/* Уважаем 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;
  }
}
