
/* ===== algorithm/templates/algorithm/index.html ===== */
.algo-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}
.algo-hero {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    color: white;
}
.algo-hero h1 {
    font-size: 2.4rem;
    color: white;
    margin-bottom: 0.5rem;
}
.algo-hero p {
    color: rgba(255,255,255,0.85);
    font-size: 1.1rem;
}

/* 分类区块 */
.algo-category {
    margin-bottom: 2.5rem;
}
.algo-category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.2rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #e2e8f0;
}
.algo-category-icon {
    font-size: 1.6rem;
}
.algo-category-title {
    font-size: 1.4rem;
    color: #182848;
    font-weight: bold;
}
.algo-category-desc {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-left: auto;
}

.algo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.2rem;
}

.algo-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    flex-direction: column;
    border-left: 4px solid #667eea;
}
.algo-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.algo-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0.6rem;
}
.algo-card-icon {
    font-size: 2rem;
    flex-shrink: 0;
}
.algo-card-title {
    font-size: 1.1rem;
    color: #182848;
    font-weight: bold;
    margin: 0;
}
.algo-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}
.algo-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: #f0f4ff;
    color: #4b6cb7;
    font-weight: 500;
}
.algo-tag.tag-dp { background: #fef3c7; color: #92400e; }
.algo-tag.tag-dfs { background: #dbeafe; color: #1d4ed8; }
.algo-tag.tag-sort { background: #d1fae5; color: #065f46; }
.algo-tag.tag-greedy { background: #fce7f3; color: #9d174d; }
.algo-tag.tag-graph { background: #e0e7ff; color: #3730a3; }
.algo-tag.tag-string { background: #fef9c3; color: #854d0e; }
.algo-tag.tag-basic { background: #f1f5f9; color: #475569; }

.algo-card p {
    color: #64748b;
    font-size: 0.88rem;
    line-height: 1.6;
    flex: 1;
    margin-bottom: 1rem;
}
.algo-card a {
    display: inline-block;
    background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: bold;
    text-align: center;
    transition: opacity 0.2s ease;
    align-self: flex-start;
}
.algo-card a:hover {
    opacity: 0.88;
}

/* 分类颜色变体 */
.algo-category[data-cat="sort"] .algo-card { border-left-color: #16a34a; }
.algo-category[data-cat="search"] .algo-card { border-left-color: #2563eb; }
.algo-category[data-cat="dp"] .algo-card { border-left-color: #d97706; }
.algo-category[data-cat="greedy"] .algo-card { border-left-color: #ec4899; }
.algo-category[data-cat="graph"] .algo-card { border-left-color: #7c3aed; }
.algo-category[data-cat="string"] .algo-card { border-left-color: #ca8a04; }
.algo-category[data-cat="basic"] .algo-card { border-left-color: #64748b; }

@media (max-width: 640px) {
    .algo-page { padding: 1rem; }
    .algo-hero h1 { font-size: 1.6rem; }
    .algo-grid { grid-template-columns: 1fr; }
}

/* ===== algorithm/templates/algorithm/sort/play.html ===== */
.viz-page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px;
}

/* 页面顶部标题栏 */
.viz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: white;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  margin-bottom: 20px;
  border: 1px solid rgba(0,0,0,.04);
}
.viz-header h1 {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.viz-header .subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 2px;
}
.viz-header .back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  transition: all .2s;
}
.viz-header .back-btn:hover {
  background: #f1f5f9;
  color: #6366f1;
  border-color: #c7d2fe;
}

/* 画布容器 */
.canvas-container {
  border-radius: 14px !important;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.06) !important;
  background: #fafbfc !important;
  border: 1px solid rgba(0,0,0,.05);
  height: min(70vh, 720px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.canvas-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6, #a78bfa);
  border-radius: 14px 14px 0 0;
  z-index: 1;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 控制面板 */
.control-panel {
  background: white;
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  border: 1px solid rgba(0,0,0,.04);
  height: min(70vh, 720px);
  overflow-y: auto;
}

/* 控制面板分区 */
.ctrl-section {
  padding: 14px 0;
  border-bottom: 1px solid #f1f5f9;
}
.ctrl-section:last-child { border-bottom: none; }
.ctrl-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #94a3b8;
  margin-bottom: 10px;
}
.ctrl-label .uk-icon { color: #a5b4fc; }

/* 统计卡片 */
.stat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  transition: all .2s;
}
.stat-card:hover {
  background: #f1f5f9;
  border-color: #c7d2fe;
}
.stat-card .stat-item {
  text-align: center;
  padding: 6px 0;
}
.stat-card .stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #6366f1;
  line-height: 1.2;
}
.stat-card .stat-label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
  margin-top: 2px;
}

/* 当前状态提示 */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  font-size: 13px;
  color: #4f46e5;
  font-weight: 600;
}
.status-bar .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #6366f1;
  animation: statusPulse 1.5s ease-in-out infinite;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.8); }
}

/* ===== algorithm/templates/algorithm/sort/index.html ===== */
.sort-intro-page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Hero 横幅 */
.sort-hero {
  position: relative;
  padding: 40px 36px 36px;
  border-radius: 18px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  color: white;
  margin-bottom: 36px;
  overflow: hidden;
}
.sort-hero::before {
  content: '';
  position: absolute;
  top: -40%; right: -10%;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.sort-hero::after {
  content: '';
  position: absolute;
  bottom: -30%; left: 10%;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.sort-hero h1 {
  font-size: 2rem;
  font-weight: 900;
  margin: 0 0 8px;
  position: relative;
  z-index: 1;
}
.sort-hero .hero-desc {
  font-size: .95rem;
  color: rgba(255,255,255,.82);
  position: relative;
  z-index: 1;
  margin: 0;
}
.sort-hero .hero-path {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 18px;
  position: relative;
  z-index: 1;
}
.sort-hero .hero-path .path-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,.18);
  font-size: 12px;
  font-weight: 600;
  color: white;
  backdrop-filter: blur(4px);
}
.sort-hero .hero-path .path-sep {
  color: rgba(255,255,255,.4);
  font-size: 11px;
}
.sort-hero .back-link {
  position: absolute;
  top: 20px; right: 24px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  background: rgba(255,255,255,.18);
  text-decoration: none;
  backdrop-filter: blur(4px);
  transition: all .2s;
}
.sort-hero .back-link:hover {
  background: rgba(255,255,255,.3);
}

/* 排序分类卡片网格 */
.sort-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

/* 排序分类卡片 */
.sort-card {
  position: relative;
  background: white;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 6px rgba(0,0,0,.05);
  border: 1px solid rgba(0,0,0,.05);
  transition: all .3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sort-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  border-radius: 14px 0 0 14px;
  background: var(--card-accent, #6366f1);
}
.sort-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(99,102,241,.12);
  border-color: #c7d2fe;
}
.sort-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.sort-card-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-accent-bg, #eef2ff);
  color: var(--card-accent, #6366f1);
  font-size: 22px;
  flex-shrink: 0;
}
.sort-card-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1e293b;
  margin: 0;
}
.sort-card-algos {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
  margin-top: 2px;
}
.sort-card p {
  font-size: .85rem;
  color: #64748b;
  line-height: 1.7;
  margin: 0 0 16px;
  flex: 1;
}
.sort-card .enter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: white;
  background: var(--card-accent, #6366f1);
  text-decoration: none;
  transition: all .2s;
}
.sort-card .enter-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,.25);
}

/* 卡片颜色变体 */
.sort-card[data-accent="green"] { --card-accent: #16a34a; --card-accent-bg: #f0fdf4; }
.sort-card[data-accent="blue"] { --card-accent: #2563eb; --card-accent-bg: #eff6ff; }
.sort-card[data-accent="amber"] { --card-accent: #d97706; --card-accent-bg: #fffbeb; }
.sort-card[data-accent="purple"] { --card-accent: #7c3aed; --card-accent-bg: #f5f3ff; }
.sort-card[data-accent="indigo"] { --card-accent: #6366f1; --card-accent-bg: #eef2ff; }

@media (max-width: 768px) {
  .sort-grid { grid-template-columns: 1fr; }
  .sort-hero { padding: 28px 20px 24px; }
  .sort-hero h1 { font-size: 1.5rem; }
  .viz-page { padding: 16px; }
}
