/* ============================================================
   魔方层先法教程 — 样式系统
   明亮活泼 / 魔方六色 / 圆角 / 响应式
   ============================================================ */

:root {
  /* 魔方六色 */
  --cube-w: #fdfdfd;
  --cube-y: #ffd23f;
  --cube-r: #e8463a;
  --cube-o: #ff7a1a;
  --cube-b: #2d7dd2;
  --cube-g: #2bb673;
  --cube-x: #d9d4cc;          /* 未知 / 灰 */
  --cube-body: #211f1d;        /* 魔方塑料体 */

  /* 界面 */
  --bg: #fff9f0;
  --bg-soft: #fff3e2;
  --card: #ffffff;
  --ink: #2a2420;
  --ink-soft: #6f655c;
  --ink-faint: #a89c90;
  --line: #efe4d4;
  --line-strong: #e4d6c2;

  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --shadow-sm: 0 2px 6px rgba(80, 60, 30, .07);
  --shadow-md: 0 10px 30px -12px rgba(90, 65, 30, .25);
  --shadow-lg: 0 26px 60px -24px rgba(90, 65, 30, .38);

  --maxw: 920px;

  --font-zh: "Noto Sans SC", system-ui, sans-serif;
  --font-round: "Baloo 2", var(--font-zh);
  --font-mono: "Baloo 2", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-zh);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 通用文字 ---------- */
h1, h2, h3, h4 { font-weight: 800; line-height: 1.25; margin: 0; }
p { margin: 0 0 1em; text-wrap: pretty; }
a { color: var(--cube-b); }

.eyebrow {
  font-family: var(--font-round);
  font-weight: 700;
  letter-spacing: .14em;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.lead { font-size: 19px; color: var(--ink-soft); }

/* ============================================================
   顶栏导航
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 249, 240, .82);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 62px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-round);
  font-weight: 800;
  font-size: 18px;
  white-space: nowrap;
}
.brand .logo {
  width: 30px; height: 30px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  flex: none;
}
.brand .logo i {
  border-radius: 2.5px;
  display: block;
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, .14), inset 0 .5px .5px rgba(255, 255, 255, .3);
}

.topnav {
  margin-left: auto;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.topnav a:hover { background: var(--bg-soft); color: var(--ink); }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  padding: 70px 0 64px;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 70% at 82% 18%, rgba(255, 210, 63, .28), transparent 60%),
    radial-gradient(50% 60% at 12% 86%, rgba(45, 125, 210, .16), transparent 60%);
  pointer-events: none;
}
.hero .wrap {
  position: relative;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 40px;
  align-items: center;
}
.hero h1 {
  font-size: clamp(34px, 5.4vw, 56px);
  letter-spacing: -.01em;
  margin: 14px 0 18px;
}
.hero h1 .hl { color: var(--cube-r); }
.hero .lead { margin-bottom: 28px; max-width: 30ch; }

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  text-decoration: none;
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
a.pill:hover {
  transform: translateY(-1px);
  border-color: var(--ink-faint);
  box-shadow: var(--shadow-md);
}
.pill .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.hero-cube {
  display: flex;
  justify-content: center;
}

/* ============================================================
   魔方图：平面面
   ============================================================ */
/* 无贴纸式（stickerless）：彩色块直接拼合，无黑色底板，细缝 + 块状立体感 */
.face {
  --gap: 3px;
  display: inline-grid;
  gap: var(--gap);
}
.face.has-ring { gap: calc(var(--gap) * .9); }
.sticker {
  border-radius: 12%;
  aspect-ratio: 1;
  box-shadow:
    0 1.5px 3px rgba(75, 55, 25, .3),
    inset 0 -3px 4px rgba(0, 0, 0, .12),
    inset 0 2px 3px rgba(255, 255, 255, .35);
}
.sticker.s-w {
  background: var(--cube-w);
  box-shadow:
    0 1.5px 3px rgba(75, 55, 25, .22),
    inset 0 0 0 1px #e7ddca,
    inset 0 -3px 4px rgba(0, 0, 0, .05),
    inset 0 2px 3px rgba(255, 255, 255, .6);
}
.sticker.s-y { background: var(--cube-y); }
.sticker.s-r { background: var(--cube-r); }
.sticker.s-o { background: var(--cube-o); }
.sticker.s-b { background: var(--cube-b); }
.sticker.s-g { background: var(--cube-g); }
.sticker.s-x {
  background: var(--cube-x);
  box-shadow:
    0 1.5px 3px rgba(75, 55, 25, .18),
    inset 0 0 0 1px rgba(0, 0, 0, .04),
    inset 0 -3px 4px rgba(0, 0, 0, .07),
    inset 0 2px 3px rgba(255, 255, 255, .4);
}
/* 环（侧面贴纸）略小，暗示是侧面 */
.sticker.ring {
  border-radius: 12%;
  transform: scale(.82);
  opacity: .96;
}

/* 图组：前后对照 */
.diagram-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 22px;
  margin: 18px 0;
}
.diagram-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}
.diagram-cell .cap, .case .cap {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.case .cap { font-size: 12px; color: var(--ink-faint); }
.arrow-to {
  font-family: var(--font-round);
  font-size: 30px;
  font-weight: 800;
  color: var(--ink-faint);
  align-self: center;
}

/* ============================================================
   魔方图：等距 3D
   ============================================================ */
.iso {
  --s: 132px;
  width: calc(var(--s) * 1.74);
  height: calc(var(--s) * 1.62);
  perspective: 900px;
  flex: none;
}
.iso-cube {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(-26deg) rotateY(-37deg);
}
.iso-face {
  position: absolute;
  inset: 0;
  margin: auto;
  width: var(--s);
  height: var(--s);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2.5px;
  padding: 3px;
  background: var(--cube-body);
  /* 魔方外角为直角 */
  border-radius: 0;
  backface-visibility: hidden;
}
/* 3D 块面：缝隙阴影由底色透出，块本身只留内浮雕（3D 场景中不用外投影） */
.iso-face .sticker {
  border-radius: 12%;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .16), inset 0 2px 2px rgba(255, 255, 255, .28);
}
.iso-face.U { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); }
.iso-face.D { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); }
.iso-face.F { transform: translateZ(calc(var(--s) / 2)); }
.iso-face.B { transform: rotateY(180deg) translateZ(calc(var(--s) / 2)); }
.iso-face.R { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); }
.iso-face.L { transform: rotateY(-90deg) translateZ(calc(var(--s) / 2)); }
.iso-face.U .sticker { filter: brightness(1.06); }
.iso-face.R .sticker, .iso-face.L .sticker { filter: brightness(.9); }
.iso-face.D .sticker { filter: brightness(.82); }
.iso-face.B .sticker { filter: brightness(.86); }

