/* Общие компоненты: иконки, кнопки, шапка, подвал, панель, поля форм, автодополнение. */

.icon {
  flex: none;
  width: var(--icon);
  height: var(--icon);
  fill: currentColor;
}

/* ---------- Кнопка-иконка (pill, зона нажатия 44 px) ---------- */

.icon-button {
  display: inline-grid;
  place-items: center;
  inline-size: var(--tap);
  block-size: var(--tap);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgb(7 14 21 / .4);
  color: var(--text-muted);
  cursor: pointer;
  transition:
    color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-out);
}

.icon-button:active {
  transform: translateY(1px);
}

@media (hover: hover) and (pointer: fine) {
  .icon-button:hover {
    color: var(--text);
    border-color: var(--line-strong);
  }
}

/* Пауза/запуск фона: видна одна из двух иконок */
.bg-toggle__play,
.bg-toggle[data-paused="true"] .bg-toggle__pause {
  display: none;
}

.bg-toggle[data-paused="true"] .bg-toggle__play {
  display: block;
}

/* ---------- Шапка ---------- */

.site-header {
  position: relative;
  z-index: var(--z-header);
}

.site-header__inner {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    "logo lang toggle"
    "nav  nav  nav";
  align-items: center;
  column-gap: var(--space-sm);
  padding-block: var(--space-sm) 0;
}

.logo {
  grid-area: logo;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: lining-nums proportional-nums;   /* «1» цифрой, а не капительной I */
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}

.site-nav {
  grid-area: nav;
}

.site-nav__list {
  display: flex;
  justify-content: space-between;
  margin: 0 calc(-1 * var(--space-sm));
  padding: 0;
  list-style: none;
}

.site-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding-inline: var(--space-sm);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-fast) ease;
}

.site-nav__link[aria-current="page"] {
  color: var(--text);
}

/* Текущий раздел: золотая волосяная линия, как линии кольца в видео */
.site-nav__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  inset: auto var(--space-sm) 8px;
  height: 1px;
  background: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .site-nav__link:hover {
    color: var(--text);
  }
}

.bg-toggle {
  grid-area: toggle;
}

/* Переключатель языка: <details> без JS, метка «RU» в той же рамке, что и кнопка фона */
.lang-switch {
  grid-area: lang;
  position: relative;
}

.lang-switch__summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: var(--tap);
  padding-inline: var(--space-md) var(--space-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgb(7 14 21 / .4);
  color: var(--text-muted);
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.06em;
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition:
    color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-out);
}

.lang-switch__summary::-webkit-details-marker {
  display: none;
}

.lang-switch__summary:active {
  transform: translateY(1px);
}

.lang-switch[open] .lang-switch__summary {
  color: var(--text);
  border-color: var(--line-strong);
}

.lang-switch__caret {
  width: 16px;
  height: 16px;
  transition: transform var(--dur-base) var(--ease-out);
}

.lang-switch[open] .lang-switch__caret {
  transform: rotate(180deg);
}

/* Закрытый список не участвует в отрисовке вовсе: иначе браузер может заранее скачать
   кириллический шрифт ради «Русский» и «Українська» на страницах en и es. */
.lang-switch:not([open]) .lang-switch__list {
  display: none;
}

.lang-switch__list {
  position: absolute;
  inset-block-start: calc(100% + var(--space-xs));
  inset-inline-end: 0;
  z-index: 1;
  min-inline-size: 11rem;
  margin: 0;
  padding: var(--space-xs);
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface-solid);
  box-shadow: var(--shadow-float);
}

.lang-switch__link {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding-inline: var(--space-md);
  border-radius: var(--radius-field);
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-fast) ease;
}

.lang-switch__link[aria-current="true"] {
  color: var(--text);
  background: var(--accent-tint);
}

@media (hover: hover) and (pointer: fine) {
  .lang-switch__summary:hover {
    color: var(--text);
    border-color: var(--line-strong);
  }

  .lang-switch__link:hover {
    color: var(--text);
  }
}

