/* Open Closed Indicator Frontend Styles - WITH POWER-ON ANIMATION */

:root {
  /* Glow variables */
  --oci-glow-1: 6px;
  --oci-glow-2: 14px;
  --oci-glow-3: 28px;

  /* Animation multipliers - same diameter */
  --oci-hover-r1-mul: 0.30;
  --oci-hover-r2-mul: 0.22;

  /* Idle glow - MUCH dimmer (80% reduction) */
  --oci-idle-r1-mul: 0.24; /* Same diameter */
  --oci-idle-r2-mul: 0.176; /* Same diameter */
  --oci-idle-intensity: 0.20; /* 80% reduction from original */

  /* Animation durations */
  --oci-on-duration: 420ms;
  --oci-off-duration: 580ms;
  --oci-hover-duration: 1600ms;
  --oci-idle-duration: 4200ms;
  --oci-power-on-duration: 800ms; /* New: Initial power-on */

  --oci-ease: ease-in-out;
}

/* Main container */
.oci-indicator {
  position: relative;
  isolation: isolate;
  z-index: 0;
  display: inline-block;
  margin: 0;
  vertical-align: middle;
  pointer-events: auto !important;
  cursor: pointer;
  color: currentColor;
  touch-action: manipulation;
  /* Eager loading - visible immediately */
  opacity: 1;
  visibility: visible;
}

/* Size variations */
.oci-size-small {
  width: 90px;
  height: calc(90px / 3.33);
}

.oci-size-medium {
  width: 110px;
  height: calc(110px / 3.33);
}

.oci-size-large {
  width: 130px;
  height: calc(130px / 3.33);
}

/* Desktop hover support */
@media (hover: hover) and (pointer: fine) {
  .oci-size-small {
    width: 110px;
    height: calc(110px / 3.33);
  }

  .oci-size-medium {
    width: 130px;
    height: calc(130px / 3.33);
  }

  .oci-size-large {
    width: 150px;
    height: calc(150px / 3.33);
  }
}

/* Visual wrapper */
.oci-visual {
  position: relative;
  width: 100%;
  height: 100%;
  line-height: 0;
  overflow: visible;
  aspect-ratio: 3.33 / 1;
  pointer-events: none;
}

/* Layer system - Only one layer visible, icons never fade */
.oci-layer {
  position: absolute;
  inset: 0;
  opacity: 0 !important;
  visibility: hidden !important;
  transform: scale(1);
  transition: none;
  will-change: filter;
  backface-visibility: hidden;
  pointer-events: none;
}

.oci-layer.is-active {
  opacity: 1 !important;
  visibility: visible !important;
  transform: scale(1);
}

/* Icon content - NEVER affected by animations */
.oci-layer svg,
.oci-layer img,
.oci-layer .oci-placeholder {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform-origin: 50% 50%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  pointer-events: none;
  animation: none !important;
  transition: none !important;
}

/* Placeholder styling */
.oci-placeholder {
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: system-ui, sans-serif;
  letter-spacing: 0.06em;
  font-size: clamp(8px, 2vw, 14px);
  opacity: 1 !important;
}

/* Hit area */
#oci-hit-area {
  position: absolute;
  inset: 0;
  z-index: 999;
  display: block;
  background: transparent;
  border: 0;
  margin: 0;
  padding: 0;
  appearance: none;
  pointer-events: auto !important;
  cursor: pointer;
  touch-action: manipulation;
  outline: none;
}

#oci-hit-area:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Animation states - WITH POWER-ON ANIMATION */

/* POWER-ON: Initial load animation from complete darkness */
.oci-indicator.oci-state-power-on {
  animation: ociPowerOn var(--oci-power-on-duration) ease-out 0s 1 both;
}

/* IDLE: Very dim, barely visible glow */
.oci-indicator.oci-state-idle {
  filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * var(--oci-idle-intensity)) currentColor)
          drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-idle-r2-mul) * var(--oci-idle-intensity)) currentColor);
  animation: ociIdleGlow var(--oci-idle-duration) var(--oci-ease) 0s infinite;
}

/* HOVER: Stronger glow animation */
.oci-indicator.oci-state-hover {
  filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-hover-r1-mul)) currentColor)
          drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-hover-r2-mul)) currentColor);
  animation: ociHoverGlow var(--oci-hover-duration) var(--oci-ease) 0s infinite;
}

/* FLICKER ON: Multiple medium-speed flickers */
.oci-indicator.oci-state-flicker-on {
  animation: ociFlickerOn var(--oci-on-duration) linear 0s 1 both;
}

/* FLICKER OFF: Progressive slower flickers */
.oci-indicator.oci-state-flicker-off {
  animation: ociFlickerOff var(--oci-off-duration) ease-out 0s 1 both;
}

/* KEYFRAME ANIMATIONS */

/* NEW: Power-on animation - neon light turning on for first time */
@keyframes ociPowerOn {
  0% {
    filter: none;
  }
  /* Initial attempts to turn on */
  8% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.1) currentColor);
  }
  12% {
    filter: none;
  }
  18% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-2) * 0.2) currentColor);
  }
  22% {
    filter: none;
  }
  /* Building up power */
  30% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.3) currentColor);
  }
  35% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.1) currentColor);
  }
  42% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.5) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * 0.4) currentColor);
  }
  48% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.2) currentColor);
  }
  /* Almost there */
  58% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.8) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * 0.6) currentColor);
  }
  65% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.4) currentColor);
  }
  /* Final power surge to idle state */
  75% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * 0.8) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-idle-r2-mul) * 0.6) currentColor);
  }
  85% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * 0.4) currentColor);
  }
  /* Settle into idle glow */
  100% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * var(--oci-idle-intensity)) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-idle-r2-mul) * var(--oci-idle-intensity)) currentColor);
  }
}

