/* =========================================================
   CONSTELLATION OF PRACTICES — Сузір'я практик
   Mobile-first. Target: 375px–430px viewport (iPhone 12 — 390x844).
   ========================================================= */

:root {
  /* Ночне небо */
  --sky-top:    #0A0E1F;
  --sky-bottom: #020308;

  /* Зорі */
  --star-idle:    rgba(232, 215, 181, 0.55); /* тепле біле */
  --star-active:  #F4C95D;                   /* золото */
  --star-thread:  #A89060;                   /* м'яке золото для ліній */

  /* Текст */
  --ink-warm:   #F2EDE6;
  --ink-soft:   rgba(242, 237, 230, 0.6);
  --ink-muted:  rgba(242, 237, 230, 0.4);

  /* CTA */
  --cta-primary-bg:   #A89060;
  --cta-primary-fg:   #0A0E1F;
  --cta-secondary-fg: #E8D7B5;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans:  'Manrope', system-ui, -apple-system, sans-serif;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Reset ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--sky-bottom);
  color: var(--ink-warm);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button {
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* ===========================================================
   SCREEN 1: HERO — Ночне небо
   =========================================================== */
.sky {
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  background:
    radial-gradient(ellipse at 50% 20%, rgba(48, 36, 80, 0.25) 0%, transparent 55%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 75%);
  overflow: hidden;
}

/* Canvas зоряного шуму (фон) */
.sky__noise {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.85;
}

/* ---------- Head ---------- */
.sky__head {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 320px;
  margin: 0 auto;
  padding-top: 4px;
}

.sky__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(22px, 6.4vw, 28px);
  line-height: 1.18;
  letter-spacing: -0.005em;
  color: var(--ink-warm);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}

.sky__sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(14px, 4vw, 16px);
  line-height: 1.4;
  color: var(--ink-soft);
  margin-top: 8px;
}

/* ---------- Stage (зоряне небо) ---------- */
.sky__stage {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  margin: 6px 0;
  /* Stage керує viewBox 390x600 */
}

.sky__svg {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  overflow: visible;
}

/* Зірки: групи з трьох елементів — glow halo, зовнішнє кільце, ядро */
.star-group {
  cursor: pointer;
  pointer-events: all;
}

.star-group .star-halo {
  fill: url(#starGlow);
  opacity: 0.0;
  transition: opacity 0.35s ease;
}

.star-group .star-core {
  fill: var(--star-idle);
  /* мерехтіння через CSS keyframes — кожна зірка з різним delay */
  animation: starTwinkle 4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.star-group:hover .star-halo,
.star-group:focus-visible .star-halo {
  opacity: 0.5;
}

/* Активний стан зірки (вибрана) */
.star-group.is-active .star-core {
  fill: var(--star-active);
  animation: starPulse 2.4s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(244, 201, 93, 0.85));
}

.star-group.is-active .star-halo {
  fill: url(#starGlowActive);
  opacity: 1;
}

/* "Підказкова" зірка — одна спалахує через 2с */
.star-group.is-hinted .star-core {
  fill: var(--star-active);
  filter: drop-shadow(0 0 5px rgba(244, 201, 93, 0.7));
  animation: starHint 1.6s ease-in-out 3;
}

@keyframes starTwinkle {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.9; }
}

@keyframes starPulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.18); opacity: 0.85; }
}

@keyframes starHint {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.45); }
}

/* Лінія з'єднання — анімується через JS (stroke-dasharray) */
.connection-line {
  opacity: 0.85;
  filter: drop-shadow(0 0 3px rgba(168, 144, 96, 0.55));
}

/* ---------- Labels (over SVG) ---------- */
.sky__labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.star-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
  color: var(--ink-warm);
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
  letter-spacing: 0.02em;
  pointer-events: none;
}

.star-label.is-visible {
  opacity: 0.95;
}

.star-label.is-active {
  opacity: 1;
  color: var(--star-active);
  font-weight: 500;
  font-style: normal;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Progress ---------- */
.sky__progress {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 0;
}

.progress__pips {
  display: flex;
  gap: 6px;
}

.pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--ink-muted);
  background: transparent;
  transition: all 0.3s ease;
}

.sky__progress[data-progress="1"] .pip:nth-child(1),
.sky__progress[data-progress="2"] .pip:nth-child(-n+2),
.sky__progress[data-progress="3"] .pip:nth-child(-n+3) {
  background: var(--star-active);
  border-color: var(--star-active);
  box-shadow: 0 0 8px rgba(244, 201, 93, 0.6);
}

