/* Local Pretendard Font Definitions - Ultimate Fallback */

/* Pretendard Variable Font - Best Performance */
@font-face {
  font-family: "Pretendard Variable";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src:
    url("/fonts/PretendardVariable.woff2") format("woff2-variations"),
    url("/fonts/pretendardvariable-400.woff2") format("woff2");
  font-named-instance: "Regular";
}

/* Pretendard Static Fonts - Compatibility Fallback */
@font-face {
  font-family: "Pretendard";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/Pretendard-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "Pretendard";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/Pretendard-Medium.woff2") format("woff2");
}

@font-face {
  font-family: "Pretendard";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/Pretendard-SemiBold.woff2") format("woff2");
}

@font-face {
  font-family: "Pretendard";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/Pretendard-Bold.woff2") format("woff2");
}

/* System Font Detection and Fallback */
@font-face {
  font-family: "Korean System";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src:
    local("Apple SD Gothic Neo"), local("Malgun Gothic"), local("맑은 고딕"), local("Noto Sans KR"),
    local("system-ui"), local("sans-serif");
}

/* Ultimate Fallback Font Stack */
:root {
  --font-pretendard-local: "Pretendard Variable", "Pretendard";
  --font-system-korean: "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR";
  --font-system-western: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui;
  --font-ultimate-fallback:
    var(--font-pretendard-local), var(--font-system-korean), var(--font-system-western), sans-serif;
}

/* Korean Typography with Local Font Priority */
body {
  font-family: var(--font-ultimate-fallback);
  font-feature-settings:
    "kern" 1,
    "liga" 0;
  text-rendering: optimizeSpeed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Korean Text Optimization */
.korean-text,
[lang="ko"],
body {
  word-break: keep-all;
  overflow-wrap: break-word;
  hyphens: none;
  line-height: 1.7;
  letter-spacing: -0.01em;
}

/* Performance: Preload Critical Fonts */
.font-preload {
  font-family: var(--font-pretendard-local);
}

/* Font Loading States */
.fonts-loading {
  font-family: var(--font-system-western);
  visibility: hidden;
}

.fonts-loaded {
  font-family: var(--font-ultimate-fallback);
  visibility: visible;
}

/* Mobile Optimization */
@media screen and (max-width: 768px) {
  body {
    font-size: 16px; /* Prevent iOS zoom */
  }

  .korean-text {
    line-height: 1.8; /* More breathing room on mobile */
  }
}

/* High DPI Optimization */
@media screen and (-webkit-min-device-pixel-ratio: 2) {
  body {
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

/* Print Optimization */
@media print {
  body {
    font-family: var(--font-system-korean), serif;
    -webkit-print-color-adjust: exact;
    color-adjust: exact;
  }
}
