/* capybara.hu – Beállítások ablak
 *
 * KULON ABLAK, nem a meta-kepernyok vaza. A hatter ugyanaz a jelenet, mint
 * a kezdokepernyon, elhomalyositva; az ablak egy fa-panel indakkal.
 *
 * MERT ZONAK a set_panel.png-n (raccsal leolvasva):
 *   cimtabla:      22%..78% vizszintesen,  4%..15% fuggolegesen
 *   belso felulet: 12%..88% vizszintesen, 20%..82% fuggolegesen
 * A CSS ezekhez igazodik -- a szoveg sosem kerul indara.
 */

.set-win {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
  container-name: setwin;
}
.set-win.hidden { display: none; }

/* ---- elhomalyositott hatter ---- */
.sw-bg {
  position: absolute;
  inset: 0;
  background: url("../assets/scene_bg.webp") center / cover no-repeat;
  filter: blur(7px) saturate(.9);
  /* a blur a szeleket atlatszova mossa -- kicsit tulmeretezzuk */
  transform: scale(1.08);
}
.sw-veil {
  position: absolute;
  inset: 0;
  background: rgba(8, 20, 12, .55);
}

/* ---- az ablak ---- */
.sw-panel {
  position: relative;
  width: min(94cqw, 420px);
  max-height: 96cqh;
  animation: swIn .28s cubic-bezier(.2, 1.25, .45, 1) both;
}
.sw-panel-img {
  width: 100%;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .5));
}

/* cim a panel sajat felso cimtablajan (MERT: 22%..78% x 4%..15%) */
.sw-title {
  position: absolute;
  left: 22%; top: 4%; width: 56%; height: 11%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(15px, 5.2cqw, 24px);
  color: #ffeec9;
  letter-spacing: .02em;
  text-shadow: 2px 2px 0 #2b1608, -1px -1px 0 #2b1608,
               0 2px 0 #2b1608, 2px 0 0 #2b1608;
}

/* a tartalom a belso deszkafeluleten (MERT: 12%..88% x 20%..82%) */
.sw-body {
  /* MERT belso felulet: 12%..88% vizszintesen, 20%..82% fuggolegesen.
     A negy blokk ennel magasabb volt -- a tartalom felul/alul levagodott.
     Ezert `justify-content: flex-start` + gorgetes, es szukebb kozok. */
  position: absolute;
  left: 12%; top: 17.5%; width: 76%; height: 60%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1cqh;
  padding: .2cqh 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.sw-body::-webkit-scrollbar { display: none; }

/* ---- also gombsor (OK / MEGSE) ----
   A belso felulet 83%-nal vegzodik, a panel kerete ~95%-nal -- a gombok
   koze esnek. */
.sw-foot {
  position: absolute;
  left: 12%; bottom: 2.5%;
  width: 76%;
  display: flex;
  gap: 4cqw;
  justify-content: center;
}
.sw-btn {
  flex: 1 1 0;
  max-width: 46%;
  aspect-ratio: 305 / 105;      /* a gombkepek aranya, laposabban */
  border: 0;
  padding: 0;
  background: no-repeat center / 100% 100%;
  cursor: pointer;
  font: 800 0/0 inherit;        /* a felirat a kepen van */
  color: transparent;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .4));
}
.sw-btn:active { transform: translateY(2px); filter: none; }
.sw-ok     { background-image: url("../assets/set_btn_ok.png"); }
.sw-cancel { background-image: url("../assets/set_btn_cancel.png"); }

/* bezaro gomb a jobb felso sarokban */
.sw-close {
  position: absolute;
  right: 2%; top: 1%;
  width: 13%;
  aspect-ratio: 1;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font: 800 0/0 inherit;
  color: transparent;
}
.sw-close::before {
  content: "✕";
  font: 800 clamp(15px, 5cqw, 22px)/1 inherit;
  color: #ffeec9;
  text-shadow: 2px 2px 0 #2b1608, -1px -1px 0 #2b1608;
}
.sw-close:active { transform: translateY(2px); }

/* ---- kozos ---- */
.sw-block { display: flex; flex-direction: column; gap: .5cqh; }
.sw-label {
  font-weight: 800;
  font-size: clamp(11px, 3.6cqw, 16px);
  color: #ffeec9;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .6);
}

