.snake-line-graph {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 200px;
  padding: 20px;
  background: transparent;
  border: 1px solid var(--color-border);
  font-family: var(--font-family);
  color: var(--color-text-primary);
  box-sizing: border-box;
}

/* Corner accents */
.snake-line-graph__corner {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--color-text-muted);
}

.snake-line-graph__corner--top-left {
  top: -1px;
  left: -1px;
  border-right: none;
  border-bottom: none;
}

.snake-line-graph__corner--top-right {
  top: -1px;
  right: -1px;
  border-left: none;
  border-bottom: none;
}

.snake-line-graph__corner--bottom-left {
  bottom: -1px;
  left: -1px;
  border-right: none;
  border-top: none;
}

.snake-line-graph__corner--bottom-right {
  bottom: -1px;
  right: -1px;
  border-left: none;
  border-top: none;
}

/* Container */
.snake-line-graph__container {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  height: 100%;
}

/* Title */
.snake-line-graph__title {
  font-size: 16px;
  font-weight: bold;
  color: var(--color-text-primary);
  text-align: center;
  margin-bottom: 10px;
  font-family: var(--font-family-mono);
}

/* SVG */
.snake-line-graph__svg {
  display: block;
  overflow: visible;
}

/* Lines */
.snake-line-graph__line {
  transition:
    stroke-width var(--transition-base),
    opacity var(--transition-base);
  fill: none;
}

.snake-line-graph__line:hover {
  filter: brightness(1.2);
}

/* Animated lines */
.snake-line-graph--animated .snake-line-graph__line {
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  animation: snake-line-graph-draw 1.5s ease-out forwards;
}

@keyframes snake-line-graph-draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* Stagger animation for multiple lines */
.snake-line-graph--animated .snake-line-graph__series:nth-child(1) .snake-line-graph__line {
  animation-delay: 0s;
}
.snake-line-graph--animated .snake-line-graph__series:nth-child(2) .snake-line-graph__line {
  animation-delay: 0.2s;
}
.snake-line-graph--animated .snake-line-graph__series:nth-child(3) .snake-line-graph__line {
  animation-delay: 0.4s;
}
.snake-line-graph--animated .snake-line-graph__series:nth-child(4) .snake-line-graph__line {
  animation-delay: 0.6s;
}
.snake-line-graph--animated .snake-line-graph__series:nth-child(5) .snake-line-graph__line {
  animation-delay: 0.8s;
}

/* Areas */
.snake-line-graph__area {
  transition: opacity var(--transition-base);
  pointer-events: none;
}

.snake-line-graph--animated .snake-line-graph__area {
  opacity: 0;
  animation: snake-line-graph-fade-in 0.8s ease-out forwards;
  animation-delay: 0.8s;
}

@keyframes snake-line-graph-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Points */
.snake-line-graph__point {
  transition:
    r var(--transition-fast),
    fill var(--transition-fast);
}

.snake-line-graph__point:hover {
  r: 6;
  filter: brightness(1.3);
}

.snake-line-graph--animated .snake-line-graph__point {
  opacity: 0;
  animation: snake-line-graph-point-fade 0.3s ease-out forwards;
}

@keyframes snake-line-graph-point-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Stagger animation for points */
.snake-line-graph--animated .snake-line-graph__series:nth-child(1) .snake-line-graph__point {
  animation-delay: 0.5s;
}
.snake-line-graph--animated .snake-line-graph__series:nth-child(2) .snake-line-graph__point {
  animation-delay: 0.7s;
}
.snake-line-graph--animated .snake-line-graph__series:nth-child(3) .snake-line-graph__point {
  animation-delay: 0.9s;
}
.snake-line-graph--animated .snake-line-graph__series:nth-child(4) .snake-line-graph__point {
  animation-delay: 1.1s;
}
.snake-line-graph--animated .snake-line-graph__series:nth-child(5) .snake-line-graph__point {
  animation-delay: 1.3s;
}

/* Series */
.snake-line-graph__series {
  transition: opacity var(--transition-base);
}

.snake-line-graph__series--active .snake-line-graph__line {
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.3));
}

/* Grid */
.snake-line-graph__grid {
  pointer-events: none;
}

/* Axes */
.snake-line-graph__axes {
  stroke: var(--color-text-muted);
}

/* Axis labels */
.snake-line-graph__axis-label {
  user-select: none;
}

/* Tooltip */
.snake-line-graph__tooltip {
  pointer-events: none;
  animation: snake-line-graph-tooltip-fade 0.2s ease-out;
}

@keyframes snake-line-graph-tooltip-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Legend */
.snake-line-graph__legend {
  position: absolute;
  top: 20px;
  right: 20px;
  background-color: #101010;
  border: 1px solid #3a3a3a;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  z-index: 10;
  transform-origin: center;
}

/* Legend animation */
.snake-line-graph__legend--animated {
  animation: snake-line-graph-legend-expand 0.3s ease-out forwards;
  animation-delay: 0.3s;
  opacity: 0;
  transform: scaleY(0);
}

@keyframes snake-line-graph-legend-expand {
  from {
    opacity: 0;
    transform: scaleY(0);
  }
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

/* Legend corner elbows */
.snake-line-graph__legend::before,
.snake-line-graph__legend::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid #8e8e90;
}

.snake-line-graph__legend::before {
  top: -1px;
  left: -1px;
  border-right: none;
  border-bottom: none;
}

.snake-line-graph__legend::after {
  bottom: -1px;
  right: -1px;
  border-left: none;
  border-top: none;
}

.snake-line-graph__legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.snake-line-graph__legend-item:hover {
  opacity: 0.8;
}

.snake-line-graph__legend-item--active {
  font-weight: bold;
}

.snake-line-graph__legend-color {
  width: 16px;
  height: 2px;
  background-color: var(--color-text-secondary);
  transition: transform var(--transition-fast);
}

.snake-line-graph__legend-item--active .snake-line-graph__legend-color {
  transform: scaleY(2);
}

.snake-line-graph__legend-label {
  color: var(--color-text-primary);
  font-family: var(--font-family-mono);
  font-size: 11px;
}

/* Interactive variant */
.snake-line-graph--interactive .snake-line-graph__line {
  cursor: pointer;
  transition: all 0.3s ease;
}

.snake-line-graph--interactive .snake-line-graph__point {
  cursor: pointer;
}

/* Variants */

/* Minimal variant */
.snake-line-graph--minimal {
  background: transparent;
  border: none;
  padding: 10px;
}

.snake-line-graph--minimal .snake-line-graph__corner {
  display: none;
}

.snake-line-graph--minimal .snake-line-graph__line {
  stroke-width: 1;
}

.snake-line-graph--minimal .snake-line-graph__point {
  display: none;
}

/* Detailed variant */
.snake-line-graph--detailed {
  padding: 30px;
  background: rgba(31, 29, 32, 0.3);
}

.snake-line-graph--detailed .snake-line-graph__line {
  stroke-width: 2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.snake-line-graph--detailed .snake-line-graph__area {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.snake-line-graph--detailed .snake-line-graph__point {
  r: 5;
  stroke-width: 2;
}

.snake-line-graph--detailed .snake-line-graph__legend {
  background-color: #1f1d20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  padding: 16px;
  border-width: 1px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .snake-line-graph {
    padding: 15px;
  }

  .snake-line-graph__legend {
    position: static;
    margin-top: 20px;
  }

  .snake-line-graph__title {
    font-size: 14px;
  }
}
