/* 易读书 · 交互科普 — 共享主题样式 */
@import url('article-components.css');

:root {
  --primary: #2563EB;
  --primary-light: #3B82F6;
  --primary-soft: #EFF6FF;
  --purple: #7C3AED;
  --orange: #F97316;
  --green: #059669;
  --red: #DC2626;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #1E293B;
  --text-muted: #64748B;
  --shadow-clay: 8px 8px 20px rgba(0,0,0,.10), -8px -8px 20px rgba(255,255,255,.9);
  --shadow-clay-hover: 12px 12px 28px rgba(0,0,0,.14), -8px -8px 20px rgba(255,255,255,.9);
  --radius: 20px;
  --radius-sm: 12px;
  --content-max: 860px;
  --content-pad: 24px;
  --nav-offset: 72px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-offset);
}
section[id],
.interactive[id] {
  scroll-margin-top: var(--nav-offset);
}
body { font-family: 'Noto Sans SC', sans-serif; background: var(--bg); color: var(--text); line-height: 1.8; overflow-x: hidden; }
h1, h2, h3 { font-family: 'Baloo 2', cursive; }

body > nav:not(.category-nav),
nav.site-nav {
  position: fixed; top: 0; left: 0; right: 0;
  background: rgba(248,250,252,.88); backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1.5px solid rgba(0,0,0,.06); z-index: 100;
  min-height: 60px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 24px;
  overflow: visible;
}
.logo {
  font-family: 'Baloo 2', cursive; font-size: 1.25rem; font-weight: 800; color: var(--primary);
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  flex-shrink: 0; white-space: nowrap; line-height: 1.35;
}
.logo svg { width: 28px; height: 28px; flex-shrink: 0; }
.nav-links { list-style: none; display: flex; gap: 6px; flex-shrink: 1; min-width: 0; justify-content: flex-end; flex-wrap: wrap; margin: 0; padding: 0; }
.nav-links a { text-decoration: none; color: var(--text-muted); font-size: .9rem; font-weight: 500; padding: 6px 14px; border-radius: 999px; transition: background .2s, color .2s; }
.nav-links a:hover { background: rgba(37,99,235,.08); color: var(--primary); }

@media (max-width: 960px) {
  .nav-links a { padding: 6px 10px; font-size: .85rem; }
}

.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: rgba(37,99,235,.08); color: var(--primary); cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle svg { width: 22px; height: 22px; }

