/* Language switch (한 ↔ EN slide switch) — shared by every page. Owner: CORE i18n.
   한국어: 회색 트랙, 손잡이 왼쪽, 오른쪽에 "한국어" / 영어: 파란 트랙, 손잡이 오른쪽, 왼쪽에 "EN".
   누를 때마다 전환, 한국어 모드에서 빠르게 5번 우클릭(터치: 5번 탭)하면 순한글 모드(i18n.js). */
.lang-switch {
  --sw-w: 4.5rem;    /* 72px: "한국어" 라벨 폭 확보 */
  --sw-h: 1.75rem;   /* 28px */
  --sw-pad: 0.1875rem;
  --sw-knob: calc(var(--sw-h) - 2px - var(--sw-pad) * 2); /* 2px = 위아래 테두리 */
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: var(--sw-w);
  height: var(--sw-h);
  padding: 0;
  margin: 0;
  border: 1px solid #d5d9e0;
  border-radius: 999px;
  background: #eceef2;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  /* 빠른 연속 탭 시 두 번 탭 확대 방지 */
  touch-action: manipulation;
  -webkit-touch-callout: none;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.lang-switch__knob {
  position: absolute;
  top: var(--sw-pad);
  left: var(--sw-pad);
  width: var(--sw-knob);
  height: var(--sw-knob);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  transition: transform 0.22s cubic-bezier(0.3, 0.7, 0.4, 1);
}

.lang-switch__label {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--sw-w) - 2px - var(--sw-knob) - var(--sw-pad) * 2);
  font-size: 0.6875rem;
  white-space: nowrap;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lang-switch__label--ko {
  right: var(--sw-pad);
  color: #7a8394;
}

.lang-switch__label--en {
  left: var(--sw-pad);
  color: #fff;
  opacity: 0;
}

/* 영어 */
.lang-switch.is-en {
  background: #26549c;
  border-color: #1f4785;
}

.lang-switch.is-en .lang-switch__knob {
  transform: translateX(calc(var(--sw-w) - var(--sw-knob) - var(--sw-pad) * 2 - 2px));
}

.lang-switch.is-en .lang-switch__label--en {
  opacity: 1;
}

.lang-switch.is-en .lang-switch__label--ko {
  opacity: 0;
}

/* 순한글 모드: "한국어" 를 브랜드색으로 */
html[data-ko-pure] .lang-switch:not(.is-en) .lang-switch__label--ko {
  color: #26549c;
}

@media (hover: hover) {
  .lang-switch:hover {
    border-color: #26549c;
  }
}

.lang-switch:focus-visible {
  outline: 2px solid #26549c;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .lang-switch,
  .lang-switch__knob,
  .lang-switch__label {
    transition: none;
  }
}

/* Desktop: between the auth links and the IPL logo block, so the IPL block is the rightmost item
   (tab order: auth → switch → IPL). */
.header__right .lang-switch--desktop {
  margin-left: 0.5rem;
}

/* Mobile aside: directly below Register / Logout */
.nav--mobile .lang-switch--mobile {
  --sw-w: 5.25rem;
  --sw-h: 2.25rem;
  align-self: center;
  margin-top: 0.75rem;
}

.nav--mobile .lang-switch--mobile .lang-switch__label {
  font-size: 0.875rem;
}

/* Touch: keep the visible switch compact but give it a ≥44px hit area */
@media (pointer: coarse) {
  .lang-switch::after {
    content: '';
    position: absolute;
    inset: -0.5rem -0.25rem;
  }
}

/* Hamburger breakpoint: desktop switch hidden (matches styles.css 860px) */
@media (max-width: 860px) {
  .header__right .lang-switch--desktop {
    display: none;
  }
}

/* Tighter header spacing so nav + auth + toggle + logo fit at ~1024–1360px */
@media (min-width: 861px) and (max-width: 1360px) {
  .header .nav {
    gap: 1.25rem;
  }
  .header__inner {
    gap: 1rem;
  }
  .header__right {
    gap: 0.5rem;
  }
}

/* 861–1279px: the full header (brand + 5–6 nav links + auth + toggle + logo) is wider than the
   viewport (this was already the case before i18n), so compact it. */
@media (min-width: 861px) and (max-width: 1279px) {
  .header .brand__title {
    font-size: 1.125rem;
  }
  .header .brand__subtitle {
    display: none;
  }
  .header .nav {
    gap: 0.875rem;
  }
  .header .nav__link {
    font-size: 0.9375rem;
  }
  .header__inner {
    gap: 0.875rem;
  }
}

@media (min-width: 1024px) and (max-width: 1090px) {
  .header .brand__title {
    font-size: 1rem;
  }
  .header .nav {
    gap: 0.75rem;
  }
  .header__inner {
    gap: 0.75rem;
  }
}

/* 861–1279px: 로그인/로그아웃 묶음을 메뉴와 구분(세로 구분선), 로고는 읽을 수 있는 크기로 */
@media (min-width: 861px) and (max-width: 1279px) {
  .header .brand__logo {
    width: 3.75rem;
  }
  .header__right {
    padding-left: 0.875rem;
    /* 짧은 세로 구분선(1px × 28px, 로고 블록 높이와 무관) */
    background: linear-gradient(rgba(38, 84, 156, 0.3), rgba(38, 84, 156, 0.3)) left center / 1px 1.75rem no-repeat;
  }
}

/* 1024–1149px: 가장 빠듯한 구간(관리자 7개 메뉴 + 로그아웃 + 언어 + IPL) → 로고 48px 유지, 간격 축소 */
@media (min-width: 1024px) and (max-width: 1149px) {
  .header .brand__logo {
    width: 3rem;
  }
  .header .brand__title {
    font-size: 1rem;
  }
  .header .nav {
    gap: 0.75rem;
  }
  .header__inner {
    gap: 0.75rem;
  }
  .header__right {
    padding-left: 0.625rem;
  }
}

/* 861–1023px: 연구실 이름을 숨기지 않고 두 줄로(순천향대학교 / 영상처리연구실) 표시 */
@media (min-width: 861px) and (max-width: 1023px) {
  .header .brand {
    gap: 0.5rem;
  }
  .header .brand__logo {
    width: 3rem;
  }
  .header .brand__title {
    font-size: 0.9375rem;
    white-space: normal;
    width: 6.5em;
    line-height: 1.25;
  }
  .header .nav {
    gap: 0.625rem;
  }
  .header .nav__link {
    font-size: 0.875rem;
  }
  .header__inner {
    gap: 0.75rem;
  }
  .header__right {
    padding-left: 0.625rem;
  }
}
