/* SKILL-EKRAN-01 (AL-655) — [K] yetenek ekranı yenilemesi
   - pencere görünür alana sığar; sol taraf (.kd-skills-main: sekme + süzgeç + ağaç + SP) kendi içinde kayar,
     sağ sütun (önizleme + ayrıntı) sabit, ayrıntı kendi içinde kayar, ana eylem düğmesi altta sabit
   - kademe ızgarası sarılır: bir bandda 6 yetenek de taşar (sınıf başına 20 yetenek)
   - 844x390 (yatay telefon): iki sütun; 390x844 (dikey dar): ayrıntı alttan açılan sayfa
   - dokunmatik / telefonda dokunma hedefleri >= 44px
   Telefon kuralları burada (phoneHud.css'e dokunulmaz). font-size >= 13px (uiTheme kuralı). */

/* ---------- Pencere ve iki sütun ---------- */
#modal-skills.modal-window--skills {
  height: calc(100vh - 98px);
  height: calc(100dvh - 98px);
  max-height: 940px;
  overflow: hidden;
}

#modal-skills .kd-skills-columns {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  grid-template-areas: "main right";
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  column-gap: 14px;
}

#modal-skills .kd-skills-main {
  grid-area: main;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 4px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "top" "insp" "filt" "tree" "pas" "sp";
  grid-template-rows: auto auto auto auto auto auto;
  align-content: start;
  row-gap: 8px;
}

#modal-skills .kd-sk-inspect-banner {
  grid-area: insp;
}

#modal-skills .kd-sk-filterbar {
  grid-area: filt;
}

#modal-skills .kd-skills-col--right {
  grid-area: right;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

#modal-skills .kd-preview-stage-card {
  flex: 0 0 auto;
}

#modal-skills .kd-skills-preview-body {
  position: static;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kd-sk-detail-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}

#modal-skills .kd-preview-upgrade-btn {
  flex: 0 0 auto;
  min-height: 44px;
}

/* Sayfa kapatma düğmesi yalnız dikey dar ekranda görünür */
.kd-sk-sheet-close {
  display: none;
}

/* ---------- Kademe ızgarası: sarılan sütunlar (20 yetenek) ---------- */
#modal-skills .kd-skill-tier-grid {
  grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
  gap: 8px;
}

#modal-skills .kd-skill-tier-block[data-count="1"] .kd-skill-tier-grid::before,
#modal-skills .kd-skill-tier-grid::before {
  display: none;
}

/* ---------- Süzgeç çubuğu ---------- */
.kd-sk-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  min-width: 0;
}

