/* ==========================================================================
   PORTFOLIO DESIGN SYSTEM & KRUSKAL VISUALIZER
   Theme: Exclusive Warm Editorial Light Mode (design.md Section 3.1)
   Typography: Lexend (Body & UI), Meow Script (Accents), Fira Code (Mono)
   Color Palette: Warm Editorial Off-White (#faf9f7) + Radiant Accents
   ========================================================================== */

:root {
  color-scheme: light;

  /* Theme Tokens: Warm Editorial Light Mode (design.md 3.1) */
  --bg-canvas: #faf9f7;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-card-solid: #ffffff;
  --bg-input: #f1f5f9;
  
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.14);
  --border-highlight: rgba(5, 150, 105, 0.4);

  --text-main: #0f172a;
  --text-muted: #334155;
  --text-dim: #64748b;

  /* Signature Accents from design.md */
  --accent-emerald: #059669;
  --accent-emerald-light: #ecfdf5;
  --accent-orange: #ea580c;
  --accent-orange-light: #fff7ed;
  --accent-rose: #e11d48;
  --accent-rose-light: #fff1f2;
  --accent-lavender: #8b5cf6;
  --accent-violet: #6366f1;

  /* Fonts */
  --font-body: 'Lexend', system-ui, -apple-system, sans-serif;
  --font-script: 'Meow Script', cursive;
  --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, monospace;
  --font-editorial: 'DM Sans', sans-serif;

  /* Radii Tokens */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
}

/* Global Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Selection Highlight (design.md 3.1) */
::selection {
  background: rgba(5, 150, 105, 0.25);
  color: #065f46;
}

/* Accessibility Focus Ring */
:focus-visible {
  outline: 2px solid var(--accent-emerald);
  outline-offset: 3px;
}

/* ==========================================================================
   AMBIENT GLOWING ORBS (Light Theme Soft Pastels)
   ========================================================================== */
.ambient-glow-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.ambient-orb-1 {
  position: absolute;
  top: -8%;
  left: 15%;
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, rgba(177, 158, 239, 0.03) 50%, transparent 70%);
  border-radius: 50%;
  filter: blur(80px);
  animation: orbDrift1 22s ease-in-out infinite alternate;
}

.ambient-orb-2 {
  position: absolute;
  top: 45%;
  right: -5%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.07) 0%, rgba(6, 182, 212, 0.03) 50%, transparent 70%);
  border-radius: 50%;
  filter: blur(90px);
  animation: orbDrift2 26s ease-in-out infinite alternate;
}

@keyframes orbDrift1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.08); }
  100% { transform: translate(-40px, 80px) scale(0.95); }
}

@keyframes orbDrift2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-70px, -50px) scale(1.1); }
  100% { transform: translate(40px, -30px) scale(0.92); }
}

/* ==========================================================================
   GLASSMORPHISM & SURFACE ELEVATIONS (Light Mode)
   ========================================================================== */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
}

.glass-panel:hover {
  border-color: var(--border-medium);
  box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.06);
}

/* ==========================================================================
   DYNAMIC MAGNETIC CURSOR (High Contrast on Light Canvas)
   ========================================================================== */
.custom-cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--accent-emerald);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 99999;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              height 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.2s ease,
              border-color 0.2s ease,
              transform 0.08s ease-out;
}

.custom-cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  width: 6px;
  height: 6px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 99999;
  transition: opacity 0.2s ease;
}

.custom-cursor-ring.cursor-hover {
  width: 52px;
  height: 52px;
  background-color: rgba(5, 150, 105, 0.12);
  border-color: var(--accent-emerald);
}

.custom-cursor-ring.cursor-hover + .custom-cursor-dot {
  opacity: 0;
}

.custom-cursor-ring.cursor-clicked {
  transform: translate(-50%, -50%) scale(0.85);
  background-color: rgba(5, 150, 105, 0.25);
}

@media (hover: none) or (pointer: coarse) or (max-width: 768px) {
  .custom-cursor-ring,
  .custom-cursor-dot {
    display: none !important;
  }
}

/* ==========================================================================
   SVG GRAPH CANVAS STYLING
   ========================================================================== */
.canvas-viewport {
  background: radial-gradient(circle at 50% 50%, #ffffff 0%, #f8fafc 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.02);
}

#graph-svg {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

/* SVG Halos & Animations */
.pulsing-halo {
  animation: haloPulse 1.8s ease-in-out infinite;
}

@keyframes haloPulse {
  0% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.18); opacity: 0.35; }
  100% { transform: scale(1); opacity: 0.85; }
}