@media (min-width: 640px) {
  .site-header__inner {
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas: "logo nav lang toggle";
    min-height: var(--header-h);
    padding-block: 0;
  }

  .site-nav {
    justify-self: end;
  }

  .site-nav__list {
    justify-content: flex-end;
    gap: var(--space-xs);
    margin: 0;
  }

  .site-nav__link {
    padding-inline: var(--space-md);
  }

  .site-nav__link[aria-current="page"]::after {
    inset-inline: var(--space-md);
  }
}

/* ---------- Подвал ---------- */

.site-footer {
  position: relative;
  z-index: var(--z-content);
  border-top: 1px solid var(--line);
  background: var(--bg);
  color: var(--text-muted);
  font-size: var(--fs-small);
}

.site-footer__inner {
  display: grid;
  gap: var(--space-lg);
  padding-block: var(--space-xl) var(--space-2xl);
}

.site-footer__disclaimer {
  max-width: 60ch;
  margin: 0;
}

.site-footer__meta {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__meta li {
  padding-block: 11px;   /* строка 22 px + 22 px: строки отстоят друг от друга на 44 px */
  line-height: 22px;
}

/* Строка, которая целиком ссылка (политика): зона нажатия во всю высоту строки, 44 px.
   Класс проставлен в footer.html, а не выбран через `:has(> a:only-child)`: `:only-child`
   считает только элементы-потомки, и такой селектор поймал бы ещё строку
   «Эфемериды: <a>Swiss Ephemeris</a>» — там ссылка тоже единственный элемент. Ссылки
   внутри предложения (GeoNames, Swiss Ephemeris) остаются частью текста. */
.site-footer__meta li.site-footer__meta-link-row {
  display: flex;
  padding-block: 0;   /* высоту строки задаёт сама ссылка */
}

.site-footer__meta li.site-footer__meta-link-row > a {
  display: flex;   /* флекс-элемент: inline-flex всё равно блокифицируется в flex */
  min-height: var(--tap);
  align-items: center;
}

.site-footer a {
  color: var(--text);
  text-decoration-color: rgb(237 234 227 / .35);
  transition: text-decoration-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
  .site-footer a:hover {
    text-decoration-color: var(--accent);
  }
}

@media (min-width: 768px) {
  .site-footer__inner {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: var(--space-3xl);
  }

  .site-footer__meta li:first-child {
    padding-top: 0;
  }
}

/* ---------- Панель поверх видео ---------- */

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface-solid);
  box-shadow: inset 0 1px 0 rgb(237 234 227 / .05), var(--shadow-float);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .panel {
    background: var(--surface);
    -webkit-backdrop-filter: blur(var(--surface-blur));
    backdrop-filter: blur(var(--surface-blur));
  }
}

@media (prefers-reduced-transparency: reduce) {
  .panel {
    background: var(--surface-solid);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ---------- Поля формы: подпись над полем, подсказка и ошибка под ним ---------- */

.field {
  display: grid;
  gap: var(--space-sm);
  align-content: start;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field__label {
  padding: 0;
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: 600;
  line-height: 1.4;
}

.field__optional {
  color: var(--text-muted);
  font-weight: 400;
}

.field__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: 1.45;
}

/* Ошибка: иконка и текст. Цвет — единственный акцент сайта, смысл несут иконка и слова. */
.field__error {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  margin: 0;
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.45;
}

.field__error .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--accent);
}

.input {
  inline-size: 100%;
  /* У полей даты и времени браузер задаёт свою минимальную ширину (152 px в Chrome):
     на телефоне в двух колонках по 148 px поле даты вылезало из колонки. */
  min-inline-size: 0;
  min-block-size: 48px;
  padding: 0 14px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-field);
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem;   /* не меньше 16 px: iOS не увеличивает страницу при фокусе */
  transition: border-color var(--dur-fast) ease, opacity var(--dur-fast) ease;
}

.input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.input:focus-visible {
  border-color: var(--accent);
  outline-offset: 1px;
}

.input[aria-invalid="true"] {
  border-color: var(--accent);
}

