/* ================================================================
   basics.css — SRAM 基础课专用样式
   存储层级、反相器、6T结构、动态演示、对比表格、术语卡片
   ================================================================ */

/* ===== 存储层级图 ===== */
.memory-hierarchy {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.memory-hierarchy h3 {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.hierarchy-bar {
  padding: 0.6rem 1rem;
  margin: 0.4rem auto;
  border-radius: var(--radius);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  transition: var(--transition);
}

.hierarchy-bar.active {
  box-shadow: 0 0 0 3px rgba(8,145,178,0.3);
  transform: scale(1.03);
}

.hint {
  font-size: 0.82rem;
  color: var(--gray);
  text-align: center;
  margin-top: 0.8rem;
}

/* ===== 反相器动画区 ===== */
.latch-demo {
  background: white;
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.status-text {
  font-size: 0.9rem;
  color: var(--green-dark);
  font-weight: 600;
  margin-top: 0.5rem;
}

/* ===== 信号图例 ===== */
.signal-legend { margin-top: 1rem; }

.signal-legend h3 {
  font-size: 0.95rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== 6T 结构图 ===== */
.cell-diagram-wrapper {
  background: white;
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.demo-svg-wrap {
  border: 2px solid var(--gray-lighter);
}

/* ===== 动态演示区 ===== */
.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.btn-mode {
  background: white;
  border: 2px solid var(--gray-light);
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  color: var(--text-light);
  transition: var(--transition);
}

.btn-mode:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.btn-mode.active {
  background: var(--primary-light);
  color: white;
  border-color: var(--primary-light);
}

.btn-mode.btn-write.active {
  background: var(--orange);
  border-color: var(--orange);
}

.btn-mode.active-read {
  background: var(--cyan);
  color: white;
  border-color: var(--cyan);
}

.btn-mode.active-hold {
  background: var(--gray);
  color: white;
  border-color: var(--gray);
}

.demo-explain {
  background: white;
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  min-height: 80px;
}

.demo-explain h3 {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

.demo-explain p {
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.6;
}

.demo-steps { margin-top: 0.5rem; }

.step {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  opacity: 0.4;
  transition: opacity 0.4s ease;
}

.step.active { opacity: 1; }

.step-num {
  background: var(--primary-light);
  color: white;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step.active .step-num { background: var(--green); }

.step-text {
  font-size: 0.88rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* ===== 对比表格 ===== */
.compare-table-wrap { overflow-x: auto; }

.compare-table {
  width: 100%;
  max-width: 800px;
  margin: 1rem auto 0;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.compare-table th,
.compare-table td {
  padding: 0.75rem 1.2rem;
  text-align: left;
  font-size: 0.9rem;
}

.compare-table th {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.compare-table tr:nth-child(even) { background: var(--bg-alt); }

.compare-table td:first-child {
  font-weight: 600;
  color: var(--text);
}

.tag-green {
  background: #dcfce7; color: var(--green-dark);
  padding: 0.15rem 0.6rem; border-radius: 4px;
  font-size: 0.85rem; font-weight: 500;
}

.tag-orange {
  background: #fef3c7; color: var(--orange-dark);
  padding: 0.15rem 0.6rem; border-radius: 4px;
  font-size: 0.85rem; font-weight: 500;
}

/* ===== 术语卡片 ===== */
.term-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.term-card {
  background: white;
  border: 2px solid var(--gray-lighter);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: var(--transition);
  perspective: 600px;
  position: relative;
  min-height: 80px;
}

.term-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-lg);
}

.term-card .term-name {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.term-card .term-desc {
  font-size: 0.85rem;
  color: var(--text-light);
  display: none;
}

.term-card.flipped .term-desc { display: block; }

.term-card .term-hint {
  font-size: 0.75rem;
  color: var(--gray-light);
}

.term-card.flipped .term-hint { display: none; }

/* ===== Basics 专用 SVG 动画 ===== */
.highlight-green { fill: #dcfce7 !important; stroke: #22c55e !important; }
.highlight-orange { fill: #fde68a !important; stroke: #f97316 !important; }
.highlight-active { stroke: #22c55e !important; stroke-width: 3 !important; }
.highlight-bl { stroke: #3b82f6 !important; stroke-width: 3 !important; }
.highlight-wl { stroke: #f59e0b !important; stroke-width: 3.5 !important; }
.node-glow { filter: drop-shadow(0 0 6px rgba(34,197,94,0.6)); }
.node-glow-red { filter: drop-shadow(0 0 6px rgba(239,68,68,0.6)); }
.node-glow-orange { filter: drop-shadow(0 0 6px rgba(249,115,22,0.6)); }

@keyframes chargeFlow {
  0% { offset-distance: 0%; opacity: 1; }
  100% { offset-distance: 100%; opacity: 1; }
}

/* ===== Basics 响应式 ===== */
@media (max-width: 768px) {
  .term-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .term-grid { grid-template-columns: 1fr; }
  .demo-controls { flex-direction: column; }
  .btn-mode { width: 100%; text-align: center; }
}