.iso.spin .iso-cube {
  animation: isospin 18s linear infinite;
}
@keyframes isospin {
  from { transform: rotateX(-26deg) rotateY(-37deg); }
  to   { transform: rotateX(-26deg) rotateY(323deg); }
}
@media (prefers-reduced-motion: reduce) {
  .iso.spin .iso-cube { animation: none; }
}

/* ============================================================
   章节
   ============================================================ */
section, .step { scroll-margin-top: 50px; }

.band { padding: 56px 0; }
.band.alt { background: var(--bg-soft); }

.sec-head { max-width: 60ch; margin-bottom: 30px; }
.sec-head h2 { font-size: clamp(26px, 3.6vw, 36px); margin: 8px 0 12px; }
.sec-head p { color: var(--ink-soft); font-size: 17px; margin: 0; }

/* 基础卡片网格 */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.info-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 22px 22px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}
.info-card h3 { font-size: 19px; }
.info-card p { font-size: 14.5px; color: var(--ink-soft); margin: 0; }
.info-card .iso { --s: 96px; }

/* ============================================================
   记号图例
   ============================================================ */
.notation-wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 30px;
  align-items: start;
}
.ref-cube {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px 18px 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.ref-cube .iso { --s: 120px; margin: 0 auto 6px; }
.ref-cube .faces-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}
.ref-cube .faces-legend b { color: var(--ink); font-family: var(--font-round); }
.ref-cube .ref-top {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ref-top .cap { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }

.move-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.move-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 13px;
  box-shadow: var(--shadow-sm);
}
.move-card .note-mini { flex: none; }
.move-card .mc-text b {
  font-family: var(--font-round);
  font-size: 20px;
  display: block;
  line-height: 1.1;
}
.move-card .mc-text span { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }

.note-mini { width: 56px; height: 56px; }

.modifier-note {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}
.mod-chip {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 18px 10px 10px;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
}
.mod-chip .k {
  font-family: var(--font-round);
  font-weight: 800;
  background: var(--ink);
  color: #fff;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 16px;
}

/* ============================================================
   步骤
   ============================================================ */
.step {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 40px 0;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}
.step-badge {
  flex: none;
  width: 60px; height: 60px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: var(--font-round);
  font-weight: 800;
  font-size: 28px;
  color: #fff;
  box-shadow: var(--shadow-md);
}
.step-head .titles h3 { font-size: clamp(21px, 3vw, 27px); }
.step-head .titles .sub {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-faint);
  font-family: var(--font-round);
  letter-spacing: .06em;
}

.step-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 36px;
  align-items: start;
}
.step-body .prose p { font-size: 16px; }
.step-body .prose p:last-child { margin-bottom: 0; }
.step-visual {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

/* 七步路线图 */
.roadmap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 22px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 34px;
}
.rm-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background .15s, transform .15s;
}
.rm-cell:hover { background: var(--bg-soft); transform: translateY(-2px); }
.rm-label { display: flex; align-items: center; gap: 6px; }
.rm-num {
  font-family: var(--font-round);
  font-weight: 800;
  color: #fff;
  width: 20px; height: 20px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 12px;
  flex: none;
}
.rm-name { font-size: 13px; font-weight: 700; white-space: nowrap; }
.rm-name small { color: var(--ink-faint); font-weight: 600; margin-left: 2px; }
.rm-arrow {
  font-family: var(--font-round);
  font-weight: 800;
  color: var(--ink-faint);
  font-size: 18px;
}
@media (max-width: 860px) {
  .rm-arrow { display: none; }
}

