/* ----- Difficulty meter (no JS) ----- */
.difficulty-meter {
  --bar-w: 18px;
  --bar-gap: 8px;
  --bar-radius: 8px;
  --bar-step: 10px;  /* growth per bar */
  --bar-base: 12px;  /* shortest height */
}

.difficulty-meter .bars {
  display: flex;
  align-items: flex-end;
  gap: var(--bar-gap);
}

/* Responsive adjustments for small screens */
@media (max-width: 991.98px) {
  .difficulty-meter {
    --bar-w: 16px;
    --bar-gap: 6px;
    --bar-step: 8px;
    --bar-base: 10px;
  }
  
  .difficulty-meter .level-text {
    font-size: 0.9rem;
    min-width: 80px;
    margin-left: 8px;
  }
}

@media (max-width: 575.98px) {
  .difficulty-meter {
    --bar-w: 14px;
    --bar-gap: 5px;
    --bar-step: 7px;
    --bar-base: 9px;
  }
  
  .difficulty-meter .level-text {
    font-size: 0.85rem;
    min-width: 70px;
    margin-left: 6px;
  }
  
  /* Ensure difficulty meter doesn't overflow on very small screens */
  .difficulty-meter .d-flex {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* Hide native radios but keep them accessible */
.difficulty-meter input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* Bar as a label */
.difficulty-meter .bar-label {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: var(--bar-w);
  border-radius: var(--bar-radius);
  opacity: 1;               /* off look */
  cursor: pointer;
  position: relative;         /* for tooltip */
  outline: none;
  box-shadow: inset 0 2px 0 rgba(0,0,0,.06);
  transition: opacity .15s ease, outline .15s ease, border .15s ease;
  border: 1px solid transparent; /* prepare for selected state */
}

/* Selected state - using attribute selector since radio is not adjacent */
.difficulty-meter .bar-label.selected {
  opacity: 1;                 /* full opacity when selected */
  border: 1px solid white;    /* white inner border */
  box-shadow: inset 0 2px 0 rgba(0,0,0,.06), 0 0 0 1px #007bff; /* blue outer border */
}

/* Heights form a ladder */
.difficulty-meter .bar-label:nth-of-type(1) { height: calc(var(--bar-base) + var(--bar-step) * 0); }
.difficulty-meter .bar-label:nth-of-type(2) { height: calc(var(--bar-base) + var(--bar-step) * 1); }
.difficulty-meter .bar-label:nth-of-type(3) { height: calc(var(--bar-base) + var(--bar-step) * 2); }
.difficulty-meter .bar-label:nth-of-type(4) { height: calc(var(--bar-base) + var(--bar-step) * 3); }
.difficulty-meter .bar-label:nth-of-type(5) { height: calc(var(--bar-base) + var(--bar-step) * 4); }

/* Color ramp (BRIGHT, high-saturation) */
.difficulty-meter .c1 { background: #00e676; } /* bright green */
.difficulty-meter .c2 { background: #00c853; } /* bright green-dark */
.difficulty-meter .c3 { background: #ffd700; } /* bright gold/yellow */
.difficulty-meter .c4 { background: #ff6d00; } /* bright orange */
.difficulty-meter .c5 { background: #ff1744; } /* bright red */

/* Locked state styling - override colors with gray */
.difficulty-meter .bar-label.locked {
  background: #e0e0e0 !important; /* light gray for locked bars */
  opacity: 1 !important; /* more transparent */
  cursor: not-allowed !important; /* indicate not clickable */
  /* Remove pointer-events: none to allow tooltips to work */
}

/* Prevent clicking on locked bars but allow hover for tooltips */
.difficulty-meter .bar-label.locked input[type="radio"] {
  pointer-events: none; /* prevent radio button interaction */
}

/* Keyboard focus ring on labels */
.difficulty-meter .bar-label:focus-visible {
  outline: 2px solid rgba(0,0,0,.35);
  outline-offset: 2px;
}

/* Visible label next to bars */
.difficulty-meter .level-text {
  font-weight: 700;
  margin-left: 12px;
  min-width: 90px;
}

/* ----- CSS-only tooltip (hover/focus/touch) ----- */
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.3;
  padding: 8px 12px;
  border-radius: 8px;
  background: #1a1a1a !important;  /* darker background for better contrast - force with !important */
  color: #ffffff !important;       /* pure white text - force with !important */
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  transform-origin: bottom center;
  translate: 0 4px;
  z-index: 1000;        /* higher z-index to ensure visibility */
  box-shadow: 0 4px 12px rgba(0,0,0,0.3); /* subtle shadow for depth */
  font-weight: 500;     /* slightly bolder text */
  /* Prevent tooltip from extending beyond viewport */
  max-width: 500px;
  /* white-space: normal; */
  /* word-wrap: break-word; */
  /* Smart positioning to prevent overflow */
  right: auto;
}

/* Adjust tooltip positioning for elements near the right edge */
[data-tooltip]:nth-last-child(-n+2)::after,
.difficulty-meter .bar-label:nth-last-child(-n+2)[data-tooltip]::after {
  left: auto;
  right: 0;
  transform: translateX(0);
}

/* Ensure all difficulty meter tooltips have consistent dark styling */
.difficulty-meter [data-tooltip]::after,
.difficulty-meter .bar-label[data-tooltip]::after,
.difficulty-meter .bar-label.locked[data-tooltip]::after,
.difficulty-meter .bar-label.selected[data-tooltip]::after {
  background: #1a1a1a !important;
  color: #ffffff !important;
  font-size: 13px !important;
  line-height: 1.3 !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
  font-weight: 500 !important;
  max-width: 500px !important;
  white-space: normal !important;
  /* word-wrap: break-word !important; */
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  translate: 0 0;
}

[data-tooltip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1a1a1a !important;  /* match the darker tooltip background - force with !important */
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 999;  /* slightly lower than tooltip but still high */
}

/* Adjust tooltip arrow positioning for elements near the right edge */
[data-tooltip]:nth-last-child(-n+2)::before,
.difficulty-meter .bar-label:nth-last-child(-n+2)[data-tooltip]::before {
  left: auto;
  right: 12px; /* position arrow to align with tooltip */
  transform: translateX(0);
}

/* Ensure all difficulty meter tooltip arrows have consistent dark styling */
.difficulty-meter [data-tooltip]::before,
.difficulty-meter .bar-label[data-tooltip]::before,
.difficulty-meter .bar-label.locked[data-tooltip]::before,
.difficulty-meter .bar-label.selected[data-tooltip]::before {
  border-top-color: #1a1a1a !important;
}

[data-tooltip]:hover::before,
[data-tooltip]:focus::before,
[data-tooltip]:focus-visible::before {
  opacity: 1;
}