/* Phase 6 · 孩子端 TV 首页样式 */

.child-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at 20% 10%, #fff1d6 0%, #ffe0b2 35%, #ffcb91 70%, #ff9d6c 100%);
  color: #1f2937;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  overflow-x: hidden;
}

.child-shell {
  width: min(1600px, 96vw);
  margin: 0 auto;
  padding: max(clamp(20px, 3vw, 40px), env(safe-area-inset-top)) max(clamp(16px, 3vw, 56px), env(safe-area-inset-right)) max(clamp(20px, 3vw, 40px), env(safe-area-inset-bottom)) max(clamp(16px, 3vw, 56px), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 3vw, 36px);
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
}

.child-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
}

/* ====== 加载 / 未登录 ====== */

.child-state-loading {
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #92400e;
}
.loading-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f59e0b;
  animation: loadingPulse 1.1s infinite ease-in-out;
}
@keyframes loadingPulse {
  0%, 100% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
}

.child-state-auth {
  align-items: center;
  justify-content: center;
}
.state-card {
  background: #ffffffee;
  border-radius: 28px;
  padding: clamp(28px, 4vw, 56px);
  max-width: 720px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(31, 41, 55, 0.18);
}
.state-emoji {
  font-size: clamp(64px, 8vw, 120px);
  line-height: 1;
  margin-bottom: 12px;
}
.state-card h1 {
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
}
.state-card p {
  margin: 0 0 24px;
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  color: #374151;
  line-height: 1.6;
}
.state-parent-note {
  font-size: clamp(0.85rem, 1.1vw, 1rem) !important;
  color: #9ca3af !important;
}
.state-actions { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.btn.big {
  padding: 18px 36px;
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  border-radius: 999px;
}
.btn.primary {
  background: #ff7a59;
  color: #fff;
  border: none;
}
.btn.primary:hover { background: #e35f3f; }

/* ====== picker ====== */

.picker-top {
  text-align: center;
  margin-bottom: clamp(20px, 3vw, 40px);
}
.picker-top h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  color: #92400e;
  text-shadow: 0 4px 0 #ffffffaa;
}
.picker-hint {
  margin: 0;
  font-size: clamp(1rem, 1.6vw, 1.4rem);
  color: #6b7280;
}
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(16px, 2.4vw, 32px);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.picker-card {
  background: #ffffffee;
  border: 4px solid transparent;
  border-radius: 28px;
  padding: clamp(20px, 2.5vw, 32px) clamp(16px, 2vw, 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  box-shadow: 0 12px 32px rgba(31, 41, 55, 0.12);
  text-align: center;
  font-family: inherit;
  color: inherit;
}
.picker-card:hover { transform: translateY(-4px); }
.picker-card:focus-visible,
.picker-card.is-focused {
  outline: none;
  border-color: #ff7a59;
  box-shadow: 0 0 0 6px rgba(255, 122, 89, 0.25), 0 16px 36px rgba(31, 41, 55, 0.18);
  transform: translateY(-4px);
}
.picker-avatar {
  font-size: clamp(56px, 6vw, 96px);
  line-height: 1;
}
.picker-name {
  font-size: clamp(1.2rem, 1.8vw, 1.8rem);
  font-weight: 800;
  color: #1f2937;
}
.picker-meta {
  font-size: clamp(0.85rem, 1.2vw, 1rem);
  color: #6b7280;
}
.picker-empty {
  text-align: center;
  font-size: 1.15rem;
  color: #92400e;
  background: #ffffffcc;
  border-radius: 20px;
  padding: 24px;
  max-width: 600px;
  margin: 0 auto;
}
.picker-foot {
  margin-top: clamp(20px, 3vw, 40px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.picker-foot-hint {
  color: #6b7280;
  font-size: clamp(0.85rem, 1.2vw, 1rem);
}

/* ====== home ====== */

.home-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.home-greet {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.5vw, 20px);
}
.home-avatar {
  font-size: clamp(56px, 6vw, 96px);
  line-height: 1;
  filter: drop-shadow(0 6px 0 #ffffffaa);
}
.home-greet-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.home-greet-text strong {
  font-size: clamp(1.6rem, 2.6vw, 2.6rem);
  color: #92400e;
  text-shadow: 0 3px 0 #ffffffaa;
}
.home-greet-text span {
  font-size: clamp(0.95rem, 1.4vw, 1.2rem);
  color: #6b7280;
}
.home-top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.home-badges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: clamp(12px, 1.8vw, 22px);
}
.badge {
  background: #ffffffee;
  border-radius: 20px;
  padding: clamp(14px, 1.8vw, 22px) clamp(16px, 2vw, 26px);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.1);
  font-size: clamp(0.95rem, 1.3vw, 1.15rem);
}
.badge-icon {
  font-size: clamp(1.6rem, 2.4vw, 2.2rem);
  line-height: 1;
}
.badge-label { color: #6b7280; flex: 1; }
.badge strong {
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  color: #1f2937;
}
.badge-unit { color: #6b7280; font-size: 0.9em; }

.home-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 2.4vw, 32px);
  flex: 1;
  min-height: clamp(280px, 38vh, 480px);
}
.home-card {
  background: linear-gradient(160deg, #ffffff 0%, #fff7e8 100%);
  border: 4px solid transparent;
  border-radius: 32px;
  padding: clamp(20px, 2.8vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 18px 40px rgba(31, 41, 55, 0.14);
  text-align: left;
  font-family: inherit;
  color: inherit;
  position: relative;
  overflow: hidden;
}
.home-card.task-card {
  background: linear-gradient(160deg, #fff5ec 0%, #ffd8b6 100%);
}
.home-card.review-card {
  background: linear-gradient(160deg, #eef6ff 0%, #c1ddff 100%);
}
.home-card.free-card {
  background: linear-gradient(160deg, #f3ffed 0%, #c4eea6 100%);
}
.home-card:hover:not([disabled]) {
  transform: translateY(-6px);
  box-shadow: 0 24px 50px rgba(31, 41, 55, 0.18);
}
.home-card:focus-visible,
.home-card.is-focused {
  outline: none;
  border-color: #ff7a59;
  box-shadow: 0 0 0 8px rgba(255, 122, 89, 0.28), 0 24px 50px rgba(31, 41, 55, 0.18);
  transform: translateY(-6px);
}
.home-card[disabled],
.home-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(40%);
}
.home-card[disabled]:hover,
.home-card.is-disabled:hover { transform: none; }
.home-card-icon {
  font-size: clamp(48px, 5.5vw, 88px);
  line-height: 1;
}
.home-card-title {
  font-size: clamp(1.4rem, 2.4vw, 2.2rem);
  font-weight: 900;
  color: #1f2937;
}
.home-card-sub {
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  color: #4b5563;
  flex: 1;
}
.home-card-done {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #16a34a 0%, #22c55e 100%);
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.95rem, 1.3vw, 1.15rem);
  text-align: center;
  padding: 10px 16px;
  letter-spacing: 0.03em;
}

.home-card-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.progress-bar {
  display: block;
  width: 100%;
  height: 14px;
  background: #ffffff99;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff7a59 0%, #ffb086 100%);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.progress-text {
  font-size: clamp(0.85rem, 1.2vw, 1.05rem);
  color: #6b7280;
}
.home-card-cta {
  margin-top: auto;
  align-self: flex-start;
  background: #ff7a59;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(255, 122, 89, 0.35);
}
.home-card.review-card .home-card-cta { background: #3b82f6; box-shadow: 0 8px 18px rgba(59, 130, 246, 0.35); }
.home-card.free-card .home-card-cta { background: #16a34a; box-shadow: 0 8px 18px rgba(22, 163, 74, 0.35); }
.home-card.is-disabled .home-card-cta { background: #9ca3af; box-shadow: none; }

.home-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.home-foot-hint {
  color: #6b7280;
  font-size: clamp(0.85rem, 1.2vw, 1rem);
}
.home-message {
  background: #fef3c7;
  color: #92400e;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: clamp(0.9rem, 1.2vw, 1.05rem);
}
.home-message.error { background: #fee2e2; color: #b91c1c; }
.home-message.info { background: #dbeafe; color: #1e40af; }
.home-message.success { background: #dcfce7; color: #166534; }

@media (min-width: 700px) and (max-width: 1180px) {
  .child-shell {
    width: 100%;
    padding: max(18px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    gap: 18px;
  }

  .picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 760px;
  }

  .home-top,
  .home-foot,
  .picker-foot {
    gap: 12px;
  }

  .home-badges {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .badge {
    min-width: 0;
    padding: 14px;
  }

  .badge-label {
    min-width: 0;
  }

  .home-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    min-height: 0;
  }

  .home-card {
    min-width: 0;
    border-radius: 24px;
    padding: 22px 18px;
  }

  .home-card-title,
  .home-card-sub,
  .home-card-cta,
  .badge-label {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 699px) {
  .child-shell {
    width: 100%;
  }

  .home-cards {
    grid-template-columns: 1fr;
    min-height: 0;
  }
}
