/* ============================================================
   THEME SYSTEM — 다크 / 라이트 모드
   ------------------------------------------------------------
   - 기본(default): 다크 모드 (HTML에 data-theme 미부여 또는 "dark")
   - 라이트 모드: <html data-theme="light"> 일 때만 아래 룰 적용
   - 기존 main.css / general.css 는 그대로 두고, 이 파일에서만 오버라이드
   ============================================================ */

/* ---- 공통: 부드러운 컬러 전환 ---- */
html,
body,
header,
footer,
section,
.wrapper,
.hd_bt,
header.scr {
  transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}

/* ============================================================
   HEADER LAYOUT FIX — 한 줄 정렬 (다크/라이트 공통)
   ------------------------------------------------------------
   원인:
   - .hd_con padding 0 160px (좌우 320px 점유)
   - #gnb > ul: flex-flow row wrap (폭 부족 시 줄바꿈 허용)
   - 메뉴/버튼 텍스트에 white-space 미지정 → 글자 단위 줄바꿈
   ============================================================ */
@media (min-width: 1200px) {
  /* 좌우 패딩 대폭 축소 + flex nowrap */
  .hd_con {
    padding: 0 30px;
    gap: 16px;
    flex-wrap: nowrap;
  }

  /* 로고 폭 축소 (280px → 200px) */
  .lg {
    width: 200px;
    flex-shrink: 0;
  }

  /* 메뉴 가운데 영역이 남는 공간을 차지 */
  .mn {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
    overflow: visible;
  }

  /* GNB: 줄바꿈 금지 + 콤팩트 패딩 */
  #gnb > ul {
    flex-flow: row nowrap;
    flex-wrap: nowrap;
    gap: 0;
  }
  #gnb > ul > li > a {
    white-space: nowrap;
    padding: 40px 10px;
    font-size: 14px;
    letter-spacing: -0.4px;
  }

  /* 우측 CTA 영역: 줄바꿈 금지 */
  .number {
    flex-shrink: 0;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
  }
  .number > a,
  .number > div {
    white-space: nowrap;
    padding: 12px 14px;
    font-size: 13px;
    gap: 6px;
  }
  .number > div > p {
    white-space: nowrap;
    font-size: 15px;
  }

  /* 토글 버튼 사이즈 정렬 */
  .theme-toggle {
    width: 40px;
    height: 40px;
    margin-left: 4px;
    font-size: 14px;
  }
}

/* 1400px 이상에서는 메뉴 여유 확보 */
@media (min-width: 1400px) {
  .hd_con {
    padding: 0 50px;
    gap: 24px;
  }
  .lg {
    width: 220px;
  }
  #gnb > ul > li > a {
    padding: 40px 14px;
    font-size: 15px;
  }
  .number > a,
  .number > div {
    padding: 14px 18px;
    font-size: 14px;
    gap: 8px;
  }
  .theme-toggle {
    width: 42px;
    height: 42px;
    margin-left: 6px;
  }
}

/* 1600px 이상에서는 원본 디자인 폭에 가깝게 */
@media (min-width: 1600px) {
  .hd_con {
    padding: 0 80px;
    gap: 30px;
  }
  .lg {
    width: 240px;
  }
  #gnb > ul > li > a {
    padding: 40px 16px;
    font-size: 16px;
  }
  .number > a,
  .number > div {
    padding: 14px 22px;
    font-size: 15px;
  }
}

/* 1900px 이상에서는 시안 그대로 */
@media (min-width: 1900px) {
  .hd_con {
    padding: 0 120px;
  }
  .lg {
    width: 260px;
  }
}

/* ============================================================
   THEME TOGGLE 버튼 (PC + 모바일 공용)
============================================================ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  transition: background .25s ease, border-color .25s ease, color .25s ease, transform .25s ease;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.theme-toggle__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transition: opacity .25s ease, transform .35s ease;
}

.theme-toggle .theme-toggle__sun { display: none; }
.theme-toggle .theme-toggle__moon { display: inline-flex; }

/* 라이트모드일 때 아이콘 교체 */
[data-theme="light"] .theme-toggle .theme-toggle__sun { display: inline-flex; }
[data-theme="light"] .theme-toggle .theme-toggle__moon { display: none; }

/* 모바일 메뉴 안의 토글 버튼 (mt-btn 하단) */
.mt-theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  margin-top: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .25s ease, border-color .25s ease;
}

.mt-theme:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mt-theme__label { display: inline-flex; align-items: center; gap: 10px; }
.mt-theme__label i { font-size: 16px; }

.mt-theme .mt-theme__sun { display: none; }
[data-theme="light"] .mt-theme .mt-theme__sun { display: inline-flex; }
[data-theme="light"] .mt-theme .mt-theme__moon { display: none; }

/* ============================================================
   LIGHT THEME — 색상 오버라이드
   ============================================================ */
[data-theme="light"] {
  /* ---- 페이지 기본 ---- */
  background-color: #ffffff;
  color: #1a1a1f;
}

