/* Основание: сброс, типографика, безопасные поля.

   Отдельные правила здесь существуют только ради WebView Телеграма и
   в обычном браузере выглядели бы избыточными — они помечены.
*/

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

html,
body {
  margin: 0;
  height: 100%;
}

html {
  /* Телеграм тянет страницу вниз жестом закрытия. Без этого при
     прокрутке списка вверх приложение норовит закрыться. */
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: var(--body);
  letter-spacing: 0.005em;
  overscroll-behavior: none;
  /* Долгое нажатие в WebView вызывает системное выделение и меню
     копирования там, где его никто не ждёт */
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Выделять нужно только то, что человек захочет скопировать —
   подпись с хештегами и заметки */
.selectable {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

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

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

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  /* Шрифт кнопки в iOS WebView иначе съезжает на системный */
  font-family: inherit;
}

input,
textarea {
  /* iOS увеличивает страницу, если поле меньше 16px */
  font-size: 16px;
  background: none;
  border: 0;
  width: 100%;
}

textarea {
  resize: none;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

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

.numeric {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.hidden {
  display: none !important;
}

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

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

#root {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.screens {
  flex: 1;
  position: relative;
}

.screen {
  padding: 0 var(--s-5);
  padding-top: calc(var(--safe-top) + var(--s-4));
  /* Нижние вкладки и системная полоса не должны накрывать последнюю
     карточку списка */
  padding-bottom: calc(var(--safe-bottom) + var(--nav-height) + var(--s-8));
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.screen[data-full="true"] {
  padding-bottom: calc(var(--safe-bottom) + var(--s-8));
}

.screen-enter {
  animation: screen-in var(--calm) var(--ease);
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}

.page-head h1 {
  font: var(--display);
  letter-spacing: -0.02em;
}

.page-head .sub {
  font: var(--meta);
  color: var(--text-dim);
  margin-top: 2px;
}

.section {
  margin-top: var(--s-7);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}

.section-head h2 {
  font: var(--head);
  letter-spacing: -0.01em;
}

.section-head .count {
  font: var(--meta);
  color: var(--text-faint);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* Планшет и десктоп: приложение остаётся колонкой, но дышит свободнее.
   Растягивать план на всю ширину монитора незачем — строка задачи
   длиной в экран читается хуже, а не лучше. */
@media (min-width: 720px) {
  .screen {
    padding-left: var(--s-7);
    padding-right: var(--s-7);
  }

  .page-head h1 {
    font-size: 30px;
  }
}
