/* ========================================
   Lunaria Tarot - Shared Styles
   ======================================== */

/* CSS Custom Properties */
:root {
  --primary: #2D1B69;
  --primary-light: #4A2D8F;
  --primary-dark: #1A0F3E;
  --gold: #D4AF37;
  --gold-light: #E8C84A;
  --gold-dark: #B8961F;
  --bg-dark: #0A0E2A;
  --bg-card: rgba(45, 27, 105, 0.4);
  --bg-card-hover: rgba(45, 27, 105, 0.6);
  --text-primary: #F0E6FF;
  --text-secondary: #B8A4D6;
  --text-muted: #8B7AAE;
  --border-color: rgba(212, 175, 55, 0.3);
  --border-glow: rgba(212, 175, 55, 0.6);
  --shadow-gold: 0 0 20px rgba(212, 175, 55, 0.2);
  --shadow-purple: 0 0 30px rgba(45, 27, 105, 0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --transition: all 0.3s ease;
  --transition-slow: all 0.6s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Starry Background - Canvas replaces static radial-gradients */
#starCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

body::before {
  content: none !important;
}
body::after {
  content: none !important;
},
/* (old static star layers removed, using canvas now) */

/* Background gradient overlay */
.bg-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(45, 27, 105, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(74, 45, 143, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(26, 15, 62, 0.4) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  line-height: 1.3;
  font-weight: 600;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

@media (min-width: 768px) {
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.4rem; }
}

p {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--gold-light);
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

/* Container */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
  z-index: 1;
}

@media (min-width: 768px) {
  .container {
    padding: 0 24px;
  }
}

/* Header */
.header {
  text-align: center;
  padding: 24px 16px 20px;
  position: relative;
  z-index: 1;
}

.header .logo {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold), var(--gold-light), #FFF5CC, var(--gold));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s ease-in-out infinite;
  letter-spacing: 3px;
  margin-bottom: 4px;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(212,175,55,0.3));
}

.header .logo-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 15px rgba(212, 175, 55, 0.6));
  animation: logoFloat 5s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.03); }
}

.header .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 6px;
  text-transform: uppercase;
  opacity: 0;
  animation: subtitleReveal 1.2s ease-out 0.3s forwards;
}

@keyframes subtitleReveal {
  0% { opacity: 0; letter-spacing: 12px; }
  100% { opacity: 1; letter-spacing: 6px; }
}

@keyframes shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@media (min-width: 768px) {
  .header {
    padding: 40px 24px 30px;
  }
  .header .logo {
    font-size: 2.8rem;
  }
  .header .logo-icon {
    font-size: 3rem;
  }
}

/* Card Components */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(212,175,55,0.0), rgba(212,175,55,0.15), rgba(212,175,55,0.0));
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: -1;
  pointer-events: none;
}

.card:hover {
  border-color: var(--border-glow);
  box-shadow: 0 0 25px rgba(212,175,55,0.15), 0 8px 32px rgba(0,0,0,0.3);
  transform: translateY(-3px);
}

.card:hover::before {
  opacity: 1;
}

.card-title {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 1.2rem;
}

/* Tarot Card */
.tarot-card {
  width: 140px;
  height: 220px;
  perspective: 1000px;
  cursor: pointer;
  flex-shrink: 0;
}

.tarot-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.tarot-card.flipped .tarot-card-inner {
  transform: rotateY(180deg);
}

.tarot-card-front,
.tarot-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.tarot-card-front {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.tarot-card-front::before {
  content: '✦';
  font-size: 2.5rem;
  color: var(--gold);
  opacity: 0.6;
}

.tarot-card-front::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 8px;
  pointer-events: none;
}

.tarot-card-back {
  background: linear-gradient(180deg, #1a1040, #0d0820);
  border: 2px solid var(--gold);
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

.tarot-card-back .card-image {
  width: 100%;
  height: 120px;
  border-radius: 6px;
  object-fit: cover;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
}

.tarot-card-back .card-name {
  font-size: 0.75rem;
  color: var(--gold);
  text-align: center;
  font-weight: 600;
}

.tarot-card-back .card-position {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
}

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

@media (min-width: 768px) {
  .tarot-card {
    width: 160px;
    height: 250px;
  }
}

/* Glow + float effect on tarot card */
.tarot-card {
  animation: cardFloat 4s ease-in-out infinite;
}
.tarot-card:nth-child(2) { animation-delay: -1.3s; }
.tarot-card:nth-child(3) { animation-delay: -2.6s; }

@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.tarot-card:not(.flipped) .tarot-card-front {
  box-shadow: 0 0 15px rgba(212,175,55,0.15), 0 0 40px rgba(45,27,105,0.3);
  animation: cardPulseGlow 3s ease-in-out infinite;
}

@keyframes cardPulseGlow {
  0%, 100% { box-shadow: 0 0 15px rgba(212,175,55,0.15), 0 0 40px rgba(45,27,105,0.3); }
  50% { box-shadow: 0 0 25px rgba(212,175,55,0.3), 0 0 60px rgba(45,27,105,0.4), 0 0 80px rgba(212,175,55,0.1); }
}

.tarot-card:hover .tarot-card-inner {
  filter: drop-shadow(0 0 20px rgba(212, 175, 55, 0.5));
}

.tarot-card.flipped .tarot-card-back {
  box-shadow: 0 0 20px rgba(212,175,55,0.2), 0 4px 20px rgba(0,0,0,0.4);
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold), var(--gold-light));
  color: var(--primary-dark);
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(212, 175, 55, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

/* Starlight glow on primary button */
.btn-glow {
  animation: btnGlow 2s ease-in-out infinite;
}

@keyframes btnGlow {
  0%, 100% {
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3), 0 0 30px rgba(212, 175, 55, 0.1);
  }
  50% {
    box-shadow: 0 4px 25px rgba(212, 175, 55, 0.5), 0 0 50px rgba(212, 175, 55, 0.2), 0 0 80px rgba(212, 175, 55, 0.1);
  }
}

.btn-secondary {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.1);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212, 175, 55, 0.05);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

