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

:root {
  --color-bg:       #faf7f2;   /* warm beige — easier on eyes */
  --color-card:     #ffffff;
  --color-primary:  #4a6cf7;
  --color-text:     #2c2c3e;   /* soft dark indigo-gray */
  --color-muted:    #6b7280;
  --color-border:   #e5e7eb;
  --color-speak:    #4a6cf7;
  --color-speak-bg: #eef0fe;

  --radius-card: 20px;
  --shadow-card: 0 4px 24px rgba(74, 108, 247, 0.10);

  /* Font sizes — word / definition / example */
  --fs-word:   clamp(1.8rem, 5vw, 2.4rem);
  --fs-def:    clamp(1rem,  3vw, 1.25rem);
  --fs-ex:     clamp(0.82rem, 2.2vw, 0.95rem);
}

html, body {
  height: 100%;
  background: var(--color-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--color-text);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── Navigation bar ── */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--color-speak-bg);
  color: var(--color-primary);
  border-radius: 50%;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  /* Accessible tap target */
  touch-action: manipulation;
}
.nav-btn:active { background: #dde2fd; }
.nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.nav-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.02em;
}

/* ── Swiper outer wrapper fills remaining viewport ── */
.swiper-wrapper-outer {
  height: calc(100dvh - 70px - 40px);   /* 70px nav-bar + 40px footer */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.swiper {
  width: 100%;
  max-width: 600px;
  height: 100%;
}

/* ── Word card (each Swiper slide) ── */
.swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
}

.word-card {
  background: var(--color-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 48px 28px 40px;   /* extra top room for id badge + check btn */
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
}

/* ── Three content rows ── */
.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.speak-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.12s;
  touch-action: manipulation;
  box-shadow: 0 3px 10px rgba(74, 108, 247, 0.30);
}
.speak-btn:active {
  transform: scale(0.78);
  box-shadow: 0 1px 4px rgba(74, 108, 247, 0.15);
}

/* ── Row 1: Word ── */
.row--word .speak-btn { margin-top: 4px; }

.word-text {
  font-size: var(--fs-word);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--color-text);
  word-break: break-word;
}

/* ── Row 2: Definition ── */
.def-text {
  font-size: var(--fs-def);
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-text);
}

/* ── Row 3: Example sentence ── */
.ex-text {
  font-size: var(--fs-def);   /* same as definition */
  font-weight: 700;
  font-style: italic;
  line-height: 1.6;
  color: var(--color-muted);
}

/* ── Swiper pagination dots ── */
.swiper-pagination {
  bottom: 6px !important;
}
.swiper-pagination-bullet {
  background: var(--color-border);
  opacity: 1;
  width: 10px;
  height: 10px;
}
.swiper-pagination-bullet-active {
  background: var(--color-primary);
}

/* ── Loading / Error overlay ── */
.state-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
  font-size: 1.1rem;
  color: var(--color-muted);
}
.state-overlay.hidden { display: none; }

.retry-btn {
  padding: 10px 28px;
  border: none;
  border-radius: 24px;
  background: var(--color-primary);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

/* ── Word id badge ── */
.word-id {
  position: absolute;
  top: 14px;
  left: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-muted);
  opacity: 0.55;
  letter-spacing: 0.04em;
}

/* ── Checkmark “我记住了” button ── */
.check-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: transparent;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.12s;
  touch-action: manipulation;
}
.check-btn.checked {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
}
.check-btn:active { transform: scale(0.85); }

/* ── Celebration overlay ── */
.celebration-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
}
.celebration-overlay.hidden { display: none; }

.celebration-star {
  font-size: 4.5rem;
  animation: celebPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.celebration-msg {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-primary);
  background: rgba(255,255,255,0.92);
  padding: 8px 24px;
  border-radius: 99px;
  box-shadow: 0 4px 20px rgba(74,108,247,0.18);
  animation: celebFade 2.8s ease-out forwards;
}
@keyframes celebPop {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg);   opacity: 1; }
}
@keyframes celebFade {
  0%  { opacity: 0; transform: translateY(14px); }
  15% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100%{ opacity: 0; }
}

/* ── Confetti pieces (spawned by JS) ── */
.confetti-piece {
  position: fixed;
  top: -2rem;
  pointer-events: none;
  animation: confettiFall linear forwards;
  z-index: 201;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0; }
}

/* ── Site footer ── */
.site-footer {
  text-align: center;
  padding: 8px 16px;
  font-size: 0.72rem;
  color: var(--color-muted);
  background: var(--color-card);
  border-top: 1px solid var(--color-border);
  line-height: 1.7;
}
.site-footer a {
  color: var(--color-muted);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

/* ── iPad ── */
@media (min-width: 768px) {
  .swiper-wrapper-outer { padding: 24px 40px; }
  .word-card { padding: 40px 44px 52px; gap: 32px; }
}
