/* ============================================================================
   TS ALL-FOR-ONE — IN-GAME ZOOM CONTROLLER & INTEGRATED SLIDER BAR
   Ornate Three Kingdoms RPG UI (Ebony Lacquer & Gilded Bronze)
   Strictly scoped under #tszm-root (zero conflict with canvas / GM / Map / Hotkeys)
   ============================================================================ */

#tszm-root {
  --zm-font: "Be Vietnam Pro", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --zm-mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  --zm-ebony: rgba(24, 16, 11, 0.90);
  --zm-gold: #c99746;
  --zm-gold-hi: #f0cf85;
  --zm-cream: #f5ead6;
  --zm-sand: #bfa886;

  position: fixed;
  inset: 0;
  z-index: 9560;
  pointer-events: none;
  font-family: var(--zm-font);
  user-select: none;
}

#tszm-root *, #tszm-root *::before, #tszm-root *::after {
  box-sizing: border-box;
}

/* ==================== INTEGRATED FLOATING ZOOM SLIDER BAR ==================== */
.tszm-bar {
  position: fixed;
  top: 148px;
  right: 14px;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 4px 7px 4px 8px;
  border-radius: 999px;
  background: var(--zm-ebony);
  border: 1px solid rgba(201, 151, 70, 0.65);
  box-shadow:
    0 6px 18px rgba(8, 4, 2, 0.58),
    inset 0 1px 0 rgba(240, 207, 133, 0.18);
  color: var(--zm-cream);
  font: 700 11px var(--zm-font);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: border-color .14s ease, box-shadow .16s ease, opacity .16s ease;
}

.tszm-bar:hover {
  border-color: var(--zm-gold-hi);
  box-shadow:
    0 8px 22px rgba(8, 4, 2, 0.72),
    0 0 12px rgba(201, 151, 70, 0.25),
    inset 0 1px 0 rgba(240, 207, 133, 0.30);
}

.tszm-bar.dragging {
  cursor: grabbing;
  opacity: 0.94;
}

.tszm-grip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px 2px 2px;
  border: 0;
  background: transparent;
  color: var(--zm-sand);
  font: 700 11px var(--zm-font);
  cursor: grab;
  touch-action: none;
  white-space: nowrap;
  border-radius: 6px;
}

.tszm-grip:hover {
  color: var(--zm-gold-hi);
}

.tszm-bar.dragging .tszm-grip {
  cursor: grabbing;
}

.tszm-btn {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 1px solid rgba(240, 207, 133, 0.55);
  background: linear-gradient(180deg, #352317 0%, #22160f 100%);
  color: var(--zm-gold-hi);
  font: 800 13px/1 var(--zm-font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
}

.tszm-btn:hover {
  background: linear-gradient(180deg, #523620 0%, #311f13 100%);
  border-color: var(--zm-gold-hi);
}

.tszm-btn:active {
  transform: scale(0.92);
}

/* ==================== CUSTOM GOLDEN RANGE SLIDER ==================== */
.tszm-slider-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 96px;
  height: 20px;
}

/* 100% baseline tick marker: (100 - 45) / (200 - 45) = 35.48% */
.tszm-tick {
  position: absolute;
  left: calc(7px + (100% - 14px) * 0.3548);
  top: 50%;
  width: 2px;
  height: 9px;
  transform: translate(-50%, -50%);
  border-radius: 1px;
  background: rgba(240, 207, 133, 0.58);
  pointer-events: none;
  z-index: 1;
}

.tszm-slider {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  z-index: 2;
  width: 100%;
  height: 5px;
  margin: 0;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(
    90deg,
    #d8a248 0%,
    #f0cf85 var(--zm-pct, 33.33%),
    rgba(255, 240, 200, 0.16) var(--zm-pct, 33.33%),
    rgba(255, 240, 200, 0.16) 100%
  );
  border: 1px solid rgba(201, 151, 70, 0.36);
}

.tszm-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3c7 0%, #e4b255 55%, #8a5b18 100%);
  border: 1.5px solid #fff0c7;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.75), 0 0 6px rgba(240, 207, 133, 0.45);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .12s ease;
}

.tszm-slider::-webkit-slider-thumb:hover {
  transform: scale(1.14);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.85), 0 0 10px rgba(240, 207, 133, 0.8);
}

.tszm-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3c7 0%, #e4b255 55%, #8a5b18 100%);
  border: 1.5px solid #fff0c7;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.75), 0 0 6px rgba(240, 207, 133, 0.45);
  cursor: pointer;
}

.tszm-slider::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: transparent;
}

/* ==================== PERCENTAGE BADGE (CLICK TO RESET 100%) ==================== */
.tszm-val {
  min-width: 42px;
  text-align: center;
  padding: 2px 5px;
  border-radius: 6px;
  border: 1px solid rgba(201, 151, 70, 0.28);
  background: rgba(255, 240, 200, 0.08);
  color: var(--zm-gold-hi);
  font: 700 11px var(--zm-mono);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.tszm-val:hover {
  background: rgba(240, 207, 133, 0.22);
  border-color: var(--zm-gold-hi);
}

.tszm-val.zoomed {
  background: rgba(201, 151, 70, 0.26);
  border-color: rgba(240, 207, 133, 0.72);
  color: #fff3c7;
}

/* Compact collapsed mode (click 🔍 without dragging) */
.tszm-bar.compact .tszm-btn,
.tszm-bar.compact .tszm-slider-wrap {
  display: none;
}

/* ==================== NON-BLOCKING FLOATING ZOOM TOAST ==================== */
.tszm-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(20, 13, 9, 0.90);
  border: 1px solid rgba(240, 207, 133, 0.72);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.62);
  color: #fff3c7;
  font: 700 12px var(--zm-font);
  opacity: 0;
  transition: opacity .16s ease, transform .16s ease;
}

.tszm-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tszm-toast-pct {
  min-width: 40px;
  text-align: right;
  font-family: var(--zm-mono);
  font-variant-numeric: tabular-nums;
  color: var(--zm-gold-hi);
}

.tszm-toast-track {
  width: 66px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 240, 200, 0.18);
  overflow: hidden;
}

.tszm-toast-fill {
  height: 100%;
  width: 33.33%;
  border-radius: 999px;
  background: linear-gradient(90deg, #c99746, #ffe39b);
}

@media (max-width: 760px) {
  .tszm-bar {
    top: 130px;
    right: 8px;
    padding: 3px 6px 3px 7px;
  }
  .tszm-slider-wrap {
    width: 72px;
  }
}
