/* ===========================
   TAROT READING APP - STYLES
   =========================== */

:root {
  --bg-dark: #0a0a1a;
  --bg-mid: #110e2a;
  --bg-card: #1a1535;
  --accent: #c9a84c;
  --accent2: #9b59b6;
  --accent3: #5dade2;
  --text: #e8e0f0;
  --text-dim: #a090c0;
  --border: rgba(201,168,76,0.3);
  --glow: rgba(201,168,76,0.15);
  --card-back: #1e1045;
  --radius: 10px;
  --card-w: 90px;
  --card-h: 150px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'Georgia', 'Times New Roman', serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Language Bar ---- */
.lang-bar {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 20px;
  background: rgba(0,0,0,0.4);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }
.lang-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: bold;
}

/* ---- Header ---- */
.site-header {
  position: relative;
  text-align: center;
  padding: 60px 20px 50px;
  overflow: hidden;
  background: radial-gradient(ellipse at center top, #1e0a4e 0%, #0a0a1a 70%);
  border-bottom: 1px solid var(--border);
}

.stars-bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, #fff 1px, transparent 1px),
    radial-gradient(circle, rgba(255,255,255,0.5) 1px, transparent 1px);
  background-size: 80px 80px, 40px 40px;
  background-position: 0 0, 20px 20px;
  opacity: 0.15;
  animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% { opacity: 0.1; }
  100% { opacity: 0.25; }
}

.header-symbol {
  font-size: 1.6rem;
  color: var(--accent);
  letter-spacing: 12px;
  margin-bottom: 16px;
  text-shadow: 0 0 20px var(--accent);
}

.site-title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  color: var(--accent);
  text-shadow: 0 0 30px rgba(201,168,76,0.5);
  letter-spacing: 4px;
  margin-bottom: 12px;
}

.site-subtitle {
  color: var(--text-dim);
  font-size: 1rem;
  font-style: italic;
  letter-spacing: 1px;
}

/* ---- Sections ---- */
main { max-width: 900px; margin: 0 auto; padding: 30px 20px 60px; }

.section {
  display: none;
  animation: fadeIn 0.5s ease;
}
.section.active { display: block; }

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

.section-title {
  text-align: center;
  color: var(--accent);
  font-size: 1.5rem;
  margin-bottom: 30px;
  letter-spacing: 2px;
}
.section-title::before, .section-title::after {
  content: ' ✦ ';
  color: var(--accent2);
  font-size: 0.8em;
}

/* ---- Spread Selection ---- */
.spread-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.spread-option {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}
.spread-option:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--glow);
  transform: translateY(-4px);
}
.spread-option h3 { color: var(--accent); margin: 14px 0 6px; font-size: 1.05rem; }
.spread-option p { color: var(--text-dim); font-size: 0.85rem; }

.spread-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  height: 70px;
}
.celtic-mini { flex-wrap: wrap; width: 100px; margin: 0 auto; gap: 3px; }

.sv-card {
  width: 24px;
  height: 38px;
  background: linear-gradient(135deg, #2a1a5e, #1a0a3e);
  border: 1px solid var(--accent);
  border-radius: 3px;
}
.sv-card.sv-center { transform: scale(1.2); border-color: #fff; }
.sv-card.sm { width: 18px; height: 28px; }
.sv-card.rotated { transform: rotate(90deg); }

/* ---- Question Section ---- */
.question-area {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
}

.question-hint {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 16px;
  font-style: italic;
}

#question-input {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  padding: 14px;
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.2s;
}
#question-input:focus {
  outline: none;
  border-color: var(--accent);
}
#question-input::placeholder { color: var(--text-dim); }

/* ---- Buttons ---- */
.btn-primary, .btn-secondary {
  display: block;
  margin: 16px auto 0;
  padding: 14px 36px;
  border-radius: 30px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
  letter-spacing: 1px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #e5c06a);
  color: #000;
  font-weight: bold;
  box-shadow: 0 4px 20px rgba(201,168,76,0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(201,168,76,0.5);
}
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.btn-secondary:hover {
  background: var(--glow);
  transform: translateY(-2px);
}
.btn-back {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  display: block;
  margin: 20px auto 0;
  transition: color 0.2s;
}
.btn-back:hover { color: var(--accent); }

/* ---- Shuffle Section ---- */
.shuffle-hint {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 30px;
}

.deck-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

/* Wider stage for fan animation */
.deck {
  position: relative;
  width: 340px;
  height: 200px;
  cursor: pointer;
}

.deck-card {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--radius);
  border: 2px solid rgba(201,168,76,0.7);
  overflow: hidden;
  /* center in the wider deck stage */
  left: calc(50% - var(--card-w)/2);
  top: calc(50% - var(--card-h)/2 + 20px);
  transform-origin: center bottom;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.35s ease;
  will-change: transform;
}

