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

body {
  width: 100vw; height: 100svh;
  overflow: hidden;
  background: #C8DCFF;   /* solid fallback — Three.js renders the real gradient */
  /* system fonts only — no remote font needed for body text */
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
}

/* ── Loader ──────────────────────────────────────── */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #C8DCFF;
}
#loader.done { display: none; }

.loader-title {
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  color: #3A1800;
  letter-spacing: 4px;
  text-shadow: 0 2px 0 #FFD88080, 0 4px 20px rgba(255,160,30,.25);
}

.loader-dots {
  margin-top: .8rem;
  font-size: 1.6rem;
  color: #7A4010AA;
  letter-spacing: 6px;
}
.loader-dots span {
  animation: dotPulse 1.2s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { animation-delay: .2s; }
.loader-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dotPulse {
  0%, 80%, 100% { opacity: .2; }
  40% { opacity: 1; }
}

/* ── Canvas ───────────────────────────────────────── */
#c {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: default;
}

/* ── Title overlay ───────────────────────────────── */
#overlay {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: clamp(1.8rem, 5vh, 3.5rem);
  pointer-events: none;
  user-select: none;
}

#title {
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  color: #3A1800;
  letter-spacing: 4px;
  text-shadow:
    0 2px 0 #FFD88080,
    0 4px 20px rgba(255,160,30,.25);
  line-height: 1;
}

#hint {
  margin-top: .6rem;
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: clamp(.9rem, 2vw, 1.15rem);
  color: #7A4010CC;
  letter-spacing: 2px;
  transition: opacity .4s;
}

#hint.hidden { opacity: 0; }

/* ── Card scrim ───────────────────────────────────── */
#scrim {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 20;
  pointer-events: none;
  transition: background .35s;
}
#scrim.show {
  background: rgba(40, 18, 0, 0.18);
  backdrop-filter: blur(6px);
  pointer-events: all;
}

/* ── Card ─────────────────────────────────────────── */
#card {
  position: relative;
  width: min(360px, 88vw);
  border-radius: 28px;
  padding: 1.8rem 1.8rem 2rem;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 80px rgba(50,20,0,.18), 0 2px 8px rgba(50,20,0,.06);
  transform: scale(0.75) translateY(24px);
  opacity: 0;
  transition:
    transform .5s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity   .35s ease;
}
#scrim.show #card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Card top accent bar */
#card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  border-radius: 28px 28px 0 0;
  background: var(--card-color, #FFD700);
}

/* Close button */
#card-close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.07);
  color: #7A6050;
  font-size: .85rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .15s, opacity .4s;
}
#card-close:hover { background: rgba(0,0,0,.13); transform: scale(1.1); }
#card-close.savor-hidden { opacity: 0; pointer-events: none; }

/* Badge */
#card-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: .88rem;
  letter-spacing: 1px;
  color: white;
  background: var(--card-color, #FFD700);
  border-radius: 100px;
  padding: .22rem .85rem;
  margin-bottom: 1.2rem;
}

/* ── Card body types ──────────────────────────────── */

/* Compliment */
.card-quote {
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: clamp(1rem, 3vw, 1.2rem);
  color: #3A2010;
  line-height: 1.65;
  text-align: center;
  padding: .5rem 0;
}
.card-quote-mark {
  font-size: 3rem;
  line-height: .6;
  color: var(--card-color);
  opacity: .4;
  font-family: Georgia, serif;
  display: block;
  margin-bottom: .3rem;
}

/* News */
.card-headline {
  font-size: 1.05rem;
  font-weight: 500;
  color: #1A1008;
  line-height: 1.55;
  margin-bottom: 1rem;
}
.card-source {
  font-size: .75rem;
  color: #9A8070;
  margin-bottom: .8rem;
}
.card-link {
  display: inline-block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--card-color);
  text-decoration: none;
  border-bottom: 1.5px solid currentColor;
  transition: opacity .2s;
}
.card-link:hover { opacity: .7; }

/* Animal */
.card-photo-wrap {
  border-radius: 16px;
  overflow: hidden;
  background: #F0E8D8;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-photo {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  display: block;
  border-radius: 16px;
}
.card-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .8rem;
  padding: 2rem 1rem;
  color: #9A8070;
  font-size: .9rem;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid #F0E0D0;
  border-top-color: var(--card-color);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Add button ──────────────────────────────────── */