.hero {
  min-height: 70vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 100px 24px 60px;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(37,99,235,.07) 0%, transparent 70%);
}
.hero-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(37,99,235,.08); color: var(--primary); font-size: .85rem; font-weight: 600; padding: 6px 16px; border-radius: 999px; margin-bottom: 24px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); font-weight: 800; line-height: 1.15; margin-bottom: 18px; letter-spacing: -.02em; }
.hero h1 .hi { background: linear-gradient(135deg, var(--primary), var(--orange)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero p { font-size: 1.1rem; color: var(--text-muted); max-width: 560px; margin-bottom: 36px; line-height: 1.85; }
.btn-primary { display: inline-flex; align-items: center; gap: 8px; background: var(--orange); color: white; font-family: 'Baloo 2', cursive; font-size: 1.1rem; font-weight: 700; padding: 15px 34px; border-radius: 999px; text-decoration: none; border: none; cursor: pointer; box-shadow: 0 6px 24px rgba(249,115,22,.32); transition: all .2s ease-out; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 32px rgba(249,115,22,.45); }
.scroll-hint { margin-top: 48px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-muted); font-size: .82rem; animation: bounce 2.2s ease-in-out infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

section { padding: 80px var(--content-pad); max-width: var(--content-max); margin: 0 auto; }
section:nth-child(even) { background: rgba(37,99,235,.025); border-radius: var(--radius); margin: 24px auto; max-width: var(--content-max); }

.section-tag { font-family: 'Baloo 2', cursive; font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--primary); margin-bottom: 12px; display: block; }
h2 { font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 800; color: var(--text); margin-bottom: 20px; line-height: 1.2; }
p { font-size: 1.03rem; color: var(--text-muted); margin-bottom: 14px; }
p:last-child { margin-bottom: 0; }

.card { background: var(--card); border-radius: var(--radius); padding: 32px; margin-bottom: 20px; box-shadow: var(--shadow-clay); transition: box-shadow .2s; }
.card:hover { box-shadow: var(--shadow-clay-hover); }
.card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.card h3 .num { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: var(--primary); color: white; border-radius: 50%; font-size: .9rem; flex-shrink: 0; }
.card h3 .num.orange { background: var(--orange); }
.card h3 .num.green { background: var(--green); }

.formula-box { background: linear-gradient(135deg, rgba(37,99,235,.06), rgba(249,115,22,.06)); border: 2px solid rgba(37,99,235,.15); border-radius: var(--radius-sm); padding: 24px 32px; text-align: center; margin: 22px 0; }
.formula { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 700; color: var(--primary); letter-spacing: .02em; font-family: 'Baloo 2', cursive; }
.formula-sub { font-size: .88rem; color: var(--text-muted); margin-top: 8px; }
.fx { color: var(--primary); }
.fdx { color: var(--red); }
.eta { color: var(--orange); }

.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 22px 0; }
.flow-item { background: var(--card); border-radius: var(--radius-sm); padding: 22px 18px; text-align: center; box-shadow: var(--shadow-clay); transition: transform .2s; }
.flow-item:hover { transform: translateY(-3px); }
.flow-icon { font-size: 2rem; margin-bottom: 10px; }
.flow-item h4 { font-family: 'Baloo 2', cursive; font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.flow-item p { font-size: .86rem; }

.tbl { width: 100%; border-collapse: separate; border-spacing: 0; border-radius: var(--radius-sm); overflow: hidden; margin: 18px 0; box-shadow: var(--shadow-clay); }
.tbl th { background: var(--primary); color: white; font-family: 'Baloo 2', cursive; font-weight: 600; font-size: .88rem; padding: 13px 18px; text-align: center; }
.tbl td { padding: 10px 18px; text-align: center; background: var(--card); font-size: .9rem; border-bottom: 1px solid rgba(0,0,0,.05); }
.tbl tr:last-child td { border-bottom: none; }
.tbl td:first-child { font-weight: 600; }

.tag-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.tag-up { background: rgba(220,38,38,.1); color: #DC2626; }
.tag-down { background: rgba(16,185,129,.1); color: #059669; }
.tag-zero { background: rgba(100,116,139,.1); color: var(--text-muted); }
.tag-beginner { background: rgba(16,185,129,.1); color: #059669; }
.tag-intermediate { background: rgba(37,99,235,.1); color: #2563EB; }
.tag-advanced { background: rgba(124,58,237,.1); color: #7C3AED; }
.tag-category { background: rgba(37,99,235,.08); color: var(--primary); margin-right: 6px; }

.alert { background: rgba(249,115,22,.08); border-left: 4px solid var(--orange); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 14px 18px; margin: 18px 0; font-size: .95rem; }
.alert strong { color: var(--orange); }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin: 22px 0; }
.panel { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-clay); border-top: 4px solid var(--primary); transition: transform .2s; }
.panel:hover { transform: translateY(-3px); }
.panel.orange { border-top-color: var(--orange); }
.panel.green { border-top-color: var(--green); }
.panel h4 { font-family: 'Baloo 2', cursive; font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.panel p { font-size: .88rem; }

.data-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 20px 0; }
.df-item { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-clay); }
.df-item .label { font-family: 'Baloo 2', cursive; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); margin-bottom: 8px; }
.df-item .value { font-family: 'Baloo 2', cursive; font-size: 1.4rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.df-item .desc { font-size: .85rem; color: var(--text-muted); }

.interactive { background: linear-gradient(135deg, rgba(37,99,235,.04), rgba(249,115,22,.04)); border-radius: var(--radius); padding: 40px 32px; margin: 24px auto; max-width: var(--content-max); box-shadow: var(--shadow-clay); }
.interactive h2 { text-align: center; margin-bottom: 6px; }
.interactive > p { text-align: center; margin-bottom: 28px; }
.canvas-wrap { position: relative; width: 100%; max-width: 700px; margin: 0 auto 24px; }
.canvas-wrap canvas { width: 100%; border-radius: var(--radius-sm); box-shadow: inset 0 2px 8px rgba(0,0,0,.07); background: #fff; cursor: crosshair; }
.canvas-badge { position: absolute; top: 10px; left: 10px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px); border-radius: 8px; padding: 8px 14px; font-family: 'Baloo 2', cursive; font-size: .8rem; color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.1); pointer-events: none; white-space: nowrap; }

.controls { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: flex-end; margin-bottom: 20px; }
.ctrl { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.ctrl label { font-family: 'Baloo 2', cursive; font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.ctrl input[type=range] { width: 130px; accent-color: var(--primary); cursor: pointer; }
.ctrl-val { font-family: 'Baloo 2', cursive; font-size: .85rem; font-weight: 700; color: var(--primary); background: rgba(37,99,235,.08); padding: 2px 10px; border-radius: 999px; }

.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn { font-family: 'Baloo 2', cursive; font-size: .95rem; font-weight: 700; padding: 11px 26px; border-radius: 999px; border: none; cursor: pointer; transition: all .2s ease-out; display: inline-flex; align-items: center; gap: 7px; }
.btn-primary-btn { background: var(--primary); color: white; box-shadow: 0 4px 14px rgba(37,99,235,.28); }
.btn-primary-btn:hover { background: var(--primary-light); transform: translateY(-1px); }
.btn-orange { background: var(--orange); color: white; box-shadow: 0 4px 14px rgba(249,115,22,.28); }
.btn-orange:hover { background: #FB923C; transform: translateY(-1px); }
.btn-gray { background: var(--card); color: var(--text); box-shadow: var(--shadow-clay); }
.btn-gray:hover { transform: translateY(-1px); box-shadow: var(--shadow-clay-hover); }

.log { background: #1E293B; border-radius: var(--radius-sm); padding: 16px 20px; max-height: 160px; overflow-y: auto; font-family: 'Courier New', monospace; font-size: .82rem; color: #94A3B8; line-height: 1.75; margin-top: 18px; }
.log::-webkit-scrollbar { width: 5px; }
.log::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
.log .s { color: #60A5FA; }
.log .v { color: #34D399; }
.log .l { color: #FBBF24; }

.deriv-viz { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin: 24px 0; padding: 20px; background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow-clay); }
.deriv-box { padding: 18px; border-radius: var(--radius-sm); text-align: center; }
.deriv-box.blue { background: rgba(37,99,235,.08); }
.deriv-box.orange { background: rgba(249,115,22,.08); }
.deriv-box.green { background: rgba(16,185,129,.08); }
.deriv-box h5 { font-family: 'Baloo 2', cursive; font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.deriv-box p { font-size: .85rem; color: var(--text-muted); margin: 0; }
.deriv-arrow { font-size: 2rem; color: var(--text-muted); text-align: center; }

.minus-viz { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin: 24px 0; padding: 20px; background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow-clay); }
.minus-box { padding: 16px; border-radius: var(--radius-sm); text-align: center; }
.minus-box.blue { background: rgba(37,99,235,.08); }
.minus-box.red { background: rgba(220,38,38,.08); }
.minus-box.green { background: rgba(16,185,129,.08); }
.minus-box h5 { font-family: 'Baloo 2', cursive; font-size: .95rem; font-weight: 700; margin-bottom: 6px; }
.minus-box p { font-size: .83rem; color: var(--text-muted); margin: 0; line-height: 1.5; }
.minus-sign { font-size: 2.2rem; color: var(--text-muted); text-align: center; padding: 0 6px; }

.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin: 24px 0; }
.method-card { background: var(--card); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-clay); border-top: 5px solid var(--primary); }
.method-card.orange { border-top-color: var(--orange); }
.method-card h4 { font-family: 'Baloo 2', cursive; font-size: 1.2rem; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.method-card p { font-size: .9rem; }
.method-card ol { font-size: .88rem; color: var(--text-muted); padding-left: 20px; margin-top: 10px; }
.method-card li { margin-bottom: 6px; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 24px 0; }
.sum-item { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-clay); border-top: 4px solid var(--primary); transition: transform .2s; }
.sum-item:hover { transform: translateY(-3px); }
.sum-item h4 { font-family: 'Baloo 2', cursive; font-size: 1rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.sum-item p { font-size: .88rem; }

.article-nav { display: flex; justify-content: center; align-items: center; gap: 16px; max-width: var(--content-max); margin: 0 auto; padding: 0 var(--content-pad) 40px; }
.article-nav a { color: var(--primary); text-decoration: none; font-weight: 600; font-size: .95rem; }
.article-nav a:hover { text-decoration: underline; }
.article-nav .nav-home { color: var(--text-muted); font-weight: 500; font-size: .88rem; }

footer { text-align: center; padding: 36px 24px; color: var(--text-muted); font-size: .82rem; border-top: 1.5px solid rgba(0,0,0,.06); margin-top: 40px; }
footer a { color: var(--primary); text-decoration: none; }

/* ── 首页专用 ── */
.site-hero { min-height: 70vh; }
.site-hero h1 { font-size: clamp(2.5rem, 7vw, 4.5rem); }
.category-nav {
  position: static;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  margin: 32px 0 48px; padding: 0 24px;
  background: transparent; backdrop-filter: none; border-bottom: none;
  min-height: unset;
}
.category-nav a { text-decoration: none; color: var(--text-muted); font-weight: 600; font-size: .95rem; padding: 10px 22px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow-clay); transition: all .2s; }
.category-nav a:hover { color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-clay-hover); }

.articles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; max-width: 1100px; margin: 0 auto; padding: 0 24px 80px; }
.article-card { background: var(--card); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-clay); transition: transform .2s, box-shadow .2s; }
.article-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-clay-hover); }
.article-card h3 { font-size: 1.15rem; margin-bottom: 10px; }
.article-card h3 a { color: var(--text); text-decoration: none; }
.article-card h3 a:hover { color: var(--primary); }
.article-card p { font-size: .92rem; margin-bottom: 12px; }
.article-card .tags { font-size: .8rem; color: var(--text-muted); }
.article-card .card-badges { margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; }

.category-section { max-width: 1100px; margin: 0 auto 48px; padding: 0 24px; }
.category-section h2 { font-size: 1.6rem; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid rgba(37,99,235,.12); }
.category-section .articles-grid { padding: 0; max-width: none; margin: 0; }

.category-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(37,99,235,.12);
}
.category-section-head h2 {
  margin: 0;
  padding: 0;
  border-bottom: none;
  line-height: 1.2;
}
.category-section-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  font-family: 'Baloo 2', cursive;
  font-size: .95rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 999px;
  text-decoration: none;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 14px rgba(37,99,235,.28);
  transition: background .2s, transform .2s, box-shadow .2s;
}
.category-section-cta:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37,99,235,.35);
}
.category-section-cta::after {
  content: "→";
  font-weight: 800;
}
.articles-grid--featured {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
  .articles-grid--featured { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --content-pad: 16px; }
  body > nav:not(.category-nav),
  nav.site-nav { padding: 10px 16px; }
  .nav-toggle { display: flex; }
  body > nav:not(.category-nav) .nav-links,
  nav.site-nav .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; background: rgba(248,250,252,.98);
    padding: 12px 16px 16px; border-bottom: 1px solid rgba(0,0,0,.06);
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
  }
  body > nav:not(.category-nav) .nav-links.open,
  nav.site-nav .nav-links.open { display: flex; }
  .controls { flex-direction: column; }
  .ctrl { flex-direction: row; width: 100%; justify-content: space-between; }
  .ctrl input[type=range] { flex: 1; min-width: 0; }
  section { padding: 60px var(--content-pad); }
  section:nth-child(even) { margin: 16px auto; }
  .card { padding: 24px 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .interactive { padding: 28px 16px; margin: 16px var(--content-pad); max-width: none; }
  .formula-box { padding: 20px 16px; }
  .canvas-badge { max-width: calc(100% - 20px); white-space: normal; font-size: .75rem; }
  .article-nav { text-align: center; }
  .articles-grid { grid-template-columns: 1fr; padding: 0 var(--content-pad) 60px; }
  .articles-grid--featured { grid-template-columns: 1fr; }
  .category-section-head { flex-direction: column; align-items: stretch; }
  .category-section-cta { width: 100%; }
  .deriv-viz { grid-template-columns: 1fr; }
  .deriv-arrow { transform: rotate(90deg); }
  .minus-viz { grid-template-columns: 1fr; }
  .minus-sign { transform: rotate(90deg); }
  .tbl th, .tbl td { padding: 10px 12px; font-size: .82rem; }
}

:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
