/* styles.css — Playful, colorful theme. Each section is a two-column panel:
   text on one side, its own inline 3D cube on the other. No shared sticky
   stage, so cubes stay put and don't distract while you read. */

:root {
  --bg: #fff7ef;
  --bg-2: #ffeede;
  --ink: #241b3a;
  --ink-soft: #5b5170;
  --paper: #ffffff;
  --line: #efe2d4;

  --red: #ff4757;
  --green: #2ed573;
  --blue: #1e90ff;
  --yellow: #ffc312;
  --orange: #ff9f1c;
  --purple: #7b5cff;

  --radius: 20px;
  --shadow: 0 14px 40px rgba(60, 40, 90, 0.10);
  --font-en: 'Nunito', 'Noto Sans SC', system-ui, sans-serif;
  --font-display: 'Baloo 2', 'Noto Sans SC', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-en);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 80% -10%, var(--bg-2), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, #ffe8f0, transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
:lang(zh) body { font-family: 'Noto Sans SC', var(--font-en); }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  z-index: 50;
  background: rgba(255, 247, 239, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 800; font-size: 1.12rem;
  color: var(--ink); text-decoration: none;
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: conic-gradient(from 45deg, var(--red), var(--yellow), var(--green), var(--blue), var(--red));
  box-shadow: inset 0 0 0 3px #fff; transform: rotate(8deg);
}
.nav { display: flex; gap: 18px; margin-left: auto; }
.nav a {
  color: var(--ink-soft); text-decoration: none; font-weight: 700; font-size: 0.92rem;
  padding: 6px 2px; border-bottom: 2px solid transparent; transition: color .2s, border-color .2s;
}
.nav a:hover { color: var(--ink); border-color: var(--purple); }
.lang-toggle {
  font-family: var(--font-display); font-weight: 700;
  border: 2px solid var(--ink); background: var(--ink); color: #fff;
  border-radius: 999px; padding: 6px 16px; cursor: pointer;
  transition: transform .15s, background .2s;
}
.lang-toggle:hover { transform: translateY(-1px); background: var(--purple); border-color: var(--purple); }

/* ---------- WebGL fallback banner ---------- */
.webgl-banner { display: none; }
body.no-webgl .webgl-banner {
  display: block;
  margin: 84px auto 0;
  max-width: 760px;
  padding: 16px 22px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
body.no-webgl .cube-stage { display: none; }

/* ---------- Layout ---------- */
.content { padding-top: 64px; }

.panel {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 86vh;
  padding: 8vh 5vw;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5%;
  align-items: center;
}
.panel:nth-child(even) .panel-text { order: 2; }
.panel:nth-child(even) .cube-stage { order: 1; }
.panel-wide { grid-template-columns: 1fr; }

.panel-text { min-width: 0; }

/* The inline cube panel. Sticks within its own section while you read it,
   then releases — calm, scoped motion instead of one ever-present cube. */
.cube-stage {
  position: sticky;
  top: 84px;
  height: min(60vh, 460px);
  border-radius: 26px;
  background:
    radial-gradient(120% 120% at 50% 0%, #ffffff, var(--bg-2) 90%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cube-stage canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.cube-stage canvas:active { cursor: grabbing; }

/* ---------- Type ---------- */
.kicker, .tag {
  font-family: var(--font-display); font-weight: 700; letter-spacing: .14em;
  font-size: 0.8rem; color: var(--purple); margin: 0 0 14px;
}
.tag { color: var(--orange); }
h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.1rem, 4vw, 3.3rem); line-height: 1.08; margin: 0 0 18px; letter-spacing: -.01em;
}
h2 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1.12; margin: 0 0 16px;
}
h3 { font-family: var(--font-display); font-weight: 700; margin: 0 0 6px; font-size: 1.12rem; }
.sub { margin-top: 28px; font-size: 1.25rem; }
.lede { font-size: 1.16rem; color: var(--ink-soft); max-width: 32em; }
.body { font-size: 1.02rem; color: var(--ink-soft); max-width: 34em; }

