/* ==========================================================================
   База: reset, типографика, ссылки, фокус, переходы между страницами.
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

html.has-modal {
  overflow: hidden;
}

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: var(--lh-body);
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1;
}

main:focus {
  outline: none;
}

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

img {
  height: auto;
}

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

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

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--selection);
}

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

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 em,
h2 em,
h3 em {
  font-style: italic;
  color: var(--ink-2);
}

p,
li,
dd {
  text-wrap: pretty;
}

strong {
  font-weight: 600;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur-fast) var(--ease-out), text-decoration-color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--accent);
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Фокус: только для клавиатуры ------------------------------------------- */

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

/* Утилиты доступности ------------------------------------------------------ */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--dur) var(--ease-out);
}

.skip-link:focus-visible {
  transform: none;
  color: var(--bg);
}

/* Мелкая типографика-помощники -------------------------------------------- */

.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-3);
}

.prose {
  max-width: 62ch;
  color: var(--ink-2);
}

.prose > * + * {
  margin-top: 1em;
}

.prose a {
  color: var(--ink);
}

.lead {
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 46ch;
}

/* Переходы между страницами (View Transitions, cross-document) ------------- */

@view-transition {
  navigation: auto;
}

/* Старая страница быстро гаснет, новая чуть поднимается. Обложка серии (view-transition-class: cover)
   перелетает из карточки в шапку серии и обратно, по пути перекадрируясь (object-fit: cover). */
::view-transition-old(root) {
  animation: vt-fade-out 180ms var(--ease-out) both;
}

::view-transition-new(root) {
  animation: vt-rise-in 380ms var(--ease-out) 60ms both;
}

::view-transition-group(*) {
  animation-duration: 520ms;
  animation-timing-function: cubic-bezier(0.2, 0.75, 0.25, 1);
}

::view-transition-old(*.cover),
::view-transition-new(*.cover) {
  height: 100%;
  object-fit: cover;
  overflow: clip;
}

@keyframes vt-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes vt-rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* Фильтр серий (filters.js): страница стоит на месте, двигаются только карточки */
html.is-filtering::view-transition-old(root),
html.is-filtering::view-transition-new(root) {
  animation: none;
}

/* Кнопка ◐: цвет расходится кругом от кнопки (color-mode.js анимирует clip-path).
   Стандартный crossfade выключаем, фото меняют фильтр мгновенно — круг всё сделает сам. */
html.is-color-switching::view-transition-old(root),
html.is-color-switching::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

html.is-color-off::view-transition-old(root) {
  z-index: 1; /* при выключении сверху старая, цветная страница — она и сжимается в кнопку */
}

html.is-color-switching .photo__img,
html.is-color-switching .photo::before {
  transition: none !important;
}

/* …и обложки не выделяются в отдельные слои, иначе круг их «не заденет» */
html.is-color-switching .photo {
  view-transition-name: none !important;
}

/* Появление при скролле (класс выставляет reveal.js) ----------------------- */

html.js [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--dur-slow) var(--ease-out) var(--reveal-delay, 0ms),
    transform var(--dur-slow) var(--ease-out) var(--reveal-delay, 0ms);
}

html.js [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

/* Меньше движения — по просьбе системы ------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  html.js [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
