/* ── Таро Онлайн — тема и анимации ─────────────────────────────────── */

:root {
  --night: #1A1033;
  --surface: #2A1B4A;
  --ink: #F3EEFF;
  --muted: #B8A9E0;
  --hairline: #4A3B6E;
  --gold: #F4C95D;
  --lilac: #C77DFF;
}

html, body { background: var(--night); }

/* ── Дышащий звёздный фон ─────────────────────────────────────────── */

#stars-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(199,125,255,0.10), transparent 55%),
    radial-gradient(ellipse at 80% 70%, rgba(244,201,93,0.07), transparent 55%),
    var(--night);
}

.stars-layer {
  position: absolute;
  inset: -10%;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 30% 70%, #fff, transparent),
    radial-gradient(1px 1px at 50% 40%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 70% 10%, #fff, transparent),
    radial-gradient(1px 1px at 85% 55%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 95% 85%, #fff, transparent),
    radial-gradient(1px 1px at 15% 90%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 60% 80%, #fff, transparent),
    radial-gradient(1px 1px at 40% 15%, #fff, transparent);
  background-repeat: repeat;
  background-size: 340px 340px;
  animation: stars-breathe 7s ease-in-out infinite;
  opacity: 0.55;
}
.stars-layer-2 {
  background-size: 480px 480px;
  animation-duration: 11s;
  animation-delay: -3s;
  opacity: 0.35;
}

@keyframes stars-breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

/* ── Header ───────────────────────────────────────────────────────── */

.moon-logo {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 35% 30%, #fffdf5, var(--gold) 60%, #b8892f 100%);
  color: #1A1033;
  font-size: 1.15rem;
  box-shadow: 0 0 22px rgba(244,201,93,0.55);
}

/* ── Screens ──────────────────────────────────────────────────────── */

.screen.hidden { display: none; }
.screen { animation: screen-in 0.5s ease both; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Spread selection cards ───────────────────────────────────────── */

.spread-card {
  background: rgba(42, 27, 74, 0.55);
  border: 1px solid var(--hairline);
  border-radius: 1.1rem;
  padding: 1.5rem 1.4rem;
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  backdrop-filter: blur(6px);
}
.spread-card:hover, .spread-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 10px 30px -8px rgba(244,201,93,0.35);
  background: rgba(42, 27, 74, 0.8);
  outline: none;
}
.spread-card .icon-wrap {
  width: 46px;
  height: 46px;
  border-radius: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(244,201,93,0.18), rgba(199,125,255,0.14));
  color: var(--gold);
  font-size: 1.25rem;
  border: 1px solid var(--hairline);
}
.spread-card h3 {
  font-family: 'Cormorant', serif;
  font-size: 1.65rem;
  color: var(--ink);
  line-height: 1.15;
}
.spread-card p { color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.spread-card .meta { color: var(--lilac); font-size: 0.8rem; font-style: italic; font-family: 'Cormorant', serif; letter-spacing: 0.02em; }

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn-primary {
  background: linear-gradient(140deg, var(--gold), #e0ac33);
  color: #1A1033;
  font-weight: 700;
  padding: 0.85rem 2.2rem;
  border-radius: 999px;
  box-shadow: 0 8px 24px -6px rgba(244,201,93,0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: 'Nunito', sans-serif;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -6px rgba(244,201,93,0.65); }

/* ── Draw stage ───────────────────────────────────────────────────── */

.draw-stage {
  position: relative;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  padding: 1rem 0 2rem;
}

.positions-layout {
  display: grid;
  gap: 1.1rem;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.layout-card_day { grid-template-areas: "day"; justify-items: center; }
.layout-three_cards {
  grid-template-columns: repeat(3, minmax(120px, 190px));
  grid-template-areas: "past present future";
}
.layout-relationship {
  grid-template-columns: repeat(3, minmax(105px, 170px));
  grid-template-areas:
    ".      partner  ."
    "you    bond     challenge"
    ".      outcome  .";
}
.layout-celtic_cross {
  grid-template-columns: repeat(3, minmax(95px, 145px)) minmax(95px, 145px);
  grid-template-rows: repeat(4, auto);
  grid-template-areas:
    ".     crown  .      outcome"
    "past  center future hopes"
    ".     base   .      environment"
    ".     .      .      self";
  gap: 0.85rem;
}

.slot {
  position: relative;
  width: 100px;
  aspect-ratio: 3 / 5;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.layout-three_cards .slot,
.layout-card_day .slot { width: 130px; }

.slot-frame {
  position: absolute;
  inset: 0;
  border-radius: 0.6rem;
  border: 1.5px dashed var(--hairline);
  background: rgba(244,201,93,0.03);
  transition: border-color 0.4s ease, box-shadow 0.4s ease, background 0.4s ease;
}
.slot.filled .slot-frame {
  border: 1.5px solid var(--gold);
  box-shadow: 0 0 24px rgba(244,201,93,0.45);
  background: rgba(244,201,93,0.05);
}
.slot img.slot-card {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.6rem;
  box-shadow: 0 6px 18px -4px rgba(0,0,0,0.55);
}
.slot img.slot-card.reversed { transform: rotate(180deg); }
.slot-label {
  position: absolute;
  bottom: -1.6rem;
  left: 0; right: 0;
  text-align: center;
  font-family: 'Cormorant', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}
.slot[data-key="cross"] {
  grid-area: center;
  transform: rotate(90deg) scale(0.82);
  z-index: 2;
}
.slot[data-key="cross"] .slot-label { display: none; }
.slot[data-key="center"] { z-index: 1; }

/* result mode: smaller, no dashed empty slots (already filled) */
.result-mode .slot { width: 78px; margin-bottom: 1.7rem; }
.result-mode .layout-three_cards .slot,
.result-mode .layout-card_day .slot { width: 100px; }

/* ── Deck ─────────────────────────────────────────────────────────── */

.deck-wrap { display: flex; flex-direction: column; align-items: center; }

.deck {
  position: relative;
  width: 120px;
  height: 200px;
  cursor: pointer;
}
.deck-card {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.7rem;
  box-shadow: 0 0 0 1px var(--hairline), 0 10px 30px -6px rgba(0,0,0,0.6);
}
.deck-card-1 { transform: translate(0, 0) rotate(-1deg); z-index: 3; animation: deck-glow 2.6s ease-in-out infinite; }
.deck-card-2 { transform: translate(4px, 3px) rotate(2deg); z-index: 2; opacity: 0.9; }
.deck-card-3 { transform: translate(-4px, 6px) rotate(-3deg); z-index: 1; opacity: 0.8; }

.deck.exhausted { cursor: default; opacity: 0.35; pointer-events: none; }

@keyframes deck-glow {
  0%, 100% { box-shadow: 0 0 0 1px var(--hairline), 0 0 16px rgba(244,201,93,0.25), 0 10px 30px -6px rgba(0,0,0,0.6); }
  50% { box-shadow: 0 0 0 1px var(--gold), 0 0 34px rgba(244,201,93,0.65), 0 10px 30px -6px rgba(0,0,0,0.6); }
}

/* ── Flying card (draw animation) ────────────────────────────────── */

.flying-card {
  position: fixed;
  z-index: 200;
  perspective: 1000px;
  pointer-events: none;
  transition: left 0.75s cubic-bezier(.22,.68,0,1.11), top 0.75s cubic-bezier(.22,.68,0,1.11),
              width 0.75s cubic-bezier(.22,.68,0,1.11), height 0.75s cubic-bezier(.22,.68,0,1.11);
}
.flying-card .card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(.45,.05,.55,.95);
  border-radius: 0.7rem;
  box-shadow: 0 10px 30px -4px rgba(0,0,0,0.65);
}
.flying-card.flipped .card-inner { transform: rotateY(180deg); }
.flying-card.reversed-final .card-inner { transform: rotateY(180deg) rotate(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.7rem;
  backface-visibility: hidden;
}
.card-face.back { transform: rotateY(0deg); }
.card-face.front { transform: rotateY(180deg); }
.flying-card.glow .card-inner { box-shadow: 0 0 30px 6px rgba(244,201,93,0.65), 0 10px 30px -4px rgba(0,0,0,0.65); }

/* ── Whisper indicator ────────────────────────────────────────────── */

.whisper-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--lilac);
  font-family: 'Cormorant', serif;
  font-style: italic;
  font-size: 1.35rem;
  justify-content: center;
}
.whisper-indicator.hidden { display: none; }
.dots { display: inline-flex; gap: 0.25rem; }
.dots i {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--lilac);
  display: inline-block;
  animation: dot-blink 1.2s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-blink { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); } 40% { opacity: 1; transform: scale(1.1); } }

/* ── Interpretation blocks ───────────────────────────────────────── */

.interp-block {
  display: flex;
  gap: 1.4rem;
  background: rgba(42,27,74,0.45);
  border: 1px solid var(--hairline);
  border-radius: 1rem;
  padding: 1.3rem;
  opacity: 0;
  animation: block-fade-in 0.6s ease forwards;
}
@keyframes block-fade-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.interp-block .interp-card {
  flex: 0 0 110px;
  aspect-ratio: 3/5;
  border-radius: 0.6rem;
  overflow: hidden;
  box-shadow: 0 6px 20px -4px rgba(0,0,0,0.5);
}
.interp-block .interp-card img { width: 100%; height: 100%; object-fit: cover; }
.interp-block .interp-card img.reversed { transform: rotate(180deg); }
.interp-block .interp-text { flex: 1; min-width: 0; }
.interp-block h4 {
  font-family: 'Cormorant', serif;
  font-style: italic;
  font-size: 1.35rem;
  color: var(--gold);
  margin-bottom: 0.15rem;
}
.interp-block .position-label { color: var(--lilac); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.4rem; display: block; }
.interp-block p { line-height: 1.7; font-size: 1.02rem; color: var(--ink); }
.interp-block .fallback-note { color: var(--muted); font-size: 0.85rem; margin-top: 0.5rem; font-style: italic; font-family: 'Cormorant', serif; }

.overall-panel {
  background: linear-gradient(150deg, rgba(244,201,93,0.1), rgba(199,125,255,0.08));
  border: 1px solid var(--gold);
  border-radius: 1.1rem;
  padding: 1.6rem 1.8rem;
  box-shadow: 0 0 40px -12px rgba(244,201,93,0.35);
}
.overall-panel.hidden { display: none; }

/* ── Toast ────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: #241539;
  border: 1px solid var(--gold);
  color: var(--ink);
  padding: 0.85rem 1.1rem;
  border-radius: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 12px 34px -8px rgba(0,0,0,0.6);
  max-width: 92vw;
  animation: toast-in 0.35s ease both;
}
.toast.hidden { display: none; }
.toast i.fa-moon { color: var(--gold); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast-retry {
  background: var(--gold);
  color: #1A1033;
  font-weight: 700;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.toast-close { color: var(--muted); padding: 0 0.2rem; }

/* ── Responsive < 768px ───────────────────────────────────────────── */

@media (max-width: 767px) {
  .positions-layout {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 2.1rem;
    max-height: 52vh;
    overflow-y: auto;
    padding: 0.5rem 0;
  }
  .result-mode.positions-layout { max-height: none; overflow: visible; }
  .slot { grid-area: auto !important; transform: none !important; }
  .slot[data-key="cross"] { transform: rotate(8deg) scale(0.9) !important; margin-top: -1.4rem; }

  .interp-block { flex-direction: column; }
  .interp-block .interp-card { flex: none; width: 130px; margin: 0 auto; }

  .btn-primary { width: 100%; }
}

/* ── Reduced motion ───────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .stars-layer, .deck-card-1, .whisper-indicator .dots i, .screen, .interp-block {
    animation: none !important;
  }
  .flying-card, .flying-card .card-inner {
    transition-duration: 0.01ms !important;
  }
}
