
/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--background);
  color: var(--on-surface);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Material Symbols */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Layout Utilities */
.container {
  max-width: 480px;
  margin: 0 auto;
  background: var(--background);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Hide Scrollbar */
.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Custom Animations */
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-slide-up {
  animation: slideUp 0.5s ease forwards;
}

.spin {
  animation: spin 1s linear infinite;
}

/* Glassmorphism */
.glass {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(20px);
  border: 1px solid var(--outline-variant);
}

/* Tonal Layering */
.layer-lowest { background-color: var(--surface-container-lowest); }
.layer-low { background-color: var(--surface-container-low); }
.layer-base { background-color: var(--surface-container); }
.layer-high { background-color: var(--surface-container-high); }
.layer-highest { background-color: var(--surface-container-highest); }

/* Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgb(var(--c-background) / 0.85);
  backdrop-filter: blur(20px);
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 8px 16px max(24px, env(safe-area-inset-bottom, 24px));
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  box-shadow: 0 -8px 40px rgba(23, 29, 20, 0.08);
  z-index: 1000;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  color: var(--on-surface-variant);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active .icon-container {
  background-color: var(--primary);
  color: white;
  transform: scale(1.1) translateY(-4px);
}

.icon-container {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  margin-bottom: 4px;
  transition: all 0.2s ease;
}

/* Components */
.hero-card {
  position: relative;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  height: 256px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 32px;
  color: white;
  background: var(--primary);
  box-shadow: var(--shadow-deep);
}

.hero-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.4;
  z-index: 0;
}

.hero-card .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--primary), transparent);
  z-index: 1;
}

.hero-card .content {
  position: relative;
  z-index: 2;
}