/* Form Elements */
textarea,
input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(10, 14, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

textarea::placeholder,
input::placeholder {
  color: var(--text-muted);
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Section */
.section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 0 0 12px rgba(212,175,55,0.25);
}

.section-icon {
  display: inline-block;
  animation: iconPulse 3s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(212,175,55,0.3)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 10px rgba(212,175,55,0.6)); transform: scale(1.1); }
}

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(212, 175, 55, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(45,27,105,0.4) 0%, rgba(10,14,42,0.98) 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-text {
  color: var(--gold);
  font-size: 1.1rem;
  letter-spacing: 3px;
  text-shadow: 0 0 15px rgba(212,175,55,0.4);
  animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% { opacity: 0.5; text-shadow: 0 0 15px rgba(212,175,55,0.2); }
  50% { opacity: 1; text-shadow: 0 0 30px rgba(212,175,55,0.6), 0 0 60px rgba(212,175,55,0.2); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Card Shuffle Animation */
.shuffle-cards {
  display: flex;
  gap: 0;
  position: relative;
  width: 120px;
  height: 160px;
}

.shuffle-card {
  position: absolute;
  width: 70px;
  height: 110px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: 1.5px solid var(--gold);
  border-radius: 8px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 1.2rem;
}

.shuffle-card::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 5px;
}

.shuffle-card:nth-child(1) {
  animation: shuffle1 1.5s ease-in-out infinite;
}

.shuffle-card:nth-child(2) {
  animation: shuffle2 1.5s ease-in-out infinite;
  animation-delay: 0.15s;
}

.shuffle-card:nth-child(3) {
  animation: shuffle3 1.5s ease-in-out infinite;
  animation-delay: 0.3s;
}

@keyframes shuffle1 {
  0%, 100% { transform: translate(-50%, -50%) rotate(-5deg); }
  25% { transform: translate(-90%, -50%) rotate(-15deg); }
  50% { transform: translate(-50%, -50%) rotate(0deg); z-index: 3; }
  75% { transform: translate(-10%, -50%) rotate(15deg); }
}

@keyframes shuffle2 {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg); z-index: 2; }
  25% { transform: translate(-50%, -70%) rotate(5deg); }
  50% { transform: translate(-50%, -50%) rotate(-5deg); }
  75% { transform: translate(-50%, -30%) rotate(-5deg); }
}

@keyframes shuffle3 {
  0%, 100% { transform: translate(-50%, -50%) rotate(5deg); }
  25% { transform: translate(-10%, -50%) rotate(15deg); }
  50% { transform: translate(-50%, -50%) rotate(0deg); }
  75% { transform: translate(-90%, -50%) rotate(-15deg); z-index: 3; }
}

/* Gold accent border */
.gold-border {
  border: 1px solid var(--border-color);
  position: relative;
}

.gold-border::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* Divider */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
  margin: 20px 0;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-gold {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.badge-purple {
  background: rgba(45, 27, 105, 0.4);
  color: var(--text-secondary);
  border: 1px solid rgba(74, 45, 143, 0.4);
}

.badge-reversed {
  background: rgba(200, 50, 50, 0.15);
  color: #E88;
  border: 1px solid rgba(200, 50, 50, 0.3);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { flex-direction: column; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Responsive Grid */
.grid {
  display: grid;
  gap: 12px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (min-width: 768px) {
  .grid { gap: 16px; }
  .md-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .md-grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dark);
}

/* Constellation line decoration */
.constellation-line {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.3), transparent);
  transform-origin: left center;
}

/* Fade in animation */
.fade-in {
  animation: fadeIn 0.8s ease-out forwards;
  opacity: 0;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.fade-in-up {
  animation: fadeInUp 0.8s ease-out forwards;
  opacity: 0;
  transform: translateY(30px);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Glow text */
.glow-text {
  text-shadow: 0 0 10px rgba(212,175,55,0.4), 0 0 30px rgba(212,175,55,0.15);
}

/* Glass morphism card */
.glass {
  background: rgba(45,27,105,0.25);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(212,175,55,0.15);
}

/* Breathing glow border */
.glow-border {
  position: relative;
}
.glow-border::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(212,175,55,0.3), transparent 40%, transparent 60%, rgba(212,175,55,0.2));
  z-index: -1;
  animation: borderGlow 3s ease-in-out infinite;
}
@keyframes borderGlow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Stagger children animation - JS adds .shown after delay */
.stagger > *:not(.shown) {
  opacity: 0 !important;
  transform: translateY(20px) !important;
}

.stagger > .shown {
  opacity: 1;
  transform: none;
}

.stagger > * {
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

/* Footer */
.footer {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  position: relative;
  z-index: 1;
}

.footer::before {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 0 auto 16px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  color: var(--text-primary);
  font-size: 0.9rem;
  z-index: 2000;
  transition: transform 0.3s ease;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}
