/* Rubik's Cube Guide — light, bilingual knowledge page */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --border: #e3e6ee;
  --text: #161b26;
  --text-2: #4a5263;
  --text-3: #7a8293;
  --accent: #e85d04;
  --accent-soft: #fff1e6;
  --green: #009b48;
  --blue: #0046ad;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --font: 'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC', 'Microsoft YaHei', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --header-h: 60px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }

/* Language switching: only the active language is shown */
html[data-lang="en"] .zh, html[data-lang="zh"] .en { display: none !important; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1440px; height: 100%; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 30px; height: 30px; display: block; }
.top-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.top-nav::-webkit-scrollbar { display: none; }
.top-nav a {
  color: var(--text-2); font-size: .92rem; font-weight: 500; padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.top-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; min-width: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); font: 600 .85rem var(--font); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1440px; margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: 210px minmax(0, 1fr) 340px; gap: 32px;
}
.toc { position: sticky; top: calc(var(--header-h) + 20px); align-self: start; max-height: calc(100vh - var(--header-h) - 40px); overflow-y: auto; padding: 24px 0; }
.toc-title { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li a { display: block; padding: 4px 10px; border-left: 2px solid transparent; color: var(--text-2); font-size: .9rem; }
.toc li a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.toc li a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc li.sub a { padding-left: 22px; font-size: .84rem; }
main { min-width: 0; padding: 24px 0 64px; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #fff 0%, #fff7f0 55%, #eef6ff 100%);
  border: 1px solid var(--border); border-radius: 20px; padding: 36px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: center;
}
.eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.hero h1 { font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.15; margin: 8px 0 10px; letter-spacing: -.02em; }
.hero .lead { font-size: 1.12rem; color: var(--text-2); margin: 0 0 12px; font-weight: 500; }
.hero p { color: var(--text-2); margin: 0 0 18px; }
.hero-cubes { display: flex; align-items: flex-end; justify-content: center; gap: 10px; }
.hero-cubes .dg { flex: 1 1 0; }
.hero-cubes .dg:nth-child(2) { flex-grow: 1.35; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px;
  font-weight: 600; font-size: .95rem; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #d35400; }

.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.quick {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease;
}
.quick:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.quick strong { display: block; font-size: .98rem; }
.quick span.meta { display: block; color: var(--text-3); font-size: .83rem; line-height: 1.45; margin-top: 2px; }

.tip {
  display: flex; gap: 10px; align-items: flex-start; margin: 18px 0 0; padding: 12px 14px;
  background: var(--accent-soft); border: 1px solid #ffd8b8; border-radius: 12px; color: #7a3300; font-size: .92rem;
}

/* ---------- Sections ---------- */
section.chapter { margin-top: 48px; }
.chapter-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.chapter-num {
  flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--text); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .95rem; transform: translateY(-4px);
}
h2 { font-size: 1.75rem; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 1.25rem; margin: 32px 0 8px; }
h4 { font-size: 1.05rem; margin: 22px 0 6px; }
.chapter > p.intro { color: var(--text-2); font-size: 1.03rem; margin: 8px 0 18px; }
p { margin: 0 0 12px; }
ul.plain { margin: 0 0 12px; padding-left: 1.2em; }
ul.plain li { margin: 4px 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-top: 16px; }
.card > h3:first-child, .card > h4:first-child { margin-top: 0; }

.memo {
  border-left: 3px solid var(--green); background: #effaf3; border-radius: 0 10px 10px 0;
  padding: 10px 14px; margin: 12px 0; font-size: .93rem; color: #1f4d33;
}
.memo b { color: #0f3d24; }
.note { border-left: 3px solid var(--blue); background: #eef4ff; border-radius: 0 10px 10px 0; padding: 10px 14px; margin: 12px 0; font-size: .93rem; color: #1b3157; }

/* Step strip with stage images */
.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px; margin: 14px 0 6px; }
.stage { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 10px 10px; text-align: center; }
.stage .dg { width: 84px; margin: 0 auto 6px; }
.stage .n { font-size: .72rem; font-weight: 700; color: var(--accent); letter-spacing: .06em; }
.stage .t { font-size: .9rem; font-weight: 600; line-height: 1.35; }
.stage .d { font-size: .8rem; color: var(--text-3); line-height: 1.4; margin-top: 2px; }

/* Algorithm chips */
.alg {
  display: inline-flex; align-items: center; gap: 8px; margin: 2px 2px; padding: 4px 10px 4px 6px;
  background: #101522; color: #f7f8fb; border: 0; border-radius: 9px; cursor: pointer;
  font: 500 .9rem/1.5 var(--mono); text-align: left; vertical-align: middle; max-width: 100%;
  transition: background .15s ease, transform .1s ease;
}
.alg:hover { background: #26304a; }
.alg:active { transform: scale(.98); }
.alg.playing { background: var(--accent); }
.alg .play {
  flex: none; width: 20px; height: 20px; border-radius: 6px; background: rgba(255, 255, 255, .14);
  display: inline-flex; align-items: center; justify-content: center;
}
.alg .play svg { width: 10px; height: 10px; fill: currentColor; }
.alg code { font: inherit; white-space: normal; word-break: break-word; }
.alg-label { font-weight: 600; }
.case-list { list-style: none; padding: 0; margin: 8px 0 0; }
.case-list > li { padding: 12px 0; border-top: 1px dashed var(--border); }
.case-list > li:first-child { border-top: 0; }
.case-list .case-title { font-weight: 600; }
.case-row { display: flex; gap: 14px; align-items: flex-start; }
.case-row .dg { flex: none; width: 92px; }
.case-row .body { min-width: 0; flex: 1; }
.case-group { margin-top: 18px; }
.case-group > .g-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }

/* Grid of cases with diagrams (OLL / PLL) */
.alg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }
.alg-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.alg-card .dg { width: 100px; margin: 0 auto; }
.alg-card .name { font-weight: 600; font-size: .92rem; line-height: 1.35; }
.alg-card .hint { font-size: .82rem; color: var(--text-3); line-height: 1.45; }
.alg-card .alg { align-self: flex-start; }

/* Notation table */
.colors { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 14px; }
.swatch { display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 5px; font-size: .9rem; font-weight: 500; }
.swatch i { width: 20px; height: 20px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .18); display: inline-block; }
.moves { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 10px 0; }
.moves .alg { justify-content: flex-start; margin: 0; }
.moves .alg small { font-family: var(--font); opacity: .7; font-size: .76rem; }
table.notation { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: .93rem; }
table.notation td { padding: 7px 10px; border-top: 1px solid var(--border); vertical-align: top; }
table.notation td:first-child { white-space: nowrap; font-family: var(--mono); font-weight: 600; width: 1%; }

