@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Text:ital,wght@0,400;0,600;1,400&family=Pinyon+Script&family=Dancing+Script:wght@500;600&display=swap');

:root {
  --bg:            #07000f;
  --bg2:           #0d0020;
  --purple-deep:   #1a0040;
  --purple:        #5b00a8;
  --purple-bright: #9b30ff;
  --gold:          #ffffff;
  --gold-light:    #ede8ff;
  --text:          #ede0ff;
  --text-dim:      #9980bb;
  --glow-purple:   rgba(155, 48, 255, 0.55);
  --glow-gold:     rgba(255, 255, 255, 0.35);
  --card-w:        110px;
  --card-h:        185px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Crimson Text', serif;
  font-size: 18px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Starfield canvas ── */
#stars-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── Sections ── */
.section {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  animation: fadeIn 0.8s ease;
}

@keyframes fadeIn { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:none; } }

/* ── Top bar ── */
.top-bar {
  position: absolute;
  top: 20px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 10;
}

.top-user {
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.top-logout {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.08em;
  border: 1px solid rgba(155,48,255,0.3);
  padding: 5px 12px;
  border-radius: 20px;
  transition: color 0.3s, border-color 0.3s;
}

.top-logout:hover {
  color: var(--purple-bright);
  border-color: var(--purple-bright);
}

/* ── Logo ── */
.logo {
  font-family: 'Pinyon Script', cursive, serif;
  font-size: clamp(3.5rem, 10vw, 7rem);
  font-weight: 400;
  color: #d4a0ff;
  text-shadow:
    0 0 10px #d4a0ff,
    0 0 30px #b060ff,
    0 0 70px rgba(160, 80, 255, 0.6),
    0 0 130px rgba(140, 40, 255, 0.3);
  animation: logoMagic 5s ease-in-out infinite;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  text-align: center;
  display: block;
}

@keyframes logoMagic {
  0%   { opacity: 1;    color: #e0b0ff; text-shadow: 0 0 10px #e0b0ff, 0 0 40px #b060ff, 0 0 90px rgba(160,80,255,0.7); transform: translateY(0px) scale(1); }
  20%  { opacity: 0.35; color: #c080ff; text-shadow: 0 0 5px #c080ff,  0 0 20px rgba(180,100,255,0.3); transform: translateY(-4px) scale(0.98); }
  40%  { opacity: 1;    color: #f0c0ff; text-shadow: 0 0 15px #f0c0ff, 0 0 50px #d060ff, 0 0 100px rgba(200,80,255,0.8); transform: translateY(-8px) scale(1.02); }
  60%  { opacity: 0.5;  color: #a060ff; text-shadow: 0 0 8px #a060ff,  0 0 30px rgba(140,60,255,0.4); transform: translateY(-3px) scale(0.99); }
  80%  { opacity: 1;    color: #e8b8ff; text-shadow: 0 0 12px #e8b8ff, 0 0 45px #c070ff, 0 0 85px rgba(180,60,255,0.6); transform: translateY(2px) scale(1.01); }
  100% { opacity: 1;    color: #e0b0ff; text-shadow: 0 0 10px #e0b0ff, 0 0 40px #b060ff, 0 0 90px rgba(160,80,255,0.7); transform: translateY(0px) scale(1); }
}

.tagline {
  font-family: 'Crimson Text', serif;
  font-size: 1.2rem;
  font-style: italic;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-bottom: 32px;
  text-align: center;
}

/* ── Tarot magic description ── */
.tarot-magic-text {
  max-width: 520px;
  text-align: center;
  margin: 0 auto 48px;
  padding: 24px 28px;
  border: 1px solid rgba(155, 48, 255, 0.2);
  border-radius: 16px;
  background: rgba(26, 0, 64, 0.35);
  backdrop-filter: blur(4px);
}

.tarot-magic-text p {
  font-family: 'Crimson Text', serif;
  font-size: 1.05rem;
  line-height: 1.8;
  color: rgba(220, 200, 255, 0.75);
  font-style: italic;
}

/* ── Spread selector ── */
.spread-selector {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 20px;
}

.spread-btn {
  background: linear-gradient(145deg, var(--purple-deep), #2a005a);
  border: 1px solid rgba(255,255,255,0.25);
  color: #ffffff;
  font-family: 'Dancing Script', cursive;
  font-size: 1.3rem;
  font-weight: 600;
  padding: 24px 32px;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s ease;
  min-width: 180px;
  box-shadow: 0 0 15px rgba(91,0,168,0.4);
}

.spread-btn small {
  display: block;
  font-family: 'Crimson Text', serif;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 6px;
  font-style: italic;
}

.spread-btn:hover, .spread-btn.active {
  background: linear-gradient(145deg, var(--purple), #4a008a);
  border-color: var(--gold-light);
  box-shadow: 0 0 25px var(--glow-purple), 0 0 50px rgba(91,0,168,0.3);
  transform: translateY(-4px);
  color: #fff;
}

/* ── Buttons ── */
.btn {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  padding: 14px 40px;
  border-radius: 50px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.3s ease;
  margin-top: 24px;
}

.btn:hover:not(:disabled) {
  background: var(--gold);
  color: var(--bg);
  box-shadow: 0 0 25px var(--glow-gold);
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ghost {
  border-color: var(--text-dim);
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 10px 24px;
}

.btn-ghost:hover {
  border-color: var(--text);
  color: var(--text);
  background: transparent;
  box-shadow: none;
}

/* ── Section headings ── */
.section-title {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  margin-bottom: 32px;
  letter-spacing: 0.1em;
  text-shadow: 0 0 18px rgba(255,255,255,0.35), 0 0 40px rgba(180,120,255,0.25);
}

/* ── Question inputs ── */
.questions-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.question-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-group label {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.1em;
}

.question-input {
  background: rgba(26, 0, 64, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Crimson Text', serif;
  font-size: 1.1rem;
  padding: 14px 18px;
  width: 100%;
  transition: border-color 0.3s, box-shadow 0.3s;
  outline: none;
}

.question-input:focus {
  border-color: rgba(255,255,255,0.5);
  box-shadow: 0 0 15px rgba(255,255,255,0.12);
}

.question-input::placeholder { color: var(--text-dim); font-style: italic; }

/* ── Progress indicator ── */
.progress-text {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 24px;
  letter-spacing: 0.08em;
}

.progress-text span {
  color: var(--gold);
  font-size: 1.1rem;
}

/* ── Card pool (face-down cards to pick from) ── */
.card-pool-wrapper {
  width: 100%;
  max-width: 900px;
  margin-bottom: 40px;
}

.card-pool-title {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 20px;
  font-size: 1.1rem;
}

.card-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 20px;
  background: rgba(13,0,32,0.5);
  border: 1px solid rgba(91,0,168,0.3);
  border-radius: 16px;
}

/* ── Card base ── */
.card {
  width: var(--card-w);
  height: var(--card-h);
  position: relative;
  cursor: pointer;
  perspective: 1000px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.card:hover .card-inner { box-shadow: 0 0 20px var(--glow-purple), 0 0 40px rgba(91,0,168,0.4); }
.card:hover { transform: translateY(-8px) scale(1.05); }

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.6), 0 0 8px rgba(91,0,168,0.3);
}

.card.flipped .card-inner { transform: rotateY(180deg); }
.card.reversed .card-front img { transform: rotate(180deg); }

.card-front, .card-back {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  overflow: hidden;
}

/* Card back — dark mystical CSS design */
.card-back {
  background: linear-gradient(135deg, #0d0028 0%, #1a0050 50%, #0d0028 100%);
  border: 1px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back-inner {
  width: 88%;
  height: 88%;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.card-back-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(255,255,255,0.03) 8px, rgba(255,255,255,0.03) 9px),
    repeating-linear-gradient(-45deg, transparent, transparent 8px, rgba(91,0,168,0.06) 8px, rgba(91,0,168,0.06) 9px);
}

.card-back-star {
  font-size: 2.2rem;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 8px var(--gold));
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 8px var(--gold)); opacity: 0.85; }
  50% { filter: drop-shadow(0 0 18px var(--gold)) drop-shadow(0 0 30px var(--glow-purple)); opacity: 1; }
}

/* Card front */
.card-front {
  transform: rotateY(180deg);
  background: #0a0018;
  border: 1px solid rgba(255,255,255,0.2);
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.7) brightness(0.85) contrast(1.1);
  transition: filter 0.3s;
}

.card-front img.loaded { filter: saturate(0.8) brightness(0.9) contrast(1.05); }

.card-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(7,0,15,0.92));
  padding: 18px 6px 6px;
  text-align: center;
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  color: var(--gold);
  letter-spacing: 0.05em;
  line-height: 1.3;
}

.card-label .reversed-badge {
  display: block;
  font-size: 0.5rem;
  color: #c070ff;
  font-style: italic;
  letter-spacing: 0;
}

/* Pool card — synlig storlek med hover-effekt */
.card.pool-card { width: 88px; height: 148px; }
.card.pool-card .card-back-star { font-size: 1.6rem; }
.card.pool-card:hover { transform: translateY(-12px) scale(1.08); z-index: 10; }
.card.pool-card .card-inner {
  box-shadow: 0 4px 20px rgba(0,0,0,0.8), 0 0 12px rgba(155,48,255,0.4);
}

/* ── Spread layouts ── */
.spread-area {
  width: 100%;
  max-width: 1000px;
}

/* Single — 3 cards in a row */
.spread-single {
  display: flex;
  gap: 30px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.spread-card-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.slot-label {
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

.slot-placeholder {
  width: var(--card-w);
  height: var(--card-h);
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.15);
  font-size: 1.5rem;
}

/* Triple — 3 question groups */
.spread-triple {
  display: flex;
  flex-direction: column;
  gap: 40px;
  width: 100%;
}

.question-group-spread {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.question-group-label {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 500px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding-bottom: 10px;
  width: 100%;
}

.question-cards-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Year star — circular layout */
.spread-year {
  position: relative;
  width: 580px;
  height: 580px;
  max-width: 90vw;
  max-height: 90vw;
}

.year-card-slot {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transform-origin: center;
}

.year-slot-label {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-align: center;
}

.year-center-slot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 2;
}

.year-center-slot .card { width: 100px; height: 168px; }
.year-center-slot .slot-label {
  font-size: 0.75rem;
  color: var(--gold);
}

/* Year star circle: cards placed via JS */
.year-ring-card { width: 68px; height: 114px; }
.year-ring-card .card-back-star { font-size: 1.3rem; }

/* ── Reading section ── */
#reading-section {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  padding: 60px 20px;
}

.reading-container {
  max-width: 750px;
  width: 100%;
}

.reading-header {
  text-align: center;
  margin-bottom: 40px;
}

.reading-orb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c060ff, #5b00a8, #0d0028);
  box-shadow: 0 0 30px var(--glow-purple), 0 0 60px rgba(91,0,168,0.4);
  margin: 0 auto 20px;
  animation: orb-float 4s ease-in-out infinite;
}

@keyframes orb-float {
  0%,100% { transform: translateY(0) scale(1); box-shadow: 0 0 30px var(--glow-purple), 0 0 60px rgba(91,0,168,0.4); }
  50% { transform: translateY(-10px) scale(1.05); box-shadow: 0 0 40px var(--glow-purple), 0 0 80px rgba(91,0,168,0.5); }
}

.reading-text {
  font-family: 'Crimson Text', serif;
  font-size: 1.2rem;
  line-height: 1.9;
  color: var(--text);
  white-space: pre-wrap;
}

/* ── Följdfrågor ── */
.followup-section {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

.followup-history {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.followup-q {
  background: rgba(155, 48, 255, 0.1);
  border-left: 3px solid var(--purple-bright);
  border-radius: 0 10px 10px 0;
  padding: 14px 18px;
  font-style: italic;
  color: var(--text-dim);
}

.followup-q::before {
  content: '✦ ';
  color: var(--purple-bright);
}

.followup-a {
  font-family: 'Crimson Text', serif;
  font-size: 1.15rem;
  line-height: 1.85;
  color: var(--text);
  padding: 0 4px;
  white-space: pre-wrap;
}

.followup-counter {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  font-style: italic;
}

.followup-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.followup-input {
  flex: 1;
  background: rgba(26, 0, 64, 0.6);
  border: 1px solid rgba(155, 48, 255, 0.35);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Crimson Text', serif;
  font-size: 1.1rem;
  padding: 12px 16px;
  outline: none;
  resize: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.followup-input:focus {
  border-color: var(--purple-bright);
  box-shadow: 0 0 12px rgba(155,48,255,0.25);
}

.followup-input::placeholder { color: var(--text-dim); font-style: italic; }

.followup-btn {
  white-space: nowrap;
  padding: 12px 22px;
}

/* ── Följdfråga med kort ── */
.card-followup-panel {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: fadeIn 0.4s ease;
}

.card-followup-title {
  font-family: 'Dancing Script', cursive;
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  text-shadow: 0 0 12px rgba(255,255,255,0.3);
}

.card-followup-hint {
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  font-size: 1rem;
}

.card-followup-draw {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.card-followup-draw-hint {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
}

.card-followup-panel .followup-input {
  width: 100%;
}

.followup-done {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  padding: 16px;
}

.reading-advice {
  display: block;
  margin-top: 28px;
  padding: 18px 24px;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(155,48,255,0.12));
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  color: #ffffff;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.85;
  letter-spacing: 0.04em;
  text-shadow: 0 0 14px rgba(255,255,255,0.25), 0 0 30px rgba(180,120,255,0.2);
}

.reading-text .cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--gold);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

.divider {
  width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 40px auto;
}

/* ── Cards drawn summary ── */
.drawn-cards-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin-bottom: 40px;
}

.reading-card-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.6s ease;
}

.reading-card-pos {
  font-family: 'Dancing Script', cursive;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.03em;
}

.reading-card-img {
  width: 80px;
  height: 135px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 0 16px rgba(155,48,255,0.35), 0 4px 12px rgba(0,0,0,0.5);
  filter: saturate(0.85) brightness(0.9);
  transition: transform 0.3s, box-shadow 0.3s;
}

.reading-card-img:hover {
  transform: scale(1.08) translateY(-4px);
  box-shadow: 0 0 28px rgba(155,48,255,0.6), 0 8px 20px rgba(0,0,0,0.6);
}

.reading-card-img.reversed {
  transform: rotate(180deg);
}

.reading-card-img.reversed:hover {
  transform: rotate(180deg) scale(1.08) translateY(4px);
}

.reading-card-name {
  font-family: 'Dancing Script', cursive;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.75);
  text-align: center;
  max-width: 90px;
  line-height: 1.2;
}

/* ── Utility ── */
[hidden] { display: none !important; }

.text-center { text-align: center; }

/* ── Responsive ── */
@media (max-width: 600px) {
  :root { --card-w: 85px; --card-h: 143px; }
  .spread-single { gap: 16px; }
  .spread-year { width: 320px; height: 320px; }
  .year-ring-card { width: 50px; height: 84px; }
  .year-center-slot .card { width: 70px; height: 118px; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 3px; }