@keyframes ociIdleGlow {
  0% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * var(--oci-idle-intensity)) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-idle-r2-mul) * var(--oci-idle-intensity)) currentColor);
  }
  48% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * var(--oci-idle-intensity) * 0.6) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-idle-r2-mul) * var(--oci-idle-intensity) * 0.6) currentColor);
  }
  52% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * var(--oci-idle-intensity) * 1.4) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-idle-r2-mul) * var(--oci-idle-intensity) * 1.4) currentColor);
  }
  100% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * var(--oci-idle-intensity)) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-idle-r2-mul) * var(--oci-idle-intensity)) currentColor);
  }
}

@keyframes ociHoverGlow {
  0% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-hover-r1-mul)) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-hover-r2-mul)) currentColor);
  }
  47% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-hover-r1-mul) * 0.8) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-hover-r2-mul) * 0.8) currentColor);
  }
  53% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-hover-r1-mul) * 1.2) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-hover-r2-mul) * 1.2) currentColor);
  }
  100% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-hover-r1-mul)) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-hover-r2-mul)) currentColor);
  }
}

/* FLICKER ON: 4 medium-speed flickers building up */
@keyframes ociFlickerOn {
  0% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * var(--oci-idle-intensity)) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-idle-r2-mul) * var(--oci-idle-intensity)) currentColor);
  }
  /* First flicker */
  8% {
    filter: none;
  }
  12% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-2) * 0.4) currentColor);
  }
  16% {
    filter: none;
  }
  /* Second flicker */
  24% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-2) * 0.6) currentColor);
  }
  28% {
    filter: none;
  }
  /* Third flicker */
  36% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.5) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * 0.8) currentColor);
  }
  40% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.2) currentColor);
  }
  /* Fourth flicker - building to full glow */
  48% {
    filter: drop-shadow(0 0 var(--oci-glow-1) currentColor)
            drop-shadow(0 0 var(--oci-glow-2) currentColor);
  }
  52% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.6) currentColor);
  }
  /* Final build to hover state */
  65% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 1.2) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * 1.2) currentColor);
  }
  75% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.8) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * 0.8) currentColor);
  }
  100% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-hover-r1-mul)) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-hover-r2-mul)) currentColor);
  }
}

/* FLICKER OFF: 5 progressively slower flickers fading out */
@keyframes ociFlickerOff {
  0% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-hover-r1-mul)) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-hover-r2-mul)) currentColor);
  }
  /* First flicker - fast */
  6% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.3) currentColor);
  }
  10% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-2) * 0.7) currentColor);
  }
  14% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.2) currentColor);
  }
  /* Second flicker - medium */
  22% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-2) * 0.5) currentColor);
  }
  28% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.15) currentColor);
  }
  /* Third flicker - slower */
  38% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-2) * 0.4) currentColor);
  }
  45% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.1) currentColor);
  }
  /* Fourth flicker - very slow */
  58% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-2) * 0.25) currentColor);
  }
  68% {
    filter: none;
  }
  /* Fifth flicker - slowest, final fade */
  78% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * 0.05) currentColor);
  }
  88% {
    filter: none;
  }
  /* Final fade to idle */
  100% {
    filter: drop-shadow(0 0 calc(var(--oci-glow-1) * var(--oci-idle-r1-mul) * var(--oci-idle-intensity)) currentColor)
            drop-shadow(0 0 calc(var(--oci-glow-2) * var(--oci-idle-r2-mul) * var(--oci-idle-intensity)) currentColor);
  }
}

/* Tooltip styles - FIXED PADDING */
.oci-tooltip {
  position: fixed;
  background: #212121;
  color: #ffffff;
  padding: 4px 8px; /* FIXED: 4px top/bottom, 8px left/right */
  border-radius: 4px;
  font-family: system-ui, sans-serif;
  font-size: 10px;
  line-height: 1.12;
  white-space: nowrap;
  max-width: min(90vw, 360px);
  text-align: center;
  z-index: 2147483000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.oci-tooltip.show {
  opacity: 1;
}

/* Style variations */
.oci-style-minimal {
  filter: brightness(0.9);
}

.oci-style-custom {
  /* Allow for custom styling via additional CSS */
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .oci-indicator,
  .oci-indicator.oci-state-idle,
  .oci-indicator.oci-state-hover,
  .oci-indicator.oci-state-flicker-on,
  .oci-indicator.oci-state-flicker-off,
  .oci-indicator.oci-state-power-on {
    animation: none !important;
    filter: drop-shadow(0 0 2px currentColor) !important;
  }
}

/* Hidden state override - for eager loading */
.oci-indicator[hidden] {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Loading state - show with basic styling while loading */
.oci-indicator.loading {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Error state - hide completely if error */
.oci-indicator.error {
  display: none !important;
}

/* High contrast support */
@media (prefers-contrast: high) {
  .oci-indicator {
    filter: contrast(1.2);
  }
}