/* layer-control.css — 지도 레이어 토글 패널 (shared/layer-control.js).
 *
 * 규칙은 docs/MAP_LAYERS.md: 이 파일은 **생김새와 동작**만 갖는다. 어디에 놓이는지
 * (top/left/z-index)와 얼마나 큰지는 지도마다 다르므로 각 페이지 CSS 가 정한다 —
 * 전국 지도의 코너와 AOI 리포트 카드 안은 여유가 다르다.
 *
 * Dashboard 의 `.dml` 에서 왔다. 두 벌 중 그쪽이 더 자란 구현이었다: fold caret 과
 * 그룹 전체 토글이 나뉘어 있고, hover 프리뷰가 (hover: hover) 로 막혀 있고, 긴
 * 목록이 패널 안에서 스크롤된다. AOI 팩토리 쪽 `.amap-layers` 는 이 파일로 흡수됐다.
 */

.lc {
  position:      absolute;
  width:         auto;              /* 접혔을 때 = 아이콘 버튼 하나 */
  background:    var(--bg1);
  border:        1px solid var(--bdr2);
  border-radius: var(--radius);
  padding:       var(--space-xs);
  box-shadow:    var(--sh-float);
}

/* ── 토글 버튼 ─────────────────────────────────────────────────────── */
.lc-toggle {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:           34px;
  height:          34px;
  padding:         0;
  background:      none;
  border:          none;
  border-radius:   var(--radius);
  color:           var(--t1);
  cursor:          pointer;
  transition:      background .12s, color .12s;
}
.lc-toggle:hover { background: var(--bg2); color: var(--t0); }
.lc.lc-open .lc-toggle { color: var(--acc); }

/* ── 열림 ──────────────────────────────────────────────────────────
   기본은 접힘(본문 숨김). 클릭이 유일한 오프너인 터치까지 포함해 어디서나 열린다.
   열리면 flex 컬럼이 되고 본문이 스크롤한다 — 긴 목록이 지도를 넘지 않게. */
.lc-body { display: none; }
.lc.lc-open {
  width:          196px;
  display:        flex;
  flex-direction: column;
}
.lc.lc-open .lc-toggle {
  width:           100%;
  justify-content: flex-start;
  padding:         0 var(--space-md);
  border-radius:   6px 6px 0 0;
  flex-shrink:     0;
}
.lc.lc-open .lc-body {
  display:     block;
  margin-top:  4px;
  padding-top: var(--space-xs);
  border-top:  1px solid var(--bdr);
  min-height:  0;
  overflow-y:  auto;
  overflow-x:  hidden;
}

/* 넘칠 때만, 그리고 아주 얇게. 완전히 숨겨두면 잘린 목록이 "여기가 끝"으로 읽혀
   아래 항목을 아무도 찾지 않는다 — 굴러가는데 굴릴 줄 모르는 쪽이 더 나쁘다. */
.lc-body { scrollbar-width: thin; scrollbar-color: var(--bdr2) transparent; }
.lc-body::-webkit-scrollbar       { width: 5px; height: 5px; }
.lc-body::-webkit-scrollbar-track { background: transparent; }
.lc-body::-webkit-scrollbar-thumb { background: var(--bdr2); border-radius: 3px; }

/* hover 프리뷰는 포인팅 장치 전용. 터치에서 :hover 가 눌어붙으면 클릭 토글과
   싸워서 두 번째 탭으로 닫히지 않는다. */
@media (hover: hover) {
  .lc:hover {
    width:          196px;
    display:        flex;
    flex-direction: column;
  }
  .lc:hover .lc-toggle {
    width:           100%;
    justify-content: flex-start;
    padding:         0 var(--space-md);
    border-radius:   6px 6px 0 0;
    flex-shrink:     0;
  }
  .lc:hover .lc-body {
    display:     block;
    margin-top:  4px;
    padding-top: var(--space-xs);
    border-top:  1px solid var(--bdr);
    min-height:  0;
    overflow-y:  auto;
    overflow-x:  hidden;
  }
}

/* ── 그룹 ──────────────────────────────────────────────────────────
   헤더 행 = fold caret + 그룹 라벨. caret 은 접고, 라벨은 자식 전부를 켜고 끈다.
   둘을 나눠 둔 이유: 하나로 합치면 "다 끄기"와 "접기" 중 하나를 잃는다. */
