/* 学习地图 · 五种视图皮肤 */
#learning-map-root {
  --map-line-1: #e11d48;
  --map-line-2: #2563eb;
  --map-line-3: #059669;
  --map-line-4: #d97706;
  --map-line-5: #7c3aed;
  --map-line-6: #0891b2;
  --map-line-7: #db2777;
  --map-line-8: #4f46e5;
}

#learning-map-root[data-map-skin="constellation"] {
  background: radial-gradient(ellipse 120% 80% at 50% 0%, rgba(30, 27, 75, 0.35), transparent 55%),
    linear-gradient(180deg, #0a0d1a 0%, #12182b 100%);
  border-radius: 16px;
  padding-bottom: 8px;
}

.map-visual-wrap {
  position: relative;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel2);
  overflow: hidden;
}

#learning-map-root[data-map-skin="constellation"] .map-visual-wrap {
  background: rgba(0, 0, 0, 0.25);
  border-color: rgba(255, 255, 255, 0.08);
}

.map-visual-scroll {
  overflow: auto;
  max-height: min(68vh, 640px);
  -webkit-overflow-scrolling: touch;
}

.map-visual-scroll.is-horizontal {
  overflow-x: auto;
  overflow-y: hidden;
}

.map-visual-inner {
  position: relative;
  min-height: 320px;
}

.map-visual-inner.is-metro { min-width: 100%; min-height: 520px; }
.map-visual-inner.is-scroll { min-width: 4200px; min-height: 360px; }
.map-visual-inner.is-constellation { min-height: 480px; }
.map-visual-inner.is-lifecycle { min-height: 420px; padding: 20px 12px; }
.map-visual-inner.is-branch { min-height: 520px; padding: 16px; }

.map-svg-layer { display: block; width: 100%; height: 100%; }
.map-svg-layer path.map-route {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.35;
}
.map-svg-layer path.map-route.is-lit {
  opacity: 1;
  stroke-dasharray: 8 6;
  animation: mapPathFlow 1.2s linear infinite;
}
.map-svg-layer path.map-route.is-dim { opacity: 0.12; }

.map-nodes-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.map-nodes-layer .map-node { pointer-events: auto; }

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.15s ease;
}
.map-node:hover { transform: translate(-50%, -50%) scale(1.08); z-index: 3; }
.map-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.map-node-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s, background 0.2s, transform 0.2s;
}
.map-node.is-boss .map-node-dot,
.map-node.is-chapter-end .map-node-dot,
.map-node.is-graduate .map-node-dot {
  width: 22px;
  height: 22px;
  border-width: 3px;
}
.map-node.is-done .map-node-dot {
  background: color-mix(in srgb, var(--green) 25%, var(--panel));
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent);
}
.map-node.is-locked .map-node-dot { opacity: 0.45; border-style: dashed; }
.map-node.is-next .map-node-dot {
  animation: mapNodePulse 1.6s ease-in-out infinite;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent);
}
@keyframes mapNodePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.map-node-label {
  font-size: 0.62rem;
  color: var(--muted);
  max-width: 72px;
  text-align: center;
  line-height: 1.2;
  pointer-events: none;
}
#learning-map-root[data-map-skin="constellation"] .map-node-label { color: rgba(255, 255, 255, 0.55); }

.map-node-star-slot {
  position: absolute;
  top: -4px;
  right: -8px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
}
.map-node-star-slot.is-filled { color: var(--gold, #f0c96e); }

.map-chapter-label {
  position: absolute;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}
#learning-map-root[data-map-skin="constellation"] .map-chapter-label {
  color: rgba(255, 255, 255, 0.75);
}

/* 卷轴 · biome 背景 */
.map-scroll-biome {
  position: absolute;
  top: 0;
  bottom: 0;
  opacity: 0.35;
  pointer-events: none;
  border-radius: inherit;
}

@keyframes mapPathFlow {
  to { stroke-dashoffset: -14; }
}
.map-scroll-biome.biome-0 { background: linear-gradient(180deg, #dcfce7, #bbf7d0); }
.map-scroll-biome.biome-1 { background: linear-gradient(180deg, #dbeafe, #bfdbfe); }
.map-scroll-biome.biome-2 { background: linear-gradient(180deg, #ede9fe, #ddd6fe); }
.map-scroll-biome.biome-3 { background: linear-gradient(180deg, #ffedd5, #fed7aa); }
.map-scroll-biome.biome-4 { background: linear-gradient(180deg, #cffafe, #a5f3fc); }
.map-scroll-biome.biome-5 { background: linear-gradient(180deg, #fce7f3, #fbcfe8); }
.map-scroll-biome.biome-6 { background: linear-gradient(180deg, #e0e7ff, #c7d2fe); }
.map-scroll-biome.biome-7 { background: linear-gradient(180deg, #f3f4f6, #e5e7eb); }

/* 生命周期 */
.map-lifecycle-phases {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.map-lifecycle-phase {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  text-align: center;
  font-size: 0.72rem;
}
.map-lifecycle-phase em {
  display: block;
  font-style: normal;
  font-weight: 600;
  font-size: 0.78rem;
  margin-bottom: 2px;
}
.map-lifecycle-phase.is-active { border-color: var(--accent); background: var(--accent-soft); }

/* 分叉路径 */
.map-branch-col {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
  opacity: 0.4;
}
.map-branch-fork {
  stroke: var(--muted);
  stroke-width: 2;
  fill: none;
  opacity: 0.5;
}

/* 抽屉 */
.map-drawer[hidden] { display: none !important; }
.map-drawer {
  position: fixed;
  inset: 0;
  z-index: 9000;
}
.map-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 24, 0.45);
}
.map-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(400px, 92vw);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  padding: 20px;
  overflow-y: auto;
  animation: mapDrawerIn 0.28s ease;
}
@keyframes mapDrawerIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.map-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.map-drawer-head h3 { margin: 0; font-size: 1rem; line-height: 1.4; }
.map-drawer-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 12px; }

.map-skin-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.map-skin-opt {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.map-skin-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.map-skin-opt strong { display: block; font-size: 0.82rem; margin-bottom: 2px; }
.map-skin-opt span { font-size: 0.7rem; color: var(--muted); }

.map-minimap {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 100px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  font-size: 0.62rem;
  color: var(--muted);
  display: grid;
  place-items: center;
  z-index: 5;
  pointer-events: none;
}

html.reduce-motion .map-node.is-next .map-node-dot,
html.reduce-motion .map-svg-layer path.map-route.is-lit {
  animation: none !important;
}