/* ---- csuszka ----
   A bogyo vegallasai: 32.5% es 92.5% (lasd capy-ui-settings.js).
   A ketto egyutt mozog -- ha itt valtozik, ott is kell. */
.sw-slider {
  position: relative;
  /* A kep aranya 4.1:1 -- a SZELESSEG hatarozza meg a sor magassagat.
     Az also gombsor 11%-ot elvett, ezert a csuszka kicsit keskenyebb,
     hogy a negy blokk gorgetes nelkul kiferjen. */
  width: 92%;
  touch-action: none;
  cursor: pointer;
  user-select: none;
}
.sw-bar { width: 100%; display: block; pointer-events: none; }
.sw-fill {
  position: absolute;
  top: 42%; height: 17%;
  border-radius: 99px;
  background: linear-gradient(#b8ef62 0 40%, #7fd132 40% 74%, #4d9a22 74% 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
  pointer-events: none;
}
.sw-knob {
  position: absolute;
  top: 50%;
  width: 11%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .45));
}
/* ---- pipa ---- */
.sw-check {
  /* felirat balra, pipa a jobb szelre igazitva */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3cqw;
  cursor: pointer;
  user-select: none;
}
.sw-check:focus-visible { outline: 2px solid #ffd166; outline-offset: 4px; border-radius: 8px; }
/* A doboz kepe MINDIG az ures valtozat -- a pipa CSS-bol kerul ra, hogy
   a fa keret kapcsolaskor ne ugorjon (a ket kesz asszet aranya elter). */
.sw-boxwrap {
  position: relative;
  width: clamp(34px, 12cqw, 54px);
  flex: 0 0 auto;
  line-height: 0;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .4));
  transition: transform .12s ease;
}
.sw-box { width: 100%; height: auto; display: block; }
/* MERT belso ures felulet: 26%..74% x 18%..72% -- a pipa ennek a kozepere */
.sw-tick {
  position: absolute;
  /* C meret: a doboz belso feluletenek nagy resze */
  left: 20%; top: 10%; width: 60%; height: 70%;
  object-fit: contain;
  opacity: 0;
  transform: scale(.55) rotate(-14deg);
  transition: opacity .14s ease, transform .18s cubic-bezier(.2, 1.5, .4, 1);
  pointer-events: none;
}
.sw-boxwrap.on .sw-tick { opacity: 1; transform: none; }
.sw-check:active .sw-boxwrap { transform: scale(.92); }
.sw-check-label {
  font-weight: 800;
  font-size: clamp(11px, 3.6cqw, 16px);
  color: #ffeec9;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .6);
}

/* ---- becenev ---- */
.sw-nick { display: flex; gap: 2cqw; align-items: stretch; }
.sw-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: .9cqh 3cqw;
  border-radius: 8px;
  border: 2px solid #5d3618;
  background: rgba(48, 27, 12, .72);
  color: #ffeec9;
  font: 700 clamp(11px, 3.4cqw, 15px)/1.2 inherit;
  outline: none;
}
.sw-input:focus { border-color: #ffd166; }
.sw-input::placeholder { color: rgba(255, 238, 201, .42); font-weight: 600; }
.sw-save {
  flex: 0 0 auto;
  width: clamp(64px, 24cqw, 104px);
  border: 0;
  padding: 0;
  background: url("../assets/set_btn_ok.png") no-repeat center / 100% 100%;
  cursor: pointer;
  font: 800 0/0 inherit;
  color: transparent;
}
.sw-save:active { transform: translateY(2px); }
.sw-save:disabled { opacity: .55; cursor: default; }

.sw-msg {
  font-size: clamp(9px, 2.9cqw, 13px);
  font-weight: 700;
  min-height: 1em;
  color: #ffeec9;
  opacity: .85;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .5);
}
.sw-msg.ok  { color: #b8ef62; opacity: 1; }
.sw-msg.err { color: #ff9a8a; opacity: 1; }

/* Fold csukva (280px): ott a 4.1:1 aranyu csuszka meg mindig 7px-el
   tobbet foglal, mint amennyi hely van. */
@container setwin (max-width: 300px) {
  .sw-slider { width: 86%; }
  .sw-body { gap: .9cqh; }
}

@keyframes swIn {
  from { opacity: 0; transform: scale(.9) translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sw-panel { animation: none; }
}