/* ---------- Buttons ---------- */
.btn-row { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.btn {
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
  padding: 11px 22px; border-radius: 999px; cursor: pointer;
  transition: transform .14s, box-shadow .2s, background .2s, color .2s;
  box-shadow: 0 3px 0 var(--ink);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--ink); }
.btn-primary { background: var(--red); color: #fff; border-color: #c81e2f; box-shadow: 0 3px 0 #c81e2f; }
.btn-primary:hover { box-shadow: 0 6px 0 #c81e2f; }
.btn-ghost { box-shadow: none; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { box-shadow: none; background: var(--bg-2); }
.btn-sm { font-size: 0.9rem; padding: 8px 16px; box-shadow: 0 2px 0 var(--ink); }
.btn-sm:hover { box-shadow: 0 4px 0 var(--ink); }

/* ---------- Anatomy cards ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 24px; }
.card {
  text-align: left; background: var(--paper); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 16px 14px; cursor: pointer;
  transition: transform .16s, border-color .2s, box-shadow .2s; font-family: var(--font-en);
}
.card h3 { font-size: 1rem; }
.card p { margin: 0; font-size: 0.86rem; color: var(--ink-soft); }
.card:nth-child(1).active { border-color: var(--yellow); box-shadow: var(--shadow); }
.card:nth-child(2).active { border-color: var(--green); box-shadow: var(--shadow); }
.card:nth-child(3).active { border-color: var(--blue); box-shadow: var(--shadow); }
.card:hover { transform: translateY(-3px); }

/* ---------- Notation chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.chip {
  font-family: var(--font-display); font-weight: 800; font-size: 1.05rem;
  width: 46px; height: 46px; border-radius: 13px; border: 2px solid var(--ink);
  background: var(--paper); color: var(--ink); cursor: pointer; box-shadow: 0 3px 0 var(--ink);
  transition: transform .12s, box-shadow .12s, background .2s, color .2s;
}
.chip:hover { transform: translateY(-2px); background: var(--purple); color: #fff; }
.chip:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- Steps ---------- */
.steps { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 14px; }
.step {
  background: var(--paper); border: 2px solid var(--line); border-left: 6px solid var(--green);
  border-radius: var(--radius); padding: 16px 18px;
}
.step:nth-child(1) { border-left-color: var(--blue); }
.step:nth-child(2) { border-left-color: var(--green); }
.step:nth-child(3) { border-left-color: var(--orange); }
.step:nth-child(4) { border-left-color: var(--red); }
.step p { margin: 4px 0 12px; color: var(--ink-soft); font-size: 0.95rem; }

/* ---------- Why notes ---------- */
.note {
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-top: 14px;
}
.note p { color: var(--ink-soft); margin: 4px 0 12px; }
.note:last-of-type p { margin-bottom: 0; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 26px; }
.stat { padding: 20px; background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius); }
.stat-num {
  display: block; font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.05;
  background: linear-gradient(90deg, var(--red), var(--orange), var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent; word-break: break-all;
}
.stat-god { font-size: clamp(2.4rem, 5vw, 3.6rem); }
.stat-label { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; display: block; margin-top: 4px; }
.stat p { color: var(--ink-soft); margin: 8px 0 0; font-size: 0.95rem; }

/* ---------- Footer ---------- */
.footer {
  max-width: 1180px; margin: 0 auto; padding: 6vh 5vw 12vh;
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px; color: var(--ink-soft);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .nav { display: none; }
  .panel {
    grid-template-columns: 1fr;
    gap: 22px;
    min-height: auto;
    padding: 7vh 7vw;
  }
  /* Cube above text on mobile, regardless of source order. */
  .panel .panel-text { order: 2; }
  .panel .cube-stage { order: 1; position: static; height: 46vh; }
  .cards { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
