/* ==========================================================================
   Homestay Korea — CSS Reset
   모던 브라우저 호환 초기화 + 기본 타이포그래피 설정
   ========================================================================== */

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

/* ---- 기본 여백 제거 ---- */
html,
body,
h1, h2, h3, h4, h5, h6,
p,
blockquote,
figure,
figcaption,
dl, dd,
ol, ul {
  margin: 0;
  padding: 0;
}

/* ---- HTML 기본 ---- */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Body ---- */
body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-white);
  text-rendering: optimizeLegibility;
}

/* ---- 헤딩 ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

/* 모바일 헤딩 크기 조정 */
@media (max-width: 767px) {
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl); }
  h4 { font-size: var(--text-lg); }
}

/* ---- 본문 텍스트 ---- */
p {
  line-height: var(--leading-relaxed);
  margin-bottom: var(--spacing-4);
}

p:last-child {
  margin-bottom: 0;
}

/* ---- 링크 ---- */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ---- 리스트 ---- */
ol, ul {
  list-style: none;
}

/* ---- 이미지 & 미디어 ---- */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  border-style: none;
  vertical-align: middle;
}

/* ---- 폼 요소 ---- */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

textarea {
  resize: vertical;
}

fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

legend {
  padding: 0;
}

/* ---- 테이블 ---- */
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

/* ---- 기타 ---- */
hr {
  border: none;
  border-top: 1px solid var(--color-border-light);
  margin: var(--spacing-8) 0;
}

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

em, i {
  font-style: italic;
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ---- 선택 영역 하이라이트 ---- */
::selection {
  background-color: var(--color-primary-light);
  color: var(--color-text-primary);
}

/* ---- 스크롤바 (WebKit 기반 브라우저) ---- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-light);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-dark);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* ---- Skip Navigation (접근성) ---- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--spacing-4);
  z-index: var(--z-tooltip);
  padding: var(--spacing-2) var(--spacing-4);
  background: var(--color-primary);
  color: var(--color-text-white);
  font-weight: var(--font-semibold);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
  outline: none;
}

/* ---- 스크린 리더 전용 ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- 포커스 표시 숨김 (마우스 사용자) ---- */
.js-focus-visible :focus:not(.focus-visible) {
  outline: none;
}

/* ---- 모션 감소 환경 ---- */
@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;
  }
}