[data-theme="light"] body {
  background-color: #ffffff;
  color: #1a1a1f;
}

/* ============================================================
   HEADER (라이트)
============================================================ */
[data-theme="light"] header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

[data-theme="light"] header.scr {
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* 메인(히어로) 페이지에서는 헤더가 투명해야 자연스러움 */
[data-theme="light"] body.is-main header:not(.scr) {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid transparent;
}

[data-theme="light"] body.is-main header:not(.scr) .lg img,
[data-theme="light"] body.is-main header:not(.scr) #gnb > ul > li > a {
  /* 영상 배경 위에서는 흰색 유지 */
  color: #fff;
}

/* 로고 — 라이트모드용 다크 로고로 반전 */
[data-theme="light"] header:not(.scr-on-hero) .lg img,
[data-theme="light"] .lg img {
  filter: invert(1) brightness(0.15) contrast(1);
}
/* 단, 히어로(메인) 비스크롤 상태에선 영상 배경이라 흰색 유지 */
[data-theme="light"] body.is-main header:not(.scr) .lg img {
  filter: none;
}

/* GNB */
[data-theme="light"] #gnb > ul > li > a {
  color: #1a1a1f;
}
[data-theme="light"] #gnb > ul > li > a:hover {
  color: #78161b;
}
[data-theme="light"] body.is-main header:not(.scr) #gnb > ul > li > a {
  color: #fff;
}
[data-theme="light"] body.is-main header:not(.scr) #gnb > ul > li > a:hover {
  color: rgba(255, 255, 255, 0.85);
}

/* 드롭다운 (이미 흰색 박스라 살짝만 조정) */
[data-theme="light"] #gnb > ul > li > ul {
  background-color: #fff;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
[data-theme="light"] #gnb > ul > li > ul > li > a {
  color: rgba(0, 0, 0, 0.78);
}
[data-theme="light"] #gnb > ul > li > ul > li > a:hover {
  color: #78161b;
}

/* CTA 버튼 (그대로 유지하되, 메인 페이지에서는 변경 없음) */
[data-theme="light"] .number > a {
  /* 네이버 그린 유지 */
  color: #fff;
}

/* 햄버거 버튼 라인 색 */
[data-theme="light"] .hd-btn span {
  background: #1a1a1f;
}
[data-theme="light"] body.is-main header:not(.scr) .hd-btn span {
  background: #fff;
}

/* theme-toggle 자체 컬러 */
[data-theme="light"] .theme-toggle {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1a1a1f;
}
[data-theme="light"] .theme-toggle:hover {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
}
[data-theme="light"] body.is-main header:not(.scr) .theme-toggle {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ============================================================
   MAIN SECTIONS (라이트)
============================================================ */

/* sc02 — 음주사건 선율로가 다른 이유 (배경: 다크 야경 → 라이트 톤) */
[data-theme="light"] #sc02 {
  background-color: #f5f5f7;
}
[data-theme="light"] #sc02::after,
[data-theme="light"] #sc02::before {
  background: linear-gradient(180deg, rgba(245, 245, 247, 0.85) 0%, rgba(245, 245, 247, 0.7) 50%, rgba(245, 245, 247, 0.95) 100%) !important;
}

[data-theme="light"] #sc02 h2,
[data-theme="light"] #sc02 .section-head__title,
[data-theme="light"] #sc02 h3 {
  color: #1a1a1f !important;
}

[data-theme="light"] #sc02 p,
[data-theme="light"] #sc02 .section-head__desc {
  color: rgba(0, 0, 0, 0.75) !important;
}

[data-theme="light"] #sc02 .reason-tag,
[data-theme="light"] #sc02 [class*="tag"] {
  background: rgba(0, 0, 0, 0.04) !important;
  border: 1px solid rgba(0, 0, 0, 0.14) !important;
  color: rgba(0, 0, 0, 0.82) !important;
}

[data-theme="light"] #sc02 [class*="card"]:not(button) {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] #sc02 [class*="card"] p,
[data-theme="light"] #sc02 [class*="card"] [class*="desc"] {
  color: rgba(0, 0, 0, 0.72) !important;
}

[data-theme="light"] #sc02 [class*="card"] [class*="big"],
[data-theme="light"] #sc02 [class*="card"] [class*="count"] {
  background: linear-gradient(180deg, #1a1a1f 0%, rgba(26, 26, 31, 0.7) 100%) !important;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* sc03 — 대표 변호사 (다크 청사 배경 유지 가능, 단 라이트 변형) */
[data-theme="light"] #sc03 {
  background-color: #ededf0;
}
[data-theme="light"] #sc03::before,
[data-theme="light"] #sc03::after {
  background: linear-gradient(90deg, rgba(237, 237, 240, 0.92) 0%, rgba(237, 237, 240, 0.6) 40%, rgba(237, 237, 240, 0.95) 100%) !important;
}
[data-theme="light"] #sc03 h2,
[data-theme="light"] #sc03 h3,
[data-theme="light"] #sc03 li,
[data-theme="light"] #sc03 .rep-info__title {
  color: #1a1a1f !important;
}
[data-theme="light"] #sc03 .rep-info__note,
[data-theme="light"] #sc03 p {
  color: rgba(0, 0, 0, 0.72) !important;
}
[data-theme="light"] #sc03 [class*="rank"] {
  border-color: rgba(0, 0, 0, 0.18) !important;
  color: rgba(0, 0, 0, 0.85) !important;
}
[data-theme="light"] #sc03 [class*="rank"] [class*="num"] {
  color: rgba(0, 0, 0, 0.55) !important;
}