.lc-group + .lc-group { margin-top: 6px; padding-top: var(--space-sm); border-top: 1px solid var(--bdr); }
.lc-ghead-row { display: flex; align-items: center; gap: 1px; }
.lc-caret {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  flex-shrink:     0;
  width:           18px;
  height:          18px;
  padding:         0;
  margin-left:     2px;
  background:      none;
  border:          none;
  border-radius:   var(--radius);
  color:           var(--t2);
  cursor:          pointer;
  transition:      color .1s;
}
.lc-caret:hover { color: var(--t0); }
.lc-caret svg { display: block; transition: transform .16s ease; }
.lc-group.lc-fold .lc-caret svg { transform: rotate(-90deg); }
.lc-group.lc-fold .lc-item { display: none; }
.lc-ghead {
  flex:           1;
  min-width:      0;
  font-family:    var(--font-sans);
  font-size:      var(--fs-2xs);
  font-weight:    600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color:          var(--t2);
  padding:        var(--space-2xs) var(--space-lg) var(--space-xs) var(--space-2xs);
  cursor:         pointer;
  border-radius:  var(--radius);
  transition:     color .1s, opacity .1s;
}
.lc-ghead:hover { color: var(--t1); }
.lc-ghead.lc-off { opacity: .5; }

/* 그룹의 수식어(큐) — 목록의 한 줄이 아니라 목록 전체에 걸리는 스위치다. 그래서
   적용 대상 **위**에 앉고, 오른쪽 체크박스가 "고르는 것이 아니라 켜는 것"이라고
   말한다. 아래 목록과는 얇은 선으로 갈린다. */
.lc-mod { margin-bottom: 5px; padding-bottom: 6px; border-bottom: 1px solid var(--bdr); border-radius: 0; }
.lc-mod .lc-label { flex: 1; }
.lc-box {
  flex-shrink:   0;
  width:         12px;
  height:        12px;
  border:        1px solid var(--bdr2);
  border-radius: 2px;
  background:    var(--bg2);
}
.lc-item:not(.lc-off) .lc-box {
  background:  var(--acc);
  border-color: var(--acc);
  box-shadow:  inset 0 0 0 2px var(--bg1);
}

/* ── 항목 ──────────────────────────────────────────────────────────── */
.lc-item {
  display:       flex;
  align-items:   center;
  gap:           9px;
  padding:       var(--space-xs) var(--space-lg);
  border-radius: var(--radius);
  cursor:        pointer;
  transition:    background .1s, opacity .1s;
}
.lc-item:hover { background: var(--bg2); }
.lc-item.lc-off { opacity: .38; }
.lc-label { font-size: var(--fs-micro); color: var(--t0); white-space: nowrap; }
.lc-line  { width: 16px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.lc-ic    { width: 16px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lc-ic svg { display: block; }

/* ── 베이스맵 행 (Map ↔ Satellite) ─────────────────────────────────
   basemap:'panel' 이면 항상, 'mobile' 이면 좁은 화면에서만 — 넓은 화면에서는
   코너의 플로팅 토글이 같은 일을 한다(그 코너를 쓸 수 있는 지도에 한해). */
.lc-basemap { display: flex; gap: var(--space-sm); padding: var(--space-2xs) var(--space-xs) var(--space-sm); }
.lc-basemap-mobile { display: none; }
.lc-bm {
  flex:           1 1 0;
  min-width:      0;
  display:        flex;
  flex-direction: column;
  gap:            4px;
  padding:        0;
  background:     none;
  border:         none;
  cursor:         pointer;
}
.lc-bm-thumb {
  height:              44px;
  border-radius:       var(--radius);
  background-size:     cover;
  background-position: center;
  border:              2px solid transparent;
  box-shadow:          inset 0 0 0 1px rgba(0,0,0,.08);
  transition:          border-color .12s;
}
/* 썸네일 주소는 shared/basemaps.js 가 installThumbVars() 로 넣어준다 — Carto 는
   키가 붙어야 해서 리터럴로 둘 수가 없다. 어느 쪽을 보일지만 여기서 정한다. */
.lc-bm-map { background-image: var(--lc-bm-dark); }
body.light .lc-bm-map { background-image: var(--lc-bm-light); }
.lc-bm-sat { background-image: var(--lc-bm-sat); }
.lc-bm.active .lc-bm-thumb { border-color: var(--acc); }
.lc-bm-lbl { font-size: var(--fs-xs); font-weight: 600; text-align: center; color: var(--t2); }
.lc-bm.active .lc-bm-lbl { color: var(--t0); }

@media (max-width: 900px) {
  .lc-desktop-only { display: none; }
  .lc-basemap-mobile { display: flex; }
  /* 패널 안 행이 켜지는 폭에서는 코너 토글을 치운다 — 같은 스위치가 둘이면
     하나는 반드시 남의 자리를 덮는다(모바일에서 좌하단은 AOI 독 자리다). */
  .lc-bm-mobile-host .sat-toggle { display: none !important; }
}

/* PLSS cadastral WMS 는 빨강으로 렌더된다 — 조용한 참조 격자로 탈색.
   (레이어 자체의 스타일이지만 이 컨트롤이 켜는 유일한 래스터라 여기 둔다.) */
.plss-layer { filter: grayscale(0.85) opacity(0.55); }
