/* Тема «Жылдыздуу түн» — звёздная ночь: тёмно-синее небо, золото, тюндюк, горы Ала-Тоо, юрты.
   Подключается ПОСЛЕ invitation.css; имена переменных — от тёмной темы (--wine = фон страницы и т.д.).
   Правила для общих элементов привязаны к детали (конструктор): [data-base=night] — страница, [data-cover=night] —
   обложка, [data-env=night] — конверт, [data-deco=night] — украшения. Свои классы (.sky, .tunduk, .neb…) — без привязки.
   Анимации — transform / opacity (кроме прорисовки линий тюндюка — один раз). */

[data-base=night] {
  --wine: #101a2f;                       /* фон страницы: ночное небо */
  --deep: #0a1122;                       /* анкета и финал */
  --gold: #d8b56e;
  --gold-soft: rgba(216, 181, 110, .5);
  --milk: #f4efe4;
  --milk-soft: rgba(244, 239, 228, .72);
  --paper: #f3ead8;
  --ink: #1d2742;
}
[data-deco=night] { --glint: #f1dcae; }
[data-env=night] { --burst: #f1dcae; }
html[data-base=night] { background: var(--deep); }
[data-base=night] .snd::before, [data-base=night] .scroll-cue::before, [data-base=night] .lang-switch::before { background: rgba(10, 17, 34, .72); }

/* ---------- Обложка: небо ---------- */
[data-cover=night] .cover { --milk: #f4efe4; --milk-soft: rgba(244, 239, 228, .72); --gold: #d8b56e; --gold-soft: rgba(216, 181, 110, .5); --glint: #f1dcae;  color: var(--milk); }
[data-cover=night] { --cover-end: #0c1426; }
[data-cover=night] .cover {
  background:
    radial-gradient(70% 38% at 50% 100%, rgba(84, 76, 150, .35), transparent 70%),
    linear-gradient(#070d1c 0%, #0e1830 55%, #18244a 100%);
}
[data-cover=night] .cover.has-photo {
  background:
    linear-gradient(to bottom, rgba(7, 13, 28, .7) 0%, rgba(10, 17, 34, .42) 28%, rgba(10, 17, 34, .6) 58%, var(--wine) 100%),
    var(--photo) var(--photo-pos, center 30%) / var(--photo-size, cover) no-repeat;
}
.sky { position: absolute; inset: 0; pointer-events: none; }
.cover.has-photo .sky .stars { opacity: .6; }

/* месяц: полупрозрачный круг, серп — внутренней тенью; ореол дышит */
.moon {
  position: absolute; right: calc(36px * var(--s)); top: calc(58px * var(--s));
  width: calc(40px * var(--s)); height: calc(40px * var(--s)); border-radius: 50%;
  box-shadow: inset calc(-9px * var(--s)) calc(4px * var(--s)) 0 0 #f3e6c4;
  transform: rotate(-18deg);
}
.moon::after {
  content: ""; position: absolute; inset: -80%; border-radius: 50%;
  background: radial-gradient(rgba(243, 230, 196, .16), rgba(243, 230, 196, 0) 62%);
  animation: halo 6s ease-in-out infinite alternate;
}
@keyframes halo { from { opacity: .45; transform: scale(.92); } to { opacity: 1; transform: scale(1.05); } }
.moon.small { right: calc(28px * var(--s)); top: calc(40px * var(--s)); width: calc(30px * var(--s)); height: calc(30px * var(--s)); }

/* тюндюк */
.tunduk { color: var(--gold); overflow: visible; }
.tunduk .rays { transform-box: fill-box; transform-origin: 50% 50%; animation: spin 160s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tunduk .lat > * { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.4s var(--ease-out) calc(.6s + var(--i, 0) * .18s) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
html.env-wait .tunduk .lat > *, html.env-wait .tunduk .rays { animation-play-state: paused; }

/* горы и юрты */
/* высота гор ограничена и высотой экрана: на коротких телефонах иначе хребты заходят на дату */
.range { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: min(calc(150px * var(--s)), 17svh); pointer-events: none; }
[data-cover=night] .cover .stage :is(.serif, .label) { text-shadow: 0 1px 10px rgba(7, 13, 28, .9); }
.range .door { animation: lamp 3.2s ease-in-out infinite alternate; }
.range .door:nth-of-type(2n) { animation-duration: 4.1s; animation-delay: -1.3s; }
@keyframes lamp { 0% { opacity: .7; } 40% { opacity: 1; } 55% { opacity: .82; } 100% { opacity: .95; } }
.flies { position: absolute; left: 0; right: 0; bottom: min(calc(22px * var(--s)), 2.5svh); height: min(calc(90px * var(--s)), 10svh); pointer-events: none; }
.flies i {
  position: absolute; left: var(--x); bottom: 0; width: 3px; height: 3px; border-radius: 50%;
  background: #ffd98c; box-shadow: 0 0 6px 2px rgba(255, 210, 120, .55);
  opacity: 0; animation: fly var(--du) ease-in-out var(--dl) infinite;
}
@keyframes fly {
  0%   { opacity: 0; transform: translate(0, 0); }
  15%  { opacity: 1; }
  50%  { transform: translate(var(--dr), calc(-40px * var(--s))); }
  85%  { opacity: .8; }
  100% { opacity: 0; transform: translate(calc(var(--dr) * -.5), calc(-84px * var(--s))); }
}

/* ---------- Конверт ---------- */
/* клапаны — переменными: «Тёмный цвет» и «Акцент» из админки перекрашивают конверт (invitation.css) */
[data-env=night] .flaps { --flap-side: #18233d; --flap-bottom: #1e2b4a; --flap-top1: #2b3b63; --flap-top2: #223256; --flap-line: #d8b56e; }
[data-env=night] .flaps { --milk: #f4efe4; --milk-soft: rgba(244, 239, 228, .72); --gold: #d8b56e; --gold-soft: rgba(216, 181, 110, .5);  color: var(--milk); }
[data-env=night] .f-side   { filter: drop-shadow(0 0 10px rgba(3, 6, 14, .45)); }
[data-env=night] .f-bottom { filter: drop-shadow(0 -6px 14px rgba(3, 6, 14, .5)); }
[data-env=night] .f-top    { filter: drop-shadow(0 10px 18px rgba(3, 6, 14, .6)); }
[data-env=night] .flap-cast { background: linear-gradient(to bottom, rgba(3, 6, 14, .6), rgba(3, 6, 14, 0) 70%); }
/* звёзды на верхнем клапане — только внутри треугольника */
.stars.in-flap { clip-path: polygon(0 0, 100% 0, 50% 56%); }

/* ---------- Разделитель: Млечный Путь ---------- */
.neb { position: relative; z-index: 1; pointer-events: none; height: calc(70px * var(--s)); }
.neb img { position: absolute; left: 0; top: calc(-44px * var(--s)); width: 100%; height: auto; display: block; }
.neb.to-deep { background: linear-gradient(var(--wine), var(--deep)); }
.neb.deep { background: var(--deep); }
.neb.from-deep { background: linear-gradient(var(--cover-end), var(--wine)); }

/* ---------- Календарь: кружок вокруг даты прорисовывается ---------- */
html.io[data-base=night] .cal .mark svg path { stroke-dasharray: 1; stroke-dashoffset: 1; }
html.io[data-base=night] .a.in .cal .mark svg path { stroke-dashoffset: 0; transition: stroke-dashoffset 1.6s var(--ease-out) .7s; }
[data-base=night] .cal .mark { text-shadow: 0 0 12px rgba(216, 181, 110, .55); }

/* отсчёт — лёгкое свечение колец */
[data-base=night] .circle { box-shadow: 0 0 18px rgba(216, 181, 110, .12), inset 0 0 14px rgba(216, 181, 110, .08); }

/* ---------- Карточка адреса: светлая бумага с синими чернилами ---------- */
[data-base=night] .card { box-shadow: 0 24px 48px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35); }
[data-base=night] .card::before { border-color: rgba(29, 39, 66, .3); }
[data-base=night] .pill { border-color: rgba(29, 39, 66, .55); }
[data-base=night] .pill:active { background: rgba(29, 39, 66, .08); }
[data-base=night] .sw i { box-shadow: 0 0 0 1px var(--gold-soft), 0 0 0 5px var(--wine), 0 0 0 6px rgba(216, 181, 110, .3); }

/* ---------- Анкета и финал ---------- */
[data-base=night] .rsvp { overflow: hidden; }
[data-base=night] .final.has-photo {
  background:
    linear-gradient(to bottom, rgba(10, 17, 34, .96) 0%, rgba(10, 17, 34, .55) 45%, rgba(10, 17, 34, .92) 100%),
    var(--photo) var(--photo-pos, center) / var(--photo-size, cover) no-repeat !important;
}

@media (prefers-reduced-motion: reduce) {
  .flies, .moon::after { display: none; }
  .tunduk .rays { animation: none; }
  .tunduk .lat > * { animation: none; stroke-dashoffset: 0; }
  .range .door { animation: none; }
  html.io[data-base=night] .cal .mark svg path { stroke-dashoffset: 0 !important; transition: none !important; }
}