#add-btn {
  position: fixed;
  bottom: clamp(1.2rem, 4vh, 2.5rem);
  right: clamp(1.2rem, 4vw, 2.5rem);
  z-index: 10;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #D4A020, #B8860B);
  color: #FFF8E0;
  font-size: 1.6rem;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(180,120,0,.35), 0 1px 3px rgba(0,0,0,.1);
  transition: transform .2s, box-shadow .2s;
  display: flex; align-items: center; justify-content: center;
}
#add-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(180,120,0,.45);
}
#add-btn:active { transform: scale(0.95); }

/* ── Gratitude panel ─────────────────────────────── */
#gratitude-scrim {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  z-index: 25;
  pointer-events: none;
  transition: background .35s;
}
#gratitude-scrim.show {
  background: rgba(40, 18, 0, 0.18);
  backdrop-filter: blur(6px);
  pointer-events: all;
}

#gratitude-panel {
  position: relative;
  width: min(360px, 88vw);
  border-radius: 28px;
  padding: 1.8rem 1.8rem 1.6rem;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 80px rgba(50,20,0,.18), 0 2px 8px rgba(50,20,0,.06);
  transform: scale(0.75) translateY(24px);
  opacity: 0;
  transition:
    transform .5s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity   .35s ease;
}
#gratitude-scrim.show #gratitude-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
}
#gratitude-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  border-radius: 28px 28px 0 0;
  background: linear-gradient(90deg, #D4A020, #F5C040);
}

#gratitude-close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 30px; height: 30px;
  border-radius: 50%; border: none;
  background: rgba(0,0,0,.07);
  color: #7A6050;
  font-size: .85rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .15s;
}
#gratitude-close:hover { background: rgba(0,0,0,.13); transform: scale(1.1); }

#gratitude-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: .88rem; letter-spacing: 1px;
  color: white;
  background: linear-gradient(135deg, #D4A020, #B8860B);
  border-radius: 100px;
  padding: .22rem .85rem;
  margin-bottom: .6rem;
}
#gratitude-count {
  font-size: .78rem; color: #B09070;
  margin-bottom: .6rem; min-height: 1.1em;
}
#gratitude-prompt {
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: 1rem; color: #3A2010;
  margin-bottom: 1rem; letter-spacing: 1px;
}
#gratitude-input {
  width: 100%;
  border: 2px solid #F0E0C8;
  border-radius: 16px;
  padding: .9rem 1rem;
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: .95rem; color: #3A2010;
  background: #FFFDF8;
  resize: none; outline: none;
  transition: border-color .2s;
}
#gratitude-input:focus { border-color: #D4A020; }
#gratitude-input::placeholder { color: #C0A880; }

#gratitude-save {
  width: 100%; margin-top: 1rem;
  padding: .75rem 1rem;
  border: none; border-radius: 16px;
  background: linear-gradient(135deg, #D4A020, #B8860B);
  color: #FFF8E0;
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: 1rem; letter-spacing: 2px;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s;
}
#gratitude-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(180,120,0,.3);
}
#gratitude-save:active { transform: translateY(0); }

/* ── Savoring pause ──────────────────────────────── */
.card-savor {
  font-size: .8rem; color: #B09070;
  text-align: center; margin-top: 1.2rem;
  opacity: 0; letter-spacing: 1px;
  animation: savorFadeIn 1.2s ease .6s forwards;
}
@keyframes savorFadeIn { to { opacity: 1; } }

/* ── Kindness & Memory cards ─────────────────────── */
.card-kindness-prompt {
  font-size: .82rem; color: #33AA55;
  text-align: center; margin-top: 1rem;
  font-weight: 500; letter-spacing: 1px;
}
/* ── Gratitude flying orb ─────────────────────────── */
.gratitude-orb {
  position: fixed;
  width: 24px; height: 24px;
  margin-left: -12px; margin-top: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, #FFD700, #FF9500);
  box-shadow: 0 0 20px rgba(255,180,0,.6), 0 0 40px rgba(255,120,0,.3);
  z-index: 30;
  pointer-events: none;
  transition: all .6s cubic-bezier(0.22, 1, 0.36, 1);
}

.card-memory-date {
  font-size: .78rem; color: #B09070;
  text-align: center;
  margin-top: .8rem; margin-bottom: .2rem;
}

a.card-headline {
  display: block;
  color: inherit;
  text-decoration: none;
  border-bottom: 1.5px dashed rgba(0,150,200,0.3);
  padding-bottom: 2px;
  transition: border-color .2s;
}
a.card-headline:hover { border-color: rgba(0,150,200,0.7); }
a.card-headline::after {
  content: ' ↗';
  font-size: 0.75em;
  opacity: 0.5;
}
