/* ==========================================================================
   base.css — 리셋, 폰트, safe-area, 모바일 함정 차단, 반응형 프리미티브
   반드시 tokens.css 다음에 로드할 것.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Modern minimal reset
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   2. Pretendard Variable 폰트
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Pretendard Variable';
  src: url('../fonts/PretendardVariable.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* 디스플레이 서체 — 마루부리 Bold 서브셋 수정본(내부명 SW Serif, 63KB).
   라이선스: fonts/LICENSE-MaruBuri.txt. 첫 방문 FOUT 허용(swap) — SW 캐시 후 즉시. */
@font-face {
  font-family: 'SW Serif';
  src: url('../fonts/MaruBuri-Bold-sub.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   3. Safe-area 인셋 변수 (노치/홈바 대응)
   -------------------------------------------------------------------------- */
:root {
  --safe-t: env(safe-area-inset-top,    0px);
  --safe-r: env(safe-area-inset-right,  0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left,   0px);
}

/* --------------------------------------------------------------------------
   4. 모바일 함정 차단 (html + body 전역)
   -------------------------------------------------------------------------- */
/* Shared viewport-responsive UI axis; cards retain their own pixel/cqw geometry. */
html { font-size: clamp(82%, 4.102564vmin, 100%); }

html, body {
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* --------------------------------------------------------------------------
   5. body 기본 스타일
   -------------------------------------------------------------------------- */
body {
  font-family: 'Pretendard Variable', -apple-system, 'Apple SD Gothic Neo',
               'Noto Sans KR', sans-serif;
  font-size: var(--fs-md);
  font-weight: 300; /* 미니멀 리디자인: 얇은 본문 (Pretendard 가변축) */
  line-height: 1.5;
  color: var(--tx-1);

  /* 트와일라잇 인디고 그라데이션 배경 (테마 변수 — 상점 테마가 오버라이드) */
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, color-mix(in srgb, var(--bg-teal) 40%, transparent) 0%, transparent 70%),
    linear-gradient(160deg, var(--bg-deep) 0%, var(--bg-mid) 55%, var(--bg-teal) 100%);
  /* iOS에서는 스크롤 컨테이너 내부에서 fixed가 scroll처럼 동작하지만,
     이 앱은 body 스크롤이 없는 풀스크린 게임이라 의도대로 고정 표시됨 */
  background-attachment: fixed;

  min-height: 100dvh;

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 특별 장소 — 짙은 스크림을 배경 레이어에 함께 합성해 카드 대비를 보존한다. */
body[data-venue]{background-image:linear-gradient(160deg,var(--bg-deep),var(--bg-mid));}
body[data-venue] .game-root{position:relative;z-index:1;}
.venue-visual-layer{position:fixed;inset:0;z-index:0;pointer-events:none;
  background-image:
    radial-gradient(ellipse 78% 72% at 50% 46%,transparent 0%,var(--venue-board-focus) 72%,rgba(2,5,12,.56) 100%),
    linear-gradient(var(--venue-tint),var(--venue-tint)),
    linear-gradient(var(--venue-scrim),color-mix(in srgb,var(--venue-scrim) 82%,#02050c)),
    var(--venue-image);
  background-size:cover;background-position:center;opacity:0;
  animation:venue-layer-in var(--motion-venue) var(--ease-out) forwards;}
@keyframes venue-layer-in{to{opacity:1;}}

@media (hover: none) and (pointer: coarse) {
  body { background-attachment: scroll; }
}

/* 세이가이하(청해파) 문양 오버레이 — 일본풍 리스킨의 은은한 금빛 파도.
   z-index:-1로 배경 그라데이션 위·콘텐츠 아래에 고정. 테마 무관 공통. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='30' viewBox='0 0 60 30'%3E%3Cg fill='none' stroke='%23d9b45c' stroke-width='1'%3E%3Ccircle cx='0' cy='30' r='28'/%3E%3Ccircle cx='0' cy='30' r='20'/%3E%3Ccircle cx='0' cy='30' r='12'/%3E%3Ccircle cx='30' cy='30' r='28'/%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3Ccircle cx='30' cy='30' r='12'/%3E%3Ccircle cx='60' cy='30' r='28'/%3E%3Ccircle cx='60' cy='30' r='20'/%3E%3Ccircle cx='60' cy='30' r='12'/%3E%3Ccircle cx='15' cy='15' r='28'/%3E%3Ccircle cx='15' cy='15' r='20'/%3E%3Ccircle cx='15' cy='15' r='12'/%3E%3Ccircle cx='45' cy='15' r='28'/%3E%3Ccircle cx='45' cy='15' r='20'/%3E%3Ccircle cx='45' cy='15' r='12'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 60px 30px;
}

/* --------------------------------------------------------------------------
   6. 스크롤 가능 패널 유틸리티 (통계/상점 등)
      터치 스크롤을 다시 허용하되 수평 스크롤은 막는다.
   -------------------------------------------------------------------------- */
.scrollable {
  touch-action: pan-y;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

/* --------------------------------------------------------------------------
   7. prefers-reduced-motion — 모션 토큰 즉시 전환으로 오버라이드
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --t-fast:      1ms;
    --t-med:       1ms;
    --t-slow:      1ms;
    --ease-out:    linear;
    --ease-spring: linear;
    --motion-dialogue-out: 1ms;
    --motion-dialogue-in: 1ms;
    --motion-venue: 1ms;
  }

  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
