/* ============================================
   SPIRITUAL REFLECTIONS — Styles
   ============================================ */

:root {
  --bg-start: #faf6f0;
  --bg-end: #f0eaff;
  --primary: #3d2c6e;
  --primary-light: #7b6ba4;
  --primary-soft: #d8d0f0;
  --accent: #c9952e;
  --accent-light: #d4b86a;
  --accent-soft: #f5e6c4;
  --text: #2c2445;
  --text-soft: #6b5f80;
  --cream: #fffdf5;
  --parchment: #fdf8f0;
  --white: #ffffff;
  --gold-glow: rgba(201, 149, 46, 0.15);
}

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

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

body {
  font-family: 'Quicksand', 'Segoe UI', sans-serif;
  color: var(--text);
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* --- App Nav Button (bottom-left) --- */
.app-nav-btn {
  position: fixed;
  bottom: 1.4rem;
  left: 1.4rem;
  z-index: 50;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 18px var(--gold-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  animation: fadeInUp 0.8s ease-out 0.8s both;
}

.app-nav-btn span {
  font-size: 1.4rem;
  line-height: 1;
}

.app-nav-btn:hover,
.app-nav-btn:focus-visible {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(201, 149, 46, 0.3);
  background: rgba(255, 255, 255, 0.9);
}

.app-nav-btn:active {
  transform: scale(0.93);
}

/* --- Floating Emojis Background --- */
.floating-emojis {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-emoji {
  position: absolute;
  opacity: 0;
  animation: floatUp linear infinite;
  will-change: transform, opacity;
}

@keyframes floatUp {
  0% {
    transform: translateY(100vh) rotate(0deg) scale(0.7);
    opacity: 0;
  }
  10% { opacity: 0.35; }
  50% { opacity: 0.4; }
  90% { opacity: 0.3; }
  100% {
    transform: translateY(-10vh) rotate(360deg) scale(1.1);
    opacity: 0;
  }
}

/* --- Layout --- */
.container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: 2rem 1.5rem 1rem;
  gap: 1.2rem;
}

/* --- Header --- */
.header {
  text-align: center;
  padding-bottom: 0.5rem;
  animation: fadeInDown 0.8s ease-out;
}

.title {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  text-shadow: 0 2px 10px rgba(61, 44, 110, 0.12);
}

.subtitle {
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  color: var(--text-soft);
  margin-top: 0.5rem;
  font-weight: 500;
}

/* --- Card Wrapper --- */
.card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 1rem;
  width: 100%;
  animation: fadeInUp 1s ease-out 0.3s both;
}

.card-hint {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  animation: pulse 2s ease-in-out infinite;
  letter-spacing: 0.05em;
}

/* --- Teaching Card Group (card + reflection sub-card) --- */
.teaching-card-group {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Teaching Card --- */
.teaching-card {
  position: relative;
  width: 100%;
  padding: 2.4rem 2rem 1.8rem;
  border-radius: 24px;
  background: var(--cream);
  border: 2px solid var(--accent-light);
  box-shadow:
    0 20px 50px var(--gold-glow),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.4s ease, border-color 0.4s ease;
  cursor: pointer;
  z-index: 2;
}

.teaching-card:hover,
.teaching-card:focus-visible {
  transform: scale(1.01);
  box-shadow:
    0 25px 60px rgba(201, 149, 46, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
}

.teaching-card:active {
  transform: scale(0.99);
}

.teaching-card:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 6px;
}

.card-inner {
  position: relative;
  text-align: center;
  width: 100%;
}

/* Category tag */
.teaching-category {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.3rem 0.9rem;
  border-radius: 50px;
  margin-bottom: 1.2rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Teaching text */
.teaching-text {
  font-family: 'Quicksand', sans-serif;
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  font-weight: 600;
  color: var(--text);
  line-height: 1.7;
  transition: opacity 0.4s ease, transform 0.4s ease;
  padding: 0 0.2rem;
}

.teaching-text.exiting {
  opacity: 0;
  transform: translateY(-20px) scale(0.97);
}

.teaching-text.entering {
  opacity: 0;
  transform: translateY(20px) scale(0.97);
}

/* Source reference */
.teaching-source {
  margin-top: 1.2rem;
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  font-weight: 600;
  color: var(--primary-light);
  font-style: italic;
  transition: opacity 0.4s ease;
}

/* Card decorations */
.card-deco {
  position: absolute;
  font-size: 1.1rem;
  color: var(--accent-light);
  opacity: 0.35;
  transition: color 0.4s ease;
}

.card-deco.top-left { top: -6px; left: -2px; }
.card-deco.top-right { top: -6px; right: -2px; }
.card-deco.bottom-left { bottom: -6px; left: -2px; }
.card-deco.bottom-right { bottom: -6px; right: -2px; }

/* Reflect hint (below the teaching) */
.reflect-hint {
  margin-top: 1.2rem;
  font-size: 0.8rem;
  color: var(--primary-light);
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.4s ease 0.3s;
  animation: pulse 2s ease-in-out infinite;
}

.reflect-hint.visible {
  opacity: 1;
}

/* --- Reflection Sub-Card --- */
.reflect-card {
  width: calc(100% - 24px);
  background: var(--parchment);
  border: 2px solid var(--primary-soft);
  border-top: none;
  border-radius: 0 0 20px 20px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.4s ease,
              padding 0.4s ease;
  padding: 0 1.6rem;
  z-index: 1;
  margin-top: -4px;
  box-shadow: 0 15px 40px var(--gold-glow);
}

.reflect-card.open {
  max-height: 400px;
  opacity: 1;
  padding: 1.6rem 1.6rem 1.8rem;
}

.reflect-card-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.reflect-question {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.2rem, 3.5vw, 1.5rem);
  font-weight: 600;
  color: var(--primary);
  line-height: 1.5;
  padding-left: 1.2rem;
  border-left: 3px solid var(--accent-light);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.reflect-card.open .reflect-question {
  opacity: 1;
  transform: translateY(0);
}

.reflect-card.open .reflect-question:nth-child(1) {
  transition-delay: 0.15s;
}

.reflect-card.open .reflect-question:nth-child(2) {
  transition-delay: 0.3s;
}

/* --- Counter --- */
.counter {
  font-size: 0.8rem;
  color: var(--text-soft);
  opacity: 0.5;
  font-weight: 600;
  padding-bottom: 0.5rem;
  animation: fadeInUp 0.8s ease-out 0.5s both;
}

/* --- Animations --- */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.97); }
}

/* Card pop on new teaching */
@keyframes cardPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.teaching-card.pop {
  animation: cardPop 0.35s ease-in-out;
}

/* --- Responsive --- */
@media (min-width: 768px) {
  .teaching-card {
    max-width: 580px;
    padding: 3rem 2.8rem 2rem;
  }

  .reflect-card {
    width: calc(100% - 32px);
  }

  .reflect-card.open {
    padding: 1.8rem 2rem 2rem;
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .floating-emoji { display: none; }
}
