/* ==========================================================================
   БАЗА: сброс, типографика, каркас страницы
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, ol, figure {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

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

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

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

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

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important; /* иначе бесконечная анимация мерцает на 0.01 мс */
  }
}

/* --- Каркас -------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

/* Отступ 20px вместо 16 — для карточек на главной, как в макете */
.container--inset { padding-inline: var(--gutter-inset); }

/* Основная область страницы */
.page {
  padding-block: var(--space-4) var(--space-8);
}

/* Оставляет место под нижнюю навигацию / закреплённую кнопку */
.page--with-tabbar {
  padding-bottom: calc(var(--tabbar-height) + var(--space-6) + env(safe-area-inset-bottom));
}

.page--with-action {
  padding-bottom: calc(var(--button-height) + var(--space-10) + env(safe-area-inset-bottom));
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack--sm { gap: var(--space-3); }
.stack--lg { gap: var(--space-6); }

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.row--between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* --- Типографика --------------------------------------------------------- */

.title-xl {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

.title-lg {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.title-md {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.text-muted { color: var(--color-text-muted); }
.text-base { font-size: var(--text-base); }
.text-sm { font-size: var(--text-sm); line-height: var(--leading-tight); }
.text-xs { font-size: var(--text-xs); }

.link {
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  filter: brightness(0.8);
}

.link:hover { color: var(--color-accent); filter: none; }

/* Акцентная ссылка в тексте */
.link--accent { font-weight: var(--weight-medium); color: var(--color-accent); filter: none; }
.link--accent:hover { color: var(--color-accent-hover); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (min-width: 48rem) {
  :root {
    --gutter: var(--space-6);
  }
}
