/* ============================================================
   算术小课堂 · 设计系统
   风格：Claymorphism 软糯3D感
   配色：靛蓝 + 暖橙 + 淡靛蓝背景
   字体：Fredoka + Nunito
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito:wght@300;400;500;600;700&display=swap');

:root {
  /* 色彩系统 */
  --indigo: #4F46E5;
  --indigo-light: #818CF8;
  --indigo-dark: #312E81;
  --orange: #F97316;
  --orange-light: #FB923C;
  --orange-dark: #C2410C;
  --green: #22C55E;
  --green-light: #4ADE80;
  --red: #EF4444;
  --yellow: #FCD34D;
  --bg: #EEF2FF;
  --bg-warm: #FFF7ED;
  --white: #FFFFFF;
  --text: #1E1B4B;
  --text-muted: #6366A8;
  --light-gray: #E0E7FF;
  --border: #C7D2FE;

  /* 间距系统 */
  --sp-xs: 8px;
  --sp-sm: 12px;
  --sp-md: 24px;
  --sp-lg: 40px;
  --sp-xl: 64px;

  /* 圆角 */
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-full: 999px;

  /* 阴影 - Claymorphism 双阴影 */
  --shadow-clay: 6px 6px 12px rgba(79, 70, 229, 0.15), -2px -2px 8px rgba(255, 255, 255, 0.8);
  --shadow-clay-inset: inset -2px -2px 6px rgba(79, 70, 229, 0.1), inset 2px 2px 6px rgba(255, 255, 255, 0.9);
  --shadow-soft: 0 4px 20px rgba(79, 70, 229, 0.08);
  --shadow-hover: 0 8px 30px rgba(79, 70, 229, 0.15);
  --shadow-nav: 0 2px 20px rgba(79, 70, 229, 0.1);

  /* 字号 */
  --fs-hero: clamp(2rem, 5vw, 3.5rem);
  --fs-h1: clamp(1.5rem, 3vw, 2.5rem);
  --fs-h2: clamp(1.25rem, 2.5vw, 1.75rem);
  --fs-h3: clamp(1.1rem, 2vw, 1.35rem);
  --fs-body: 16px;
  --fs-small: 14px;
  --fs-tiny: 12px;

  /* 导航高度 */
  --nav-height: 72px;

  /* 过渡 */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Fredoka', 'PingFang SC', sans-serif;
  font-weight: 600;
  line-height: 1.3;
}

a { color: var(--indigo); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--orange); }

img { max-width: 100%; height: auto; }

/* ============================================================
   顶部导航
   ============================================================ */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
  box-shadow: var(--shadow-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-lg);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--indigo);
}
.nav-brand .brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--indigo), var(--orange));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.2rem;
  box-shadow: var(--shadow-clay);
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}
.nav-links a {
  display: block;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--fs-small);
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
}
.nav-links a:hover {
  background: var(--light-gray);
  color: var(--indigo);
}
.nav-links a.active {
  background: linear-gradient(135deg, var(--indigo), var(--indigo-light));
  color: var(--white);
  box-shadow: var(--shadow-clay);
}

.nav-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--indigo);
}

/* 打印按钮 */
.print-bar {
  display: flex;
  gap: 8px;
}
.print-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  background: var(--white);
  color: var(--indigo);
  font-size: var(--fs-tiny);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Nunito', sans-serif;
}
.print-btn:hover {
  background: var(--indigo);
  color: var(--white);
  border-color: var(--indigo);
}
.print-btn.child-btn {
  border-color: var(--orange-light);
  color: var(--orange-dark);
}
.print-btn.child-btn:hover {
  background: var(--orange);
  color: var(--white);
  border-color: var(--orange);
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--nav-height) var(--sp-lg) var(--sp-xl);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -20%; right: -10%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.08), transparent 70%);
  border-radius: 50%;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -20%; left: -10%;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.08), transparent 70%);
  border-radius: 50%;
}

.hero-content {
  max-width: 1080px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-xl);
  align-items: center;
  position: relative;
  z-index: 1;
}

.hero-text h1 {
  font-size: var(--fs-hero);
  color: var(--indigo-dark);
  margin-bottom: var(--sp-md);
  line-height: 1.15;
}
.hero-text .subtitle {
  font-size: var(--fs-h3);
  color: var(--text-muted);
  margin-bottom: var(--sp-lg);
  line-height: 1.6;
}
.hero-text .hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-lg);
}
.hero-tag {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  background: var(--white);
  color: var(--indigo);
  font-size: var(--fs-small);
  font-weight: 700;
  box-shadow: var(--shadow-clay);
}
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  color: var(--white);
  font-weight: 700;
  font-size: var(--fs-body);
  box-shadow: var(--shadow-clay);
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: 'Nunito', sans-serif;
}
.hero-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(249, 115, 22, 0.3);
}
.hero-cta:active { transform: translateY(0); }

