/* ============================================================
   폰트 시스템 (한글·영문 자폭 조정)
   - 영문 / 숫자 / 기호 → Arial (OS 기본 서체), 없으면 Pretendard
   - 한글              → Pretendard (CDN, unicode-range 로 한글만)
   - 모든 텍스트 자폭 0.83 압축 → js/font-system.js (.char-narrow)
   ============================================================ */
@font-face {
  font-family: "Pretendard";
  src: url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/packages/pretendard/dist/web/variable/woff2/PretendardVariable.woff2")
    format("woff2-variations");
  font-weight: 45 920;
  font-display: swap;
  unicode-range:
    U+1100-11FF, U+3000-303F, U+3130-318F, U+A960-A97F, U+AC00-D7A3,
    U+D7B0-D7FF, U+FF00-FFEF;
}

/* Arial 없을 때 영문·숫자·기호용 Pretendard (Latin 등) */
@font-face {
  font-family: "Pretendard";
  src: url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/packages/pretendard/dist/web/variable/woff2/PretendardVariable.woff2")
    format("woff2-variations");
  font-weight: 45 920;
  font-display: swap;
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+2070-209F, U+20A0-20CF, U+2100-214F,
    U+2150-218F, U+2190-21FF, U+2200-22FF, U+2300-23FF, U+2C60-2C7F,
    U+A720-A7FF, U+FB00-FB4F;
}

/* ============================================================
   Figma Variables → CSS 변수 (Figma에 등록된 값만 사용)
   ============================================================ */
:root {
  /* Color */
  --color-black: #000000;
  --color-white: #ffffff;
  --color-primary-01: #d298ff;
  --color-primary-02: #fffb00;
  --color-primary-03: #00d9ff;
  --color-primary-04: #00ff4d;

  /* Font family — Arial(영문) 우선, 없으면 Pretendard fallback */
  --font-family-ko: Arial, "Pretendard", sans-serif;
  --font-family-en: Arial, "Pretendard", sans-serif;

  /* Font weight */
  --font-weight-regular-en: 400;
  --font-weight-regular-ko: 500;

  /* Font size */
  --font-size-caption-sm: 20px;
  --font-size-caption-lg: 28px;
  --font-size-body: 28px;
  --font-size-title: 40px;
  --font-size-nav: var(--font-size-title);

  /* Spacing */
  --spacing-4: 4px;
  --spacing-8: 8px;
  --spacing-12: 12px;
  --spacing-20: 20px;
  --spacing-28: 28px;
  --spacing-40: 40px;
  --spacing-56: 56px;
  --spacing-80: 80px;
}

