/* ==========================================================================
   ABM for Kids — 共用样式
   目标：把 NetLogo 那种 90 年代 Swing 界面，换成孩子愿意点、家长愿意看的界面。
   设计要点：大圆角、柔和阴影、鲜艳但不刺眼、控件足够大（触摸友好）。
   ========================================================================== */

:root {
  --bg: #eef1ff;
  --bg-2: #ffffff;
  --fg: #0f172a;
  --fg-soft: #475467;
  --muted: #7b8794;
  --line: #e4e7ec;
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #ffffff;
  --brand: #5b5bf5;
  --brand-2: #a855f7;
  --brand-soft: rgba(91, 91, 245, 0.12);
  --accent: #f59e0b;
  --ok: #10b981;
  --danger: #ef4444;
  --shadow-sm: 0 2px 8px -2px rgba(15, 23, 42, 0.12);
  --shadow: 0 18px 40px -22px rgba(15, 23, 42, 0.45);
  --radius: 22px;
  --radius-sm: 14px;
}

html[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg-2: #121829;
  --fg: #eef2ff;
  --fg-soft: #b6c0d4;
  --muted: #8b96ad;
  --line: #253048;
  --card: rgba(23, 30, 49, 0.78);
  --card-solid: #141b2d;
  --brand: #7c7cff;
  --brand-2: #c084fc;
  --brand-soft: rgba(124, 124, 255, 0.16);
  --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  color: var(--fg);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(168, 85, 247, 0.22), transparent 60%),
    radial-gradient(1000px 500px at 95% 0%, rgba(56, 189, 248, 0.20), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(14px, 3vw, 28px);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 88%, transparent), transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.2px;
  text-decoration: none;
}

.brand .logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 18px;
  box-shadow: var(--shadow-sm);
}

.spacer { flex: 1; }

.back-link {
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-soft);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  transition: transform 0.15s ease, color 0.15s ease;
}
.back-link:hover { transform: translateY(-1px); color: var(--fg); }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.icon-btn:hover { transform: translateY(-1px); }

/* ---------------------------------------------------------------- 首页 */

.home {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(8px, 2vw, 20px) clamp(14px, 3vw, 28px) 60px;
}

.hero { padding: 26px 0 30px; }

.hero h1 {
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.12;
  margin: 0 0 14px;
  letter-spacing: -0.5px;
}

.hero h1 .grad {
  background: linear-gradient(100deg, var(--brand), var(--brand-2), #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  font-size: clamp(15px, 1.8vw, 18px);
  color: var(--fg-soft);
  max-width: 62ch;
  line-height: 1.7;
  margin: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 8px;
}

.card {
  position: relative;
  display: block;
  text-decoration: none;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-4px); }

.card .thumb {
  height: 116px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  display: grid;
  place-items: center;
  font-size: 40px;
  background: linear-gradient(135deg, var(--brand-soft), transparent 70%), var(--bg-2);
  border: 1px solid var(--line);
}

.card h3 { margin: 0 0 6px; font-size: 18px; }
.card p { margin: 0; color: var(--fg-soft); font-size: 14px; line-height: 1.6; }

.card .tag {
  display: inline-block;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}

.card.soon { opacity: 0.55; pointer-events: none; }
.card.soon .tag { background: rgba(125, 135, 150, 0.16); color: var(--muted); }

.section-title {
  margin: 44px 0 14px;
  font-size: 19px;
  font-weight: 800;
}

.notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.note {
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg-soft);
}
.note b { color: var(--fg); display: block; margin-bottom: 4px; }

/* ---------------------------------------------------------------- 仿真页布局 */

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 clamp(10px, 2vw, 22px) clamp(10px, 2vw, 18px);
}

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

@media (max-width: 900px) {
  .app { height: auto; min-height: 100dvh; }
  .stage { grid-template-columns: 1fr; }
}

.canvas-wrap {
  position: relative;
  min-height: 320px;
  height: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    radial-gradient(900px 420px at 50% 0%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 65%),
    var(--bg-2);
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 900px) {
  .canvas-wrap { height: 62vh; }
}

.canvas-wrap canvas { display: block; width: 100%; height: 100%; }

.hud {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.chip {
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--card-solid) 82%, transparent);
  border: 1px solid var(--line);
  color: var(--fg-soft);
  backdrop-filter: blur(8px);
}
.chip b { color: var(--fg); font-variant-numeric: tabular-nums; }

.hint {
  position: absolute;
  left: 14px;
  bottom: 12px;
  right: 14px;
  font-size: 12.5px;
  color: var(--muted);
  pointer-events: none;
  text-shadow: 0 1px 0 var(--bg-2);
}

/* ---------------------------------------------------------------- 控制面板 */

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding-right: 2px;
}

.block {
  padding: 15px 16px 17px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}

.block h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}

.ctrl { display: block; margin-bottom: 15px; }
.ctrl:last-child { margin-bottom: 0; }

.ctrl-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 600;
}
.ctrl-head .unit { font-size: 12px; color: var(--muted); font-weight: 500; }

.ctrl-head output {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 9px;
  border-radius: 8px;
  font-size: 13px;
}

/* 又粗又好按的滑块 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: 3px solid var(--card-solid);
  box-shadow: 0 3px 10px -2px rgba(91, 91, 245, 0.7);
  transition: transform 0.12s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }

input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: 3px solid var(--card-solid);
  box-shadow: 0 3px 10px -2px rgba(91, 91, 245, 0.7);
}

.btn-row { display: flex; flex-wrap: wrap; gap: 9px; }

.btn {
  flex: 1 1 auto;
  min-width: 104px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-solid);
  color: var(--fg);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }

.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(91, 91, 245, 0.9);
}

.btn.warm {
  border-color: transparent;
  background: linear-gradient(135deg, #fb923c, var(--danger));
  color: #fff;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  margin-top: 12px;
}
.switch input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }

.legend { display: grid; gap: 8px; font-size: 13px; color: var(--fg-soft); }
.legend .row { display: flex; align-items: center; gap: 9px; }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.legend b { color: var(--fg); font-variant-numeric: tabular-nums; }

.gradbar {
  height: 10px;
  border-radius: 999px;
  margin: 4px 0 6px;
  background: linear-gradient(90deg, hsl(48 95% 58%), hsl(285 78% 62%));
}
.gradlabels {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

.chart-wrap {
  margin-top: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
  overflow: hidden;
}
.chart-wrap canvas { display: block; width: 100%; height: 150px; }

.tip {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
  margin: 10px 0 0;
}

kbd {
  font-family: inherit;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}