.deck-card svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Glow pulse on the top card when idle */
.deck-card:last-child {
  box-shadow: 0 0 12px rgba(201,168,76,0.3);
  animation: deck-idle-pulse 3s ease-in-out infinite;
}

@keyframes deck-idle-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(201,168,76,0.2); }
  50%       { box-shadow: 0 0 22px rgba(201,168,76,0.55), 0 0 40px rgba(155,89,182,0.2); }
}

/* Particle sparkle */
.deck-sparkle {
  position: absolute;
  pointer-events: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: sparkle-out 0.7s ease-out forwards;
}
@keyframes sparkle-out {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--sx), var(--sy)) scale(0); opacity: 0; }
}

.shuffle-count-display {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}
#shuffle-count {
  font-size: 1.5rem;
  color: var(--accent);
  font-weight: bold;
}

.shuffle-buttons { display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ---- Tarot Card ---- */
.tarot-card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
  flex-shrink: 0;
}

.tarot-card.face-down .card-front { display: none; }
.tarot-card.face-down .card-back { display: flex; }
.tarot-card.face-up .card-front { display: flex; }
.tarot-card.face-up .card-back { display: none; }

.tarot-card.reversed .card-front { transform: rotate(180deg); }

.tarot-card.flipping {
  animation: card-flip 0.6s ease;
}
@keyframes card-flip {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg) scale(1.05); }
  100% { transform: rotateY(0deg); }
}

.card-back, .card-front {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius) - 2px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-back {
  background: transparent;
  padding: 0;
}
.card-back svg {
  display: block;
  width: 100%;
  height: 100%;
}

.card-front {
  flex-direction: column;
  padding: 8px 6px;
  gap: 4px;
}

.card-symbol {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.3));
}

.card-name-short {
  font-size: 0.55rem;
  text-align: center;
  line-height: 1.2;
  word-break: keep-all;
  color: rgba(255,255,255,0.9);
  font-weight: bold;
  letter-spacing: 0.5px;
}

.card-number {
  font-size: 0.5rem;
  color: rgba(255,255,255,0.6);
  position: absolute;
  top: 5px;
  left: 7px;
}