/* ============================================================
   Reset
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE, Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
}

body {
  font-family: var(--font-family-ko);
  color: var(--color-black);
  background-color: var(--color-white);
}

/* 메인 페이지만 스크롤 잠금 — 배경색은 .stage / .stage__bg 에서 제어 */
body.main-page {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============================================================
   공통 유틸
   - blend-text: 흰 글자 + 배경과 색 반전(mix-blend-difference)
   - char-narrow: 모든 텍스트 자폭 0.83 압축 (js/font-system.js 가 자동으로 감쌈)
   ============================================================ */
.blend-text {
  color: var(--color-white);
  isolation: isolate;
  mix-blend-mode: difference;
}

/* 한글·영문 자폭 압축(자동 적용):
   스크립트가 공백 제외 텍스트 구간을 이 span 으로 감싸고,
   음수 margin-right 는 레이아웃 폭에 맞춰 스크립트가 계산해 넣습니다. */
.char-narrow {
  display: inline-block;
  -webkit-transform: scaleX(0.83);
  transform: scaleX(0.83);
  transform-origin: left center;
}

/* 과거 수동 압축 클래스 → 이제 자동 시스템이 처리하므로 압축 효과는 제거
   (기존 마크업 호환 및 밑줄 등 다른 스타일 유지용) */
.ko-narrow {
  display: inline;
}

/* ============================================================
   Text Style (Figma)
   ============================================================ */
.title-en {
  font-family: var(--font-family-en);
  font-weight: var(--font-weight-regular-en);
  font-size: var(--font-size-title);
  line-height: 1.05;
}

.caption-lg-ko {
  font-family: var(--font-family-ko);
  font-weight: var(--font-weight-regular-ko);
  font-size: var(--font-size-caption-lg);
  line-height: 1;
}

.caption-sm-ko {
  font-family: var(--font-family-ko);
  font-weight: var(--font-weight-regular-ko);
  font-size: var(--font-size-caption-sm);
  line-height: 1;
}

.caption-en {
  font-family: var(--font-family-en);
  font-weight: var(--font-weight-regular-en);
  font-size: var(--font-size-caption-sm);
  line-height: 1;
}

.caption-md-en {
  font-family: var(--font-family-en);
  font-weight: var(--font-weight-regular-en);
  font-size: var(--font-size-caption-md, var(--font-size-body));
  line-height: 1;
}

/* ============================================================
   네비게이션 (Figma: Frame 7)
   - 로고 / work / about / en — flex space-between
   - ::before = 페이지색 배경(블렌드 없음)
   - 각 항목에 blend → 글자·밑줄이 함께 반전
   - 밑줄은 text-decoration underline (header padding-bottom 으로 잘림 방지)
   ============================================================ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 42px;
  padding: 0 0 1px;
  color: var(--color-white);
}

/* 헤더 배경 레이어 — 페이지별 색은 about/work CSS에서 ::before에 지정 */
.nav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* 콘텐츠 항목 — 각각 blend (자식 개별 blend 시 배경(::before)만 보여 흰색으로 보임) */
.nav__logo,
.nav__logo .nav__link,
.nav > .nav__link,
.nav__lang {
  position: relative;
  z-index: 1;
  font-family: var(--font-family-en);
  font-weight: var(--font-weight-regular-en);
  font-size: var(--font-size-nav);
  line-height: 1.05;
  color: var(--color-white);
  isolation: isolate;
  mix-blend-mode: difference;
}

.nav__logo {
  letter-spacing: -0.02em;
}

.nav__logo .nav__link,
.nav > .nav__link {
  color: inherit;
  text-decoration: none;
}

.nav__text {
  pointer-events: none;
}

.nav__external-slot {
  display: inline;
}

/* 호버·active 밑줄 — .char-narrow 에 직접 (scaleX transform 과 text-decoration 충돌 방지) */
.nav__logo .nav__link:hover .char-narrow,
.nav > .nav__link:hover .char-narrow,
.nav > .nav__link.is-active .char-narrow,
.nav__lang:hover .char-narrow,
.nav__lang.is-active .char-narrow {
  text-decoration: underline;
  text-underline-position: from-font;
  text-decoration-thickness: 3px;
}

.nav__lang {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

/* Mobile: 헤더 28px + underline 2px (전 페이지·인앱 브라우저 공통) */
@media (max-width: 767px) {
  :root {
    --font-size-nav: 28px;
  }

  .nav {
    height: 29px;
    padding: 0 2px 1px;
  }

  .nav__logo,
  .nav__logo .nav__link,
  .nav > .nav__link,
  .nav__lang {
    font-size: var(--font-size-nav);
    line-height: 1;
  }

  .nav__logo .nav__link:hover .char-narrow,
  .nav > .nav__link:hover .char-narrow,
  .nav > .nav__link.is-active .char-narrow,
  .nav__lang:hover .char-narrow,
  .nav__lang.is-active .char-narrow,
  .filter.is-active,
  .view.is-active,
  .cv-block__label .char-narrow {
    text-decoration-thickness: 2px;
  }

  .list-row {
    border-bottom-width: 2px;
  }
}

/* 메인 페이지: 헤더(.nav) 전체에 blend — 내부 요소 개별 blend 해제 */
body.main-page .nav {
  isolation: isolate;
  mix-blend-mode: difference;
}

body.main-page .nav__logo,
body.main-page .nav > .nav__link,
body.main-page .nav__lang {
  mix-blend-mode: normal;
}

/* ============================================================
   무대 (배경색 + 작품 커버 순환)
   ============================================================ */
.stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* 순환되는 배경색 */
.stage__bg {
  position: absolute;
  inset: 0;
  background-color: var(--color-primary-01);
}

/* 화면 중앙의 작품 커버 (배경색이 여백으로 보임) */
.stage__cover {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 100dvh;
  width: auto;
  max-width: 100vw;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.stage__cover.is-visible {
  opacity: 1;
}

/* ============================================================
   단어 파편 (Figma: keyworkds)
   - 흰 배경 + 검정 글자 + 가로 80% 압축 + mix-blend-difference
   ============================================================ */
.word-rain {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  isolation: isolate;
  mix-blend-mode: difference;
}

.word-fragment {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0 2px;
  font-family: var(--font-family-ko);
  font-weight: var(--font-weight-regular-ko);
  font-size: var(--font-size-caption-sm);
  line-height: 1;
  color: var(--color-black);
  background: var(--color-white);
  white-space: nowrap;
  transform-origin: left top;
  will-change: transform;
}

/* ============================================================
   입력창 (Figma: Frame 27)
   ============================================================ */
.typing-box {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: var(--spacing-8);
}

.typing-box__input {
  width: 212px;
  padding: 4px 6px;
  border: 1px solid #767676;
  border-radius: 3px;
  background: var(--color-white);
  color: var(--color-black);
  font-family: var(--font-family-ko);
  font-size: 16px;
  line-height: 1.2;
  text-align: center;
}

.typing-box__input::placeholder {
  color: rgb(168, 168, 168);
  opacity: 1;
}

.typing-box__input:focus {
  outline: none;
}

.typing-box__send {
  padding: 4px 6px;
  border: 1px solid #767676;
  border-radius: 3px;
  background: var(--color-white);
  color: var(--color-black);
  font-family: var(--font-family-en);
  font-size: 16px;
  line-height: 1.2;
  cursor: pointer;
}

/* ============================================================
   Main 페이지 반응형 (Figma Mobile — body.main-page 만 적용)
   - 767px 이하: Mobile Mode Variables
   - 768~1023: Tablet (Desktop·Mobile 보간)
   - 1024~1439: Desktop (기본 스타일)
   - 1440px~: Wide
   ============================================================ */

/* --- Mobile (max-width: 767px) --- */
@media (max-width: 767px) {
  body.main-page {
    --font-size-caption-sm: 16px;
    --font-size-caption-lg: 22px;
  }

  body.main-page .stage {
    max-width: 100%;
    overflow-x: hidden;
  }

  body.main-page .stage__cover {
    top: 50%;
    left: 0;
    width: 100%;
    height: auto;
    max-width: 100%;
    transform: translateY(-50%);
    object-fit: contain;
  }

  body.main-page .typing-box {
    left: 2px;
    right: 2px;
    width: calc(100% - 4px);
    transform: none;
    justify-content: center;
  }
}

/* --- Small mobile (max-width: 480px) --- */
@media (max-width: 480px) {
  body.main-page .typing-box {
    flex-wrap: wrap;
    row-gap: var(--spacing-8);
    bottom: 16px;
  }

  body.main-page .typing-box__input {
    width: 100%;
    max-width: 212px;
    min-width: 0;
  }
}

/* --- Tablet (768px ~ 1023px) --- */
@media (min-width: 768px) and (max-width: 1023px) {
  body.main-page .stage__cover {
    top: 50%;
    left: 50%;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: calc(100dvh - 80px);
    transform: translate(-50%, -50%);
    object-fit: contain;
  }
}

/* --- Wide (min-width: 1440px) --- */
@media (min-width: 1440px) {
  body.main-page .stage__cover {
    height: 100dvh;
    width: auto;
    max-width: 100vw;
  }
}
