/* =====================================================================================
   [controls] SAJÁT VEZÉRLŐK – B · Műszak tokenekkel (style.css :root). Párja: js/ui/controls.js
   legördülő (.cx-dd + .cx-pop), szegmentált (.cx-seg), szám-léptető (.cx-num), csúszka (.cx-range), kapcsoló (.cx-sw),
   színválasztó (.cx-color + .cx-cpop), tooltip (.cx-tip), párbeszéd (.cx-dlg), görgetősáv
   Csak transform / opacity animál (nincs elrendezés-animáció); a lebegő rétegek position: fixed + transform.
   ===================================================================================== */

/* a natív elem marad (érték, űrlap), de nem látszik és nem kattintható */
.cx-native { position: absolute !important; width: 1px !important; height: 1px !important; margin: 0 !important; padding: 0 !important; border: 0 !important;
  opacity: 0 !important; pointer-events: none !important; clip-path: inset(50%) !important; overflow: hidden !important; }

/* ---------- legördülő: gomb ---------- */
.cx-dd { all: unset; box-sizing: border-box; cursor: var(--cur-ptr, pointer); position: relative; display: inline-flex; align-items: center; gap: var(--s2); width: 100%; min-width: 0; height: var(--h);
  padding: 0 34px 0 12px; border-radius: var(--r); background: var(--fill); box-shadow: inset 0 0 0 1px var(--line-2);
  font-family: var(--f-body); font-size: 14px; font-weight: 500; line-height: 1; color: var(--ink); text-align: left;
  transition: background var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.cx-dd:hover { background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--line-3); }
.cx-dd:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.cx-dd.open { background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--ink-2); }
.cx-dd[disabled] { opacity: .4; cursor: var(--cur-no, not-allowed); }
.cx-dd-v { display: inline-flex; align-items: center; gap: var(--s2); min-width: 0; flex: 1; }
.cx-dd-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-dd-img { width: 44px; height: 24px; object-fit: contain; flex: none; }
.cx-dd.has-img { padding-left: 6px; }
.cx-dd-ch { position: absolute; right: 12px; top: 50%; width: 11px; height: 8px; margin-top: -4px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  transition: transform var(--t) var(--ease); }
.cx-dd.open .cx-dd-ch { transform: rotate(180deg); stroke: var(--ink); }
.cx-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); }
/* kis változat (pl. a Fejlődés fejlécében) */
.pg-title .cx-dd, .cx-dd.sm { height: 30px; font-size: var(--fs-sm, 12.5px); border-radius: var(--r-sm); padding-left: 10px; padding-right: 28px; width: auto; max-width: 240px; }
.pg-title .cx-dd-ch, .cx-dd.sm .cx-dd-ch { right: 9px; }

/* ---------- lebegő lista ---------- */
.cx-pop { position: fixed; left: 0; top: 0; z-index: 2000; overflow-y: auto; overscroll-behavior: contain; padding: 4px; outline: none;
  background: var(--surface-3, rgba(9, 9, 11, .96)); border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--line-2), var(--sh-lg);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  font-family: var(--f-body); color: var(--ink); animation: cx-pop-in 140ms var(--ease-film) both; transform-origin: top center; contain: layout paint; }
.cx-pop.up { transform-origin: bottom center; }
@keyframes cx-pop-in { from { opacity: 0; } to { opacity: 1; } }
.cx-opt { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 30px 6px 10px; border-radius: var(--r-sm); cursor: var(--cur-ptr, pointer); color: var(--ink-2); font-size: 14px; }
.cx-opt.act { background: var(--fill-3); color: var(--ink); }
.cx-opt.sel { color: var(--ink); }
.cx-opt.sel b { font-weight: 600; }
.cx-opt[aria-disabled="true"] { opacity: .38; cursor: var(--cur-no, not-allowed); }
.cx-opt-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cx-opt-t b { font-weight: 500; overflow-wrap: anywhere; }
.cx-opt-t small { font-family: var(--f-mono); font-size: 11px; letter-spacing: .02em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-opt img { width: 72px; height: 40px; object-fit: contain; flex: none; border-radius: var(--r-xs); background: var(--fill); }
.cx-pop.imgs .cx-opt { min-height: 52px; }
.cx-tick { position: absolute; right: 10px; top: 50%; width: 14px; height: 14px; margin-top: -7px; fill: none; stroke: var(--light); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.cx-opt.sel .cx-tick { opacity: 1; }

/* ---------- szegmentált választó ---------- */
.cx-seg { display: flex; gap: 2px; padding: 3px; min-width: 0; border-radius: var(--r); background: var(--fill); box-shadow: inset 0 0 0 1px var(--line); }
.cx-seg button { all: unset; box-sizing: border-box; cursor: var(--cur-ptr, pointer); flex: 1 1 0; min-width: 0; height: 32px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); font-family: var(--f-body); font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--t) var(--ease), color var(--t); }
.cx-seg button:hover { color: var(--ink); background: var(--fill-2); }
.cx-seg button[aria-checked="true"] { background: var(--paper); color: var(--on-paper); font-weight: 600; }
.cx-seg button:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.cx-seg button[disabled] { opacity: .4; cursor: var(--cur-no, not-allowed); }
.cx-seg.dis { opacity: .5; }