/* Card Colors by type */
.tarot-card[data-type="major"] .card-front {
  background: linear-gradient(160deg, #2d1b5e, #1a0c3e);
  border-top: 3px solid #c9a84c;
}
.tarot-card[data-type="wands"] .card-front {
  background: linear-gradient(160deg, #5e1b1b, #3e0c0c);
  border-top: 3px solid #e05030;
}
.tarot-card[data-type="cups"] .card-front {
  background: linear-gradient(160deg, #1b3a5e, #0c1e3e);
  border-top: 3px solid #4090e0;
}
.tarot-card[data-type="swords"] .card-front {
  background: linear-gradient(160deg, #2a2a3a, #15151f);
  border-top: 3px solid #90a0c0;
}
.tarot-card[data-type="pentacles"] .card-front {
  background: linear-gradient(160deg, #1a3a1a, #0c200c);
  border-top: 3px solid #60b060;
}

/* ---- Reading Layout ---- */
.question-display {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 24px;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.2);
}

/* 1-card layout */
.layout-1 {
  display: flex;
  justify-content: center;
  margin: 30px 0;
}
.layout-1 .card-slot { display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* 3-card layout */
.layout-3 {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin: 30px 0;
}
.layout-3 .card-slot { display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* Celtic Cross layout */
.layout-celtic {
  display: grid;
  grid-template-areas:
    ". . . top . . . . right4"
    ". left cen cross right . . . right3"
    ". . . bot . . . . right2"
    ". . . . . . . . right1";
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
  max-width: 700px;
  margin: 20px auto;
}

.layout-celtic .card-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.layout-celtic .slot-top    { grid-area: top; }
.layout-celtic .slot-left   { grid-area: left; }
.layout-celtic .slot-center { grid-area: cen; }
.layout-celtic .slot-cross  { grid-area: cross; }
.layout-celtic .slot-right  { grid-area: right; }
.layout-celtic .slot-bot    { grid-area: bot; }
.layout-celtic .slot-right1 { grid-area: right1; }
.layout-celtic .slot-right2 { grid-area: right2; }
.layout-celtic .slot-right3 { grid-area: right3; }
.layout-celtic .slot-right4 { grid-area: right4; }

.layout-celtic .slot-cross .tarot-card { transform: rotate(90deg); }
.layout-celtic .slot-cross .tarot-card.reversed { transform: rotate(270deg); }

.card-slot-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.3;
  max-width: 90px;
}

.tarot-card:hover {
  box-shadow: 0 0 20px rgba(201,168,76,0.4);
  z-index: 10;
}
.tarot-card.face-down:hover { box-shadow: 0 0 20px rgba(155,89,182,0.5); }
.tarot-card.face-up:hover { box-shadow: 0 0 20px rgba(201,168,76,0.6); }

/* ---- Reading Summary ---- */
.reading-summary {
  margin-top: 30px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.reading-summary h3 {
  color: var(--accent);
  margin-bottom: 16px;
  font-size: 1.1rem;
  letter-spacing: 1px;
}
.card-reading-entry {
  padding: 16px 0;
  border-bottom: 1px solid rgba(201,168,76,0.1);
}
.card-reading-entry:last-child { border-bottom: none; }

.card-reading-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.card-reading-symbol {
  font-size: 1.4rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.card-reading-name { font-weight: bold; color: var(--accent); font-size: 1rem; }
.card-reading-position { font-size: 0.8rem; color: var(--text-dim); }
.orient-label {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: auto;
}
.orient-label.upright { background: rgba(93,173,98,0.2); color: #5dde6e; border: 1px solid rgba(93,173,98,0.3); }
.orient-label.reversed { background: rgba(192,57,43,0.2); color: #e74c3c; border: 1px solid rgba(192,57,43,0.3); }

.card-reading-meaning { color: var(--text); font-size: 0.9rem; line-height: 1.7; }

.reading-actions { text-align: center; margin-top: 24px; }

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
}
.modal-box {
  position: relative;
  z-index: 1;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.modal-close:hover { background: rgba(201,168,76,0.2); color: var(--accent); }

.modal-inner {
  display: flex;
  gap: 24px;
  padding: 30px;
  flex-wrap: wrap;
}

.modal-card-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.tarot-card.modal-size {
  --card-w: 120px;
  --card-h: 200px;
  width: 120px;
  height: 200px;
}
.tarot-card.modal-size .card-symbol { font-size: 2.8rem; }
.tarot-card.modal-size .card-name-short { font-size: 0.65rem; }

.orient-badge {
  font-size: 0.8rem;
  padding: 4px 14px;
  border-radius: 20px;
  font-weight: bold;
}
.orient-badge.upright { background: rgba(93,173,98,0.2); color: #5dde6e; border: 1px solid rgba(93,173,98,0.3); }
.orient-badge.reversed { background: rgba(192,57,43,0.2); color: #e74c3c; border: 1px solid rgba(192,57,43,0.3); }

.modal-info-side { flex: 1; min-width: 200px; }

.modal-card-name {
  color: var(--accent);
  font-size: 1.4rem;
  margin-bottom: 16px;
  line-height: 1.3;
}
.modal-section { margin-bottom: 18px; }
.modal-section h4 {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}

.keyword-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.keyword-tag {
  background: rgba(201,168,76,0.1);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
}

.meaning-text {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.8;
}
.position-hint {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.7;
  font-style: italic;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--accent2); border-radius: 3px; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  :root { --card-w: 72px; --card-h: 120px; }
  .site-header { padding: 40px 16px 35px; }
  .layout-3 { gap: 14px; }
  .layout-celtic { transform: scale(0.85); transform-origin: top center; }
  .modal-inner { flex-direction: column; }
  .lang-bar { justify-content: center; }
}
