/* style.css — 等高线地形图交互教学系统 */
:root {
  --bg: #f3f0e8;
  --panel: #fdfcf8;
  --ink: #33302a;
  --ink2: #6f6a5c;
  --line: #e3ddcd;
  --accent: #3a7d44;
  --accent2: #1f6feb;
  --warn: #e2492f;
  --radius: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; color: var(--ink); }

#app {
  display: grid;
  height: 100%;
  grid-template-rows: 50px 1fr 54px;
  grid-template-columns: 292px 1fr 312px;
  grid-template-areas:
    "top top top"
    "left mid right"
    "btm btm btm";
}

/* ================= 顶栏 ================= */
#topbar {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between;
  background: #2f3b33;
  color: #f4f1e6;
  padding: 0 14px;
  z-index: 40;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; }
.brand { display: flex; align-items: baseline; gap: 8px; font-size: 16px; }
.brand b { font-weight: 700; letter-spacing: 1px; }
.brand-sub { font-size: 11px; opacity: .65; }
.pill-btn {
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.08);
  color: #f4f1e6;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  transition: background .15s;
}
.pill-btn:hover { background: rgba(255,255,255,.2); }
.icon-btn {
  border: none; background: transparent; color: inherit;
  font-size: 17px; line-height: 1;
  width: 34px; height: 34px; border-radius: 8px;
}
.icon-btn:hover { background: rgba(128,128,128,.18); }

/* ================= 侧栏通用 ================= */
#left-panel, #right-panel {
  background: var(--panel);
  overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
  z-index: 30;
}
#left-panel { grid-area: left; border-right: 1px solid var(--line); }
#right-panel { grid-area: right; border-left: 1px solid var(--line); }

#left-panel section, #right-panel section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
h3 { font-size: 14px; margin-bottom: 10px; display: flex; align-items: baseline; justify-content: space-between; }
.h3-sub { font-size: 11px; color: var(--ink2); font-weight: 400; }

/* ================= 地形按钮网格 ================= */
#terrain-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.terrain-btn {
  border: 1px solid var(--line);
  background: #faf8f2;
  border-radius: 8px;
  padding: 7px 2px 5px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px;
  transition: all .15s;
}
.terrain-btn .ti { font-size: 19px; }
.terrain-btn:hover { border-color: var(--accent); background: #f2f7ee; }
.terrain-btn.on {
  border-color: var(--accent);
  background: #e8f3e6;
  box-shadow: 0 0 0 1px var(--accent) inset;
  font-weight: 700;
}

/* ================= 分段按钮 ================= */
.seg { display: flex; background: #edeae0; border-radius: 9px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1;
  border: none; background: transparent;
  border-radius: 7px;
  padding: 7px 4px;
  font-size: 13px;
  color: var(--ink2);
}
.seg button.on { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.small button { padding: 6px 4px; font-size: 12px; }

.tool-box { margin-top: 10px; }
.tip { font-size: 12px; color: var(--ink2); line-height: 1.55; margin-top: 8px; }

.wide-btn {
  width: 100%;
  border: 1px solid var(--line);
  background: #faf8f2;
  border-radius: 8px;
  padding: 9px;
  font-size: 14px;
}
.wide-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.wide-btn:hover { filter: brightness(1.05); }

.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--ink2);
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.ghost-btn.wide { width: 100%; margin-top: 10px; }

.row-btns { display: flex; gap: 8px; margin-top: 10px; }
.row-btns .ghost-btn { flex: 1; }

/* ================= 滑杆行 ================= */
.row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink2);
  margin: 9px 0;
}
.row > input[type=range] { flex: 1; accent-color: var(--accent); min-width: 0; }
.row select {
  flex: 1; border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 6px; background: #fff; font-size: 13px;
}
.rv { min-width: 52px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }

.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink2); margin: 8px 0; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; }

.light-box { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 6px; }
.light-box summary { font-size: 13px; cursor: pointer; color: var(--ink); }

/* ================= 中央视口 ================= */
#viewport {
  grid-area: mid;
  position: relative;
  overflow: hidden;
  background: linear-gradient(#aed4ee 0%, #cfe6f2 45%, #e9efdd 100%);
}
#viewport canvas { display: block; }

#hint-bar {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  max-width: 86%;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 999px;
  padding: 7px 18px;
  font-size: 13px;
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(30,50,40,.12);
  pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#elev-hud {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  background: rgba(47,59,51,.82);
  color: #fff;
  font-size: 12px;
  border-radius: 999px;
  padding: 4px 14px;
  pointer-events: none;
}

#morph-badge {
  position: absolute; top: 10px; left: 12px;
  display: none;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 8px;
  padding: 6px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