details.more { margin-top: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px; }
details.more summary { cursor: pointer; font-weight: 600; }
details.more ol { margin: 10px 0 4px; padding-left: 1.4em; font-size: .92rem; }
details.more li { margin: 4px 0; }

.resources { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.resource { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; color: var(--text); box-shadow: var(--shadow); }
.resource:hover { text-decoration: none; border-color: #c7cddb; }
.resource strong { display: block; color: var(--blue); }
.resource span { display: block; font-size: .9rem; color: var(--text-2); margin-top: 4px; line-height: 1.55; }

/* Diagrams */
.dg svg { display: block; width: 100%; height: auto; }

/* ---------- Player dock ---------- */
.dock { position: sticky; top: calc(var(--header-h) + 20px); align-self: start; padding: 24px 0; }
.dock-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 16px; }
.dock-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dock-title { font-weight: 700; font-size: .98rem; line-height: 1.3; }
.dock-sub { font-size: .78rem; color: var(--text-3); }
.dock-alg { font: 500 .88rem/1.5 var(--mono); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; margin: 10px 0 4px; min-height: 2.2em; word-break: break-word; }
.dock-player { height: 280px; display: flex; align-items: center; justify-content: center; }
.dock-player twisty-player { width: 100%; height: 280px; }
.dock-empty { color: var(--text-3); font-size: .9rem; text-align: center; padding: 0 12px; }
.dock-close { display: none; }
.dock-hint { font-size: .8rem; color: var(--text-3); margin-top: 8px; line-height: 1.5; }

footer.site-footer { border-top: 1px solid var(--border); margin-top: 24px; padding: 28px 20px 40px; text-align: center; color: var(--text-3); font-size: .88rem; }
footer.site-footer a { color: var(--text-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .toc { display: none; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .dock {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 50; padding: 0;
    transform: translateY(110%); transition: transform .25s ease;
  }
  .dock.open { transform: none; }
  .dock-card { border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(16, 24, 40, .18); padding: 12px 16px 16px; }
  .dock-player, .dock-player twisty-player { height: 230px; }
  .dock-close { display: inline-flex; }
  .dock-hint { display: none; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .header-inner { gap: 10px; padding: 0 12px; }
  .brand-text { display: none; }
  .layout { padding: 0 16px; }
  .hero { grid-template-columns: 1fr; padding: 24px 20px; }
  .hero-cubes { order: -1; max-width: 340px; margin: 0 auto; }
  .card { padding: 18px 16px; }
  .case-row { flex-direction: column; }
  .case-row .dg { width: 84px; }
  h2 { font-size: 1.5rem; }
}
