/* =============================================================
   นอนนับแกะ — Night Sky Theme
   ============================================================= */

/* --- CSS Variables --- */
:root {
  /* Tool-specific */
  --bg-deep: #080b1a;
  --bg-night: #0d1130;
  --bg-indigo: #151b47;
  --text-primary: #e8e4f0;
  --text-secondary: #b0a8c0;
  --text-dim: #6b6280;
  --accent: #b8a9fa;
  --accent-hover: #9d8af0;
  --accent-glow: rgba(184, 169, 250, 0.3);
  --moon-yellow: #f5e6b8;
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.08);
  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --transition: 0.3s ease;
  --transition-slow: 0.8s ease;

  /* Map to shared --mf-* variables */
  --mf-text: var(--text-primary);
  --mf-text-secondary: var(--text-secondary);
  --mf-text-dim: var(--text-dim);
  --mf-accent: var(--accent);
  --mf-accent-glow: var(--accent-glow);
  --mf-border: var(--card-border);
  --mf-btn-text: var(--bg-deep);
}

/* Body theme (reset + font from shared/css/base.css) */
body {
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-night) 40%, var(--bg-indigo) 100%);
}

/* --- Stars Background --- */
.stars-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: twinkle var(--twinkle-duration, 3s) ease-in-out infinite;
  animation-delay: var(--twinkle-delay, 0s);
}

@keyframes twinkle {
  0%, 100% { opacity: var(--star-min-opacity, 0.2); }
  50% { opacity: var(--star-max-opacity, 0.8); }
}

/* Dim overlay for progressive dimming during shuffle */
.dim-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  z-index: 1;
  transition: background 3s ease;
}

/* Ambient glow behind word area */
.shuffle-container::before {
  content: '';
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(184, 169, 250, 0.06) 0%, rgba(245, 230, 184, 0.03) 40%, transparent 70%);
  pointer-events: none;
  animation: ambientPulse 12s ease-in-out infinite;
}

@keyframes ambientPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Screen system: inherited from shared/css/base.css */

/* ===== LANDING SCREEN ===== */
.landing-container {
  text-align: center;
  max-width: 480px;
  width: 100%;
  animation: fadeUp 1s ease forwards;
}

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

.landing-sheep {
  font-size: 96px;
  margin-bottom: 12px;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(184, 169, 250, 0.3));
}

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

.landing-title {
  font-family: 'Nunito', sans-serif;
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--moon-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.landing-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.landing-desc {
  font-size: 17px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.7;
}

.landing-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 36px;
  text-align: left;
}

.landing-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  transition: var(--transition);
}

.landing-step:hover {
  background: rgba(255, 255, 255, 0.08);
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--moon-yellow));
  color: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.step-text {
  font-size: 15px;
  color: var(--text-primary);
}

.landing-science {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}

.science-badge {
  display: inline-block;
  background: rgba(184, 169, 250, 0.15);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 6px;
}

.landing-hub-link {
  display: inline-block;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  transition: var(--transition);
}

.landing-hub-link:hover {
  color: var(--accent);
}

/* ===== SETUP SCREEN ===== */
.setup-container {
  text-align: center;
  max-width: 520px;
  width: 100%;
  animation: fadeUp 0.8s ease forwards;
}

.setup-title {
  font-family: 'Nunito', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.setup-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.mood-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.mood-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font-family: inherit;
  font-size: 15px;
}

.mood-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateX(4px);
}

.mood-btn.selected {
  background: rgba(184, 169, 250, 0.15);
  border-color: var(--accent);
}

.mood-emoji {
  font-size: 28px;
  flex-shrink: 0;
}

.mood-label {
  font-weight: 600;
  font-size: 16px;
  display: block;
}

.mood-desc {
  font-size: 13px;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
}

/* Duration */
.duration-section {
  animation: fadeUp 0.6s ease forwards;
  margin-top: 8px;
}

.duration-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.duration-btn {
  padding: 16px 8px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  font-family: inherit;
}

.duration-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.duration-btn.active {
  background: rgba(184, 169, 250, 0.15);
  border-color: var(--accent);
}

.duration-number {
  display: block;
  font-family: 'Nunito', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
}

.duration-unit {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
}

.duration-desc {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===== SHUFFLE SCREEN ===== */
.shuffle-container {
  text-align: center;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  position: relative;
}

.shuffle-timer {
  font-family: 'Nunito', sans-serif;
  font-size: 18px;
  color: var(--text-dim);
  letter-spacing: 2px;
  position: absolute;
  top: 40px;
  transition: opacity 2s ease;
}

/* Word Display */
.word-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 260px;
}