.hero-image {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-clay);
  background: var(--white);
}
.hero-image img {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* ============================================================
   主内容区
   ============================================================ */
.main-content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--sp-lg);
}

.section-anchor {
  scroll-margin-top: calc(var(--nav-height) + 20px);
}

.section-header {
  margin-bottom: var(--sp-lg);
  padding-top: var(--sp-xl);
}
.section-badge {
  display: inline-block;
  padding: 4px 16px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--indigo), var(--indigo-light));
  color: var(--white);
  font-size: var(--fs-tiny);
  font-weight: 700;
  margin-bottom: var(--sp-sm);
}
.section-header h2 {
  font-size: var(--fs-h1);
  color: var(--indigo-dark);
  margin-bottom: var(--sp-sm);
}
.section-header .section-subtitle {
  font-size: var(--fs-h3);
  color: var(--text-muted);
  font-weight: 400;
}

.content-block {
  margin-bottom: var(--sp-lg);
}
.content-block h3 {
  font-size: var(--fs-h2);
  color: var(--indigo);
  margin-bottom: var(--sp-sm);
  margin-top: var(--sp-lg);
}
.content-block p {
  font-size: var(--fs-body);
  color: var(--text);
  margin-bottom: var(--sp-sm);
  max-width: 65ch;
  line-height: 1.8;
}
.content-block ul, .content-block ol {
  margin-left: 20px;
  margin-bottom: var(--sp-sm);
}
.content-block li {
  margin-bottom: 6px;
  line-height: 1.7;
}
.content-block strong {
  color: var(--indigo-dark);
  font-weight: 700;
}

/* ============================================================
   卡片网格
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--sp-lg);
  margin: 0 auto var(--sp-xl);
  max-width: 1000px;
}

.img-card {
  background: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-clay);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.img-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}
.img-card .img-wrapper {
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
}
.img-card .img-wrapper img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.img-card:hover .img-wrapper img {
  transform: scale(1.05);
}
.img-card .card-body {
  padding: var(--sp-md);
  flex: 1;
}
.img-card .card-body h4 {
  font-size: var(--fs-h3);
  color: var(--indigo-dark);
  margin-bottom: var(--sp-xs);
}
.img-card .card-body p {
  font-size: var(--fs-small);
  color: var(--text-muted);
  line-height: 1.6;
}

/* ============================================================
   提示框
   ============================================================ */
.tip-box, .callout, .warn-box {
  border-radius: var(--radius-md);
  padding: var(--sp-md) var(--sp-lg);
  margin: var(--sp-md) auto;
  max-width: 800px;
}
.tip-box {
  background: linear-gradient(135deg, #E8F8F0 0%, #F0FBF5 100%);
  border-left: 4px solid var(--green);
}
.callout {
  background: linear-gradient(135deg, #FFF5E8 0%, #FFF8F0 100%);
  border-left: 4px solid var(--orange);
}
.warn-box {
  background: linear-gradient(135deg, #FFF0F0 0%, #FFF8F0 100%);
  border-left: 4px solid var(--red);
}
.tip-title, .callout-title, .warn-title {
  font-weight: 700;
  margin-bottom: var(--sp-xs);
}
.tip-title { color: var(--green); }
.callout-title { color: var(--orange-dark); }
.warn-title { color: var(--red); }
.tip-box p, .callout p, .warn-box p {
  margin-bottom: var(--sp-xs);
  font-size: var(--fs-body);
}

/* ============================================================
   数字练习面板
   ============================================================ */
.practice-panel {
  background: linear-gradient(135deg, rgba(238, 242, 255, 0.95), rgba(249, 115, 22, 0.06));
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-md) var(--sp-lg);
  margin: var(--sp-md) auto;
  max-width: 800px;
  text-align: center;
}
.practice-panel h4 {
  font-size: var(--fs-h3);
  color: var(--indigo-dark);
  margin-bottom: var(--sp-xs);
}
.practice-panel p {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-bottom: var(--sp-sm);
}

/* ============================================================
   滚动渐入动画
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   参考来源
   ============================================================ */
.sources-section {
  max-width: 800px;
  margin: var(--sp-xl) auto;
  padding: var(--sp-lg);
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
.sources-section h3 {
  font-size: var(--fs-h2);
  color: var(--indigo-dark);
  margin-bottom: var(--sp-sm);
}
.sources-section ol {
  margin-left: 20px;
}
.sources-section li {
  margin-bottom: var(--sp-xs);
  font-size: var(--fs-small);
  color: var(--text-muted);
}
.verification-date {
  margin-top: var(--sp-md);
  padding-top: var(--sp-sm);
  border-top: 1px solid var(--light-gray);
  font-size: var(--fs-tiny);
  color: var(--text-muted);
}

/* ============================================================
   移动端导航浮窗
   ============================================================ */
.nav-fab {
  position: fixed;
  bottom: 24px;
  left: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--indigo-light));
  color: var(--white);
  border: none;
  cursor: pointer;
  z-index: 910;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: none;
}
.nav-fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5); }
.nav-fab:active { transform: scale(0.95); }
.nav-fab-icon { font-size: 1.2rem; line-height: 1; }
.nav-fab-label { font-size: 0.65rem; font-weight: 600; margin-top: 2px; }

