/*
 * Base Styles & Reset
 * Сброс стилей, глобальные стили, типографика, утилиты
 */

/* ===== MODERN CSS RESET ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

button {
  background: none;
  border: none;
  cursor: pointer;
}

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

/* Focus styles для accessibility */
*:focus {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

*:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Удаляем стандартный маркер у details */
details > summary {
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

/* Скрываем элементы визуально, но оставляем доступными для скринридеров */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== БАЗОВЫЕ СТИЛИ ===== */
body {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
  color: var(--text-1);
  background-color: var(--bg-0);
  overflow-x: hidden;
  position: relative;
  margin: 0;
}

/* Grid Overlay для всего сайта (фоновая сетка) */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: var(--grid-cell-size) var(--grid-cell-size);
  opacity: var(--grid-overlay-opacity-content);
  pointer-events: none;
  z-index: 0;
}

/* Ambient glow layer */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(600px circle at calc(40% + var(--ambient-x, 0px)) calc(20% + var(--ambient-y, 0px)),
      rgba(0, 122, 255, 0.18), transparent 60%),
    radial-gradient(480px circle at calc(70% - var(--ambient-x, 0px)) calc(70% + var(--ambient-y, 0px)),
      rgba(0, 200, 255, 0.12), transparent 65%);
  opacity: 0.45;
  filter: blur(10px) hue-rotate(var(--ambient-hue, 0deg));
  pointer-events: none;
  z-index: 0;
}

/* Все остальное содержимое должно быть выше overlay */
.header,
.main,
.footer {
  position: relative;
  z-index: 1;
}

/* ===== ТИПОГРАФИКА ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-normal);
  margin: 0 0 var(--space-16) 0;  /* Сброс margin и установка только снизу */
}

h1 {
  font-size: var(--font-size-h1);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-24);  /* 24px после H1 */
}

h2 {
  font-size: var(--font-size-h2);
  margin-bottom: var(--space-16);  /* 16px после H2 */
}

h3 {
  font-size: var(--font-size-h3);
  margin-bottom: var(--space-16);  /* 16px после H3 */
}

p {
  margin: 0 0 var(--space-16) 0;  /* 16px между параграфами */
}

p:last-child {
  margin-bottom: 0;  /* Убираем margin у последнего параграфа */
}

strong, b {
  font-weight: var(--font-weight-semibold);
}

em, i {
  font-style: italic;
}

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

/* Micro текст для лейблов секций */
.micro {
  font-size: var(--font-size-micro);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-micro);
  letter-spacing: var(--letter-spacing-micro);
  color: var(--text-3);
  text-transform: uppercase;
}

/* ===== ССЫЛКИ ===== */
a:not([class]) {
  color: var(--text-2);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-in-out);
}

a:not([class]):hover,
a:not([class]):focus {
  color: var(--text-1);
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-underline-offset: 4px;
}

a:not([class]):focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Transitions для всех интерактивных элементов */
a,
button,
input,
textarea,
select {
  transition: all var(--duration-fast) var(--ease-in-out);
}

/* ===== СПИСКИ ===== */
ul, ol {
  margin: 0 0 var(--space-16) 0;
  padding-left: var(--space-24);  /* 24px отступ слева */
}

li {
  margin-bottom: var(--space-8);  /* 8px между элементами списка (10-16 по ТЗ) */
}

li:last-child {
  margin-bottom: 0;  /* Убираем margin у последнего элемента */
}

/* ===== КОД ===== */
code, pre {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', 'Droid Sans Mono',
               'Courier New', monospace;
  font-size: 0.875rem;
}

code {
  padding: 2px 6px;  /* Небольшой padding для инлайн кода */
  background-color: var(--surface-2);
  border-radius: 4px;
}

pre {
  padding: var(--space-20, 20px);  /* 20px padding в code блоках */
  background-color: var(--surface-2);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0 0 var(--space-16) 0;
}

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

/* ===== УТИЛИТАРНЫЕ КЛАССЫ ДЛЯ ОТСТУПОВ ===== */
/* Margin */
.m-0 { margin: 0 !important; }
.m-8 { margin: var(--space-8) !important; }
.m-16 { margin: var(--space-16) !important; }
.m-24 { margin: var(--space-24) !important; }
.m-32 { margin: var(--space-32) !important; }
.m-48 { margin: var(--space-48) !important; }
.m-64 { margin: var(--space-64) !important; }

