/* ============================================================
   css/nav.css - 상단 메뉴 (kids.seoul.go.kr 방식, 시니어용 큰 글씨)
   PC(1021px~): 로고줄 + 주메뉴(마우스 올리면 하위 상자) + 전체메뉴 패널
   ~1020px   : 로고줄 + 가로 스와이프 탭 + 오른쪽 드로어(아코디언)
   ~768px    : 하단 고정 바 추가
   ============================================================ */
:root { --header-h: 150px; --nav-blue: var(--primary, #2563eb); --nav-bottom-h: 0px; }

.nav-skip {
  position: absolute; left: -9999px; top: 0; z-index: 3000;
  background: #111; color: #fff; padding: 12px 18px; font-size: 18px;
}
.nav-skip:focus { left: 8px; top: 8px; }

/* ---------- 헤더 틀 ---------- */
#site-header.nav-v2 {
  height: auto; padding: 0; background: #fff;
  border-bottom: 1px solid #dcdcdc;
  position: sticky; top: 0; z-index: 900;
}
/* style.css의 #site-header .inner(flex·height:100%) 초기화 후 줄마다 다시 지정 */
#site-header.nav-v2 .inner { display: block; height: auto; gap: 0; max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.nav-top { border-bottom: 1px solid #eee; }
#site-header.nav-v2 .nav-top__inner { display: flex; align-items: center; justify-content: space-between; height: 90px; gap: 12px; }
.nav-top .logo { margin: 0; line-height: 0; }
.nav-logo { height: 76px; width: auto; }

.nav-util { display: flex; align-items: center; gap: 8px; }
.nav-util__link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 17px; color: #333; padding: 8px 10px; border-radius: 8px; text-decoration: none; white-space: nowrap;
}
.nav-util__link:hover { background: #f1f5f9; color: var(--nav-blue); }
.nav-util__my { font-weight: bold; color: var(--nav-blue); }

.nav-font { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; margin-right: 4px; }
.nav-font button {
  min-width: 48px; height: 42px; font-size: 17px; font-weight: bold;
  background: #fff; border: 0; cursor: pointer; color: #111;
}
.nav-font button + button { border-left: 1px solid #cbd5e1; font-size: 20px; }
.nav-font button:hover { background: #eff6ff; color: var(--nav-blue); }

.nav-allbtn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 16px; margin-left: 4px;
  background: var(--nav-blue); color: #fff; border: 0; border-radius: 10px;
  font-size: 17px; font-weight: bold; cursor: pointer;
}
.nav-allbtn:hover { filter: brightness(1.1); }
.nav-burger { display: inline-flex; flex-direction: column; gap: 4px; }
.nav-burger i { display: block; width: 20px; height: 2px; background: currentColor; border-radius: 2px; }

/* ---------- PC 주메뉴 ---------- */
#site-header.nav-v2 .nav-gnb__list { display: flex; justify-content: center; list-style: none; margin: 0 auto; height: 58px; gap: 0; }
.nav-gnb__item { position: relative; }
.nav-gnb__link {
  display: block; height: 58px; line-height: 58px; padding: 0 26px;
  font-size: 20px; font-weight: bold; color: #111; text-decoration: none; position: relative; white-space: nowrap;
}
.nav-gnb__link::after {
  content: ''; position: absolute; left: 26px; right: 26px; bottom: 0; height: 4px;
  background: var(--nav-blue); border-radius: 4px 4px 0 0; transform: scaleX(0); transition: transform .15s;
}
.nav-gnb__item:hover > .nav-gnb__link,
.nav-gnb__item:focus-within > .nav-gnb__link,
.nav-gnb__item.is-current > .nav-gnb__link { color: var(--nav-blue); }
.nav-gnb__item:hover > .nav-gnb__link::after,
.nav-gnb__item:focus-within > .nav-gnb__link::after,
.nav-gnb__item.is-current > .nav-gnb__link::after { transform: scaleX(1); }

/* 하위 메뉴 상자 - 대메뉴 바로 아래 가운데 */
.nav-gnb__sub {
  display: none; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  min-width: 210px; background: #fff; border: 1px solid #d4d4d8; border-top: 3px solid var(--nav-blue);
  box-shadow: 0 10px 24px rgba(0,0,0,.12); z-index: 950;
}
.nav-gnb__item:hover > .nav-gnb__sub,
.nav-gnb__item:focus-within > .nav-gnb__sub { display: block; }
.nav-gnb__sub ul { list-style: none; margin: 0; padding: 0; }
.nav-gnb__sub--2col { min-width: 400px; }
.nav-gnb__sub--2col ul { display: grid; grid-template-columns: 1fr 1fr; }
.nav-gnb__sub a {
  display: block; height: 48px; line-height: 48px; padding: 0 18px;
  font-size: 17px; color: #111; text-align: center; white-space: nowrap; text-decoration: none;
  border-bottom: 1px solid #eee;
}
.nav-gnb__sub a:hover, .nav-gnb__sub a:focus { background: #f0f4ff; color: var(--nav-blue); font-weight: bold; }

/* ---------- 태블릿·모바일 가로 탭 (PC에서는 숨김) ---------- */
.nav-slide { display: none; position: relative; background: #fff; }
.nav-slide ul {
  display: flex; list-style: none; margin: 0; padding: 0 8px;
  overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.nav-slide ul::-webkit-scrollbar { display: none; }
.nav-slide li a {
  display: block; padding: 0 16px; height: 52px; line-height: 52px;
  font-size: 18px; font-weight: bold; color: #333; text-decoration: none; position: relative;
}
.nav-slide li.is-current a { color: var(--nav-blue); }
.nav-slide li.is-current a::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 0; height: 4px; background: var(--nav-blue); border-radius: 4px 4px 0 0;
}
/* 오른쪽에 더 있다는 표시 */
.nav-slide::after {
  content: ''; position: absolute; top: 0; right: 0; width: 28px; height: 100%;
  background: linear-gradient(to right, rgba(255,255,255,0), #fff); pointer-events: none;
}

/* ---------- 전체메뉴 ---------- */
.nav-all[hidden] { display: none; }
.nav-all { position: fixed; inset: 0; z-index: 2000; }
.nav-all__dim { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.nav-all__panel {
  position: absolute; left: 0; right: 0; top: 0; max-height: 100vh; overflow-y: auto;
  background: #fff; padding: 24px 0 32px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.nav-all__head, .nav-all__user, .nav-all__cols { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.nav-all__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.nav-all__head strong { font-size: 26px; }
.nav-all__close {
  font-size: 18px; font-weight: bold; padding: 10px 18px; border: 2px solid #cbd5e1; border-radius: 10px; background: #fff; cursor: pointer;
}
.nav-all__user { display: none; }
.nav-all__cols { list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 20px; }
.nav-all__titlebar { display: flex; align-items: center; border-bottom: 3px solid var(--nav-blue); margin-bottom: 8px; }
.nav-all__title { flex: 1; display: block; padding: 10px 0; font-size: 20px; font-weight: bold; color: #111; text-decoration: none; }
.nav-all__toggle { display: none; }
.nav-all__sub { list-style: none; margin: 0; padding: 0; }
.nav-all__sub a { display: block; padding: 7px 0; font-size: 17px; color: #333; text-decoration: none; }
.nav-all__sub a:hover { color: var(--nav-blue); text-decoration: underline; }
body.nav-lock { overflow: hidden; }

/* ---------- 모바일 하단 고정 바 (768px 이하에서만) ---------- */
.nav-bottom { display: none; }

/* ============================================================
   반응형
   ============================================================ */
@media (max-width: 1200px) {
  .nav-gnb__link { padding: 0 18px; font-size: 19px; }
  .nav-gnb__link::after { left: 18px; right: 18px; }
}

@media (max-width: 1020px) {
  :root { --header-h: 124px; }
  #site-header.nav-v2 .nav-top__inner { height: 72px; }
  .nav-logo { height: 58px; }
  .nav-gnb { display: none; }
  .nav-slide { display: block; }
  .nav-allbtn__txt { display: none; }
  .nav-allbtn { width: 52px; padding: 0; justify-content: center; }
  .nav-burger i { width: 24px; height: 3px; }

  /* 전체메뉴 → 오른쪽 드로어 */
  .nav-all__panel {
    left: auto; right: 0; bottom: 0; width: min(88vw, 420px); max-height: none; height: 100%;
    padding: 16px 0 24px; animation: navSlideIn .2s ease;
  }
  .nav-all__head, .nav-all__user, .nav-all__cols { padding: 0 18px; }
  .nav-all__user { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
  .nav-all__user a {
    flex: 1 1 auto; text-align: center; padding: 12px 10px; font-size: 18px; font-weight: bold;
    border: 2px solid #cbd5e1; border-radius: 10px; color: #111; text-decoration: none;
  }
  .nav-all__user a.primary { background: var(--nav-blue); border-color: var(--nav-blue); color: #fff; }
  .nav-all__cols { grid-template-columns: 1fr; gap: 0; }
  .nav-all__titlebar { border-bottom: 1px solid #e5e7eb; margin: 0; }
  .nav-all__title { padding: 16px 4px; font-size: 21px; }
  .nav-all__toggle {
    display: block; width: 56px; height: 56px; border: 0; background: none; font-size: 18px; color: #555; cursor: pointer;
  }
  .nav-all__toggle span { display: inline-block; transition: transform .2s; }
  .nav-all__col.is-open .nav-all__toggle span { transform: rotate(180deg); }
  .nav-all__sub { display: none; background: #f8fafc; padding: 6px 0; }
  .nav-all__col.is-open .nav-all__sub { display: block; }
  .nav-all__sub a { padding: 12px 20px; font-size: 19px; }
}
@keyframes navSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

@media (max-width: 768px) {
  :root { --nav-bottom-h: 68px; }
  #site-header.nav-v2 .inner { padding: 0 12px; }
  #site-header.nav-v2 .nav-top__inner { height: 64px; }
  .nav-logo { height: 50px; }
  .nav-util { gap: 4px; }
  .nav-util__hide-m { display: none; }
  .nav-util__my span { display: none; }
  .nav-util__my { font-size: 24px; padding: 6px 8px; }
  .nav-font button { min-width: 42px; height: 40px; font-size: 15px; }
  .nav-font button + button { font-size: 18px; }
  .nav-slide li a { padding: 0 13px; font-size: 17px; height: 50px; line-height: 50px; }

  .nav-bottom {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
    height: var(--nav-bottom-h); background: #fff; border-top: 1px solid #d4d4d8;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08); padding-bottom: env(safe-area-inset-bottom);
  }
  .nav-bottom a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 15px; font-weight: bold; color: #444; text-decoration: none;
  }
  .nav-bottom a span { font-size: 24px; line-height: 1; }
  .nav-bottom a.is-current { color: var(--nav-blue); background: #eff6ff; }

  /* 하단 바와 겹치지 않게: 본문 여백, 하단 광고·읽어주기 버튼 위로 */
  body { padding-bottom: var(--nav-bottom-h); }
  .footer-banner { bottom: var(--nav-bottom-h) !important; }
  body .tts-ui { bottom: calc(130px + var(--nav-bottom-h)); }
}

/* ============================================================
   화면 설정 (글자 크기 3단계·고대비) - 본문에만 적용
   ============================================================ */
html[data-font="2"] #content { zoom: 1.15; }
html[data-font="3"] #content { zoom: 1.3; }
html[data-contrast="1"] #content { filter: contrast(1.35); }
html[data-contrast="1"] #content a { text-decoration: underline; }
