/* ─────────────────────────────────────────────────────────────
   ScienceEd Student Dashboard — Progress Visualisation Styles
   Design tokens from mockup 7.5-progress-visualisation
   ───────────────────────────────────────────────────────────── */

/* ── Design Tokens ──────────────────────────────── */
:root {
  --sd-bg-deep: #080b11;
  --sd-bg-glass: rgba(17, 24, 39, 0.72);
  --sd-bg-glass-hover: rgba(17, 24, 39, 0.85);
  --sd-primary: #4da6ff;
  --sd-primary-dim: rgba(77, 166, 255, 0.15);
  --sd-primary-glow: rgba(77, 166, 255, 0.08);
  --sd-success: #4caf50;
  --sd-success-dim: rgba(76, 175, 80, 0.15);
  --sd-warning: #ff9800;
  --sd-warning-dim: rgba(255, 152, 0, 0.15);
  --sd-text-primary: #f1f5f9;
  --sd-text-secondary: #94a3b8;
  --sd-text-tertiary: #64748b;
  --sd-border: rgba(148, 163, 184, 0.1);
  --sd-border-hover: rgba(148, 163, 184, 0.2);
  --sd-radius-sm: 8px;
  --sd-radius-md: 12px;
  --sd-radius-lg: 16px;
  --sd-radius-xl: 20px;
  --sd-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ── Section Title ──────────────────────────────── */
.sd-section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--sd-text-primary);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  letter-spacing: -0.01em;
}
.sd-section-title .sd-section-icon {
  font-size: 1.15rem;
  line-height: 1;
}
.sd-section-title .sd-section-badge {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--sd-text-tertiary);
  background: rgba(148, 163, 184, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.25rem;
}

/* ── Glass Panel ────────────────────────────────── */
.sd-glass-panel {
  background: var(--sd-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--sd-border);
  border-radius: var(--sd-radius-lg);
  box-shadow: var(--sd-shadow);
}

