/* ============================================================
   儿童认字卡 – 样式表
   Children's Flashcard App Styles
   ============================================================ */

/* ── Variables ── */
:root {
  --grad-start: #FF6B6B;
  --grad-end:   #FF8E53;
  --card-bg:    rgba(255,255,255,0.96);
  --card-radius: 28px;
  --card-shadow: 0 20px 60px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.12);
  --text-main:  #1a1a2e;
  --text-muted: #555;
  --nav-h:      80px;
  --nav-h-sm:   68px;
  --transition: 0.28s cubic-bezier(.4,0,.2,1);
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Noto Sans CJK SC', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.5s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Layout ── */
.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 8px;
  flex-shrink: 0;
}
.app-title {
  color: #fff;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 800;
  letter-spacing: .02em;
  text-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.header-actions { display: flex; gap: 8px; }

/* ── Category Nav ── */
.cat-scroll-wrap {
  flex-shrink: 0;
  overflow-x: auto;
  padding: 4px 16px 10px;
  scrollbar-width: none;
}
.cat-scroll-wrap::-webkit-scrollbar { display: none; }

#cat-nav {
  display: flex;
  gap: 8px;
  width: max-content;
  padding-bottom: 2px;
}

.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 16px;
  border: none;
  border-radius: 40px;
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  color: rgba(255,255,255,0.9);
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 62px;
}
.cat-btn .cat-icon { font-size: 1.35rem; line-height: 1; }
.cat-btn .cat-label { font-size: 0.72rem; }
.cat-btn:hover  { background: rgba(255,255,255,0.35); transform: translateY(-1px); }
.cat-btn.active {
  background: #fff;
  color: var(--grad-start);
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transform: translateY(-2px);
}

/* ── Main Stage ── */
.stage-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  min-height: 0;
}

#card-stage {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  width: 100%;
  max-width: 480px;
  aspect-ratio: 3/4;
  max-height: min(72vh, 520px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 24px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
#card-stage:hover { transform: translateY(-3px); box-shadow: 0 28px 70px rgba(0,0,0,0.28); }
#card-stage:active { transform: scale(0.98); }
#card-stage.card-speaking { box-shadow: 0 0 0 4px var(--grad-start), var(--card-shadow); }

/* ── Card inner elements ── */
.card-emoji {
  font-size: clamp(3.5rem, 14vw, 6rem);
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12));
}
.card-main {
  font-size: clamp(3rem, 14vw, 6.5rem);
  font-weight: 900;
  color: var(--text-main);
  line-height: 1;
  text-align: center;
  letter-spacing: -0.02em;
}
.card-main.pinyin-big { font-size: clamp(3.5rem, 16vw, 7rem); color: #2c7ef7; }
.card-main.alpha-big {
  font-size: clamp(3rem, 12vw, 5.5rem);
  display: flex; align-items: baseline; gap: 4px;
}
.alpha-big .upper { color: #e74c3c; }
.alpha-big .lower-sep { color: #aaa; font-weight: 300; }
.alpha-big .lower { color: #3498db; }
.card-pinyin {
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  color: #e74c3c;
  font-weight: 700;
  letter-spacing: 0.06em;
}
/* Number card: hero numeral */
.card-numeral-hero {
  font-size: clamp(7rem, 38vw, 15rem);
  font-weight: 900;
  line-height: 1;
  color: var(--grad-start);
  letter-spacing: -0.04em;
  text-shadow: 0 6px 24px rgba(0,0,0,0.10);
  flex-shrink: 0;
}
/* Number card: info row (emoji + 汉字) */
.card-num-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: -4px;
}
.card-num-emoji {
  font-size: clamp(1.6rem, 5.5vw, 2.4rem);
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.10));
}
.card-num-char {
  font-size: clamp(2rem, 8vw, 3.4rem);
  font-weight: 900;
  color: var(--text-main);
  line-height: 1;
  letter-spacing: -0.02em;
}
/* Shape card: large shape emoji */
.card-shape-icon {
  font-size: clamp(6.5rem, 32vw, 13rem);
  line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.18));
}
.card-word {
  font-size: clamp(1rem, 3.5vw, 1.4rem);
  color: #666;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.card-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: #2c7ef7;
  border-radius: 20px;
  padding: 3px 14px;
}