.input:disabled {
  opacity: .45;
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  .input:not(:disabled):hover {
    border-color: rgb(154 166 184 / .85);
  }
}

/* Дата и время: значок выбора светлый (color-scheme: dark) */
.input::-webkit-calendar-picker-indicator {
  opacity: .8;
  cursor: pointer;
}

/* Координаты: стрелки «больше/меньше» в поле широты бесполезны */
.input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ---------- Переключатель-чипы (радиокнопки) ---------- */

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

@media (min-width: 400px) {
  .segmented {
    gap: 6px;
  }
}

@media (max-width: 359px) {
  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.segmented__item {
  position: relative;
  display: grid;
}

/* Сама радиокнопка невидима, но получает фокус и управляется стрелками */
.segmented__input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 4px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: var(--fs-small);
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  transition:
    color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    background-color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-out);
}

.segmented__input:checked + .chip {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--text);
}

.segmented__input:focus-visible + .chip {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.segmented__input:active + .chip {
  transform: translateY(1px);
}

@media (hover: hover) and (pointer: fine) {
  .segmented__input:not(:checked):hover + .chip {
    color: var(--text);
    border-color: rgb(154 166 184 / .85);
  }
}

/* ---------- Галочка ---------- */

.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: var(--tap);
  padding-block: 12px;
  color: var(--text);
  font-size: var(--fs-small);
  line-height: 20px;
  cursor: pointer;
}

.check__input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.check a {
  color: var(--text);
  text-decoration-color: rgb(237 234 227 / .45);
  transition: text-decoration-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
  .check a:hover {
    text-decoration-color: var(--accent);
  }
}

/* ---------- Кнопки: primary — золото, secondary — золотая обводка; обе pill ---------- */

.button {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 28px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) ease;
}

/* Подсветка при наведении — слой с opacity, сам фон не анимируется */
.button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  transition: opacity var(--dur-fast) ease;
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
}

.button--primary::before {
  background: rgb(255 255 255 / .16);
}

.button--secondary {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--text);
}

.button--secondary::before {
  background: var(--accent-tint);
}

.button__icon {
  transition: transform var(--dur-base) var(--ease-out);
}

/* Отправлено, ждём ответ сервера (data-pending ставит forms.js): нажатие не выглядит потерянным.
   Кнопка не выключается — иначе браузер не отправил бы форму; повторную отправку не даёт forms.js. */
form[data-pending] {
  cursor: progress;
}

form[data-pending] .button[type="submit"] {
  opacity: .55;
}

@media (hover: hover) and (pointer: fine) {
  .button:hover::before {
    opacity: 1;
  }

  .button:hover .button__icon {
    transform: translateX(3px);
  }
}

/* ---------- Автодополнение (combobox + listbox) ---------- */

.combobox {
  position: relative;
}

