/* shared/base.css — 모든 사이트 공통 리셋 + 토스트 + 푸터 + 크로스 프로모 + 언어 전환 + 별점 위젯 (모바일 우선, --app-width) */

:root {
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
  --max-width: 480px;
  /* 모든 미니앱은 모바일 화면이 기본: 데스크톱에서도 이 폭의 한 줄 레이아웃을 가운데에 둔다(배경은 꽉 채움).
     여러 칸 데스크톱 레이아웃은 쓰지 않는다. 화면 고정 요소(모달·하단 바·전체 화면 탭 영역)도 이 폭 안에 둔다. */
  --app-width: 480px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --toast-bg: rgba(20, 18, 30, 0.94);
  --toast-fg: #fff;
}

/* 일본어 페이지: 가나/한자는 일본어 글꼴로 (Pretendard에는 가나가 없다) */
html:lang(ja) {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Yu Gothic UI', 'Yu Gothic', Meiryo, 'Noto Sans JP', 'Pretendard', sans-serif;
}
/* 일본어 제목은 문절 단위로 줄바꿈 (지원 브라우저만, 나머지는 무시) */
html:lang(ja) :is(h1, h2, h3, summary) { word-break: auto-phrase; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------------- 토스트 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(12px);
  background: var(--toast-bg);
  color: var(--toast-fg);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  /* 긴 문구(번역 포함)도 좁은 화면 안에서 줄바꿈 */
  width: max-content;
  max-width: calc(min(100vw, var(--app-width, 480px)) - 32px);
  white-space: normal;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------------- 크로스 프로모 ---------------- */
#more-tests {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: var(--max-width);
  margin: 0 auto;
}
.more-test-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, background 0.15s ease;
}
.more-test-card:active { transform: scale(0.98); }
.more-test-emoji { font-size: 26px; line-height: 1; flex-shrink: 0; }
.more-test-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.more-test-title { font-weight: 700; font-size: 15px; }
.more-test-desc {
  font-size: 12.5px;
  opacity: 0.65;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.more-test-arrow { opacity: 0.4; font-size: 16px; flex-shrink: 0; }

/* ---------------- 푸터 ---------------- */
.site-footer {
  max-width: var(--max-width);
  margin: 40px auto 0;
  padding: 24px 20px 40px;
  text-align: center;
  font-size: 12px;
  opacity: 0.55;
  line-height: 1.8;
}
.site-footer a { text-decoration: underline; text-underline-offset: 2px; }

/* ---------------- 언어 전환 ---------------- */
.lang-switch {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 0 0;
  font-size: 12px;
  line-height: 1;
}
.lang-switch a {
  padding: 6px 9px;
  border-radius: 999px;
  opacity: 0.6;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.lang-switch a:hover { opacity: 0.9; }
.lang-switch a[aria-current="page"] {
  opacity: 1;
  font-weight: 800;
  background: rgba(150, 150, 160, 0.16);
}

/* 기본 언어 루트에서만 JS로 삽입되는 "다른 언어 버전" 배너 */
.lang-banner {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 32px);
  max-width: calc(var(--max-width) - 40px);
  margin: 12px auto 0;
  padding: 10px 8px 10px 16px;
  border-radius: var(--radius-md);
  background: var(--toast-bg);
  color: var(--toast-fg);
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  animation: lang-banner-in 0.3s ease;
}
.lang-banner-text { flex: 1; min-width: 0; }
/* 한국어 페이지 위에 뜨는 일본어 배너도 일본어 글꼴로 */
.lang-banner:lang(ja) { font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Yu Gothic', Meiryo, 'Noto Sans JP', var(--font-sans); }
.lang-banner-cta {
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff;
  color: #14121e;
  font-weight: 700;
  font-size: 12.5px;
  white-space: nowrap;
}
.lang-banner-close {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}
@keyframes lang-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- 유틸 ---------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---------------- 별점 위젯 (common.js renderRating) ----------------
   사이트마다 --mg-star-on / --mg-star-off / --mg-rating-font 로 색·글꼴을 바꿀 수 있다. */
.mg-rating {
  text-align: center;
  margin: 24px auto;
  max-width: var(--max-width, 480px);
  font-family: var(--mg-rating-font, inherit);
}
.mg-rating-title { font-weight: 700; font-size: 15px; margin: 0 0 6px; }
.mg-rating-stars { display: inline-flex; gap: 2px; }
.mg-star {
  font-size: 34px;
  line-height: 1;
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
  color: var(--mg-star-off, rgba(128, 128, 128, 0.35));
  transition: transform 0.12s ease, color 0.12s ease;
}
.mg-star.is-on { color: var(--mg-star-on, #f5b301); }
.mg-star:hover, .mg-star:focus-visible { transform: scale(1.12); }
.mg-star:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 6px; }
.mg-rating-meta { font-size: 13px; opacity: 0.75; margin: 6px 0 0; }
@media (prefers-reduced-motion: reduce) { .mg-star { transition: none; } }

/* ---------------- 앱 중간 광고 (common.js renderAd) ----------------
   자리를 미리 잡지 않는다: 광고가 없거나(unfilled) 아직 안 불렀으면 높이가 없다. */
.mg-ad {
  display: block;
  min-height: 1px;
  width: 100%;
  max-width: var(--app-width, 480px);
  margin: 16px auto;
  overflow: hidden;
}
.mg-ad:not([data-mg-ad-ready]) { margin: 0 auto; }
.mg-ad:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }

/* ---------------- 하트 버튼 (common.js heartButton) ---------------- */
.mg-rating-row { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.mg-heart {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 14px 6px 12px;
  border: 1.5px solid var(--mg-heart-border, rgba(255, 59, 92, 0.35));
  border-radius: 999px;
  background: var(--mg-heart-bg, rgba(255, 59, 92, 0.08));
  color: var(--mg-heart-fg, #ff3b5c);
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mg-heart-icon { font-size: 18px; display: inline-block; transform-origin: 50% 60%; }
.mg-heart.is-on .mg-heart-icon { color: var(--mg-heart-on, #ff3b5c); }
.mg-heart.is-pop .mg-heart-icon { animation: mg-heart-pop 0.45s cubic-bezier(.2, 1.6, .4, 1); }
.mg-heart-num:empty { display: none; }
.mg-heart:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
@keyframes mg-heart-pop { 0% { transform: scale(1); } 35% { transform: scale(1.45); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .mg-heart.is-pop .mg-heart-icon { animation: none; } }
