/* preloader.css */

.site-preloader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: #ffffff;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 520ms ease,
    visibility 520ms ease;
}

.site-preloader.is-hiding {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

html.site-preloader-skip .site-preloader {
  display: none !important;
}

.site-preloader__loader {
  --preloader-size: 390.68px;
  /* The ring is sized in whole EVEN pixels (≈73.22% of the box, the Figma
     ratio) rather than a percentage: a fractional ring width makes the two
     half-windows of the fill land on different subpixel offsets, and once the
     compositor snaps each animated half to device pixels independently, the
     two arcs meet at 6 o'clock a couple of pixels apart (the visible "second
     stripe" tear on the booking transition loader). An even integer keeps
     both halves integer-wide, so they snap identically and the arcs join. */
  --preloader-ring-size: 286px;
  /* Нахлёст половин друг на друга. Окна обрезки больше не встречаются встык по
     диаметру, а заходят одно за другое на этот запас: даже если Safari округлит
     их края к разным пикселям, дуги всё равно перекрываются и разрыва нет.
     Дуги при этом длиннее нахлёста (см. разметку кольца в functions.php) —
     важно, чтобы сглаженный край обрезки попадал на сплошную краску соседней
     дуги, а не на её сглаженный кончик: два полупрозрачных края давали светлую
     засечку. */
  --preloader-seam: 2px;
  --preloader-logo-width: 53.28%;
  --preloader-logo-height: 47.64%;

  position: relative;
  width: min(var(--preloader-size), 72vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.site-preloader__logo {
  width: var(--preloader-logo-width);
  height: var(--preloader-logo-height);
  max-width: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: brightness(0) saturate(100%) invert(45%) sepia(16%) saturate(1507%) hue-rotate(344deg) brightness(91%)
    contrast(85%);
}

.site-preloader__progress {
  position: absolute;
  inset: 50% auto auto 50%;
  width: var(--preloader-ring-size);
  height: var(--preloader-ring-size);
  overflow: visible;
  transform: translate(-50%, -50%);
}

.site-preloader__track,
.site-preloader__value {
  fill: none;
  stroke-width: 1.2;
}

.site-preloader__track {
  stroke: #c6c1a1;
}

/* Заполнение — тот же круг, что и дорожка, в том же svg: рисуются одним
   проходом, поэтому идеально совпадают по радиусу и толщине. Видимая часть
   задаётся длиной штриха: 301.594 — это длина окружности r=48 (2πr) в единицах
   viewBox, а stroke-dashoffset прячет её целиком и уменьшается до нуля. */
.site-preloader__value {
  stroke: #af6c37;
  stroke-dasharray: 301.594;
  stroke-dashoffset: 301.594;
  animation: site-preloader-fill 1500ms linear infinite;
}

/* Один оборот заливки. Крутится бесконечно, а не один раз: CSS-часы стартуют с
   первой отрисовки, а скрипт, который убирает лоадер, подключается в подвале —
   разовая анимация успевала бы замереть на полном кольце и читалась бы как
   зависший лоадер. */
@keyframes site-preloader-fill {
  from {
    stroke-dashoffset: 301.594;
  }

  to {
    stroke-dashoffset: 0;
  }
}

@media (max-width: 1440px) {
  .site-preloader__loader {
    --preloader-size: 328.68px;
    --preloader-ring-size: 240px;
  }
}

@media (max-width: 1179px) {
  .site-preloader__loader {
    --preloader-size: 276.18px;
    --preloader-ring-size: 202px;
  }
}

@media (max-width: 767px) {
  .site-preloader__loader {
    --preloader-size: 221px;
    --preloader-ring-size: 162px;
    width: min(var(--preloader-size), 68vw);
  }
}

/* Reduced motion gets a complete, still ring — not a sped-up one. Squeezing the
   duration to 1ms was survivable while the fill ran once, but against a looping
   animation it is a 1ms strobe, and either way it reads as a loader that is dead
   rather than one that is deliberately still. rotate(180deg) is each rotor's
   end-of-sweep position, so together they show the full circle. */
/* Уменьшенная анимация: показываем законченное кольцо, а не ускоренное. */
@media (prefers-reduced-motion: reduce) {
  .site-preloader {
    transition-duration: 1ms;
  }

  .site-preloader__value {
    animation: none;
    stroke-dashoffset: 0;
  }
}
