/* ─────────── Tokens ─────────── */
:root {
  --c-bg-deep:      #0a0612;
  --c-rose:         #e3bfc4;
  --c-rose-deep:    #c89aa0;
  --c-blue-grey:    #b8c4cc;
  --c-cream:        #f0e1d2;
  --c-yellow:       #e8c468;
  --c-text:         #f0e1d2;
  --c-text-soft:    rgba(240, 225, 210, 0.85);
  --c-text-faint:   rgba(240, 225, 210, 0.55);

  --acc-knight-1:   #7d97a4;
  --acc-knight-2:   #e8c468;
  --acc-seeker-1:   #8eb0a3;
  --acc-seeker-2:   #e8c468;
  --acc-mage-1:     #2e6b7d;
  --acc-mage-2:     #b8c4cc;
  --acc-firefly-1:  #e3bfc4;
  --acc-firefly-2:  #e8c468;

  --serif: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ─────────── Reset ─────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
html, body { height: 100%; overflow-x: hidden; overscroll-behavior-y: contain; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

body {
  font-family: var(--serif);
  font-weight: 400;
  color: var(--c-text);
  background: var(--c-bg-deep);
  line-height: 1.55;
  min-height: 100vh;
  overflow-y: auto;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─────────── Cover layer (album / archetype) ───────────
   Два <img> сложены друг на друга для кросс-фейда.
   Aspect-ratio картинки сохраняется (object-fit: cover —
   это кадрирование, а не растяжение). Контейнер
   увеличен на 16% для запаса под параллакс.
   ────────────────────────────────────────────────────── */
.cover-layer {
  position: fixed;
  inset: 0;
  z-index: -3;
  overflow: hidden;
  background: var(--c-bg-deep);
}

.cover-stage {
  position: absolute;
  inset: 0;
  --tx: 0px;
  --ty: 0px;
  --mx: 0px;
  --my: 0px;
  transform: translate3d(calc(var(--tx) + var(--mx)), calc(var(--ty) + var(--my)), 0);
  transition: transform 1.4s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.cover-img {
  position: absolute;
  inset: -5%;
  width: 110%;
  height: 110%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.42) saturate(0.95) blur(1.2px);
  opacity: 0;
  transition: opacity 1s ease;
  will-change: opacity;
  pointer-events: none;
}
.cover-img.is-active { opacity: 1; }

/* На результате — слегка приподнимаем фото архетипа: голова остаётся видна,
   а ноги/нижняя часть кадрируются мягче. */
body.is-result .cover-img { object-position: center 15%; }

/* затемнение и виньетка поверх картинки для читаемости */
.cover-overlay {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 25%, rgba(8, 4, 18, 0.55) 90%),
    linear-gradient(180deg, rgba(0,0,0,0.18), rgba(0,0,0,0.05) 45%, rgba(0,0,0,0.4));
}

/* акцентное свечение архетипа на результате */
.cover-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 35%, var(--accent-glow, transparent), transparent 55%);
  opacity: 0;
  transition: opacity 1.2s ease;
  mix-blend-mode: screen;
}
body.is-result .cover-overlay::after { opacity: 0.7; }

/* зерно через SVG noise filter */
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: 0.14;
  mix-blend-mode: overlay;
}

/* ─────────── Stage / Screens ─────────── */
.stage {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3vh 24px;
}
.stage:has(#screen-result.active) {
  align-items: flex-start;
  padding-top: 2vh;
}

.screen {
  width: 100%;
  max-width: 720px;
  text-align: center;
  display: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.screen.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}
.screen.exiting {
  opacity: 0;
  transform: translateY(-20px);
}

/* ─────────── Welcome ─────────── */
.welcome h1 {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(2rem, 5.6vw, 3.6rem);
  line-height: 1.15;
  letter-spacing: -0.005em;
  margin-bottom: 1.4rem;
  color: var(--c-cream);
  text-wrap: balance;
  text-shadow: 0 2px 20px rgba(0,0,0,0.55), 0 0 60px rgba(0,0,0,0.4);
}
.welcome h1 em {
  font-style: normal;
  font-weight: 700;
  color: var(--c-rose);
}
.welcome .sub {
  font-family: var(--serif);
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  font-weight: 400;
  color: var(--c-text-soft);
  margin-bottom: 3rem;
  letter-spacing: 0.005em;
  text-shadow: 0 1px 12px rgba(0,0,0,0.6);
}