.nav-fab-overlay {
  display: none;
  position: fixed;
  top: var(--nav-height); left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(2px);
  z-index: 930;
  opacity: 0;
  transition: opacity 0.3s;
}
.nav-fab-overlay.open { display: block; opacity: 1; }

.nav-fab-panel {
  display: none;
  position: fixed;
  bottom: 0; left: 0; top: var(--nav-height);
  width: 240px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 940;
  padding: var(--sp-md);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  flex-direction: column;
  gap: 4px;
}
.nav-fab-panel.open {
  display: flex;
  transform: translateX(0);
}

.nav-fab-title {
  font-weight: 700;
  color: var(--indigo);
  margin-bottom: var(--sp-sm);
  font-size: var(--fs-body);
  padding-bottom: var(--sp-xs);
  border-bottom: 2px solid var(--border);
}

.nav-fab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 var(--sp-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--fs-body);
  transition: background 0.2s, color 0.2s;
}
.nav-fab-item:hover { background: rgba(79, 70, 229, 0.1); color: var(--indigo); }
.nav-fab-item.active {
  background: linear-gradient(135deg, var(--indigo), var(--indigo-light));
  color: var(--white);
  font-weight: 600;
}
.nav-fab-num {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.nav-fab-item.active .nav-fab-num { background: rgba(255, 255, 255, 0.3); }

.nav-fab-print {
  display: flex;
  gap: var(--sp-xs);
  margin-top: var(--sp-sm);
  padding-top: var(--sp-sm);
  border-top: 1px solid var(--light-gray);
}
.nav-fab-print .print-btn { flex: 1; font-size: 0.7rem; padding: 6px 8px; text-align: center; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-actions .print-bar { display: none; }
  .nav-toggle { display: block; }
  .nav-fab { display: flex !important; }
  .nav-fab-panel { display: flex; }
  .nav-fab-overlay { display: block; }

  .hero-content {
    grid-template-columns: 1fr;
    gap: var(--sp-lg);
  }
  .hero-image { max-width: 500px; }

  .card-grid { grid-template-columns: 1fr; }
  .content-block p { font-size: 15px; }

  .main-content { padding: 0 var(--sp-md); }
  .top-nav { padding: 0 var(--sp-md); }
}

/* 移动端菜单展开 */
.nav-menu-mobile {
  display: none;
  position: fixed;
  top: var(--nav-height); left: 0; right: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  z-index: 999;
  padding: var(--sp-md);
  box-shadow: var(--shadow-nav);
  flex-direction: column;
  gap: 4px;
}
.nav-menu-mobile.open { display: flex; }
.nav-menu-mobile a {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
}
.nav-menu-mobile a:hover { background: var(--light-gray); }
.nav-menu-mobile a.active { background: var(--indigo); color: var(--white); }

/* ============================================================
   打印样式
   ============================================================ */
@media print {
  body { background: white !important; color: black; font-size: 12pt; }
  .top-nav, .nav-fab, .nav-fab-panel, .nav-fab-overlay,
  .nav-actions, .nav-toggle, .print-bar,
  .nav-menu-mobile { display: none !important; }

  .hero { min-height: auto; padding: 20px; }
  .hero-content { grid-template-columns: 1fr; }
  .hero-image { max-width: 100%; }

  .main-content { max-width: 100%; padding: 0; }
  .section-anchor { scroll-margin-top: 0; }

  .reveal { opacity: 1 !important; transform: none !important; }

  .img-card, .card-grid { break-inside: avoid; page-break-inside: avoid; }
  .img-card { box-shadow: none; border: 1px solid #ddd; }

  h1, h2, h3, h4 { break-after: avoid; }
  .tip-box, .callout, .warn-box, .practice-panel { break-inside: avoid; }

  .sources-section { break-inside: avoid; }
}

/* 少儿版打印 */
body.print-child .content-block p,
body.print-child .content-block ul,
body.print-child .content-block ol,
body.print-child .tip-box,
body.print-child .callout,
body.print-child .warn-box,
body.print-child .practice-panel,
body.print-child .section-header .section-subtitle { display: none; }

body.print-child .section-header h2 { font-size: 1.5rem; }
body.print-child .img-card .card-body h4 { font-size: 1.1rem; }
body.print-child .img-card .card-body p { font-size: 0.8rem; display: block; }
body.print-child .sources-section { display: none; }

/* ============================================================
   prefers-reduced-motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