.kd-sk-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.kd-sk-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--kd-bronze-dim, #5c4630);
  background: var(--kd-bg-socket, #16131d);
  color: var(--kd-text-sand, #e5d3b3);
  font-size: var(--kd-fs-xs, 13px);
  font-weight: 800;
  white-space: nowrap;
  cursor: var(--kd-cursor-link, pointer);
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.kd-sk-filter:hover {
  border-color: var(--kd-bronze-bright, #cfa060);
}

.kd-sk-filter.is-active {
  border-color: var(--kd-ember-gold, #fbbf24);
  background: linear-gradient(180deg, rgba(180, 83, 9, 0.5), rgba(68, 26, 6, 0.75));
  color: #fef3c7;
}

.kd-sk-filter:focus-visible {
  outline: 2px solid var(--kd-ember-gold, #fbbf24);
  outline-offset: 2px;
}

.kd-sk-filter-hint {
  font-size: var(--kd-fs-xs, 13px);
  color: var(--kd-text-muted, #a8a29e);
  white-space: nowrap;
}

/* ---------- Salt-inceleme şeridi ---------- */
.kd-sk-inspect-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 10px;
  border-radius: var(--kd-radius-sm, 6px);
  border: 1px solid rgba(96, 165, 250, 0.55);
  background: linear-gradient(180deg, rgba(30, 58, 138, 0.42), rgba(15, 23, 42, 0.82));
  color: #dbeafe;
  font-size: var(--kd-fs-sm, 14px);
  font-weight: 700;
}

.kd-sk-inspect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kd-sk-inspect-actions .kd-btn {
  min-height: 36px;
}

.kd-class-tab-hint {
  font-size: var(--kd-fs-xs, 13px);
  font-weight: 700;
  color: var(--kd-text-muted, #a8a29e);
}

.kd-class-pick-btn.is-own:not(.is-active) {
  border-style: dashed;
}

/* Salt-incelenen ağaç: soluk değil, ama sürükleme yok */
.kd-skill-node.is-readonly {
  cursor: var(--kd-cursor-link, pointer);
  touch-action: auto;
}

/* ---------- Düğüm köşe simgesi (nişan şekli) + sürükleme tutamağı ---------- */
.kd-skill-node-aim {
  position: absolute;
  right: 1px;
  bottom: 1px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 5px;
  background: rgba(7, 6, 10, 0.86);
  border: 1px solid rgba(207, 160, 96, 0.6);
  pointer-events: none;
}

.kd-skill-node-aim[data-nisan="nokta"] {
  border-color: rgba(251, 191, 36, 0.85);
}

.kd-skill-node-aim[data-nisan="hedef"] {
  border-color: rgba(248, 113, 113, 0.85);
}

.kd-skill-node-aim[data-nisan="kendi"] {
  border-color: rgba(74, 222, 128, 0.8);
}

/* İki sütun nokta: "sürüklenebilir" işareti (emoji/simge karakteri yok, CSS ile) */
.kd-skill-node-grip {
  position: absolute;
  left: 2px;
  top: 50%;
  width: 4px;
  height: 14px;
  transform: translateY(-50%);
  background-image: radial-gradient(circle, rgba(232, 214, 160, 0.55) 1px, transparent 1.4px);
  background-size: 4px 4.7px;
  pointer-events: none;
  opacity: 0.7;
}

.kd-skill-node.is-draggable:hover .kd-skill-node-grip {
  opacity: 1;
}

/* ---------- Sağ panel: temel açıklama + kural çipleri ---------- */
.kd-sk-desc {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 9px;
  border-radius: var(--kd-radius-sm, 6px);
  background: rgba(24, 19, 30, 0.85);
  border: 1px solid rgba(148, 111, 71, 0.34);
}

.kd-sk-desc-text {
  margin: 0;
  font-size: var(--kd-fs-sm, 14px);
  line-height: 1.4;
  color: var(--kd-text-ivory, #f5ecd7);
}

.kd-sk-rule-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.kd-sk-rule-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(148, 111, 71, 0.55);
  background: #120f17;
  color: var(--kd-text-sand, #e5d3b3);
  font-size: var(--kd-fs-xs, 13px);
  font-weight: 800;
  white-space: nowrap;
}

.kd-sk-rule-chip.is-aim {
  border-color: rgba(251, 191, 36, 0.75);
  color: #fde68a;
}

.kd-sk-rule-long {
  margin: 0;
  font-size: var(--kd-fs-xs, 13px);
  line-height: 1.35;
  color: var(--kd-text-muted, #a8a29e);
}

/* ---------- 2x6 alt bar atama ızgarası ---------- */
#modal-skills .kd-quick-bind-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px 9px;
  border-radius: var(--kd-radius-sm, 6px);
  background: rgba(24, 19, 30, 0.85);
  border: 1px solid rgba(148, 111, 71, 0.34);
}

.kd-quick-bind-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 8px;
}

.kd-quick-bind-hint {
  font-size: var(--kd-fs-xs, 13px);
  color: var(--kd-text-muted, #a8a29e);
}

#modal-skills .kd-quick-bind-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
}

#modal-skills .kd-quick-key-btn {
  position: relative;
  height: auto;
  min-height: 44px;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 6px;
  overflow: hidden;
}

.kd-quick-key-letter {
  font-size: var(--kd-fs-md, 15px);
  font-weight: 900;
  line-height: 1;
}

.kd-quick-key-occ {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--kd-fs-xs, 13px);
  font-weight: 600;
  line-height: 1.15;
  color: var(--kd-text-muted, #a8a29e);
}

#modal-skills .kd-quick-key-btn.is-occupied {
  border-color: rgba(251, 146, 60, 0.6);
  background: rgba(67, 32, 10, 0.55);
}

#modal-skills .kd-quick-key-btn.is-occupied .kd-quick-key-occ {
  color: #fdba74;
}

#modal-skills .kd-quick-key-btn.is-bound .kd-quick-key-occ {
  color: #bbf7d0;
}

#modal-skills .kd-quick-key-btn.is-confirm {
  border-color: #f87171;
  background: rgba(127, 29, 29, 0.6);
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.45);
}

.kd-quick-bind-warn {
  min-height: 20px;
  font-size: var(--kd-fs-xs, 13px);
  color: var(--kd-text-muted, #a8a29e);
}

.kd-quick-bind-warn.is-active {
  color: #fecaca;
  font-weight: 800;
}

/* ---------- 1180px ve altı (tablet/dar masaüstü): yine iki sütun, eski "alt alta" kuralı ezilir ---------- */
@media (max-width: 1180px) {
  #modal-skills .kd-skills-columns {
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-areas: "main right";
    grid-template-rows: minmax(0, 1fr);
  }
  #modal-skills .kd-skills-col--right {
    display: flex;
  }
}

/* ---------- Yatay telefon (844x390): iki sütun, sol bağımsız kayar, sağda önizleme + yükselt sabit ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  #modal-skills.modal-window--skills,
  body.kd-phone #modal-skills.modal-window--skills {
    gap: 6px !important;
    overflow: hidden;
  }
  #modal-skills .kd-skills-columns {
    grid-template-columns: minmax(0, 1fr) 304px;
    column-gap: 8px;
  }
  /* 2x6 yuva ızgarası 304px sütunda 6 x 44px'e sığsın */
  #modal-skills .kd-quick-bind-grid {
    gap: 3px;
  }
  #modal-skills .kd-skills-col--right {
    gap: 6px;
  }
  #modal-skills .kd-preview-stage-card {
    padding: 4px;
  }
  #modal-skills #skill-preview-canvas {
    max-width: 196px;
  }
  #modal-skills .kd-skills-preview-body {
    padding: 6px;
    gap: 6px;
  }
  #modal-skills .kd-sk-detail-head .kd-sk-detail-icon,
  #modal-skills .kd-sk-detail-head img {
    max-width: 40px;
    max-height: 40px;
  }
  #modal-skills .kd-skill-tier-grid {
    grid-template-columns: repeat(auto-fill, minmax(186px, 1fr));
  }
  #modal-skills .kd-skill-tier-block {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 6px;
  }
  #modal-skills .kd-sk-filter-hint {
    display: none;
  }
}