/* ── Progress Rings (Redesigned Stat Cards) ────────────────────────────────── */
.sd-rings-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.sd-ring-card {
  background: var(--sd-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--sd-border);
  border-radius: var(--sd-radius-md);
  padding: 1.25rem 1rem;
  text-align: center;
  transition: all 0.3s ease;
  animation: sd-fadeInUp 0.5s ease forwards;
  opacity: 0;
}
.sd-ring-card:nth-child(1) { animation-delay: 0.05s; }
.sd-ring-card:nth-child(2) { animation-delay: 0.15s; }
.sd-ring-card:nth-child(3) { animation-delay: 0.25s; }
.sd-ring-card:nth-child(4) { animation-delay: 0.35s; }
.sd-ring-card:hover {
  border-color: var(--sd-border-hover);
  background: var(--sd-bg-glass-hover);
  transform: translateY(-2px);
}
.sd-ring-wrapper {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 0.6rem;
}
.sd-ring-svg {
  width: 72px;
  height: 72px;
  transform: rotate(-90deg);
}
.sd-ring-bg {
  fill: none;
  stroke: rgba(148, 163, 184, 0.08);
  stroke-width: 5;
}
.sd-ring-fg {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 188.5;
  stroke-dashoffset: 188.5;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.sd-ring-fg.ring-primary { stroke: var(--sd-primary); }
.sd-ring-fg.ring-success { stroke: var(--sd-success); }
.sd-ring-fg.ring-warning { stroke: var(--sd-warning); }
.sd-ring-fg.ring-info { stroke: #a78bfa; }
.sd-ring-fg.animated { stroke-dashoffset: var(--ring-offset, 0); }
.sd-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.sd-ring-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--sd-text-primary);
  line-height: 1.2;
}
.sd-ring-card-label {
  font-size: 0.7rem;
  color: var(--sd-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.sd-ring-change {
  font-size: 0.68rem;
  font-weight: 600;
  margin-top: 0.15rem;
  line-height: 1.2;
}
.sd-ring-change.up { color: var(--sd-success); }
.sd-ring-change.down { color: #ef4444; }

/* ── Mastery Graphs (Sparklines) ────────────────── */
.sd-mastery-graphs {
  margin-bottom: 1.75rem;
  opacity: 0;
  animation: sd-fadeInUp 0.5s ease 0.1s forwards;
}
.sd-mastery-graphs-inner {
  padding: 1.25rem 1.25rem 0.75rem;
}
.sd-sparkline-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.sd-sparkline-card {
  padding: 0.75rem;
  border-radius: var(--sd-radius-sm);
  background: rgba(148, 163, 184, 0.03);
  transition: background 0.2s;
}
.sd-sparkline-card:hover {
  background: rgba(148, 163, 184, 0.06);
}
.sd-sparkline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.sd-sparkline-code {
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--sd-text-tertiary);
  letter-spacing: 0.02em;
}
.sd-sparkline-pct {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sd-text-secondary);
}
.sd-sparkline-canvas-wrap {
  height: 40px;
  position: relative;
}
.sd-sparkline-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Sim Completion Timeline ────────────────────── */
.sd-timeline-section {
  margin-bottom: 1.75rem;
  opacity: 0;
  animation: sd-fadeInUp 0.5s ease 0.2s forwards;
}
.sd-timeline-inner {
  padding: 1rem 1.25rem;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,0.15) transparent;
}
.sd-timeline-inner::-webkit-scrollbar {
  width: 4px;
}
.sd-timeline-inner::-webkit-scrollbar-track {
  background: transparent;
}
.sd-timeline-inner::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,0.15);
  border-radius: 2px;
}
.sd-timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sd-timeline-item {
  display: flex;
  gap: 0.85rem;
  padding-bottom: 1rem;
  position: relative;
}
.sd-timeline-item:last-child {
  padding-bottom: 0;
}
.sd-timeline-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  position: relative;
  z-index: 1;
  border: 2px solid var(--sd-border);
}
.sd-timeline-icon.icon-physics {
  background: rgba(77, 166, 255, 0.15);
  border-color: rgba(77, 166, 255, 0.3);
}
.sd-timeline-icon.icon-life {
  background: rgba(76, 175, 80, 0.15);
  border-color: rgba(76, 175, 80, 0.3);
}
.sd-timeline-icon.icon-earth {
  background: rgba(255, 152, 0, 0.15);
  border-color: rgba(255, 152, 0, 0.3);
}
.sd-timeline-icon.icon-engineering {
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.3);
}
.sd-timeline-icon.icon-logic {
  background: rgba(236, 72, 153, 0.15);
  border-color: rgba(236, 72, 153, 0.3);
}
.sd-timeline-content {
  flex: 1;
  min-width: 0;
  padding-bottom: 0.15rem;
}
.sd-timeline-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sd-text-primary);
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-timeline-meta {
  font-size: 0.72rem;
  color: var(--sd-text-tertiary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.sd-timeline-score {
  font-weight: 600;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}
.sd-timeline-score.high { color: var(--sd-success); }
.sd-timeline-score.medium { color: var(--sd-warning); }
.sd-timeline-score.low { color: #ef4444; }
/* Timeline connecting line */
.sd-timeline-item::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: rgba(148, 163, 184, 0.08);
}
.sd-timeline-item:last-child::after {
  display: none;
}
.sd-timeline-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--sd-text-tertiary);
  font-size: 0.85rem;
}

/* ── Streak Tracker ─────────────────────────────── */
.sd-streak-section {
  margin-bottom: 1.75rem;
  opacity: 0;
  animation: sd-fadeInUp 0.5s ease 0.3s forwards;
}
.sd-streak-inner {
  padding: 1.25rem;
}
.sd-streak-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.sd-streak-count {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sd-streak-flame {
  font-size: 1.6rem;
  line-height: 1;
  animation: sd-flame-pulse 1.5s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(255, 152, 0, 0.5));
}
.sd-streak-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--sd-text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}
.sd-streak-label {
  font-size: 0.75rem;
  color: var(--sd-text-tertiary);
  font-weight: 500;
  line-height: 1.2;
}
.sd-streak-best {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--sd-text-secondary);
}
.sd-streak-best-value {
  font-weight: 700;
  color: var(--sd-text-primary);
}
/* Heatmap */
.sd-heatmap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.sd-heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.sd-heatmap-cell:hover {
  transform: scale(1.3);
  z-index: 2;
}
.sd-heatmap-cell.level-0 { background: rgba(148, 163, 184, 0.06); }
.sd-heatmap-cell.level-1 { background: rgba(77, 166, 255, 0.15); }
.sd-heatmap-cell.level-2 { background: rgba(77, 166, 255, 0.3); }
.sd-heatmap-cell.level-3 { background: rgba(76, 175, 80, 0.3); }
.sd-heatmap-cell.level-4 { background: rgba(76, 175, 80, 0.55); }
.sd-heatmap-cell.level-5 { background: rgba(76, 175, 80, 0.75); }
/* Heatmap tooltip */
.sd-heatmap-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.68rem;
  color: var(--sd-text-primary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.sd-heatmap-cell:hover .sd-heatmap-tooltip {
  opacity: 1;
}
.sd-heatmap-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.65rem;
  color: var(--sd-text-tertiary);
}
.sd-heatmap-labels span { text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Layout Grid for Visualizations ──────────────── */
.sd-viz-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}
.sd-viz-full {
  grid-column: 1 / -1;
}