/* «дыхание» под заголовком, чтобы текст не сливался с обложкой */
.welcome::before,
.question::before {
  content: "";
  position: absolute;
  inset: -10% -8% -20% -8%;
  background: radial-gradient(ellipse at center, rgba(8, 4, 18, 0.55) 0%, rgba(8, 4, 18, 0.25) 45%, transparent 75%);
  z-index: -1;
  pointer-events: none;
  filter: blur(8px);
}
.welcome, .question { position: relative; }

/* стеклянная кнопка */
.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 1em 2.6em;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 0 0 0 rgba(227, 191, 196, 0),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: all 0.5s ease;
  text-decoration: none;
}
.glass-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(227, 191, 196, 0.6);
  box-shadow:
    0 0 36px 6px rgba(227, 191, 196, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

/* ─────────── Progress ─────────── */
.progress-wrap {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 2.4rem clamp(20px, 5vw, 48px) 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.progress-wrap.visible { opacity: 1; }
.progress-track {
  height: 1px;
  background: rgba(239, 230, 220, 0.18);
  position: relative;
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg,
    rgba(184, 196, 204, 0.5),
    rgba(227, 191, 196, 0.9),
    rgba(232, 196, 104, 0.6));
  box-shadow: 0 0 12px rgba(227, 191, 196, 0.6);
  transition: width 0.6s ease;
}
.progress-label {
  margin-top: 0.9rem;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--c-text-faint);
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
}

/* ─────────── Question ─────────── */
.q-text {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.5rem, 3.6vw, 2.2rem);
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--c-cream);
  margin-bottom: 3.5rem;
  text-wrap: pretty;
  min-height: 3.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 2px 24px rgba(0,0,0,0.7), 0 0 50px rgba(0,0,0,0.5);
}

/* шкала 1-5 */
.scale {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(0.6rem, 2.2vw, 1.4rem);
  margin-bottom: 1.4rem;
}
.scale-btn {
  --size: clamp(44px, 7vw, 60px);
  width: var(--size); height: var(--size);
  border-radius: 50%;
  background: rgba(20, 12, 30, 0.32);
  border: 1px solid rgba(239, 230, 220, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--c-text-soft);
  transition: all 0.4s ease;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.scale-btn:hover {
  transform: scale(1.12);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(227, 191, 196, 0.65);
  color: var(--c-cream);
  box-shadow: 0 0 24px rgba(227, 191, 196, 0.5);
}
.scale-btn.selected {
  background: linear-gradient(135deg,
    rgba(227, 191, 196, 0.6),
    rgba(232, 196, 104, 0.45));
  border-color: rgba(255, 255, 255, 0.7);
  color: var(--c-cream);
  box-shadow: 0 0 30px rgba(227, 191, 196, 0.55);
  transform: scale(1.1);
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  max-width: 480px;
  margin: 0 auto;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--c-text-faint);
  font-family: var(--serif);
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
}

/* финальный вопрос — карточки */
.fear-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 540px;
  margin: 0 auto;
}
.fear-card {
  padding: 2.4rem 1.4rem;
  background: rgba(20, 12, 30, 0.35);
  border: 1px solid rgba(239, 230, 220, 0.22);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--c-text);
  transition: all 0.5s ease;
  letter-spacing: 0.005em;
}
.fear-card:hover {
  background: rgba(40, 28, 50, 0.45);
  border-color: rgba(227, 191, 196, 0.6);
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55),
              0 0 30px rgba(227, 191, 196, 0.32);
  color: var(--c-cream);
}

/* ─────────── Loading ─────────── */
.loading {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  color: var(--c-text-soft);
  letter-spacing: 0.01em;
  text-shadow: 0 2px 18px rgba(0,0,0,0.7);
}
.dots { display: inline-flex; gap: 0.4em; margin-left: 0.5em; }
.dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-rose);
  display: inline-block;
  animation: pulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(227, 191, 196, 0.8);
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 60%, 100% { transform: scale(0.6); opacity: 0.4; }
  30% { transform: scale(1.1); opacity: 1; }
}

/* ─────────── Result ─────────── */
.result {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  animation: resultIn 0.9s ease forwards;
}
@keyframes resultIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.result-card {
  position: relative;
  padding: 1.6rem 1.8rem 1.6rem;
  background: rgba(20, 12, 30, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 22px;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow:
    0 30px 80px -20px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  margin-bottom: 1rem;
  overflow: hidden;
  transition: box-shadow 0.8s ease, border-color 0.8s ease;
}
.result-card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at 50% 30%,
    var(--accent-glow, rgba(227, 191, 196, 0.4)),
    transparent 55%);
  z-index: -1;
  opacity: 0.75;
  transition: background 0.8s ease;
}