.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: var(--space-8) !important; }
.mt-16 { margin-top: var(--space-16) !important; }
.mt-24 { margin-top: var(--space-24) !important; }
.mt-32 { margin-top: var(--space-32) !important; }
.mt-48 { margin-top: var(--space-48) !important; }
.mt-64 { margin-top: var(--space-64) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-8 { margin-bottom: var(--space-8) !important; }
.mb-16 { margin-bottom: var(--space-16) !important; }
.mb-24 { margin-bottom: var(--space-24) !important; }
.mb-32 { margin-bottom: var(--space-32) !important; }
.mb-48 { margin-bottom: var(--space-48) !important; }
.mb-64 { margin-bottom: var(--space-64) !important; }

/* Padding */
.p-0 { padding: 0 !important; }
.p-8 { padding: var(--space-8) !important; }
.p-16 { padding: var(--space-16) !important; }
.p-24 { padding: var(--space-24) !important; }
.p-32 { padding: var(--space-32) !important; }
.p-48 { padding: var(--space-48) !important; }
.p-64 { padding: var(--space-64) !important; }

.pt-0 { padding-top: 0 !important; }
.pt-8 { padding-top: var(--space-8) !important; }
.pt-16 { padding-top: var(--space-16) !important; }
.pt-24 { padding-top: var(--space-24) !important; }
.pt-32 { padding-top: var(--space-32) !important; }
.pt-48 { padding-top: var(--space-48) !important; }
.pt-64 { padding-top: var(--space-64) !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-8 { padding-bottom: var(--space-8) !important; }
.pb-16 { padding-bottom: var(--space-16) !important; }
.pb-24 { padding-bottom: var(--space-24) !important; }
.pb-32 { padding-bottom: var(--space-32) !important; }
.pb-48 { padding-bottom: var(--space-48) !important; }
.pb-64 { padding-bottom: var(--space-64) !important; }

/* ===== УТИЛИТАРНЫЕ КЛАССЫ ДЛЯ ВЫРАВНИВАНИЯ ===== */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

.flex { display: flex !important; }
.flex-col { flex-direction: column !important; }
.items-start { align-items: flex-start !important; }
.items-center { align-items: center !important; }
.items-end { align-items: flex-end !important; }
.justify-start { justify-content: flex-start !important; }
.justify-center { justify-content: center !important; }
.justify-end { justify-content: flex-end !important; }
.justify-between { justify-content: space-between !important; }
.gap-8 { gap: var(--space-8) !important; }
.gap-16 { gap: var(--space-16) !important; }
.gap-24 { gap: var(--space-24) !important; }
.gap-32 { gap: var(--space-32) !important; }
.gap-48 { gap: var(--space-48) !important; }

/* ===== УТИЛИТАРНЫЕ КЛАССЫ ДЛЯ ОТОБРАЖЕНИЯ ===== */
.block { display: block !important; }
.inline-block { display: inline-block !important; }
.inline { display: inline !important; }
.hidden { display: none !important; }

.w-full { width: 100% !important; }
.h-full { height: 100% !important; }

/* ===== УТИЛИТАРНЫЕ КЛАССЫ ДЛЯ ЦВЕТОВ ===== */
.text-blue { color: var(--blue) !important; }
.text-red { color: var(--red) !important; }
.text-white { color: var(--text-1) !important; }
.text-gray-light { color: var(--text-2) !important; }
.text-gray { color: var(--text-3) !important; }

.bg-black { background-color: var(--bg-0) !important; }
.bg-black-light { background-color: var(--bg-1) !important; }
.bg-surface { background-color: var(--surface) !important; }

/* ===== SCROLLBAR СТИЛИ (опционально) ===== */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-1);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
  border: 3px solid var(--bg-1);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ===== ПОДДЕРЖКА PREFERS-REDUCED-MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) *,
  html:not(.force-motion) *::before,
  html:not(.force-motion) *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== PRINT СТИЛИ ===== */
@media print {
  body {
    background: white;
    color: black;
  }

  .no-print {
    display: none !important;
  }
}


*, *:active, *:focus {
  outline: none !important;
}