/* Edge & Weight Hover */
.edge-item line {
  transition: stroke-width 0.2s ease, opacity 0.2s ease;
}
.edge-item:hover line {
  opacity: 1 !important;
  stroke-width: 5px !important;
}

/* ==========================================================================
   STATUS PILLS & BADGES (Light Theme)
   ========================================================================== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: all 0.25s ease;
}

.status-pill::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-init {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}

.status-inspect {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
  box-shadow: 0 0 12px rgba(234, 88, 12, 0.15);
}

.status-accept {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
  box-shadow: 0 0 14px rgba(5, 150, 105, 0.18);
}

.status-reject {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
  box-shadow: 0 0 12px rgba(225, 29, 72, 0.15);
}

.status-complete {
  background: linear-gradient(135deg, #ecfdf5, #f5f3ff);
  color: #065f46;
  border-color: #a7f3d0;
  box-shadow: 0 0 16px rgba(5, 150, 105, 0.2);
}

/* ==========================================================================
   DSU VISUALIZER & CHIPS (Light Theme)
   ========================================================================== */
.dsu-sets-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dsu-set-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid;
  font-size: 0.8rem;
  font-weight: 500;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dsu-set-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.set-root-tag {
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  color: #ffffff !important;
}

/* Live Find Box */
.find-box {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.find-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: #0f172a;
}

.find-tag {
  background: #e2e8f0;
  color: #0f172a;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.find-op {
  color: var(--accent-orange);
  font-weight: 700;
}

.find-verdict {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
}

.verdict-accept {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.verdict-reject {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.find-empty {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: italic;
}

/* ==========================================================================
   SORTED EDGE TABLE & STATUS CHIPS (Light Theme)
   ========================================================================== */
.table-scroll-container {
  overflow-y: auto;
  max-height: 240px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
}

.table-scroll-container::-webkit-scrollbar {
  width: 5px;
}
.table-scroll-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-medium);
  text-align: left;
  z-index: 10;
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.data-table tr:hover {
  background: #f8fafc;
}

/* Edge Rows Dynamic States */
.row-active-inspect {
  background: #fff7ed !important;
  box-shadow: inset 3px 0 0 var(--accent-orange);
}

.row-accepted {
  background: #f0fdf4;
}

.row-rejected {
  opacity: 0.65;
  text-decoration: line-through;
  text-decoration-color: #e11d48;
}

/* Status Chips */
.status-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
}

.chip-pending {
  background: #f1f5f9;
  color: #64748b;
}

.chip-inspecting {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.chip-accepted {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.chip-rejected {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.chip-skipped {
  background: #f1f5f9;
  color: #64748b;
}

/* ==========================================================================
   LIVE PSEUDOCODE TRACKER (Modern Slate Container)
   ========================================================================== */
.code-tracker-body {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
}

.code-line {
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
  color: #94a3b8;
}

.code-line .line-num {
  width: 20px;
  color: #64748b;
  font-size: 0.75rem;
  user-select: none;
}

.code-line .kw { color: #f472b6; font-weight: 600; }
.code-line .fn { color: #38bdf8; font-weight: 600; }
.code-line .comment { color: #64748b; font-style: italic; }

.active-code-line {
  background: rgba(5, 150, 105, 0.25);
  color: #ffffff;
  border-left: 3px solid #10b981;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
  font-weight: 600;
}

/* ==========================================================================
   PLAYBACK TIMELINE & CONTROLS
   ========================================================================== */
#step-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 9999px;
  outline: none;
  transition: background 0.2s ease;
}

#step-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-emerald);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(5, 150, 105, 0.4);
  transition: transform 0.15s ease;
}

#step-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

/* ==========================================================================
   TAB PANES & TOOLKIT
   ========================================================================== */
.tab-pane {
  display: none;
  animation: fadeInPane 0.25s ease forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeInPane {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.code-snippet-block {
  display: none;
}

.code-snippet-block.active {
  display: block;
}

/* ==========================================================================
   TOAST NOTIFICATION (Light Theme)
   ========================================================================== */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--border-medium);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 10000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   RESPONSIVENESS
   ========================================================================== */
@media (max-width: 1024px) {
  .workspace-layout {
    grid-template-columns: 1fr !important;
  }
}