/* Color swatch */
.card-color-swatch {
  width: clamp(100px, 30vw, 160px);
  height: clamp(100px, 30vw, 160px);
  border-radius: 50%;
  border: 6px solid rgba(0,0,0,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
}

/* ── Bounce animation ── */
.bounce { animation: bounceIn 0.5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes bounceIn {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  80%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* ── Slide transitions ── */
@keyframes slideOutLeft  { to { transform: translateX(-110%); opacity: 0; } }
@keyframes slideOutRight { to { transform: translateX(110%);  opacity: 0; } }
@keyframes slideInRight  { from { transform: translateX(110%); opacity: 0; } }
@keyframes slideInLeft   { from { transform: translateX(-110%); opacity: 0; } }

#card-stage.slide-out-left  { animation: slideOutLeft  0.28s cubic-bezier(.4,0,.2,1) forwards; }
#card-stage.slide-out-right { animation: slideOutRight 0.28s cubic-bezier(.4,0,.2,1) forwards; }
#card-stage.slide-in-right  { animation: slideInRight  0.32s cubic-bezier(.4,0,.2,1) both; }
#card-stage.slide-in-left   { animation: slideInLeft   0.32s cubic-bezier(.4,0,.2,1) both; }

/* ── Bottom bar ── */
.bottom-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px 16px;
  gap: 12px;
}
.nav-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.nav-btn:hover { background: rgba(255,255,255,0.45); transform: scale(1.08); }
.nav-btn:active { transform: scale(0.92); }

.center-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#counter {
  color: rgba(255,255,255,.85);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: .05em;
}

/* Progress dots */
#progress-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 10px;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: all 0.25s ease;
  flex-shrink: 0;
}
.dot.active {
  background: #fff;
  transform: scale(1.5);
  box-shadow: 0 0 6px rgba(255,255,255,0.8);
}

/* Condensed progress bar */
.dot-progress {
  width: 100px; height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.3);
  position: relative;
  overflow: hidden;
}
.dot-progress::after {
  content: '';
  position: absolute;
  top:0; left:0; bottom:0;
  width: var(--pct, 0%);
  background: #fff;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Speak button */
#speak-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
#speak-btn:hover { background: rgba(255,255,255,0.4); transform: scale(1.1); }
#speak-btn.speaking {
  background: #fff;
  color: var(--grad-start);
  animation: pulse-ring 0.8s ease infinite;
}

/* auto btn */
#auto-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
#auto-btn:hover { background: rgba(255,255,255,0.35); }
#auto-btn.active { background: #fff; color: var(--grad-start); }

/* ── Pulse ring ── */
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.7); }
  70%  { box-shadow: 0 0 0 12px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,30,0.9);
  color: #fff;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 0.88rem;
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: all 0.35s ease;
  z-index: 999;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Safe-area support (iPhone notch) ── */
@supports (padding: max(0px)) {
  .app-header { padding-top: max(12px, env(safe-area-inset-top)); }
  .bottom-bar { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .cat-scroll-wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

/* ── Responsive tweaks ── */

/* Tablet (iPad) */
@media (min-width: 600px) {
  .app-title { font-size: 1.5rem; }
  #card-stage { max-height: min(68vh, 540px); }
  .nav-btn { width: 58px; height: 58px; font-size: 1.8rem; }
  #speak-btn { width: 62px; height: 62px; font-size: 1.7rem; }
}

/* Desktop */
@media (min-width: 900px) {
  #card-stage { aspect-ratio: 5/6; max-height: min(65vh, 560px); }
  .cat-scroll-wrap { padding: 4px 32px 12px; }
  .bottom-bar { padding: 10px 32px 20px; }
  .app-header { padding: 16px 32px 8px; }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  #card-stage {
    aspect-ratio: 4/3;
    max-height: 60vh;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
  }
  .card-emoji { font-size: 3rem; }
  .card-main  { font-size: 2.8rem; }
  .card-pinyin{ font-size: 1rem; }
  .card-numeral-hero { font-size: 5.5rem; }
  .card-num-char { font-size: 1.8rem; }
  .card-num-emoji { font-size: 1.5rem; }
  .card-shape-icon { font-size: 5rem; }
  .cat-btn .cat-label { display: none; }
  .cat-btn { padding: 6px 12px; min-width: auto; }
}

/* Very small phones */
@media (max-width: 360px) {
  .cat-btn { padding: 6px 10px; min-width: 52px; }
  .cat-btn .cat-icon { font-size: 1.1rem; }
}