/* sc04 — 변호사 12인 */
[data-theme="light"] #sc04 {
  background-color: #f5f5f7;
}
[data-theme="light"] #sc04 h2,
[data-theme="light"] #sc04 [class*="title"] {
  color: #1a1a1f !important;
}
[data-theme="light"] #sc04 [class*="desc"],
[data-theme="light"] #sc04 p {
  color: rgba(0, 0, 0, 0.72) !important;
}
[data-theme="light"] #sc04 [class*="name"] {
  color: rgba(0, 0, 0, 0.78) !important;
}
[data-theme="light"] #sc04 [class*="name"] strong {
  color: #1a1a1f !important;
}

/* sc05 — 성공사례 (어두운 배경 카드, 라이트모드는 밝은 배경) */
[data-theme="light"] #sc05 {
  background-color: #e9e9ec;
}
[data-theme="light"] #sc05 h2,
[data-theme="light"] #sc05 .section-head__title {
  color: #1a1a1f !important;
}

/* sc06 — LAW MANS YOUTUBE (다크 유지, 배경 영상이 어둡기 때문) */
/* 라이트모드에서도 영상 톤 유지 권장 — 텍스트만 조정 */
[data-theme="light"] #sc06 {
  background-color: #1a1a1e;
}

/* sc07 — 찾아오시는 길 + 상담폼 (원래 라이트 배경이라 거의 그대로) */
[data-theme="light"] #sc07,
[data-theme="light"] .section-contact {
  background: #ffffff !important;
}

/* ============================================================
   FOOTER (라이트)
============================================================ */
[data-theme="light"] footer {
  background: #f5f5f7;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .ft-wrap > p,
[data-theme="light"] .ft_txt,
[data-theme="light"] .ft_cp {
  color: rgba(0, 0, 0, 0.7) !important;
}

[data-theme="light"] .ft-bt {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .ft-lg > img {
  filter: invert(1) brightness(0.15);
}

/* ============================================================
   MOBILE 메뉴 (mt-menu) — 라이트 적용
============================================================ */
[data-theme="light"] .mt-menu {
  background: #ffffff;
}
[data-theme="light"] .mt-area .mt-tp .mt-lg img {
  filter: invert(1) brightness(0.15);
}
[data-theme="light"] .mt-area .hd-close {
  color: #1a1a1f;
}
[data-theme="light"] .mo_mn_mn > li > a {
  color: #1a1a1f;
}
[data-theme="light"] .mo_mn_mn > li > ul > li > a {
  color: rgba(0, 0, 0, 0.75);
}
[data-theme="light"] .mt-theme {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #1a1a1f;
}
[data-theme="light"] .mt-theme:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* ============================================================
   FIXED-CS (우측 고정 빠른상담) — 라이트 모드
============================================================ */
[data-theme="light"] .fixed-cs {
  /* 다크 그라데이션 박스를 화이트 변형으로 */
}
[data-theme="light"] .fcs-con {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .fcs-num h2 {
  color: #1a1a1f !important;
}
[data-theme="light"] .fcs-text span {
  color: rgba(0, 0, 0, 0.78) !important;
}
[data-theme="light"] .fcs-text input {
  background: #fafafa !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
  color: #1a1a1f !important;
}
[data-theme="light"] .fcs-text input::placeholder {
  color: rgba(0, 0, 0, 0.5) !important;
}
[data-theme="light"] .fcs-pol label {
  color: rgba(0, 0, 0, 0.78) !important;
}

/* ============================================================
   서브 페이지 (sub 레이아웃) — 라이트
============================================================ */
[data-theme="light"] body.is-sub .wrapper {
  background: #ffffff;
}

/* ============================================================
   PREFERS-COLOR-SCHEME — 시스템 설정 자동 적용 (no data-theme)
   ============================================================ */
/*
 * data-theme 속성이 없을 때만 시스템 설정을 따름 — JS에서
 * 사용자 명시 설정이 있으면 항상 data-theme를 강제로 박아 넣으므로 안전
 */
@media (prefers-color-scheme: light) {
  html:not([data-theme]) {
    /* 시스템 라이트인 사용자에게도 라이트모드로 자연스럽게 전환 */
    /* 하지만 기본 사이트가 다크 디자인이라, 디폴트는 다크 유지를 권장.
       자동 전환을 원한다면 아래 주석 해제: */
    /*
    background-color: #ffffff;
    color: #1a1a1f;
    */
  }
}