/* 分情况图解 */
.cases {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.case {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}
.case .case-tag {
  align-self: flex-start;
  font-family: var(--font-round);
  font-weight: 800;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.case p { margin: 0; font-size: 13.5px; color: var(--ink-soft); }
.case p b { color: var(--ink); }

/* 公式 */
.algo {
  margin: 6px 0 4px;
}
.algo-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.algo-label .tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  white-space: nowrap;
}
.formula {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 14px;
  background: linear-gradient(180deg, #fffdf8, #fff6e8);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
}
.mv {
  font-family: var(--font-round);
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  min-width: 38px;
  height: 38px;
  padding: 0 11px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  letter-spacing: .02em;
}
/* 颜色按面 */
.mv[data-f="R"] { background: var(--cube-o); }
.mv[data-f="L"] { background: var(--cube-r); }
.mv[data-f="U"] { background: var(--cube-y); color: #5b4a17; text-shadow: none; }
.mv[data-f="D"] { background: var(--cube-w); color: #6f655c; }
.mv[data-f="F"] { background: var(--cube-g); }
.mv[data-f="B"] { background: var(--cube-b); }

.tip {
  display: flex;
  gap: 12px;
  background: #fff8e6;
  border: 1px solid #f3e1b0;
  border-radius: 14px;
  padding: 14px 16px;
  margin-top: 18px;
}
.tip .ic {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--cube-y);
  display: grid; place-items: center;
  font-size: 15px;
  margin-top: 1px;
}
.tip p { margin: 0; font-size: 14.5px; color: #6b5a30; }
.tip b { color: #4f4220; }

.callout-flip {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(100deg, #2d7dd2, #2bb673);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 8px 0 4px;
  box-shadow: var(--shadow-md);
}
.callout-flip .big { font-size: 30px; }
.callout-flip b { font-size: 17px; }
.callout-flip p { margin: 2px 0 0; font-size: 14px; opacity: .95; }

/* 重复提示 */
.repeat-note {
  font-size: 13px;
  color: var(--ink-soft);
  font-style: normal;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.repeat-note .loop { font-family: var(--font-round); font-weight: 800; }

/* ============================================================
   速查表
   ============================================================ */
.cheat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.cheat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.cheat-top h3 { font-size: 20px; }
.btn-print {
  font-family: var(--font-zh);
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .12s, background .15s;
}
.btn-print:hover { transform: translateY(-1px); background: #000; }

.cheat-table { width: 100%; border-collapse: collapse; }
.cheat-table th, .cheat-table td {
  text-align: left;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.cheat-table th {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
}
.cheat-table tr:last-child td { border-bottom: 0; }
.cheat-table .num {
  font-family: var(--font-round);
  font-weight: 800;
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 15px;
}
.cheat-table .st-name { font-weight: 700; font-size: 15.5px; white-space: nowrap; }
.cheat-table .st-name small { display: block; font-weight: 600; color: var(--ink-faint); font-size: 12px; font-family: var(--font-round); letter-spacing: .04em; }
.cheat-table .f-cell { display: flex; flex-wrap: wrap; gap: 5px; }
.cheat-table .mv { font-size: 15px; height: 30px; min-width: 30px; padding: 0 8px; border-radius: 8px; }

/* ============================================================
   页脚
   ============================================================ */
.foot {
  padding: 40px 0 64px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13.5px;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 860px) {
  .hero { padding: 48px 0 44px; }
  .hero .wrap { grid-template-columns: 1fr; gap: 30px; }
  .hero-cube { order: -1; }
  .hero .iso { --s: 116px; }
  .notation-wrap { grid-template-columns: 1fr; gap: 22px; }
  .ref-cube { max-width: 320px; margin: 0 auto; }
  .move-grid { grid-template-columns: repeat(2, 1fr); }
  .step-body { grid-template-columns: 1fr; gap: 22px; }
  .step-visual { order: -1; }
  .grid-3 { grid-template-columns: 1fr; max-width: 340px; margin: 0 auto; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 18px; }
  .topnav { display: none; }
  .move-grid { grid-template-columns: 1fr; }
  .cheat-table th:nth-child(3), .cheat-table td:nth-child(3) { display: none; }
  .cheat-table th, .cheat-table td { padding: 12px 16px; }
  .step-badge { width: 50px; height: 50px; font-size: 23px; border-radius: 15px; }
}

/* ============================================================
   打印（仅速查表）
   ============================================================ */
@media print {
  body { background: #fff; }
  .topbar, .hero, .band:not(.print-keep), .foot, .btn-print, .topnav { display: none !important; }
  .print-keep { display: block !important; padding: 0; }
  .cheat { box-shadow: none; border: 1px solid #ccc; }
  .cheat-top { background: #fff; }
  .mv { box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .sticker, .iso-face { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  @page { margin: 14mm; }
}
