/* ==========================================================================
   be my tree — base.css
   최소 리셋 + 페이지 기본값(지하 = 다크 기본, 지상 = [data-theme="light"]). improvement-plan-v2.md §1
   html.no-js / [data-reveal] 등 동작 상태는 interactions.css(C) 소관.
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--page-bg);
  color-scheme: dark;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: var(--fw-regular);
  font-size: var(--web-fs-body);
  line-height: var(--web-lh-body);
  letter-spacing: var(--ls-snug);
  word-break: keep-all;
  overflow-wrap: break-word;
  text-wrap: pretty;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
p, blockquote, figure, dl, dd, ol, ul {
  margin: 0;
}
ol, ul { padding: 0; list-style: none; }

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--fw-bold);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-tighter);
  text-wrap: balance;
}

strong, b { font-weight: var(--fw-bold); }

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button { cursor: pointer; }

/* 지상(light) 섹션 — 텍스트 색은 캔버스 유무와 무관하게 항상 여기서 결정 (§1.2)
   WebGL 없음·JS 없음: --light-bg 불투명 면 / html.webgl-live: 투명(캔버스가 하늘을 그림)
   webgl-ready(캔버스 페이드인 중)에는 면을 유지해야 다크 바탕이 비치지 않는다 — scene/index.js reveal() */
[data-theme="light"] {
  background-color: var(--light-bg);
  color: var(--text);
  transition: background-color var(--dur-slow) var(--ease-standard);
}
html.webgl-live [data-theme="light"] { background-color: transparent; }

/* Links — 다크 면 기준. 밝은 면에서 그린 텍스트 금지이므로 기본 링크는 흰 글씨 + 밑줄 */
a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: currentColor;
  transition: color var(--dur-base) var(--ease-standard),
              text-decoration-color var(--dur-base) var(--ease-standard);
}
a:hover { text-decoration-color: var(--bmt-root-green); }

::selection {
  background: var(--bmt-root-green);
  color: var(--bmt-ground-brown);
}

/* Focus — 2px 실선, offset 3px. 다크 흰색(on #3F3B30 11.17) · 라이트 Ground Brown(on #F4F4F4 13.05) */
:focus { outline: none; }
:focus-visible {
  outline: var(--focus-ring-w) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

/* Accessibility helpers */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
  padding: 12px 20px;
  background: var(--bmt-root-green);
  color: var(--text-on-green);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transform: translateY(-100%);
  transition: transform var(--dur-base) var(--ease-standard);
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline-color: var(--bmt-ground-brown);
  outline-offset: -4px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 레이어: 고정 WebGL 캔버스(.scene, z-index 0) 위에 콘텐츠가 오도록 (markup-contract §7).
   static 요소는 positioned 캔버스 아래에 칠해지므로 main·footer를 반드시 positioned로 둔다. */
main,
.site-footer {
  position: relative;
  z-index: 1;
}