.progress__text {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Social proof line — under progress */
.sky__social {
  position: relative;
  z-index: 2;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-soft);
  min-height: 1.4em;
  margin: 6px 16px 0;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.sky__social.is-visible {
  opacity: 1;
}

/* Fallback CTA */
.fallback-cta {
  display: block;
  margin: 16px auto 0;
  padding: 12px 24px;
  border: 1px solid var(--cta-secondary-fg);
  border-radius: 4px;
  color: var(--cta-secondary-fg);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  max-width: 280px;
}

/* Hidden after JS init */
.js-ready .fallback-cta {
  display: none;
}

/* ===========================================================
   SCREEN 3: NAMING — Імʼя сузірʼя
   =========================================================== */
.naming {
  position: fixed;
  inset: 0;
  z-index: 10;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(168, 144, 96, 0.15) 0%, transparent 60%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 80%);
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(40px + var(--safe-top)) 24px calc(40px + var(--safe-bottom));
  opacity: 0;
  transition: opacity 0.5s ease;
}

.naming.is-open {
  display: flex;
  opacity: 1;
}

.naming__inner {
  max-width: 360px;
  text-align: center;
}

.naming__eyebrow {
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.naming__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(34px, 9.5vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--star-active);
  text-shadow: 0 0 24px rgba(244, 201, 93, 0.45);
  margin-bottom: 28px;
  animation: titleAppear 0.9s ease-out;
}

@keyframes titleAppear {
  from { opacity: 0; transform: translateY(12px); letter-spacing: 0.05em; }
  to   { opacity: 1; transform: translateY(0);    letter-spacing: -0.01em; }
}

.naming__manifesto {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(15px, 4.2vw, 17px);
  line-height: 1.55;
  color: var(--ink-warm);
  opacity: 0.85;
  margin-bottom: 36px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.naming__continue {
  padding: 14px 32px;
  border: 1px solid var(--cta-secondary-fg);
  border-radius: 4px;
  color: var(--cta-secondary-fg);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: all 0.25s ease;
}

.naming__continue:hover,
.naming__continue:focus-visible {
  background: var(--cta-secondary-fg);
  color: var(--sky-top);
}

/* ===========================================================
   SCREEN 4: COZY CORNER + Lead magnet
   =========================================================== */
.cozy {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--sky-top) 0%, #050714 100%);
  display: none;
  flex-direction: column;
  padding: 0;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.cozy.is-open {
  display: flex;
  opacity: 1;
}

.cozy__sky {
  position: relative;
  flex: 1 1 auto;
  min-height: 50dvh;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(48, 36, 80, 0.4) 0%, transparent 60%),
    linear-gradient(180deg, #0A0E1F 0%, #050714 60%, #020308 100%);
  overflow: hidden;
}

.cozy__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.cozy__window {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  pointer-events: none;
}

.cozy__window svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cozy__window-text {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12px;
  color: rgba(232, 215, 181, 0.55);
  letter-spacing: 0.05em;
}

.cozy__inner {
  background: #0A0E1F;
  padding: 28px 24px calc(28px + var(--safe-bottom));
  text-align: center;
  border-top: 1px solid rgba(168, 144, 96, 0.15);
}

.cozy__eyebrow {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.cozy__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(26px, 7vw, 32px);
  color: var(--star-active);
  margin-bottom: 22px;
  letter-spacing: -0.005em;
}

.cozy__ctas {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
  margin: 0 auto;
}

.cozy__cta {
  display: block;
  padding: 14px 24px;
  border-radius: 4px;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: all 0.25s ease;
  width: 100%;
}

.cozy__cta--primary {
  background: var(--cta-primary-bg);
  color: var(--cta-primary-fg);
  border: 1px solid var(--cta-primary-bg);
}

.cozy__cta--primary:hover,
.cozy__cta--primary:focus-visible {
  background: #C2A878;
  border-color: #C2A878;
}

.cozy__cta--secondary {
  background: transparent;
  color: var(--cta-secondary-fg);
  border: 1px solid var(--cta-secondary-fg);
}

.cozy__cta--secondary:hover,
.cozy__cta--secondary:focus-visible {
  background: var(--cta-secondary-fg);
  color: var(--sky-top);
}

.cozy__back {
  display: block;
  margin: 18px auto 0;
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.cozy__back:hover {
  color: var(--ink-soft);
}

/* ===========================================================
   Reduced motion preferences
   =========================================================== */
@media (prefers-reduced-motion: reduce) {
  .star-group .star-core,
  .star-group.is-active .star-core,
  .star-group.is-hinted .star-core {
    animation: none;
  }

  .naming__title {
    animation: none;
  }

  .naming,
  .cozy {
    transition: none;
  }
}

/* ===========================================================
   Tablet / Desktop adjustments (≥ 768px) — center content
   =========================================================== */
@media (min-width: 768px) {
  .sky,
  .naming,
  .cozy {
    max-width: 480px;
    margin: 0 auto;
  }

  .cozy__sky {
    min-height: 60vh;
  }
}