#legend {
  position: absolute; left: 12px; bottom: 12px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 10px;
  padding: 8px 12px;
  width: 190px;
  pointer-events: none;
}
.lg-title { font-size: 11px; color: var(--ink2); margin-bottom: 5px; }
.lg-bar { height: 10px; border-radius: 5px; border: 1px solid rgba(0,0,0,.15); }
.lg-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink); margin-top: 3px; font-variant-numeric: tabular-nums; }
.lg-note { font-size: 10.5px; color: var(--ink2); margin-top: 2px; }

/* ================= 右侧数据卡 ================= */
.desc { font-size: 12.5px; line-height: 1.7; color: var(--ink); }
.keypoint {
  margin-top: 8px;
  font-size: 12.5px; line-height: 1.6;
  background: #eef5e9;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 8px 10px;
}
.example { margin-top: 8px; font-size: 12px; color: var(--ink2); }

.kv { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.kv td { padding: 5px 2px; border-bottom: 1px dashed var(--line); }
.kv td:first-child { color: var(--ink2); width: 42%; }
.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.kv tr:last-child td { border-bottom: none; }

.empty {
  font-size: 12.5px; color: var(--ink2);
  background: #faf8f2; border: 1px dashed var(--line);
  border-radius: 8px; padding: 14px 10px;
  text-align: center; line-height: 1.6;
}
#cr-canvas { width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.note { font-size: 11.5px; color: var(--ink2); line-height: 1.6; margin-top: 8px; }

/* ================= 底部控制栏 ================= */
#bottom-bar {
  grid-area: btm;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 0 12px;
  z-index: 35;
  overflow-x: auto;
}
.ctl-btn {
  border: 1px solid var(--line);
  background: #faf8f2;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  white-space: nowrap;
  transition: all .15s;
}
.ctl-btn:hover { border-color: var(--accent); color: var(--accent); }
.ctl-btn.on { background: #e8f3e6; border-color: var(--accent); color: var(--accent); font-weight: 700; }
.ctl-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.ctl-btn.accent:hover { color: #fff; filter: brightness(1.08); }
.speed-box { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink2); white-space: nowrap; }
.speed-box input { width: 90px; accent-color: var(--accent); }
#bottom-bar .chk { margin: 0; white-space: nowrap; }

/* ================= 弹窗 ================= */
#modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(30, 40, 34, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 18px;
}
#modal {
  background: var(--panel);
  border-radius: 14px;
  width: min(680px, 94vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 18px 60px rgba(0,0,0,.3);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.modal-body { padding: 16px 18px; overflow-y: auto; line-height: 1.75; font-size: 13.5px; }
.modal-body p { margin-bottom: 10px; }

.gd-step { display: flex; gap: 12px; margin-bottom: 14px; align-items: flex-start; }
.gd-icon { font-size: 24px; }
.gd-step b { font-size: 13.5px; color: var(--accent); }
.gd-step p { margin: 2px 0 0; color: var(--ink); }
.gd-tip { background: #eef5e9; border-radius: 8px; padding: 10px 12px; }

.kn-cur { background: #eef5e9; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.kn-cur b { font-size: 15px; }
.kn-cur p { margin-top: 6px; }
.kn-cur .kn-play { margin-top: 10px; }
.kn-key { color: var(--accent); font-weight: 600; }
.kn-body { padding: 10px 14px 14px; }
.kn-body p { padding: 0; }
.kn-body .kn-play { margin-top: 8px; }
.kn-item { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fff; }
.kn-item summary { padding: 11px 14px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.kn-item[open] summary { border-bottom: 1px dashed var(--line); }
.kn-item > p { padding: 10px 14px; }
.kn-table { border-collapse: collapse; margin: 10px 14px 14px; font-size: 12.5px; width: calc(100% - 28px); }
.kn-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; }
.kn-table tr.head td { background: #edeae0; font-weight: 700; }

/* ================= 移动端 ================= */
.mobile-only { display: none !important; }
@media (max-width: 900px) {
  .mobile-only { display: flex !important; align-items: center; justify-content: center; }
  .brand b { font-size: 14px; }
  .brand-sub { display: none; }
  .pill-btn { padding: 6px 10px; font-size: 12px; }

  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 48px 1fr 52px;
    grid-template-areas: "top" "mid" "btm";
  }
  #left-panel, #right-panel {
    position: fixed;
    top: 48px; bottom: 52px;
    width: min(310px, 86vw);
    box-shadow: 0 8px 40px rgba(0,0,0,.25);
    transition: transform .25s ease;
  }
  #left-panel { left: 0; transform: translateX(-104%); }
  #right-panel { right: 0; transform: translateX(104%); }
  #left-panel.open, #right-panel.open { transform: translateX(0); }
  .panel-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 15px;
  }
  #hint-bar { font-size: 11.5px; padding: 6px 12px; top: 8px; }
  #legend { transform: scale(.85); transform-origin: left bottom; }
  #bottom-bar { gap: 6px; justify-content: flex-start; }
  .ctl-btn { padding: 7px 10px; font-size: 12px; }
  .speed-box input { width: 64px; }
}
