/*
 * Основа вёрстки: сброс, типографика, контейнер, шапка, футер, кнопка-иконка, кнопка темы.
 * Цвета, отступы, размеры и длительности — только через токены (tokens.css).
 * Брейкпоинты: до 640 px, 641–1024 px, от 1025 px.
 */

/* Сброс */

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

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

body {
  min-height: 100vh;
  min-height: 100dvh;  /* iOS: dvh — высота видимой области, vh считает адресную строку убранной */
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--font-size-16);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-ui);
  transition:
    background-color var(--duration-theme),
    color var(--duration-theme);
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

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

img,
video {
  height: auto;
}

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

[hidden] {
  display: none !important;
}

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

h1,
h2,
h3,
h4,
b,
strong {
  font-weight: var(--font-weight-semibold);
}

p {
  line-height: var(--line-height-text);
}

a {
  color: inherit;
}

/* Только семейство: размер моноширинного текста задаёт сам компонент. */
.mono {
  font-family: var(--font-mono);
}

/* Состояния и доступность */

/*
 * main получает фокус программно (ссылка «Перейти к содержимому», tabindex="-1"), и щелчок по пустому месту страницы
 * тоже его фокусирует: рамка вокруг всей страницы не нужна. Фокус клавиатуры на интерактивных элементах внутри
 * по-прежнему обведён (:focus-visible выше).
 */
main[tabindex="-1"]:focus {
  outline: none;
}

:focus-visible {
  outline: var(--focus-ring-width) solid var(--accent);
  outline-offset: var(--focus-ring-offset);
  /* Прокрутка к элементу в фокусе не прижимает его к краю окна: обводка видна целиком. */
  scroll-margin: var(--space-4);
}

.visually-hidden,
.skip-link:not(:focus):not(:active) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--layer-top);
  display: inline-flex;
  align-items: center;
  height: var(--control-size);
  padding-inline: var(--space-4);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-field);
  background-color: var(--surface);
  color: var(--text);
}

/* Иконки: размер задаётся атрибутами SVG, цвет наследуется от текста */

.icon {
  display: block;
  flex-shrink: 0;
}

/* Контейнер: ширина содержимого до --container-max, по бокам поля */

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

/*
 * Круглая кнопка-иконка. Цвет иконки кнопка наследует (см. сброс) и сама его плавно
 * не меняет: при смене темы он идёт вместе с цветом текста страницы. Собственный
 * переход color внутри body, где цвет тоже меняется плавно, Chrome начинает заново
 * на каждом кадре, и иконка приходит к новому цвету вдвое позже остального.
 */

.icon-button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: var(--control-size);
  height: var(--control-size);
  padding: 0;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-full);
  background-color: var(--surface);
  cursor: pointer;
  transition:
    background-color var(--duration-theme),
    border-color var(--duration-theme);
}

@media (hover: hover) {
  .icon-button:hover {
    background-color: var(--line);
  }
}

/*
 * Кнопка темы. Без JavaScript она ничего не делает, поэтому показывается только
 * с меткой data-theme-ready: theme.js ставит её на корневой элемент до первой отрисовки.
 * В светлой теме в кнопке луна, в тёмной — солнце. Обе иконки лежат в разметке;
 * тёмная тема определяется теми же двумя условиями, что и в tokens.css.
 */

:root:not([data-theme-ready]) [data-theme-toggle] {
  display: none;
}

.theme-toggle__sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__moon {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle__sun {
    display: block;
  }
}

:root[data-theme="dark"] .theme-toggle__moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__sun {
  display: block;
}

/* Шапка */

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--header-padding-block);
  border-bottom: var(--border-width) solid var(--line);
}

/*
 * Ссылка-имя: область нажатия высотой с кнопку, имя и «/ фото» стоят на общей
 * базовой линии по центру этой высоты. Высота шапки от ссылки не зависит.
 */
.brand {
  display: grid;
  grid-auto-flow: column;
  align-content: center;
  align-items: baseline;
  justify-content: start;
  column-gap: var(--brand-gap);
  min-height: var(--control-size);
  text-decoration: none;
}

.brand__name {
  font-size: var(--font-size-18);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-tight);
}

.brand__tag {
  color: var(--muted);
  font-size: var(--font-size-12);
}

/* Футер */

.site-footer__bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--footer-padding-top) var(--footer-padding-bottom);
  border-top: var(--border-width) solid var(--line);
  color: var(--muted);
  font-size: var(--font-size-13);
}

.site-footer__contact {
  font-size: var(--font-size-12);
}

.site-footer__credit {
  text-decoration-thickness: var(--border-width);
  text-underline-offset: var(--space-1);
}

/* Телефон: линии шапки и футера идут от края до края экрана */

@media (max-width: 640px) {
  .site-header {
    border-bottom: var(--border-width) solid var(--line);
  }

  .site-header__bar {
    padding-block: var(--space-3);
    border-bottom: 0;
  }

  .brand {
    column-gap: var(--space-1);
  }

  .brand__name {
    font-size: var(--font-size-17);
    letter-spacing: normal;
  }

  .site-footer {
    border-top: var(--border-width) solid var(--line);
  }

  .site-footer__bar {
    border-top: 0;
  }
}

/* Меньше движения: без переходов и анимаций */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* Страницы 404 и 500 (MAI-77): спокойное сообщение и ссылка в ленту */

.status-page {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  padding-block: var(--space-9);
}

.status-page__code {
  color: var(--muted);
  font-size: var(--font-size-12);
  letter-spacing: var(--letter-spacing-eyebrow);
}

.status-page__title {
  max-width: var(--intro-title-max-width);
  font-size: var(--font-size-32);
  letter-spacing: var(--letter-spacing-display-phone);
  line-height: var(--line-height-display-phone);
  overflow-wrap: anywhere;
}

.status-page__text {
  max-width: var(--intro-lead-max-width);
  color: var(--muted);
  font-size: var(--font-size-18);
  overflow-wrap: anywhere;
}

.status-page__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-size);
  padding-inline: var(--space-5);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-full);
  background-color: var(--surface);
  font-size: var(--font-size-14);
  text-decoration: none;
}

@media (hover: hover) {
  .status-page__link:hover {
    background-color: var(--line);
  }
}

@media (max-width: 640px) {
  .status-page {
    padding-block: var(--space-7);
  }
}
