/* [1. 테마 변수 및 초기화] */
:root {
  --bg: #0f1115;
  --card: #181c23;
  --text: #f3f5f7;
  --muted: #b7c0cc;
  --line: #2a313d;
  --accent: #6ea8fe;
  --accent-soft: rgba(110, 168, 254, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --header-h: 64px;
  --footer-h: 60px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* [2. 고정 헤더 레이아웃] */
.global-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-h);
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible; /* 언어바 확장을 위해 필수 */
}

.header-inner {
  width: 100%;
  max-width: 1080px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  overflow: visible;
}

.header-left { display: flex; gap: 10px; }
.header-right { display: flex; gap: 16px; align-items: center; position: relative; overflow: visible; }
/* [언어 바 - PC/모바일 디자인 무결성 강화] */
.lang-bar {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px;
  border-radius: 14px;
  border: 1px solid var(--line);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  align-items: center;
  position: relative;
  overflow: hidden; /* 영역 밖으로 텍스트가 나가지 않게 차단 */
}

/* PC 버전: 마우스 올리면 왼쪽으로 부드럽게 확장 */
@media (min-width: 769px) {
  .lang-bar {
    width: 80px; /* 초기 너비 (활성 언어 1개만 보일 정도) */
    height: 32px;
    justify-content: flex-end; /* 활성 언어를 오른쪽에 고정 */
  }

  .lang-bar:hover {
    width: 360px; /* 모든 언어가 보일 수 있는 충분한 너비 */
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent);
  }

  .lang-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    border-radius: 11px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    width: 70px;
    height: 26px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    white-space: nowrap; /* 텍스트 줄바꿈 방지 */
  }

  .lang-btn.active {
    background: var(--accent);
    color: #000;
  }

  /* 호버하지 않았을 때는 활성화되지 않은 버튼들의 너비를 0으로 만들어 숨김 */
  .lang-bar:not(:hover) .lang-btn:not(.active) {
    width: 0;
    opacity: 0;
    padding: 0;
    margin: 0;
    pointer-events: none;
  }
}

/* 모바일 버전: 클릭 시 아래로 리스트 출력 */
@media (max-width: 768px) {
  .lang-bar {
    width: 80px;
    height: 32px;
    cursor: pointer;
    flex-direction: column;
    overflow: visible; /* 아래로 리스트가 보여야 하므로 visible */
    z-index: 3000;
  }

  .lang-btn {
    width: 74px;
    height: 28px;
    color: var(--muted);
    background: transparent;
    border: none;
    font-size: 11px;
    font-weight: 700;
    display: none; /* 기본 상태에선 숨김 */
    align-items: center;
    justify-content: center;
    border-radius: 11px;
  }

  .lang-btn.active {
    display: flex;
    background: var(--accent);
    color: #000;
  }

  /* 모바일 클릭 시 활성화 (absolute로 띄워서 Guest 정보 안 밀리게) */
  .lang-bar.mobile-active {
    background: var(--card);
    border-color: var(--accent);
    height: auto;
    position: absolute;
    right: 0;
    top: 0;
    box-shadow: var(--shadow);
    padding: 4px;
    overflow: visible;
  }

  .lang-bar.mobile-active .lang-btn {
    display: flex;
    margin-bottom: 4px;
  }
  .lang-bar.mobile-active .lang-btn:last-child {
    margin-bottom: 0;
  }
}
/* 모바일 버전: 하단 드롭다운 */
@media (max-width: 768px) {
  .lang-bar { width: 78px; height: 32px; cursor: pointer; flex-direction: column; overflow: visible; z-index: 3000; }
  
  .lang-btn {
    width: 70px;
    height: 26px;
    color: var(--muted);
    background: transparent;
    border: none;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    transition: 0.2s;
  }

  .lang-btn.active { display: flex; background: var(--accent); color: #000; }

  /* 모바일 클릭 시 활성화 상태 */
  .lang-bar.mobile-active {
    background: var(--card);
    border-color: var(--accent);
    height: auto;
    position: absolute;
    right: 0;
    top: 0;
    box-shadow: var(--shadow);
    padding: 3px;
  }
  
  .lang-bar.mobile-active .lang-btn { display: flex; margin-bottom: 4px; }
  .lang-bar.mobile-active .lang-btn:last-child { margin-bottom: 0; }
}

/* [4. 메인 네비게이션 및 히어로 카드] */
.page { padding-top: var(--header-h); padding-bottom: var(--footer-h); min-height: 100vh; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 20px; }

.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 40px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.main-nav {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox 전용 */
}
.main-nav::-webkit-scrollbar { display: none; /* Chrome 전용 */ }

.nav-item {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 110px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-item.active { background: var(--accent); color: #000; border-color: var(--accent); }
.nav-item:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* [5. 서비스 리스트 아이템 및 툴팁] */
.service-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  position: relative;
  transition: 0.2s ease;
}

.service-link:hover { color: var(--accent) !important; transform: scale(1.002); }

.arrow { opacity: 0.3; margin-left: 8px; font-size: 12px; transition: 0.3s; }
.service-link:hover .arrow { opacity: 1; transform: translateX(5px); }

.service-desc {
  font-size: 13px;
  color: var(--muted);
  margin-left: 12px;
  font-weight: normal;
  transition: 0.2s;
}

/* 흰색 툴팁 디자인 */
.tooltip {
  visibility: hidden;
  position: absolute;
  bottom: 130%;
  left: 0;
  background: #fff;
  color: #000;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 100;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  font-weight: 600;
  pointer-events: none;
  transform: translateY(5px);
}

.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 15px;
  border-width: 6px;
  border-style: solid;
  border-color: #fff transparent transparent transparent;
}

.service-link:hover .tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

/* [6. 버튼 및 기타] */
.nav-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  transition: 0.2s;
}

.nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.global-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--footer-h);
  background: rgba(15, 17, 21, 0.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  z-index: 1000;
}

/* [7. 인증 모달 (Auth Modal)] */
.auth-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.auth-modal-content {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  padding: 32px 24px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.auth-modal-overlay.active .auth-modal-content {
  transform: translateY(0);
}

.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.auth-modal-close:hover {
  color: var(--text);
}

/* Card section styles (cardsect) */
#card-section {
  margin-top: 20px;
}
.card-section { position: relative; }
.card-stage {
  position: relative;
  overflow: hidden;
  min-height: 96px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  border: 1px solid var(--line);
  padding: 18px;
}
.card-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: translateX(100%);
  transition: transform 0.6s cubic-bezier(.2,.9,.2,1), opacity 0.6s ease;
  display: flex;
  align-items: center;
}
.card-panel { will-change: transform, opacity; }

/* Card controls (prev/next) */
.card-controls {
  position: absolute;
  inset: 0; /* full overlay */
  pointer-events: none; /* allow stage clicks except buttons */
  z-index: 30;
}
.card-btn {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
.card-btn:hover { background: rgba(110,168,254,0.12); transform: translateY(-50%) scale(1.03); }
.card-btn:active { transform: translateY(-50%) scale(0.98); }
.card-btn-prev { left: 14px; }
.card-btn-next { right: 14px; }

/* Mobile: make buttons slightly smaller and less obtrusive */
@media (max-width: 640px) {
  .card-btn { width: 36px; height: 36px; font-size: 18px; }
  .card-btn-prev { left: 8px; }
  .card-btn-next { right: 8px; }
}
.card-panel .card-inner { padding: 0 48px; }
.card-panel.visible {
  opacity: 1;
  transform: translateX(0);
}
.card-panel.slide-in {
  opacity: 1;
  transform: translateX(0);
}
.card-panel.slide-out {
  opacity: 0;
  transform: translateX(-100%);
}
.card-panel .card-inner { width: 100%; padding: 0 70px; }
.card-panel h2 { margin: 0 0 6px 0; font-size: 26px; }
.card-panel p { margin: 0; color: var(--muted); }

.auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}

.auth-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--muted);
}

.auth-btn-email {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s;
}

/* Highlight signup button on hover */
.auth-btn:hover {
  background-color: var(--accent);
  color: white;
}

/* Recovery section styling */
.recovery-section {
  margin-top: 16px;
  text-align: center;
}

.recovery-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.recovery-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.recovery-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
}

.recovery-btn:hover {
  text-decoration: underline;
}

input:-webkit-autofill {
  background-color: var(--bg-muted, #333) !important;
  color: var(--muted, #666) !important;
  border: 1px solid var(--line) !important;
}