.combobox__icon {
  position: absolute;
  top: 14px;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.combobox__input {
  padding-left: 44px;
}

.listbox {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline: 0;
  z-index: 3;
  max-height: min(320px, 45svh);
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--surface-solid);
  box-shadow: var(--shadow-float);
  transform-origin: top center;
  transition:
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

/* Появление: сдвиг от поля вниз, без масштаба из нуля; закрывается сразу */
@starting-style {
  .listbox {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.listbox__option {
  display: grid;
  gap: 2px;
  min-height: var(--tap);
  padding: 9px 12px;
  border-radius: calc(var(--radius-field) - 4px);   /* внутренний радиус = внешний − отступ */
  cursor: pointer;
}

.listbox__option[aria-selected="true"] {
  background: var(--accent-tint);
  box-shadow: inset 2px 0 0 var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .listbox__option:hover {
    background: var(--accent-tint);
  }
}

.listbox__name {
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
}

.listbox__details {
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: 1.35;
}

/* ---------- Форма натальной карты (главная и страница карты) ---------- */

.natal-form {
  display: grid;
  gap: 20px;
}

.natal-form__row {
  display: grid;
  gap: 20px;
}

@media (min-width: 360px) {
  .natal-form__row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

.natal-form__accuracy {
  gap: 10px;
}

/* Пояснение к «Не знаю»: видно, только когда выбран этот вариант (работает и без JS) */
.natal-form__note {
  display: none;
  gap: var(--space-sm);
  align-items: flex-start;
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: 1.45;
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

.natal-form__note .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--accent);
}

.natal-form:has(input[name="accuracy"][value="unknown"]:checked) .natal-form__note {
  display: flex;
}

@starting-style {
  .natal-form__note {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* Без JS время не выключается, но выглядит неактивным */
.natal-form:has(input[name="accuracy"][value="unknown"]:checked) [data-time-input] {
  opacity: .45;
}

.natal-form__actions {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.natal-form__submit {
  width: 100%;
}

.natal-form__privacy {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-small);
  text-align: center;
}

/* Город: ручной режим открывает поля координат под галочкой, а поиск остаётся на месте
   приглушённым, чтобы галочка не уезжала из-под курсора (работает и без JS) */
.city {
  display: grid;
  gap: 4px;
}

.city__toggle {
  justify-self: start;
}

/* Пока под полем ошибка, общая подсказка «начните вводить…» не повторяет её */
.city__auto:has(.field__error:not([hidden])) [data-city-hint][data-default] {
  display: none;
}

.city__manual {
  display: none;
  gap: 20px;
  margin-top: 4px;
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

.city:has([data-city-manual]:checked) .city__manual {
  display: grid;
}

@starting-style {
  .city__manual {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.city__auto {
  scroll-margin-top: var(--space-md);   /* city-autocomplete.js поднимает поле, чтобы список был виден */
  transition: opacity var(--dur-fast) ease;
}

.city:has([data-city-manual]:checked) .city__auto {
  opacity: .45;
  pointer-events: none;
}

.city__auto .input:disabled {
  opacity: 1;   /* приглушён весь блок поиска, поле не темнеет дважды */
}

.city__coords {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm) 12px;
}

.city__coords-hint {
  grid-column: 1 / -1;
}

/* Вопрос о времени на переводе часов: текст и кнопки-варианты (одно нажатие — выбор и расчёт) */
.time-choice {
  display: grid;
  gap: 12px;
  padding: var(--space-md);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-field);
  background: var(--accent-tint);
}

.time-choice__text {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.45;
}

.time-choice__text .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--accent);
}

.time-choice__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.time-choice__button {
  min-height: var(--tap);
  padding-inline: 18px;
  font-size: var(--fs-small);
}

/* ---------- Ссылка-действие рядом с кнопками ---------- */

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgb(237 234 227 / .35);
  text-underline-offset: 0.25em;
  transition: text-decoration-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
  .text-link:hover {
    text-decoration-color: var(--accent);
  }
}

/* Иконка перед текстом кнопки */
.button__lead {
  margin-left: -4px;
}

/* ---------- Страницы результатов: карточка, заголовок раздела, числа ---------- */

.panel-solid {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface-2);
}

.section-title {
  font-size: var(--fs-h2);
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Страницы результатов: как посчитано ---------- */

.conventions {
  display: grid;
  gap: var(--space-md);
  padding-block: var(--space-2xl) var(--space-xl);
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: var(--fs-small);
}

.conventions__title {
  color: var(--text);
  font-size: 1.5rem;
}

.conventions__list {
  display: grid;
  gap: 6px var(--space-2xl);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 768px) {
  .conventions__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Страницы результатов: «Изменить данные» (details с формой) ---------- */

.edit__toggle {
  list-style: none;
}

.edit__toggle::-webkit-details-marker {
  display: none;
}

.edit__caret {
  transition: transform var(--dur-base) var(--ease-out);
}

.edit[open] .edit__caret {
  transform: rotate(180deg);
}

.edit__panel {
  max-width: 560px;
  margin-top: var(--space-lg);
  padding: var(--space-lg) var(--space-md);
  background: var(--surface-solid);
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

@starting-style {
  .edit[open] .edit__panel {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@media (min-width: 640px) {
  .edit__panel {
    padding: var(--space-xl);
  }
}
