/* ============================================================================
   RATINGS — category-rate widget
   Per-category 0..100 sliders inside a titled card. Gold accent (--warn)
   matches the star-rate palette. Mobile-first: rows stack cleanly on narrow
   viewports (one category is literally mobile adaptability).
   ========================================================================= */

.wfe-catrate {
  display: block;
  background: var(--surface, #221d19);
  border: 1px solid var(--border, rgba(255,220,180,0.07));
  border-radius: var(--r-md, 10px);
  padding: 12px 14px;
}

.wfe-catrate-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #f1e8de);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wfe-catrate-ver {
  font-size: 10px;
  opacity: 0.6;
  font-family: monospace;
  color: var(--muted, #b3a89c);
  font-weight: 400;
}

.wfe-catrate-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wfe-catrate-row {
  display: block;
}

.wfe-catrate-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.wfe-catrate-label {
  font-size: 13px;
  color: var(--text, #f1e8de);
}
.wfe-catrate-aggr {
  font-size: 11px;
  color: var(--muted, #b3a89c);
  background: var(--surface-2, #2a231e);
  border: 1px solid var(--border, rgba(255,220,180,0.07));
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.wfe-catrate-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- custom fixed-width fill bar (replaces the native range slider) --- */
.wfe-catrate-bar {
  position: relative;
  flex: 0 0 auto;
  width: 220px;
  max-width: 100%;
  height: 14px;
  border-radius: var(--r-md, 10px);
  background: var(--surface-2, #2a231e);
  border: 1px solid var(--border, rgba(255,220,180,0.07));
  cursor: pointer;
  overflow: hidden;
  touch-action: none; /* let pointer drag own the gesture, no scroll-jank */
}
.wfe-catrate-bar:focus-visible {
  outline: 2px solid var(--warn, #d59148);
  outline-offset: 3px;
}
/* The colored fill: width=score, color set inline (red→green by score). */
.wfe-catrate-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--muted, #b3a89c);
  transition: width 0.18s ease, background-color 0.18s ease;
  will-change: width;
}
/* No votes yet: neutral empty track, no red fill. */
.wfe-catrate-novotes .wfe-catrate-bar {
  border-style: dashed;
  border-color: var(--border-2, rgba(255,220,180,0.12));
}
/* my_score notch on the track. */
.wfe-catrate-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  margin-left: -1px;
  background: var(--text, #f1e8de);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.45);
  border-radius: 1px;
  pointer-events: none;
}

.wfe-catrate-mine {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted, #b3a89c);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wfe-catrate-clear {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-2, rgba(255,220,180,0.12));
  color: var(--muted, #b3a89c);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
@media (hover:hover) {
  .wfe-catrate-clear:hover {
    color: var(--text, #f1e8de);
    border-color: var(--warn, #d59148);
  }
}

/* Narrow viewports: let the fixed-width bar flex down so it never overflows. */
@media (max-width: 480px) {
  .wfe-catrate-bar { flex: 1 1 auto; width: auto; }
  .wfe-catrate-control { gap: 8px; }
}

/* ── Mobile adaptivity ─────────────────────────────────────────────────────── */

/* Tap-target кнопки «×» очистки — 44×44 на тач */
@media (pointer:coarse) {
  .wfe-catrate-clear {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Увеличиваем высоту трека: легче попасть пальцем */
  .wfe-catrate-bar {
    height: 22px;
    border-radius: var(--r-md, 10px);
  }
}

@media (max-width:640px) {
  /* Карточка: уменьшаем горизонтальные падинги */
  .wfe-catrate { padding: 10px 10px; }

  /* Строка заголовка: label + aggr переносятся, не обрезаются */
  .wfe-catrate-head {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  /* Строка контрола: bar + mine + clear — не выходят за экран */
  .wfe-catrate-control {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Bar всегда растягивается на всю доступную ширину */
  .wfe-catrate-bar { flex: 1 1 100%; width: auto; min-width: 0; }

  /* mine и clear — в одну строку после бара */
  .wfe-catrate-mine { flex: 1 1 auto; }
  .wfe-catrate-clear { flex: 0 0 auto; }
}

@media (max-width:380px) {
  .wfe-catrate { padding: 8px 8px; }
  .wfe-catrate-label { font-size: 12px; }
  .wfe-catrate-aggr  { font-size: 10px; }
}

/* mobile_adaptability на десктопе: bar показывает avg + marker, но не реагирует
   на драг/клавиатуру. Подсказка «только с мобильного» рядом с label. */
.wfe-catrate-desktop-locked .wfe-catrate-bar {
  cursor: not-allowed;
  opacity: 0.85;
}
.wfe-catrate-desktop-locked .wfe-catrate-bar:focus-visible {
  outline: none;
}
.wfe-catrate-locknote {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted, #b3a89c);
  background: var(--surface-2, #2a231e);
  border: 1px dashed var(--border-2, rgba(255,220,180,0.12));
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
}
