/* ============================================
   Base Styles - Reset & Typography
   ============================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-x: hidden;
  letter-spacing: var(--letter-spacing-normal);
  font-feature-settings: 'kern' 1, 'liga' 1;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  position: relative;
}

/* Subtle grain texture overlay for depth */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: overlay;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text);
  letter-spacing: var(--letter-spacing-tight);
  text-wrap: balance;
}

h1 {
  font-size: clamp(var(--font-size-3xl), 5vw, var(--font-size-5xl));
  font-weight: var(--font-weight-extrabold);
  letter-spacing: -0.04em; /* More aggressive tight spacing for character */
  line-height: 1.15;
}

h2 {
  font-size: clamp(var(--font-size-2xl), 4vw, var(--font-size-3xl));
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h3 {
  font-size: var(--font-size-xl);
  line-height: 1.3;
}

h4 {
  font-size: var(--font-size-lg);
  line-height: 1.35;
}

p {
  margin-bottom: var(--spacing-5);
  color: var(--color-text-secondary);
  max-width: 65ch; /* Уменьшено для лучшей читаемости */
}

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

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

a:hover {
  color: var(--color-primary-dark);
}

strong {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

/* ---- Lists ---- */
ul, ol {
  list-style: none;
}

/* ---- Images ---- */
img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ---- Form Elements ---- */
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

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

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

main {
  padding-top: var(--header-height);
}

section {
  padding: var(--spacing-24) 0;
}

@media (max-width: 768px) {
  section {
    padding: var(--spacing-16) 0;
  }

  /* Touch-friendly targets */
  a, button, input, select, textarea {
    min-height: 44px;
  }

  /* Better tap highlight */
  * {
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
  }
}

/* ---- Section Titles ---- */
.section-header {
  text-align: center;
  margin-bottom: var(--spacing-16);
}

/* Asymmetric variant - left aligned for visual variety */
.section-header--left {
  text-align: left;
  max-width: 680px;
}

.section-label {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent);
  margin-bottom: var(--spacing-4);
}

.section-title {
  margin-bottom: var(--spacing-4);
}

.section-subtitle {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  max-width: 580px;
  margin: 0 auto;
  line-height: 1.7;
  letter-spacing: 0;
}

/* ---- Utility Classes ---- */
.text-center {
  text-align: center;
}

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

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

.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;
}

/* ---- Selection ---- */
::selection {
  background-color: var(--color-accent-light);
  color: var(--color-text);
}

/* ---- Focus States ---- */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ---- Custom Scrollbar ---- */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: var(--color-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: 6px;
  border: 2px solid var(--color-surface);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary-dark);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary) var(--color-surface);
}