.word-emoji {
  font-size: 100px;
  transition: opacity 1s ease, transform 1s ease;
  filter: drop-shadow(0 6px 20px rgba(184, 169, 250, 0.25));
}

.word-emoji.fade-out {
  opacity: 0;
  transform: scale(0.7);
}

.word-emoji.fade-in {
  animation: wordFadeIn 1s ease forwards;
}

.word-text {
  font-size: 36px;
  font-weight: 500;
  color: var(--text-primary);
  transition: opacity 1s ease, transform 1s ease;
  letter-spacing: 2px;
  text-shadow: 0 2px 16px rgba(184, 169, 250, 0.2);
}

.word-text.fade-out {
  opacity: 0;
  transform: translateY(12px);
}

.word-text.fade-in {
  animation: wordTextFadeIn 1s ease forwards;
}

@keyframes wordFadeIn {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

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

/* Breathing Ring */
.breathing-ring {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  border: 2px solid rgba(184, 169, 250, 0.12);
  box-shadow: 0 0 60px 20px rgba(184, 169, 250, 0.04), inset 0 0 60px 20px rgba(184, 169, 250, 0.03);
  animation: breathe 10s ease-in-out infinite;
  pointer-events: none;
}

@keyframes breathe {
  0%, 100% { transform: scale(0.85); opacity: 0.35; }
  50% { transform: scale(1.2); opacity: 0.08; }
}

/* Progress Dots */
.progress-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  position: absolute;
  bottom: 100px;
}

.progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.5s ease, transform 0.5s ease;
}

.progress-dot.active {
  background: var(--accent);
  transform: scale(1.4);
}

.progress-dot.past {
  background: var(--text-secondary);
}

/* Controls */
.shuffle-controls {
  display: flex;
  gap: 16px;
  justify-content: center;
  position: absolute;
  bottom: 40px;
}

.control-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-family: inherit;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.control-btn-stop {
  width: auto;
  border-radius: 24px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
}

/* ===== RESULT SCREEN ===== */
.result-container {
  text-align: center;
  max-width: 440px;
  width: 100%;
  animation: fadeUp 0.8s ease forwards;
}

.result-card {
  background: var(--card-bg, #1a1a3e);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: 36px 28px;
  position: relative;
  overflow: hidden;
}

.result-card-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at center, var(--grad-start, rgba(184, 169, 250, 0.1)) 0%, transparent 60%);
  pointer-events: none;
  opacity: 0.4;
}

.result-card-content {
  position: relative;
  z-index: 1;
}

.result-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.result-emoji {
  font-size: 96px;
  margin-bottom: 12px;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 6px 20px rgba(184, 169, 250, 0.25));
}

.result-animal-name {
  font-family: 'Nunito', sans-serif;
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--grad-start, var(--accent)), var(--grad-end, var(--moon-yellow)));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.result-animal-title {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-weight: 600;
}

.result-animal-desc {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: 20px;
}

.result-divider {
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, var(--grad-start, var(--accent)), var(--grad-end, var(--moon-yellow)));
  margin: 0 auto 20px;
  border-radius: 1px;
}

.result-tip {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 16px;
}

.result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-stat-number {
  font-family: 'Nunito', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
}

.result-stat-label {
  font-size: 12px;
  color: var(--text-dim);
}

.result-session-msg {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.result-branding {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}

/* Card Preview */
.card-preview {
  margin-top: 20px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--card-border);
}

.card-preview img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-lg);
}

/* Buttons, .result-actions, .btn-link: inherited from shared/css/base.css
   Tool-specific overrides: */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #9d8af0);
  width: 100%;
}

.btn-secondary {
  width: 100%;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .landing-title {
    font-size: 36px;
  }

  .landing-sheep {
    font-size: 72px;
  }

  .landing-desc {
    font-size: 15px;
  }

  .setup-title {
    font-size: 24px;
  }

  .word-emoji {
    font-size: 80px;
  }

  .word-text {
    font-size: 28px;
  }

  .result-card {
    padding: 28px 20px;
  }

  .result-emoji {
    font-size: 80px;
  }

  .result-animal-name {
    font-size: 26px;
  }

  .duration-grid {
    gap: 8px;
  }

  .duration-number {
    font-size: 26px;
  }
}

/* ===== UTILITY ANIMATIONS ===== */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Screen transitions */
.screen.fade-exit {
  opacity: 0;
  transition: opacity 0.4s ease;
}