.btn-primary {
  background: white;
  color: var(--primary);
  padding: 16px 24px;
  border-radius: var(--radius-full);
  font-weight: 700;
  border: none;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.btn-primary:active {
  transform: scale(0.95);
}

/* Side Menu */
.side-menu {
  position: fixed;
  top: 0;
  left: -100%;
  width: 80%;
  max-width: 320px;
  height: 100vh;
  background: var(--background);
  z-index: 2000;
  transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 40px 24px;
}

.side-menu.active {
  left: 0;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1999;
  display: none;
}

.menu-overlay.active {
  display: block;
}

/* Views */
.info-view {
  position: fixed;
  inset: 0;
  background: var(--background);
  z-index: 1500;
  display: none;
  flex-direction: column;
  padding: 20px 24px 100px;
  overflow-y: auto;
}

.info-view.active {
  display: flex;
}

/* ── 추가: 애니메이션 (tailwind 빌드에 없던 클래스) ── */
@keyframes slideDown {
  from { transform: translate(-50%, -12px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}
.animate-slide-down { animation: slideDown 0.3s ease forwards; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.animate-fade-in { animation: fadeIn 0.4s ease forwards; }

/* 탄소 게이지 줄무늬 애니메이션 (animate-[slide_1s_linear_infinite]) */
@keyframes slide { from { background-position: 0 0; } to { background-position: 20px 0; } }

@keyframes scanMove {
  0%   { top: 0%; }
  50%  { top: calc(100% - 2px); }
  100% { top: 0%; }
}

/* 줄바꿈(\n)이 포함된 번역 문구 표시 */
.pre-line { white-space: pre-line; }

/* ── 다국어 폰트: 언어별로 알맞은 글꼴이 먼저 선택되도록 ── */
:lang(zh) body, body:lang(zh) {
  font-family: 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', 'Source Han Sans SC', var(--font-body);
}
:lang(ja) body, body:lang(ja) {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', 'Meiryo', var(--font-body);
}
:lang(vi) body, body:lang(vi) {
  font-family: 'Plus Jakarta Sans', 'Manrope', 'Noto Sans', 'Segoe UI', Roboto, system-ui, sans-serif;
}
:lang(zh) .font-headline, :lang(ja) .font-headline { font-family: inherit; }

/* 네이티브 앱: 노치/상태바 영역 확보 (Android 15+ 는 화면을 상태바 아래까지 그림) */
.native-app body { padding-top: env(safe-area-inset-top, 0px); }
.native-app #langSelectorBar { top: calc(4rem + env(safe-area-inset-top, 0px)); }
.native-app .side-menu { padding-top: calc(40px + env(safe-area-inset-top, 0px)); }
.native-app #onboarding > div:first-child { padding-top: calc(3.5rem + env(safe-area-inset-top, 0px)); }
.native-app header.fixed { padding-top: env(safe-area-inset-top, 0px); height: calc(4rem + env(safe-area-inset-top, 0px)); }

/* 탄소 게이지 줄무늬 */
.carbon-stripes {
  background-image: linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.2) 75%, transparent 75%, transparent);
  background-size: 20px 20px;
  animation: slide 1s linear infinite;
}

/* 기능 스위치: 꺼진 기능의 버튼 숨김 / 대체 버튼 표시 */
html.no-ai-scan [data-feature="aiScan"] { display: none !important; }
html:not(.no-ai-scan) [data-feature-off="aiScan"] { display: none !important; }

/* 홈 히어로 배경 (외부 이미지 대신 로컬 패턴) */
.hero-pattern {
  background-image:
    radial-gradient(circle at 85% 15%, rgba(255,255,255,0.18) 0 60px, transparent 61px),
    radial-gradient(circle at 70% 85%, rgba(134,239,172,0.25) 0 90px, transparent 91px),
    linear-gradient(135deg, #0d631b 0%, #2e7d32 100%);
}

/* ── 다크 모드 보정 (Tailwind 기본색 bg-white 등) ── */
html.dark .bg-white { background-color: var(--surface-container-lowest) !important; }
html.dark .bg-white\/50 { background-color: rgb(var(--c-surface-container-lowest) / 0.5) !important; }
html.dark .bg-amber-50 { background-color: rgba(245, 158, 11, 0.12) !important; }
html.dark .border-amber-200 { border-color: rgba(245, 158, 11, 0.35) !important; }
html.dark .text-amber-800, html.dark .text-amber-900, html.dark .text-amber-700 { color: #fcd34d !important; }
html.dark .bg-amber-100 { background-color: rgba(245, 158, 11, 0.18) !important; }
html.dark .glass { background: rgb(var(--c-surface-container-lowest) / 0.6); }
html.dark select, html.dark input { color: var(--on-surface); }
/* 검은색·진한 마크(종이 등)가 어두운 배경에서 보이도록 */
html.dark img[src*="marks/"] { background: #fff; border-radius: 14px; padding: 3px; }
html.dark .hero-pattern {
  background-image:
    radial-gradient(circle at 85% 15%, rgba(255,255,255,0.10) 0 60px, transparent 61px),
    radial-gradient(circle at 70% 85%, rgba(134,239,172,0.12) 0 90px, transparent 91px),
    linear-gradient(135deg, #0b4a15 0%, #1f5f26 100%);
}
html.dark .bg-primary { background-color: rgb(var(--c-primary)); }

/* 초록 배경 위의 흰 버튼은 다크 모드에서도 흰색 유지 (히어로·퀴즈 시작 등) */
html.dark .bg-primary .bg-white, html.dark .hero-pattern .bg-white { background-color: #fff !important; color: #0d631b !important; }
/* 검은색 '종이' 표시 라벨 */
html.dark [style*="#1d1d1d"] { color: var(--on-surface) !important; }

/* 키보드가 열린 동안: 하단 메뉴가 키보드 위로 떠서 입력창·검색 결과를 가리지 않도록 숨김 */
html.kb-open .bottom-nav { display: none !important; }

/* 광고 배너(AdMob)가 하단 메뉴 위에 있을 때 내용이 가려지지 않도록 */
html.has-ad body { padding-bottom: calc(8rem + var(--ad-h, 0px)); }