/* ---------- szám-léptető ---------- */
.cx-num { display: flex; align-items: stretch; min-width: 0; height: var(--h); border-radius: var(--r); background: var(--fill); box-shadow: inset 0 0 0 1px var(--line-2); overflow: hidden;
  transition: box-shadow var(--t) var(--ease); }
.cx-num:hover { box-shadow: inset 0 0 0 1px var(--line-3); }
.cx-num:focus-within { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45), 0 0 0 3px rgba(255, 255, 255, .08); }
.cx-num.dis { opacity: .45; }
.cx-num > input[type=number] { order: 2; flex: 1 1 auto; min-width: 0; width: 100%; height: 100% !important; margin: 0 !important; padding: 0 4px !important; border: 0 !important; border-radius: 0 !important;
  background: none !important; box-shadow: none !important; outline: none; text-align: center; font-family: var(--f-mono); font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.cx-num > input[type=number]::-webkit-inner-spin-button, .cx-num > input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cx-num > input::placeholder { color: var(--dim); font-family: var(--f-body); font-size: 12.5px; }
.cx-num-b { all: unset; box-sizing: border-box; cursor: var(--cur-ptr, pointer); flex: none; width: 34px; display: grid; place-items: center; color: var(--muted); touch-action: manipulation;
  transition: background var(--t-fast), color var(--t-fast); }
.cx-num-b[data-d="-1"] { order: 1; box-shadow: inset -1px 0 0 var(--line); }
.cx-num-b[data-d="1"] { order: 3; box-shadow: inset 1px 0 0 var(--line); }
.cx-num-b svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.cx-num-b:hover { background: var(--fill-2); color: var(--ink); }
.cx-num-b:active { background: var(--fill-3); }
.cx-num-b[disabled] { cursor: var(--cur-no, not-allowed); opacity: .5; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ---------- csúszka: sín + kitöltés + fogó ---------- */
input[type=range].cx-range { --p: 50%; height: 24px; background: transparent; }
input[type=range].cx-range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--paper) 0 var(--p), rgba(245, 242, 236, .14) var(--p) 100%); }
input[type=range].cx-range::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(245, 242, 236, .14); }
input[type=range].cx-range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--paper); }
input[type=range].cx-range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--paper); border: 0;
  box-shadow: 0 0 0 4px var(--bg-2, #0E0E10), 0 1px 6px rgba(0, 0, 0, .6); transition: transform var(--t-fast) var(--ease), box-shadow var(--t); }
input[type=range].cx-range::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 4px var(--bg-2, #0E0E10), 0 1px 6px rgba(0, 0, 0, .6); }
input[type=range].cx-range:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range].cx-range:active::-webkit-slider-thumb { transform: scale(1.2); box-shadow: 0 0 0 4px var(--bg-2, #0E0E10), 0 0 0 9px rgba(245, 242, 236, .14); }
input[type=range].cx-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--bg-2, #0E0E10), 0 0 0 6px var(--ink); }
input[type=range].cx-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--bg-2, #0E0E10), 0 0 0 6px var(--ink); }
input[type=range].cx-range[disabled] { opacity: .4; cursor: var(--cur-no, not-allowed); }
.cx-val { flex: none; min-width: 44px; text-align: right; font-family: var(--f-mono); font-size: 12.5px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- kapcsoló ---------- */
input[type=checkbox].cx-sw { width: 36px; height: 20px; border-radius: 20px; background: rgba(245, 242, 236, .16); box-shadow: inset 0 0 0 1px var(--line); }
input[type=checkbox].cx-sw::after { left: 3px; top: 3px; width: 14px; height: 14px; background: var(--ink-2); }
input[type=checkbox].cx-sw:hover { background: rgba(245, 242, 236, .22); }
input[type=checkbox].cx-sw:checked { background: var(--paper); box-shadow: none; }
input[type=checkbox].cx-sw:checked::after { transform: translateX(16px); background: var(--on-paper); }
input[type=checkbox].cx-sw[disabled] { opacity: .4; cursor: var(--cur-no, not-allowed); }

/* ---------- színválasztó ---------- */
.cx-color { all: unset; box-sizing: border-box; cursor: var(--cur-ptr, pointer); display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 4px; border-radius: var(--r-sm);
  background: var(--fill); box-shadow: inset 0 0 0 1px var(--line-2); font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); justify-self: end; }
.cx-color:hover { background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--line-3); }
.cx-color:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.cx-color-sw { width: 24px; height: 24px; border-radius: var(--r-xs); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); }
.cx-cpop { padding: 12px; }
.cx-sws { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.cx-swb { all: unset; cursor: var(--cur-ptr, pointer); aspect-ratio: 1; border-radius: var(--r-xs); background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); transition: transform var(--t-fast) var(--ease); }
.cx-swb:hover { transform: scale(1.12); }
.cx-swb.on, .cx-swb:focus-visible { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--ink); }
.cx-hex { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-family: var(--f-mono); font-size: 11px; color: var(--muted); letter-spacing: .08em; }
.cx-hex input { flex: 1; min-width: 0; height: 30px; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); font-family: var(--f-mono); font-size: 13px; outline: none; }
.cx-hex input:focus { box-shadow: inset 0 0 0 1px var(--ink-2); }