.archetype-name {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(2rem, 4.6vw, 2.8rem);
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin-bottom: 0.9rem;
  color: var(--c-cream);
  text-shadow: 0 0 30px var(--accent-glow, rgba(227, 191, 196, 0.5)),
               0 2px 24px rgba(0,0,0,0.6);
}

.archetype-desc {
  font-family: var(--serif);
  font-size: clamp(0.92rem, 1.4vw, 1rem);
  font-weight: 400;
  line-height: 1.55;
  color: var(--c-text-soft);
  margin: 0 auto 0;
  max-width: 56ch;
  text-align: left;
  text-wrap: pretty;
}

.playlist {
  margin: 1.2rem 0 0.8rem;
  display: flex;
  justify-content: center;
}
.playlist-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7em;
  width: 100%;
  max-width: 480px;
  background: linear-gradient(135deg,
    rgba(232, 196, 104, 0.95),
    rgba(227, 174, 104, 0.95));
  border: 1px solid rgba(255, 230, 160, 0.7);
  color: #1a1a1a;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  font-style: normal;
  padding: 1.05em 2rem;
  border-radius: 999px;
  text-decoration: none;
  transition: all 0.5s ease;
  box-shadow:
    0 12px 40px -10px rgba(232, 196, 104, 0.55),
    0 0 60px -10px rgba(232, 196, 104, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.playlist-link:hover {
  background: linear-gradient(135deg,
    rgba(244, 210, 120, 1),
    rgba(232, 184, 110, 1));
  border-color: rgba(255, 240, 180, 0.95);
  transform: translateY(-2px);
  box-shadow:
    0 16px 50px -10px rgba(232, 196, 104, 0.7),
    0 0 80px -10px rgba(232, 196, 104, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  color: #0a0a0a;
}
.playlist-link svg {
  width: 24px; height: 24px;
  opacity: 1;
  color: #1a1a1a;
  stroke-width: 1.8;
}

.restart-wrap {
  margin-top: 0.6rem;
}
.restart-btn {
  background: none;
  border: none;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--c-text-faint);
  letter-spacing: 0.04em;
  padding: 0.6em 1em;
  text-decoration: underline;
  text-decoration-color: rgba(240, 225, 210, 0.3);
  text-underline-offset: 4px;
  transition: color 0.4s ease, text-decoration-color 0.4s ease;
  cursor: pointer;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
}
.restart-btn:hover {
  color: var(--c-text-soft);
  text-decoration-color: rgba(240, 225, 210, 0.6);
}

/* ─────────── Responsive ─────────── */
@media (max-width: 720px) {
  .stage { padding: 2vh 18px 3vh; }
  .stage:has(#screen-result.active) { padding-top: 1.2vh; }
  .progress-wrap { padding: 1.4rem 18px 0; }
  .progress-label { font-size: 0.68rem; letter-spacing: 0.22em; }
  .welcome h1 { font-size: clamp(1.7rem, 7vw, 2.4rem); margin-bottom: 1rem; }
  .welcome .sub { font-size: 1rem; margin-bottom: 2.2rem; }
  .glass-btn { padding: 0.95em 2.2em; font-size: 0.92rem; letter-spacing: 0.16em; }
  .q-text {
    font-size: clamp(1.3rem, 5.5vw, 1.7rem);
    margin-bottom: 2.4rem;
    min-height: auto;
    padding: 0 0.4rem;
  }
  .scale { gap: 0.55rem; flex-wrap: nowrap; }
  .scale-btn { --size: 48px; font-size: 1rem; }
  .scale-labels { font-size: 0.72rem; padding: 0 0.2rem; gap: 1rem; }
  .scale-labels span { max-width: 45%; }
  .fear-grid { grid-template-columns: 1fr; gap: 0.7rem; max-width: 380px; }
  .fear-card { padding: 1.6rem 1rem; font-size: 1.15rem; }
  .result-card { padding: 1.2rem 1rem 1.2rem; border-radius: 16px; margin-bottom: 0.8rem; }
  .archetype-name { font-size: clamp(1.7rem, 7vw, 2.1rem); margin-bottom: 0.6rem; }
  .archetype-desc { font-size: 0.92rem; line-height: 1.5; }
  .playlist { margin: 0.9rem 0 0.5rem; }
  .playlist-link { font-size: 0.95rem; padding: 0.95em 1.5em; }
  .playlist-link svg { width: 18px; height: 18px; }
}

@media (max-width: 380px) {
  .scale-btn { --size: 42px; font-size: 0.95rem; }
  .scale-labels { font-size: 0.68rem; }
}

/* ─────────── Reduced motion ─────────── */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 200ms !important; }
  .cover-stage { transition: none; }
}
