/* ============================================================
   昆虫百科图鉴 · 样式
   专业图鉴的结构感 + 适合 6-10 岁的明快配色
   ============================================================ */

:root {
  --green: #3fa45f;
  --green-dark: #25754170;
  --green-ink: #1f6b3d;
  --amber: #ffb12e;
  --pink: #ff7aa8;
  --blue: #2f7fd6;
  --teal: #15b6c4;
  --cream: #fffdf6;
  --paper: #ffffff;
  --ink: #34343f;
  --muted: #6d6d7c;
  --line: #ece7da;
  --shadow: 0 8px 24px rgba(40, 40, 50, 0.10);
  --shadow-lg: 0 16px 40px rgba(40, 40, 50, 0.16);
  --radius: 20px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Heiti SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.75;
  font-size: 17px;
}

/* ---------- 拼音 ruby ---------- */
ruby { ruby-align: center; }
rt {
  font-size: 0.55em; color: var(--green-ink);
  font-weight: 600; letter-spacing: 0.02em;
  transition: opacity 0.2s ease;
}
body:not(.pinyin-on) rt { opacity: 0; }
body:not(.pinyin-on) .bug-pinyin,
body:not(.pinyin-on) .life-pinyin,
body:not(.pinyin-on) .body-pinyin,
body:not(.pinyin-on) .modal-pinyin,
body:not(.pinyin-on) .gloss-pinyin,
body:not(.pinyin-on) .chip-pinyin,
body:not(.pinyin-on) .order-pinyin { visibility: hidden; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 11px 22px;
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { font-size: 1.3rem; font-weight: 800; color: var(--green-ink); text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  text-decoration: none; color: var(--ink);
  padding: 6px 12px; border-radius: 999px;
  font-weight: 700; font-size: 0.92rem;
  transition: background 0.18s, color 0.18s, transform 0.1s;
}
.nav a:hover { background: var(--green); color: #fff; transform: translateY(-2px); }
.pinyin-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; cursor: pointer;
  background: var(--amber); color: #5a3d00;
  font-family: var(--font); font-weight: 800; font-size: 0.92rem;
  padding: 8px 15px; border-radius: 999px; box-shadow: var(--shadow);
  transition: transform 0.1s, filter 0.15s;
}
.pinyin-btn:hover { transform: translateY(-2px); filter: brightness(1.03); }
.pinyin-btn:active { transform: scale(0.96); }
.pinyin-btn .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--green-ink); }
body:not(.pinyin-on) .pinyin-btn .dot { background: #c3c3c3; }

/* ---------- 主视觉 ---------- */
.hero {
  position: relative; overflow: hidden; text-align: center;
  padding: 60px 22px 70px;
  background:
    radial-gradient(circle at 18% 22%, #d6f3e0 0%, transparent 46%),
    radial-gradient(circle at 84% 26%, #ffe6ee 0%, transparent 46%),
    linear-gradient(165deg, #eafff3 0%, #fff8e6 100%);
}
.hero-text { position: relative; z-index: 2; max-width: 760px; margin: 0 auto; }
.hero-kicker {
  display: inline-block; background: #fff; color: var(--green-ink);
  font-weight: 800; font-size: 0.92rem; padding: 6px 16px;
  border-radius: 999px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.hero h1 { font-size: clamp(2.1rem, 6.5vw, 3.6rem); font-weight: 900; line-height: 1.2; }
.hero h1 .hl {
  background: linear-gradient(120deg, var(--green), var(--teal));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { font-size: clamp(1rem, 2.5vw, 1.25rem); margin: 18px auto 26px; max-width: 580px; color: #4a4a58; }
.cta {
  display: inline-block; text-decoration: none;
  background: var(--green); color: #fff; font-weight: 800; font-size: 1.12rem;
  padding: 14px 34px; border-radius: 999px; box-shadow: var(--shadow);
  transition: transform 0.12s, filter 0.15s;
}
.cta:hover { transform: translateY(-3px) scale(1.03); filter: brightness(1.05); }
.hero-bugs { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.float { position: absolute; font-size: 2.4rem; opacity: 0.9; animation: floaty 6s ease-in-out infinite; }
.b1 { left: 7%;  top: 24%; } .b2 { left: 84%; top: 18%; animation-delay: 1s; }
.b3 { left: 13%; top: 68%; animation-delay: 2s; } .b4 { left: 80%; top: 64%; animation-delay: 1.5s; }
.b5 { left: 46%; top: 10%; animation-delay: .5s; } .b6 { left: 60%; top: 76%; animation-delay: 2.5s; }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-20px) rotate(6deg); } }

/* ---------- 通用区块 ---------- */
.section { max-width: 1120px; margin: 0 auto; padding: 56px 22px; }
.section-alt { background: linear-gradient(180deg, #f3fbf6 0%, #fffdf6 100%); max-width: none; }
.section-alt > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
.section-title { text-align: center; font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 900; }
.section-sub { text-align: center; color: var(--muted); margin: 8px auto 28px; font-size: 1.04rem; max-width: 640px; }
.fact-banner {
  margin-top: 26px; background: #fff4d6; border-radius: var(--radius);
  padding: 18px 22px; text-align: center; font-size: 1.02rem;
  box-shadow: var(--shadow); border: 2px dashed var(--amber);
}

/* ---------- 什么是昆虫 ---------- */
.def-row { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.def-card {
  background: var(--paper); border-radius: var(--radius); padding: 24px;
  text-align: center; box-shadow: var(--shadow); border-top: 5px solid var(--green);
}
.def-ico { font-size: 2.4rem; }
.def-title { font-size: 1.25rem; font-weight: 900; margin-top: 6px; }
.def-desc { color: var(--muted); margin-top: 6px; }

/* ---------- 图鉴工具：搜索 + 分类筛选 ---------- */
.guide-tools { display: flex; flex-direction: column; gap: 16px; margin-bottom: 22px; }
.search-wrap { position: relative; max-width: 460px; margin: 0 auto; width: 100%; }
.search-ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 1.1rem; }
#search {
  width: 100%; font-family: var(--font); font-size: 1.02rem;
  padding: 13px 16px 13px 46px; border-radius: 999px;
  border: 2px solid var(--line); background: #fff; color: var(--ink);
  box-shadow: var(--shadow); transition: border-color 0.15s;
}
#search:focus { outline: none; border-color: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font); cursor: pointer;
  background: #fff; color: var(--ink); border: 2px solid var(--line);
  padding: 8px 15px; border-radius: 999px; font-weight: 700; font-size: 0.95rem;
  box-shadow: 0 3px 10px rgba(40,40,50,0.05);
  transition: transform 0.1s, border-color 0.15s, background 0.15s, color 0.15s;
}
.chip:hover { transform: translateY(-2px); }
.chip .chip-ico { width: 1.25em; height: 1.25em; display: inline-flex; align-items: center; justify-content: center; }
.chip .chip-ico svg { width: 100%; height: 100%; }
.chip-pinyin { font-size: 0.72rem; color: var(--green-ink); font-weight: 700; }
.chip-count { font-size: 0.78rem; opacity: 0.6; }
.chip.active { color: #fff; border-color: transparent; }
.chip.active .chip-pinyin { color: rgba(255,255,255,0.9); }

/* 面包屑导航 */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; justify-content: center; min-height: 24px; }
.crumb {
  font-family: var(--font); cursor: pointer; border: none; background: transparent;
  color: var(--green-ink); font-weight: 800; font-size: 0.98rem;
  padding: 4px 8px; border-radius: 8px; transition: background 0.15s;
}
.crumb:last-child { color: var(--ink); }
.crumb:hover { background: #e6f5ec; }
.crumb-sep { color: #b9b9c4; font-weight: 700; }

/* 分层瓷砖（目 / 科 / 属） */
.drill-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.drill-tile {
  position: relative; cursor: pointer; display: flex; align-items: center; gap: 14px;
  background: var(--paper); border-radius: 16px; padding: 16px 44px 16px 16px;
  box-shadow: var(--shadow); border: 1px solid var(--line); border-left: 6px solid var(--c, var(--green));
  transition: transform 0.14s, box-shadow 0.14s;
}
.drill-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.drill-tile:focus-visible { outline: 3px dashed var(--blue); outline-offset: 2px; }
.tile-ico { font-size: 2rem; width: 2.4rem; text-align: center; flex-shrink: 0; }
.tile-ico svg { width: 2rem; height: 2rem; }
.tile-main { min-width: 0; flex: 1; }
.tile-title { font-size: 1.15rem; font-weight: 900; line-height: 1.25; }
.tile-latin { font-style: italic; font-weight: 500; color: var(--muted); font-size: 0.85rem; }
.tile-pinyin { color: var(--green-ink); font-weight: 700; font-size: 0.82rem; }
.tile-sub { color: var(--muted); font-size: 0.86rem; margin-top: 2px; }
.tile-badge { color: #fff; font-weight: 800; font-size: 0.78rem; padding: 3px 10px; border-radius: 999px; flex-shrink: 0; }
.tile-arrow { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: #c3c3cd; font-size: 1.5rem; font-weight: 700; }

.result-meta { text-align: center; color: var(--muted); font-weight: 700; margin: 14px 0 16px; font-size: 0.95rem; }
.empty-hint { text-align: center; color: var(--muted); padding: 30px; font-size: 1.1rem; }

/* ---------- 物种卡片 ---------- */
.card-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.bug-card {
  position: relative; cursor: pointer; overflow: hidden;
  background: var(--paper); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--line);
  transition: transform 0.16s, box-shadow 0.16s;
}
.bug-card:hover { transform: translateY(-7px); box-shadow: var(--shadow-lg); }
.bug-card:hover .vis-img { transform: scale(1.06); }
.bug-card:focus-visible { outline: 3px dashed var(--blue); outline-offset: 3px; }

/* 卡片顶部大图横幅 */
.bug-banner { position: relative; height: 188px; background: var(--c, #eee); }
.bug-banner .vis { border-radius: 0; }
.bug-order-badge {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  font-size: 0.74rem; font-weight: 800; color: #fff;
  padding: 4px 11px; border-radius: 999px;
  background: var(--c, var(--green));
  box-shadow: 0 2px 8px rgba(0,0,0,0.28);
}
.bug-body { padding: 14px 16px 16px; }
.bug-name { font-size: 1.3rem; font-weight: 900; line-height: 1.2; }
.bug-pinyin { color: var(--green-ink); font-weight: 700; font-size: 0.82rem; }
.bug-sci { color: var(--muted); font-style: italic; font-size: 0.82rem; margin-top: 2px; word-break: break-word; }
.bug-tag {
  margin-top: 10px; font-size: 0.9rem; font-weight: 700; color: #4a4a58;
  background: #f4f6f2; border-radius: 12px; padding: 9px 12px;
}
.bug-more { margin-top: 10px; text-align: right; font-size: 0.82rem; font-weight: 800; color: var(--blue); }

/* 照片 / 图标通用容器 */
.vis { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; background: #eef1ec; }
.vis-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 3.4rem; }
.vis-fallback svg { width: 56px; height: 56px; }
.vis-fallback.big { font-size: 4.6rem; }
.vis-fallback.big svg { width: 80px; height: 80px; }
.vis-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s ease; }

/* ---------- 变态发育 ---------- */
.meta-row { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.meta-card { background: var(--paper); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); border-top: 6px solid var(--c); }
.meta-type { font-size: 1.35rem; font-weight: 900; }
.meta-type .meta-pinyin { display: block; font-size: 0.8rem; color: var(--green-ink); font-weight: 700; }
.meta-stages { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0; }
.meta-stage { background: #f4f6f2; border-radius: 12px; padding: 8px 12px; font-weight: 800; font-size: 0.95rem; }
.meta-arrow { color: var(--c); font-weight: 900; }
.meta-note { color: #4a4a58; }
.meta-examples { margin-top: 12px; font-size: 0.92rem; color: var(--muted); font-weight: 700; }

/* ---------- 身体结构 ---------- */
.body-row { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.body-part { background: var(--paper); border-radius: var(--radius); padding: 24px; text-align: center; box-shadow: var(--shadow); border-top: 6px solid var(--green); }
.body-emoji { font-size: 2.6rem; }
.body-name { font-size: 1.35rem; font-weight: 900; margin-top: 4px; }
.body-pinyin { color: var(--green-ink); font-weight: 700; font-size: 0.82rem; }
.body-desc { margin-top: 8px; color: #4a4a58; }

/* ---------- 昆虫之最 ---------- */
.record-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.record-card { background: var(--paper); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: flex-start; }
.record-emoji { font-size: 2.2rem; line-height: 1; flex-shrink: 0; }
.record-title { font-weight: 900; font-size: 1.1rem; }
.record-who { color: var(--green-ink); font-weight: 800; font-size: 0.92rem; }
.record-detail { color: #4a4a58; font-size: 0.95rem; margin-top: 2px; }

/* ---------- 名词词典 ---------- */
.glossary-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.gloss-card { background: var(--paper); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow); border-left: 5px solid var(--teal); }
.gloss-term { font-size: 1.15rem; font-weight: 900; }
.gloss-pinyin { color: var(--green-ink); font-weight: 700; font-size: 0.82rem; margin-left: 6px; }
.gloss-def { color: #4a4a58; margin-top: 4px; font-size: 0.96rem; }

/* ---------- 测验 ---------- */
.quiz-box { max-width: 640px; margin: 0 auto; background: var(--paper); border-radius: var(--radius); padding: 30px 26px; box-shadow: var(--shadow); text-align: center; }
.quiz-progress { font-weight: 800; color: var(--green-ink); margin-bottom: 6px; }
.quiz-bar { height: 8px; background: #eee; border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.quiz-bar > span { display: block; height: 100%; background: var(--green); transition: width 0.3s; }
.quiz-q { font-size: 1.3rem; font-weight: 900; margin: 6px 0 20px; }
.quiz-options { display: grid; gap: 11px; }
.quiz-opt {
  font-family: var(--font); font-size: 1.08rem; font-weight: 700;
  background: #f3f6f4; color: var(--ink); border: 2px solid transparent;
  border-radius: 14px; padding: 13px 16px; cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.quiz-opt:hover:not(:disabled) { transform: translateY(-2px); background: #e6f5ec; }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.correct { background: #d6f5e0; border-color: var(--green); }
.quiz-opt.wrong { background: #ffd9d9; border-color: #ff6b5e; }
.quiz-tip { margin-top: 16px; min-height: 1.5em; color: var(--green-ink); font-weight: 700; }
.quiz-next { margin-top: 16px; font-family: var(--font); background: var(--green); color: #fff; border: none; cursor: pointer; font-weight: 800; font-size: 1.04rem; padding: 12px 30px; border-radius: 999px; box-shadow: var(--shadow); transition: transform 0.1s, filter 0.15s; }
.quiz-next:hover { transform: translateY(-2px); filter: brightness(1.05); }
.quiz-next[hidden] { display: none; }
.quiz-result { font-size: 1.3rem; font-weight: 900; }
.quiz-stars { font-size: 2.4rem; margin: 12px 0; letter-spacing: 4px; }

/* ---------- 页脚 ---------- */
.footer { text-align: center; padding: 40px 22px; background: var(--green-ink); color: #eafff3; }
.footer .tiny { font-size: 0.88rem; opacity: 0.85; margin-top: 6px; }

/* ---------- 物种弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(40,40,50,0.55); padding: 18px; animation: fade 0.2s ease; }
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card { position: relative; background: var(--cream); width: min(600px, 100%); max-height: 90vh; overflow-y: auto; border-radius: 24px; box-shadow: 0 24px 64px rgba(0,0,0,0.34); animation: pop 0.25s cubic-bezier(.2,.9,.3,1.4); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close { position: absolute; top: 14px; right: 14px; z-index: 3; width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer; font-size: 1.05rem; font-weight: 900; background: #fff; color: var(--ink); box-shadow: var(--shadow); transition: transform 0.1s, background 0.15s; }
.modal-close:hover { transform: rotate(90deg); background: var(--pink); color: #fff; }

.modal-hero { text-align: center; padding: 26px 24px 20px; color: #fff; border-radius: 24px 24px 0 0; }
.modal-photo {
  width: 130px; height: 130px; margin: 0 auto 12px;
  border-radius: 22px; overflow: hidden;
  border: 4px solid rgba(255,255,255,0.9);
  box-shadow: 0 10px 26px rgba(0,0,0,0.28);
}
.modal-photo .vis { border-radius: 0; background: rgba(255,255,255,0.18); }
.modal-name { font-size: 2rem; font-weight: 900; margin-top: 4px; }
.modal-pinyin { font-weight: 700; opacity: 0.95; }
.modal-alias { font-size: 0.95rem; opacity: 0.92; margin-top: 2px; }
.modal-credit { font-size: 0.74rem; opacity: 0.9; margin-top: 10px; }

/* 弹窗顶部大图横幅（可点击放大） */
.modal-photobar {
  display: block; position: relative; width: 100%; height: 240px;
  border: none; padding: 0; margin: 0; cursor: zoom-in; background: #eef1ec;
}
.modal-photobar .vis { height: 100%; }
.modal-photobar:hover .vis-img { transform: scale(1.04); }
.zoom-hint {
  position: absolute; right: 12px; bottom: 12px;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 0.78rem; font-weight: 700;
  padding: 5px 12px; border-radius: 999px; pointer-events: none;
}

/* 在大自然里的角色 */
.role-box {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 16px;
  background: #eafaf0; border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow); border-left: 5px solid var(--green);
}
.role-ico { font-size: 1.4rem; line-height: 1.2; }
.role-lbl { font-weight: 900; color: var(--green-ink); font-size: 0.9rem; }

/* 图片放大灯箱 */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.88); padding: 24px; animation: fade 0.2s ease;
}
.lightbox[hidden] { display: none; }
.lightbox-fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 100%; }
.lightbox-fig img { max-width: 92vw; max-height: 78vh; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); object-fit: contain; background: #222; }
.lightbox-fig figcaption { color: #fff; font-size: 0.95rem; text-align: center; }
.lightbox-fig figcaption em { color: #cfe4ff; }
.lightbox-close {
  position: fixed; top: 18px; right: 18px; width: 46px; height: 46px; border-radius: 50%;
  border: none; cursor: pointer; font-size: 1.2rem; font-weight: 900; color: #222; background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.modal-body { padding: 22px 24px 30px; }

.taxonomy { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 6px; }
.tax-pill { background: #fff; border-radius: 999px; padding: 5px 14px; font-weight: 800; font-size: 0.86rem; box-shadow: var(--shadow); }
.tax-pill .tax-lbl { color: var(--muted); font-weight: 700; margin-right: 4px; }
.sci-line { text-align: center; font-style: italic; color: var(--muted); margin: 10px 0 4px; font-size: 1.02rem; }

.modal-intro { margin: 16px 0; font-size: 1.06rem; background: #fff; padding: 16px 18px; border-radius: 16px; box-shadow: var(--shadow); }
.modal-section-h { font-weight: 900; font-size: 1.08rem; margin: 18px 0 8px; }
.fact-list { list-style: none; display: grid; gap: 10px; }
.fact-list li { background: #fff; border-radius: 14px; padding: 12px 14px 12px 40px; box-shadow: var(--shadow); position: relative; }
.fact-list li::before { content: "💡"; position: absolute; left: 12px; top: 12px; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-box { background: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.mini-box .lbl { font-weight: 900; color: var(--green-ink); font-size: 0.86rem; }
.power-badge { margin-top: 18px; text-align: center; background: linear-gradient(120deg, var(--amber), var(--pink)); color: #4a2a30; font-weight: 900; font-size: 1.06rem; padding: 14px; border-radius: 16px; box-shadow: var(--shadow); }
@media (max-width: 460px) { .mini-grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto; } }