/* ── Animations ──────────────────────────────────── */
@keyframes sd-fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes sd-flame-pulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 6px rgba(255, 152, 0, 0.4));
  }
  50% {
    transform: scale(1.08);
    filter: drop-shadow(0 0 12px rgba(255, 152, 0, 0.7));
  }
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1080px) {
  .sd-rings-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .sd-sparkline-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .sd-viz-grid {
    grid-template-columns: 1fr;
  }
}

/* Tablet (768px) */
@media (max-width: 768px) {
  .sd-rings-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .sd-ring-wrapper {
    width: 60px;
    height: 60px;
  }
  .sd-ring-svg {
    width: 60px;
    height: 60px;
  }
  .sd-ring-value {
    font-size: 0.9rem;
  }
  .sd-sparkline-grid {
    grid-template-columns: 1fr;
  }
  .sd-viz-grid {
    grid-template-columns: 1fr;
  }
  .sd-streak-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .sd-streak-number {
    font-size: 1.4rem;
  }
  .sd-heatmap {
    gap: 3px;
  }
  .sd-timeline-inner {
    max-height: 280px;
  }
}

/* Mobile (480px) */
@media (max-width: 480px) {
  .sd-rings-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .sd-ring-card {
    padding: 0.85rem 0.6rem;
  }
  .sd-ring-wrapper {
    width: 48px;
    height: 48px;
  }
  .sd-ring-svg {
    width: 48px;
    height: 48px;
  }
  .sd-ring-value {
    font-size: 0.8rem;
  }
  .sd-ring-card-label {
    font-size: 0.6rem;
  }
  .sd-heatmap {
    gap: 2px;
  }
  .sd-heatmap-cell:hover {
    transform: scale(1.2);
  }
  .sd-timeline-inner {
    max-height: 220px;
  }
  .sd-timeline-item {
    gap: 0.5rem;
  }
  .sd-timeline-icon {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }
  .sd-timeline-item::after {
    left: 13px;
  }
}

/* Extra small (375px) */
@media (max-width: 375px) {
  .sd-rings-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .sd-ring-card {
    padding: 0.65rem 0.4rem;
  }
}

/* Extra small (360px) — prevent overflow on very narrow phones */
@media (max-width: 360px) {
  .sd-rings-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
  }
  .sd-ring-card {
    padding: 0.45rem 0.25rem;
  }
  .sd-ring-wrapper {
    width: 36px;
    height: 36px;
  }
  .sd-ring-svg {
    width: 36px;
    height: 36px;
  }
  .sd-ring-value {
    font-size: 0.65rem;
  }
  .sd-ring-card-label {
    font-size: 0.55rem;
  }
  .sd-ring-change {
    font-size: 0.6rem;
  }
  .sd-heatmap {
    gap: 1px;
  }
  .sd-heatmap-cell {
    border-radius: 1px;
  }
  .sd-heatmap-cell:hover {
    transform: scale(1.15);
  }
  .sd-timeline-inner {
    max-height: 180px;
  }
  .sd-timeline-item {
    gap: 0.35rem;
    padding-bottom: 0.5rem;
  }
  .sd-timeline-icon {
    width: 22px;
    height: 22px;
    font-size: 0.6rem;
    border-width: 1.5px;
  }
  .sd-timeline-item::after {
    left: 10px;
    top: 24px;
  }
  .sd-timeline-title {
    font-size: 0.75rem;
  }
  .sd-timeline-meta {
    font-size: 0.62rem;
  }
  .dashboard-sim-card {
    padding: 0.55rem 0.6rem;
    gap: 0.4rem;
  }
  .dashboard-sim-name {
    font-size: 0.82rem;
  }
  .dashboard-sim-meta {
    font-size: 0.7rem;
  }
  .dashboard-sim-arrow {
    font-size: 1.1rem;
  }
  .sd-streak-inner {
    padding: 0.7rem;
  }
  .sd-streak-number {
    font-size: 1.3rem;
  }
  .sd-streak-flame {
    font-size: 1.2rem;
  }
  .sd-streak-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .sd-streak-best {
    font-size: 0.7rem;
  }
  .sd-section-title {
    font-size: 0.9rem;
  }
  .sd-mastery-card {
    padding: 0.65rem 0.75rem;
  }
  .dashboard-category-title {
    font-size: 0.78rem;
  }
}