/* ---------- Dikey dar ekran (390x844): tek sütun, ayrıntı alttan açılan sayfa ---------- */
@media (max-width: 600px) {
  /* 97vw + backdrop kenar boşluğu dar ekranda taşar: pencere backdrop'un iç genişliğine oturur */
  #modal-skills.modal-window--skills {
    position: relative;
    width: 100% !important;
    padding: 10px 10px 12px !important;
  }
  #modal-skills .kd-skills-columns {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main";
  }
  #modal-skills .kd-skill-tier-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  #modal-skills .kd-skill-tier-block {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 6px;
  }
  #modal-skills .kd-skills-col--right {
    /* "right" alanı tek sütunda yok: kalırsa Chrome sabit sayfayı 0 genişlikli örtük sütuna oturtur */
    grid-area: auto;
    /* pencerenin içinde alttan açılır: oyunun alt barı (sürükle-bırak hedefi) pencerenin altında görünür kalır */
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    max-height: 86%;
    padding: 30px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    border-radius: 14px 14px 0 0;
    border-top: 1.5px solid var(--kd-bronze-base, #946f47);
    background: var(--kd-bg-obsidian, #121017);
    box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.75);
    transform: translateY(calc(100% + 12px));
    visibility: hidden;
    transition: transform 180ms ease, visibility 0s linear 180ms;
  }
  #modal-skills .kd-skills-col--right.is-sheet-open {
    transform: translateY(0);
    visibility: visible;
    transition: transform 180ms ease;
  }
  #modal-skills .kd-skills-col--right::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 50%;
    width: 44px;
    height: 4px;
    margin-left: -22px;
    border-radius: 2px;
    background: rgba(207, 160, 96, 0.55);
  }
  #modal-skills .kd-sk-sheet-close {
    display: inline-flex;
    position: absolute;
    top: 4px;
    right: 8px;
    z-index: 2;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    min-width: 44px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--kd-bronze-dim, #5c4630);
    background: var(--kd-bg-socket, #16131d);
    color: var(--kd-text-sand, #e5d3b3);
    font-size: var(--kd-fs-sm, 14px);
    font-weight: 800;
  }
  #modal-skills .kd-preview-stage-card {
    align-self: stretch;
  }
  #modal-skills #skill-preview-canvas {
    max-width: 240px;
    margin-inline: auto;
  }
  #modal-skills .kd-sk-filter-hint {
    display: none;
  }
}

/* ---------- Dokunma hedefleri >= 44px (telefon kipi ve dokunmatik ekran) ---------- */
body.kd-phone #modal-skills .kd-sk-filter,
body.kd-phone #modal-skills .kd-class-pick-btn,
body.kd-phone #modal-skills .kd-skill-plus-btn,
body.kd-phone #modal-skills .kd-sk-inspect-actions .kd-btn,
body.kd-phone #modal-skills .kd-preview-toggle-btn,
body.kd-phone #modal-skills .kd-preview-replay-btn,
body.kd-phone #modal-skills .kd-quick-key-btn,
body.kd-phone #modal-skills .kd-preview-upgrade-btn,
body.kd-phone #modal-skills .kd-sk-respec-btn,
body.kd-phone #modal-skills .kd-sp-toggle-btn {
  min-height: 44px;
}

body.kd-phone #modal-skills .kd-skill-plus-btn,
body.kd-phone #modal-skills .kd-class-pick-btn,
body.kd-phone #modal-skills .kd-quick-key-btn,
body.kd-phone #modal-skills .kd-sp-toggle-btn {
  min-width: 44px;
}

body.kd-phone #modal-skills .kd-skill-node {
  min-height: 48px;
}

@media (pointer: coarse) {
  #modal-skills .kd-sk-filter,
  #modal-skills .kd-class-pick-btn,
  #modal-skills .kd-sk-inspect-actions .kd-btn,
  #modal-skills .kd-preview-toggle-btn,
  #modal-skills .kd-preview-replay-btn,
  #modal-skills .kd-quick-key-btn,
  #modal-skills .kd-sk-respec-btn,
  #modal-skills .kd-sp-toggle-btn {
    min-height: 44px;
  }
  #modal-skills .kd-class-pick-btn,
  #modal-skills .kd-quick-key-btn,
  #modal-skills .kd-sp-toggle-btn {
    min-width: 44px;
  }
  #modal-skills .kd-skill-plus-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Telefonda pencere kaydırması kapalı: kaydırma sol alanda (çift kaydırma çubuğu yok) */
body.kd-phone #modal-skills.modal-window--skills {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
