/* ========================================
   Linked Legends: The Chain of Destiny
   Realm-Specific Styles
   ======================================== */

/* ========================================
   Realm Theme Colors
   ======================================== */

/* Realm 1 - Build & Print (Forest Green) */
.realm-1 {
  --realm-primary: #00ff88;
  --realm-secondary: #00cc6a;
  --realm-bg: linear-gradient(135deg, #0d2818 0%, #0a1f15 100%);
}

/* Realm 2 - Insert/Delete (Ocean Blue) */
.realm-2 {
  --realm-primary: #00d4ff;
  --realm-secondary: #0099cc;
  --realm-bg: linear-gradient(135deg, #0a1929 0%, #071422 100%);
}

/* Realm 3 - Reverse (Sunset Orange) */
.realm-3 {
  --realm-primary: #ff9f43;
  --realm-secondary: #f39c12;
  --realm-bg: linear-gradient(135deg, #2d1a0a 0%, #1f1308 100%);
}

/* Realm 4 - Reorder (Royal Purple) */
.realm-4 {
  --realm-primary: #9d4edd;
  --realm-secondary: #7b2cbf;
  --realm-bg: linear-gradient(135deg, #1a0a2e 0%, #140822 100%);
}

/* Realm 5 - Cycle Detection (Mystic Teal) */
.realm-5 {
  --realm-primary: #00cec9;
  --realm-secondary: #00a8a5;
  --realm-bg: linear-gradient(135deg, #0a2424 0%, #081c1c 100%);
}

/* Realm 6 - Remove Cycle (Blood Red) */
.realm-6 {
  --realm-primary: #ff4757;
  --realm-secondary: #c0392b;
  --realm-bg: linear-gradient(135deg, #2d0a0a 0%, #1f0808 100%);
}

/* Realm 7 - DLL (Crystal Blue) */
.realm-7 {
  --realm-primary: #74b9ff;
  --realm-secondary: #0984e3;
  --realm-bg: linear-gradient(135deg, #0a1929 0%, #061422 100%);
}

/* Realm 8 - LRU Cache (Golden) */
.realm-8 {
  --realm-primary: #ffd700;
  --realm-secondary: #f39c12;
  --realm-bg: linear-gradient(135deg, #2d2810 0%, #1f1c0a 100%);
}

/* Realm 9 - Clone (Electric Purple) */
.realm-9 {
  --realm-primary: #a29bfe;
  --realm-secondary: #6c5ce7;
  --realm-bg: linear-gradient(135deg, #1a1a2e 0%, #141428 100%);
}

/* Realm 10 - Intersection (Emerald) */
.realm-10 {
  --realm-primary: #2ecc71;
  --realm-secondary: #27ae60;
  --realm-bg: linear-gradient(135deg, #0a2818 0%, #081f15 100%);
}

/* ========================================
   Visual Node Styles
   ======================================== */

.visual-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: var(--node-bg);
  border: 3px solid var(--node-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.visual-node:hover {
  border-color: var(--node-highlight);
  box-shadow: var(--shadow-glow);
  transform: scale(1.05);
}

.visual-node.selected {
  border-color: var(--node-selected);
  box-shadow: var(--shadow-gold);
}

.visual-node.head {
  border-color: var(--accent-green);
}

.visual-node.tail {
  border-color: var(--accent-orange);
}

.visual-node.current {
  border-color: var(--accent-blue);
  animation: glow 1s ease-in-out infinite;
}

.visual-node.slow-pointer {
  border-color: var(--pointer-slow);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

.visual-node.fast-pointer {
  border-color: var(--pointer-fast);
  box-shadow: 0 0 20px rgba(255, 71, 87, 0.5);
}

.node-value {
  font-family: var(--font-code);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.node-address {
  font-family: var(--font-code);
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.node-label {
  position: absolute;
  top: -25px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.node-label.head-label {
  background: var(--accent-green);
  color: var(--bg-primary);
}

.node-label.tail-label {
  background: var(--accent-orange);
  color: var(--bg-primary);
}

.node-label.current-label {
  background: var(--accent-blue);
  color: var(--bg-primary);
}

/* ========================================
   DLL Node Styles
   ======================================== */

.dll-node {
  width: 100px;
}

.dll-node .prev-indicator,
.dll-node .next-indicator {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.dll-node .prev-indicator {
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent-orange);
}

.dll-node .next-indicator {
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent-green);
}

/* ========================================
   Random Pointer Node Styles
   ======================================== */

.random-node {
  position: relative;
}

.random-node .random-indicator {
  position: absolute;
  bottom: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  background: var(--accent-purple);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

/* ========================================
   Link/Arrow Styles
   ======================================== */

.visual-link {
  position: absolute;
  pointer-events: none;
}

.link-line {
  stroke: var(--pointer-next);
  stroke-width: 3;
  fill: none;
  marker-end: url(#arrowhead);
}

.link-line.prev-link {
  stroke: var(--pointer-prev);
  marker-start: url(#arrowhead-prev);
  marker-end: none;
}

.link-line.random-link {
  stroke: var(--pointer-random);
  stroke-dasharray: 5 5;
  marker-end: url(#arrowhead-random);
}

.link-line.cycle-link {
  stroke: var(--accent-red);
  stroke-width: 4;
  animation: pulse 1s ease-in-out infinite;
}

/* Arrow SVG Markers */
.arrow-marker {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ========================================
   Pointer Indicator Styles
   ======================================== */

.pointer-indicator {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: var(--font-code);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 10;
}

.pointer-indicator.slow {
  background: rgba(0, 212, 255, 0.2);
  color: var(--pointer-slow);
  border: 1px solid var(--pointer-slow);
}

.pointer-indicator.fast {
  background: rgba(255, 71, 87, 0.2);
  color: var(--pointer-fast);
  border: 1px solid var(--pointer-fast);
}

.pointer-indicator.curr {
  background: rgba(0, 212, 255, 0.2);
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
}

.pointer-indicator.prev {
  background: rgba(255, 159, 67, 0.2);
  color: var(--accent-orange);
  border: 1px solid var(--accent-orange);
}

.pointer-indicator.next {
  background: rgba(0, 255, 136, 0.2);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

/* ========================================
   Realm 1 - Build & Print Specific
   ======================================== */

.realm-1-container {
  background: var(--realm-bg);
}

.build-zone {
  position: absolute;
  bottom: 20%;
  left: 10%;
  right: 10%;
  height: 200px;
  border: 2px dashed rgba(0, 255, 136, 0.3);
  border-radius: 16px;
  display: flex;
  align-items: center;
  padding: 20px;
  gap: 10px;
}

.node-palette {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
}

.palette-node {
  width: 60px;
  height: 60px;
  background: var(--node-bg);
  border: 2px dashed var(--node-border);
  border-radius: 12px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all var(--transition-fast);
}

.palette-node:hover {
  border-style: solid;
  border-color: var(--accent-green);
  transform: scale(1.1);
}

/* ========================================
   Realm 2 - Insert/Delete Specific
   ======================================== */

.insertion-point {
  position: absolute;
  width: 10px;
  height: 80px;
  background: rgba(0, 212, 255, 0.3);
  border: 2px dashed var(--accent-blue);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.insertion-point:hover {
  background: rgba(0, 212, 255, 0.5);
  width: 80px;
}

.deletion-target {
  border-color: var(--accent-red) !important;
  animation: shake 0.3s ease;
}

.garbage-pit {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 80px;
  background: linear-gradient(180deg, transparent, rgba(255, 71, 87, 0.3));
  border-top: 2px solid var(--accent-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* ========================================
   Realm 3 - Reverse Specific
   ======================================== */

.reverse-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.direction-indicator {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  color: var(--accent-orange);
  animation: pulse 1s ease-in-out infinite;
}

.reverse-progress {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-step {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--node-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-step.active {
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.progress-step.completed {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: var(--bg-primary);
}

/* ========================================
   Realm 4 - Reorder Specific
   ======================================== */

.reorder-phases {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
}

.phase-indicator {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 2px solid var(--node-border);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.phase-indicator.active {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
  animation: pulse 1s ease-in-out infinite;
}

.phase-indicator.completed {
  background: rgba(0, 255, 136, 0.2);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.middle-marker {
  position: absolute;
  top: 50%;
  height: 100%;
  width: 2px;
  background: var(--accent-purple);
  transform: translateY(-50%);
}

.middle-marker::after {
  content: 'MID';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--accent-purple);
}

/* ========================================
   Realm 5 - Cycle Detection Specific
   ======================================== */

.cycle-track-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.cycle-track-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.racer {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.5s ease;
  z-index: 20;
}

.racer.slow {
  background: var(--pointer-slow);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.5);
}

.racer.fast {
  background: var(--pointer-fast);
  box-shadow: 0 0 15px rgba(255, 71, 87, 0.5);
}

.meeting-point {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 3px solid var(--accent-gold);
  border-radius: 50%;
  animation: goldGlow 1s ease-in-out infinite;
}

.meeting-point::after {
  content: '🎯';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
}

/* ========================================
   Realm 6 - Remove Cycle Specific
   ======================================== */

.cycle-cut-point {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 2px dashed var(--accent-red);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all var(--transition-fast);
}

.cycle-cut-point:hover {
  border-style: solid;
  background: rgba(255, 71, 87, 0.2);
  transform: scale(1.2);
}

.cycle-cut-point.correct {
  border-color: var(--accent-green);
  background: rgba(0, 255, 136, 0.2);
}

.infinite-loop-warning {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 40px;
  background: rgba(255, 71, 87, 0.9);
  border-radius: 16px;
  text-align: center;
  animation: shake 0.5s ease infinite;
  z-index: 100;
}

.infinite-loop-warning h2 {
  font-size: 2rem;
  margin-bottom: 10px;
}

.infinite-loop-warning p {
  font-size: 1rem;
}

/* ========================================
   Realm 7 - DLL Specific
   ======================================== */

.dll-container {
  display: flex;
  align-items: center;
  gap: 20px;
}

.dll-visual-node {
  position: relative;
  width: 100px;
  height: 80px;
}

.prev-arrow,
.next-arrow {
  position: absolute;
  width: 40px;
  height: 3px;
  top: 50%;
  transform: translateY(-50%);
}

.prev-arrow {
  left: -40px;
  background: linear-gradient(90deg, var(--pointer-prev), transparent);
}

.next-arrow {
  right: -40px;
  background: linear-gradient(90deg, transparent, var(--pointer-next));
}

.dll-action-zone {
  position: absolute;
  padding: 10px;
  background: rgba(116, 185, 255, 0.1);
  border: 2px dashed var(--realm-primary);
  border-radius: 8px;
}

/* ========================================
   Realm 8 - LRU Cache Specific
   ======================================== */

.lru-container {
  display: flex;
  gap: 30px;
  padding: 20px;
}

.cache-visual {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cache-dll {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow-x: auto;
}

.cache-dll-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hashmap-visual {
  width: 300px;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 20px;
}

.hashmap-header {
  font-size: 0.9rem;
  color: var(--accent-gold);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hashmap-entries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hashmap-entry {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: 6px;
  font-family: var(--font-code);
  font-size: 0.85rem;
}

.hashmap-key {
  color: var(--accent-blue);
}

.hashmap-value {
  color: var(--text-muted);
}

.app-swipe-zone {
  display: flex;
  gap: 15px;
  padding: 20px;
  overflow-x: auto;
}

.app-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.app-icon:hover {
  transform: scale(1.1);
}

.app-icon.recently-used {
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

/* ========================================
   Realm 9 - Clone Specific
   ======================================== */

.clone-container {
  display: flex;
  flex-direction: column;
  gap: 40px;
  padding: 20px;
}

.original-list,
.cloned-list {
  position: relative;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: 12px;
}

.list-label {
  position: absolute;
  top: -10px;
  left: 20px;
  padding: 4px 12px;
  background: var(--bg-primary);
  border-radius: 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.original-list .list-label {
  color: var(--accent-blue);
}

.cloned-list .list-label {
  color: var(--accent-purple);
}

.random-link-visual {
  position: absolute;
  pointer-events: none;
}

.random-link-line {
  stroke: var(--accent-purple);
  stroke-width: 2;
  stroke-dasharray: 5 5;
  fill: none;
}

.interweave-indicator {
  position: absolute;
  padding: 4px 8px;
  background: rgba(162, 155, 254, 0.2);
  border: 1px solid var(--accent-purple);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--accent-purple);
}

/* ========================================
   Realm 10 - Intersection Specific
   ======================================== */

.intersection-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.path-visual {
  position: absolute;
  display: flex;
  align-items: center;
}

.path-a-visual {
  top: 30%;
  left: 10%;
}

.path-b-visual {
  top: 60%;
  left: 10%;
}

.path-label {
  position: absolute;
  left: -40px;
  font-family: var(--font-code);
  font-size: 0.9rem;
  font-weight: 600;
}

.path-a-visual .path-label {
  color: var(--accent-blue);
}

.path-b-visual .path-label {
  color: var(--accent-green);
}

.intersection-node {
  border: 3px solid var(--accent-gold) !important;
  box-shadow: var(--shadow-gold);
  animation: goldGlow 1s ease-in-out infinite;
}

.intersection-marker {
  position: absolute;
  width: 80px;
  height: 80px;
  border: 3px dashed var(--accent-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intersection-marker::after {
  content: '🔗';
  font-size: 2rem;
}

.length-counter {
  position: absolute;
  padding: 8px 16px;
  background: var(--bg-card);
  border-radius: 8px;
  font-family: var(--font-code);
  font-size: 0.9rem;
}

.length-counter.path-a {
  top: 25%;
  right: 20%;
  color: var(--accent-blue);
}

.length-counter.path-b {
  top: 55%;
  right: 20%;
  color: var(--accent-green);
}

/* ========================================
   Objective Display
   ======================================== */

.objective-banner {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--bg-card), var(--bg-tertiary));
  border: 2px solid var(--accent-gold);
  border-radius: 8px;
  max-width: 600px;
  text-align: center;
  z-index: 50;
}

.objective-banner h4 {
  font-size: 0.8rem;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.objective-banner p {
  font-size: 0.95rem;
  color: var(--text-primary);
}

/* ========================================
   Step-by-Step Guide
   ======================================== */

.step-guide {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 15px 20px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--bg-tertiary);
}

.guide-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.guide-step.active {
  background: rgba(0, 212, 255, 0.2);
  color: var(--accent-blue);
}

.guide-step.completed {
  background: rgba(0, 255, 136, 0.2);
  color: var(--accent-green);
}

.guide-step .step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.guide-step.active .step-number {
  background: var(--accent-blue);
  color: var(--bg-primary);
}

.guide-step.completed .step-number {
  background: var(--accent-green);
  color: var(--bg-primary);
}

.guide-step.completed .step-number::after {
  content: '✓';
}

/* ========================================
   Tooltip Styles
   ======================================== */

.tooltip {
  position: absolute;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--node-border);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  animation: fadeIn 0.2s ease;
}

.tooltip::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--node-border);
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 1200px) {
  .edu-panel {
    width: 220px;
  }

  .control-panel {
    width: 200px;
  }
}

@media (max-width: 992px) {
  .edu-panel,
  .control-panel {
    display: none;
  }

  .code-panel {
    left: 0;
    right: 0;
  }
}

@media (max-width: 768px) {
  .visual-node {
    width: 60px;
    height: 60px;
  }

  .node-value {
    font-size: 1rem;
  }

  .node-address {
    font-size: 0.55rem;
  }
}
