/* === Custom Styles for Cortex-M Audio Learning Site === */

/* Layout */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
  transition: transform 0.3s ease;
}

.main-content {
  margin-left: 260px;
  min-height: 100vh;
}

@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
}

/* Sidebar */
.sidebar-nav a {
  display: block;
  padding: 0.5rem 1rem;
  color: #94a3b8;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  font-size: 0.875rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: #e2e8f0;
  background: rgba(255,255,255,0.05);
  border-left-color: #3b82f6;
}

.sidebar-nav a.completed {
  color: #4ade80;
}

.sidebar-nav .section-title {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
}

/* Code Walkthrough */
.code-walkthrough {
  position: relative;
  margin: 1.5rem 0;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid #1e293b;
}

.code-walkthrough .file-header {
  background: #1e293b;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  color: #94a3b8;
}

.code-walkthrough .file-header .file-path {
  color: #38bdf8;
}

.code-block {
  position: relative;
  overflow-x: auto;
}

.code-block pre {
  margin: 0;
  padding: 1rem;
  font-size: 0.8rem;
  line-height: 1.7;
  tab-size: 4;
}

/* Annotation markers */
.ann-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.4em;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  font-size: 0.65em;
  font-weight: 700;
  font-style: normal;
  vertical-align: middle;
  margin: 0 0.3em;
  cursor: help;
  position: relative;
}

.ann-marker:hover::after {
  content: attr(data-note);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  white-space: nowrap;
  max-width: 300px;
  white-space: normal;
  z-index: 10;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
  margin-bottom: 0.5rem;
}

/* Annotation list below code */
.annotation-list {
  background: #0f172a;
  padding: 1rem 1.5rem;
  border-top: 1px solid #1e293b;
}

.annotation-list .ann-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.annotation-list .ann-num {
  flex-shrink: 0;
  width: 1.6em;
  height: 1.6em;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7em;
  font-weight: 700;
  margin-top: 0.15em;
}

/* Line highlighting */
.line-highlight {
  background: rgba(59, 130, 246, 0.1);
  display: block;
  margin: 0 -1rem;
  padding: 0 1rem;
  border-left: 3px solid #3b82f6;
}

/* Collapsible code sections */
.code-collapse-toggle {
  background: #1e293b;
  border: none;
  color: #94a3b8;
  padding: 0.5rem 1rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s;
}

.code-collapse-toggle:hover {
  background: #334155;
  color: #e2e8f0;
}

.code-collapse-toggle .arrow {
  transition: transform 0.2s;
}

.code-collapse-toggle.open .arrow {
  transform: rotate(90deg);
}

.code-collapse-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.code-collapse-content.open {
  max-height: 5000px;
}

/* Progress tracking */
.progress-bar {
  height: 4px;
  background: #1e293b;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  transition: width 0.5s ease;
}

.phase-card {
  transition: all 0.2s;
  border: 1px solid transparent;
}

.phase-card:hover {
  border-color: #3b82f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.phase-card.completed {
  border-color: #22c55e;
}

.phase-card.completed .phase-status {
  background: #22c55e;
}

.phase-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #475569;
}

/* Project cards */
.project-card {
  border: 1px solid #1e293b;
  border-radius: 0.75rem;
  padding: 1.25rem;
  transition: all 0.2s;
  background: #0f172a;
}

.project-card:hover {
  border-color: #3b82f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.project-card .stars {
  color: #fbbf24;
}

/* Timeline */
.timeline {
  position: relative;
  padding: 1rem 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #1e293b;
}

.timeline-item {
  position: relative;
  width: 45%;
  padding: 1rem;
  border-radius: 0.5rem;
  background: #0f172a;
  border: 1px solid #1e293b;
}

.timeline-item:nth-child(odd) {
  margin-left: 0;
  margin-right: auto;
}

.timeline-item:nth-child(even) {
  margin-left: auto;
  margin-right: 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  top: 1.5rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #0f172a;
}

.timeline-item:nth-child(odd)::before {
  right: -6px;
  transform: translateX(50%);
  right: -22px;
}

.timeline-item:nth-child(even)::before {
  left: -22px;
}

@media (max-width: 768px) {
  .timeline::before {
    left: 20px;
  }
  .timeline-item {
    width: calc(100% - 50px);
    margin-left: 50px !important;
    margin-right: 0 !important;
  }
  .timeline-item:nth-child(odd)::before,
  .timeline-item:nth-child(even)::before {
    left: -30px;
  }
}

/* Glossary */
.glossary-card {
  border: 1px solid #1e293b;
  border-radius: 0.5rem;
  padding: 1rem;
  background: #0f172a;
  transition: all 0.2s;
}

.glossary-card:hover {
  border-color: #3b82f6;
}

/* Mermaid diagrams */
.mermaid {
  margin: 1.5rem 0;
  display: flex;
  justify-content: center;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0f172a;
}

::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Print styles */
@media print {
  .sidebar, .mobile-header, .progress-bar {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
  }
}

/* Tooltip */
[data-tooltip] {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted #64748b;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 50;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

/* Callouts */
.callout {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  margin: 1rem 0;
  border-left: 4px solid;
}

.callout-info {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}

.callout-tip {
  background: rgba(34, 197, 94, 0.1);
  border-color: #22c55e;
}

.callout-warning {
  background: rgba(234, 179, 8, 0.1);
  border-color: #eab308;
}

.callout-important {
  background: rgba(168, 85, 247, 0.1);
  border-color: #a855f7;
}

/* Smooth scroll */
html {
  scroll-behavior: smooth;
}

/* Fade in animation */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s, transform 0.5s;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== AI Era Annotation System ===== */

.ai-era-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.ai-era-main {
  min-width: 0;
}

.ai-era-sidebar {
  position: sticky;
  top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-note {
  border-radius: 0 8px 8px 0;
  padding: 0.75rem 1rem;
}

.ai-note-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 0.4rem;
}

.ai-note h4 {
  font-size: 0.85rem;
  margin: 0 0 0.3rem;
  line-height: 1.3;
}

.ai-note p {
  font-size: 0.78rem;
  margin: 0;
  line-height: 1.5;
  color: #94a3b8;
}

/* 不可替代 (Irreplaceable) - Red */
.ai-note-must {
  border-left: 3px solid #ef4444;
  background: rgba(239, 68, 68, 0.05);
}
.ai-note-must .ai-note-badge {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.ai-note-must h4 {
  color: #f87171;
}

/* 可淡化 (Can Automate) - Green */
.ai-note-auto {
  border-left: 3px solid #22c55e;
  background: rgba(34, 197, 94, 0.05);
}
.ai-note-auto .ai-note-badge {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}
.ai-note-auto h4 {
  color: #4ade80;
}

/* 人机协作 (Collaborate) - Cyan */
.ai-note-collab {
  border-left: 3px solid #06b6d4;
  background: rgba(6, 182, 212, 0.05);
}
.ai-note-collab .ai-note-badge {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
}
.ai-note-collab h4 {
  color: #22d3ee;
}

@media (max-width: 1023px) {
  .ai-era-layout {
    grid-template-columns: 1fr;
  }
  .ai-era-sidebar {
    position: static;
  }
}