/* ---------- tooltip ---------- */
.cx-tip { position: fixed; left: 0; top: 0; z-index: 2100; max-width: 300px; padding: 7px 10px; border-radius: var(--r-sm); pointer-events: none;
  background: var(--paper); color: var(--on-paper); box-shadow: var(--sh);
  font-family: var(--f-body); font-size: 12.5px; font-weight: 500; line-height: 1.4; text-shadow: none; white-space: pre-line; opacity: 0; }
.cx-tip.on { animation: cx-tip-in 120ms var(--ease) both; }
@keyframes cx-tip-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- párbeszéd ---------- */
.cx-dlg-back { position: fixed; inset: 0; z-index: 2200; display: grid; place-items: center; padding: 16px; background: rgba(4, 4, 5, .62); opacity: 0; transition: opacity 160ms var(--ease); }
.cx-dlg-back.in { opacity: 1; }
.cx-dlg-back.out { opacity: 0; transition-duration: 120ms; }
.cx-dlg { width: min(440px, 100%); padding: 24px; border-radius: var(--r-lg); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line-2), var(--sh-lg); transform: translateY(8px); transition: transform 220ms var(--ease-film); }
.cx-dlg-back.in .cx-dlg { transform: none; }
.cx-dlg-t { margin: 0 0 8px; font-family: var(--f-disp); font-weight: 800; font-size: 28px; line-height: .95; text-transform: uppercase; color: var(--ink); }
.cx-dlg-b { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; white-space: pre-line; }
.cx-dlg-in { display: block; width: 100%; height: var(--h); margin-top: 16px; padding: 0 12px; border: 0; border-radius: var(--r); background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--ink); font-family: var(--f-body); font-size: 15px; outline: none; }
.cx-dlg-in:focus { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45), 0 0 0 3px rgba(255, 255, 255, .08); }
.cx-dlg-f { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- görgetősáv: vékony, tokenes (a style.css alapját finomítja) ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-3); background-clip: padding-box; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

/* ---------- <details> összecsukó: saját nyíl a böngésző háromszöge helyett ---------- */
details > summary { list-style: none; cursor: var(--cur-ptr, pointer); }
details > summary::-webkit-details-marker { display: none; }
details:not(.fold) > summary { display: flex; align-items: center; gap: 8px; }
details:not(.fold) > summary::before { content: ""; flex: none; width: 6px; height: 6px; margin: 0 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform var(--t) var(--ease); }
details:not(.fold)[open] > summary::before { transform: rotate(45deg); }

@media (prefers-reduced-motion: reduce) { .cx-pop, .cx-tip.on { animation: none; } .cx-dlg, .cx-dlg-back { transition: none; } }
:root[data-anim="reduced"] .cx-pop, :root[data-anim="reduced"] .cx-tip.on { animation: none; }
