/* ============================================================================
 * site-system.v1.css — habix.ai 3-도메인 공유 디자인 시스템 (Phase 0)
 *
 * 적용 대상: habix.ai · universe.habix.ai · blog.habix.ai
 *
 * 호스팅:
 *   GET https://habix.ai/_shared/site-system.v1.css
 *     → habix.ai Worker가 이 파일을 그대로 응답 (s-maxage=86400, immutable)
 *
 * 사용:
 *   <link rel="stylesheet" href="https://habix.ai/_shared/site-system.v1.css">
 *
 * 변경 정책:
 *   - 이 파일은 v1 freeze. 깨질 수 있는 변경은 v2 신규 파일을 만들고
 *     3 repo에서 import 경로를 함께 업데이트.
 *   - 토큰 값만 추가/조정은 in-place 가능(기존 클래스명·구조 보존).
 * ========================================================================== */

/* Pretendard Variable — 한글 본문 가독성 (orioncactus/pretendard v1.3.9) */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable.css');

/* ── 1. 디자인 토큰 ──────────────────────────────────────────────────────── */
:root {
  /* 색 — 페이지 배경 / elevated 카드 */
  --color-bg-page: #faf8f4;
  --color-bg-elevated: #ffffff;
  --color-bg-subtle: #f3f0ea;

  /* 텍스트 위계 */
  --color-text-primary: #1a1a2e;
  --color-text-secondary: #3d3830;
  --color-text-muted: #7a7068;

  /* 브랜드 오렌지 (habix.ai 시그니처) */
  --color-brand-orange: #c8623a;
  --color-brand-orange-hover: #d9744f;
  --color-brand-orange-focus: rgba(200, 98, 58, 0.35);
  --color-brand-orange-glow: rgba(200, 98, 58, 0.15);

  /* 보더 */
  --color-border: #e8e3d8;
  --color-border-strong: #ddd7c8;

  /* 폰트 — 한글 본문 가독성 우선 Pretendard, fallback Noto Sans KR */
  --font-heading-serif: Georgia, 'Times New Roman', serif;
  --font-body-sans: 'Pretendard Variable', 'Pretendard', 'Noto Sans KR',
    'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular,
    Menlo, monospace;

  /* 가독성 토큰 (행간/자간 여유 — 라이트 타겟 가독성 개선) */
  --line-height-body: 1.75;
  --line-height-tight: 1.45;
  --letter-spacing-body: -0.011em;

  /* 공간 */
  --space-section-y: 80px;
  --space-section-y-mobile: 56px;

  /* 라운드 / 그림자 */
  --radius-card: 12px;
  --radius-chip: 999px;
  --shadow-elevated: 0 12px 32px rgba(0, 0, 0, 0.08);
  --shadow-header: 0 1px 0 rgba(0, 0, 0, 0.04);
}

/* ── 2. SR only (a11y) ──────────────────────────────────────────────────── */
.hx-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── 3. Header ───────────────────────────────────────────────────────────── */
.hx-site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-header);
  font-family: var(--font-body-sans);
}
.hx-site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}
.hx-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-brand-orange);
  text-decoration: none;
  line-height: 1;
}
.hx-logo:hover { text-decoration: none; opacity: 0.9; }
.hx-logo__mark {
  color: var(--color-text-primary);
}
.hx-logo__dot {
  color: var(--color-brand-orange);
  margin: 0 1px;
}
.hx-logo__suffix {
  color: var(--color-brand-orange);
}

/* 도메인 스위처 — 중앙 */
.hx-switcher {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-chip);
  list-style: none;
  margin: 0;
}
.hx-switcher__item { display: inline-flex; }
.hx-switcher__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-chip);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}
.hx-switcher__link:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-primary);
  text-decoration: none;
}
.hx-switcher__link[aria-current="page"] {
  background: var(--color-bg-elevated);
  color: var(--color-brand-orange);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.hx-switcher__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}
.hx-switcher__link[aria-current="page"] .hx-switcher__dot { opacity: 1; }

/* CTA — 우측 */
.hx-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--color-brand-orange);
  color: #fff;
  font-family: var(--font-body-sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.18s ease, transform 0.18s ease;
}
.hx-cta:hover {
  background: var(--color-brand-orange-hover);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}
.hx-cta:focus-visible {
  outline: 2px solid var(--color-brand-orange-focus);
  outline-offset: 3px;
}

/* GNB — Features/Products/Lectures 등 dropdown nav (habix 도메인 전용) */
.hx-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 16px;
}
.hx-nav { display: inline-flex; }
.hx-nav__list {
  display: inline-flex;
  align-items: center;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.hx-nav__item {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.hx-nav__link,
.hx-nav__trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.18s ease;
  white-space: nowrap;
}
.hx-nav__link:hover,
.hx-nav__trigger:hover {
  color: var(--color-brand-orange);
  text-decoration: none;
}
.hx-nav__link[aria-current="page"],
.hx-nav__trigger[aria-current="page"] {
  color: var(--color-brand-orange);
}
.hx-nav-dd > .hx-nav__trigger::after {
  content: "▾";
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform 0.25s ease;
}
.hx-nav-dd:hover > .hx-nav__trigger::after { transform: rotate(180deg); }
.hx-nav-dd__menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  min-width: 240px;
  padding: 8px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: var(--shadow-elevated);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  z-index: 1100;
}
.hx-nav-dd:hover > .hx-nav-dd__menu,
.hx-nav-dd:focus-within > .hx-nav-dd__menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.hx-nav-dd__link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.hx-nav-dd__link:hover {
  background: var(--color-bg-subtle);
  color: var(--color-brand-orange);
  text-decoration: none;
}
.hx-nav-dd__tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  text-transform: none;
}

/* 햄버거 (모바일) */
.hx-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
}
.hx-hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--color-text-primary);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

/* 반응형 — P0-3 fix: 721~960px 사각지대 해소. 한 breakpoint(960px)로 통일.
 * 데스크탑(>960px): 가운데 .hx-switcher chip + 우측 GNB + CTA
 * 모바일/태블릿(≤960px): 가운데 chip 숨김 + GNB 숨김 + 햄버거 노출 → 합본 드로어(.hx-mobile-drawer)
 */
@media (max-width: 960px) {
  .hx-header-actions .hx-nav { display: none; }
  .hx-switcher { display: none; }
  /* P0-3: 부모 nav도 숨겨야 grid 빈 cell이 pointer-events 가로채지 않음 */
  .hx-switcher-nav { display: none; }
  .hx-hamburger { display: inline-flex; }
  .hx-site-header__inner {
    grid-template-columns: auto 1fr auto;
    padding: 0 16px;
  }
  .hx-cta { padding: 7px 12px; font-size: 12px; }
}
@media (max-width: 720px) {
  .hx-site-header__inner {
    height: 52px;
  }
}

/* P0-4 fix: 합본 모바일 드로어 — 도메인 스위처 + GNB 메뉴를 하나의 컨테이너에서 stack.
 * --hx-switcher-h 동기화 의존 제거. document flow로 자연스럽게 쌓임.
 */
/* P0-4: 페이지 자체 `nav { height:56px }` 같은 글로벌 셀렉터를 reset.
 * height: auto + position 명시로 내용 잘림 방지. */
.hx-mobile-drawer {
  display: none;
  height: auto;
  padding: 0;
}
@media (max-width: 960px) {
  .hx-mobile-drawer.is-open {
    display: block;
    position: absolute;
    top: 100%; left: 0; right: 0;
    height: auto;
    background: var(--color-bg-page);
    border-bottom: 1px solid var(--color-border);
    z-index: 999;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    box-shadow: var(--shadow-elevated);
  }
  .hx-mobile-drawer__inner {
    padding: 12px 16px 16px;
  }
  .hx-mobile-drawer__switch-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .hx-mobile-drawer__switch-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: 6px;
  }
  .hx-mobile-drawer__switch-link:hover {
    background: var(--color-bg-subtle);
    color: var(--color-brand-orange);
    text-decoration: none;
  }
  .hx-mobile-drawer__switch-link[aria-current="page"] {
    color: var(--color-brand-orange);
    background: var(--color-bg-elevated);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }
  .hx-mobile-drawer__dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    opacity: 0.55;
  }
  .hx-mobile-drawer__switch-link[aria-current="page"] .hx-mobile-drawer__dot { opacity: 1; }
  .hx-mobile-drawer__divider {
    height: 1px;
    background: var(--color-border);
    margin: 12px 0 8px;
  }
  .hx-mobile-drawer__nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .hx-mobile-drawer__group {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 14px 14px 6px;
  }
  .hx-mobile-drawer__link {
    display: block;
    padding: 10px 14px 10px 22px;
    font-size: 14px;
    color: var(--color-text-primary);
    text-decoration: none;
    border-radius: 6px;
  }
  .hx-mobile-drawer__link--top {
    padding-left: 14px;
    font-weight: 600;
  }
  .hx-mobile-drawer__link:hover {
    background: var(--color-bg-subtle);
    color: var(--color-brand-orange);
    text-decoration: none;
  }
  .hx-mobile-drawer__link[aria-current="page"] {
    color: var(--color-brand-orange);
  }
}

/* ── 4. Footer ───────────────────────────────────────────────────────────── */
.hx-site-footer {
  margin-top: var(--space-section-y);
  background: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-body-sans);
  color: var(--color-text-muted);
}
.hx-site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 32px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 32px;
}
.hx-foot-col__title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-text-primary);
  margin: 0 0 14px;
}
.hx-foot-col__list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hx-foot-col__list a {
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.18s ease;
}
.hx-foot-col__list a:hover {
  color: var(--color-brand-orange);
  text-decoration: none;
}
.hx-foot-brand .hx-logo { font-size: 14px; }
.hx-foot-brand__desc {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-text-muted);
  max-width: 280px;
}
.hx-foot-sns {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}
.hx-foot-sns a {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center; justify-content: center;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.hx-foot-sns a:hover {
  border-color: var(--color-brand-orange);
  color: var(--color-brand-orange);
}

.hx-site-footer__legal {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px 32px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}
.hx-site-footer__legal-biz {
  flex: 1 1 auto;
  text-align: center;
  min-width: 280px;
}

@media (max-width: 860px) {
  .hx-site-footer__inner {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
  }
  .hx-foot-brand { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .hx-site-footer__inner {
    grid-template-columns: 1fr;
    padding: 36px 18px 24px;
  }
  .hx-site-footer__legal { padding: 14px 18px 24px; }
}

/* ── 5. 다크 컨텍스트 오버라이드 (universe.habix.ai 호환) ─────────────────
 * universe는 dark navy SPA. body[data-theme="dark"]가 있을 때 헤더/푸터를
 * 다크 배경에 맞춰 색 보정. light 페이지(/about)는 별도 처리 불필요.
 * ─────────────────────────────────────────────────────────────────────── */
body[data-theme="dark"] .hx-site-header {
  background: rgba(15, 23, 42, 0.86);
  border-bottom-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}
body[data-theme="dark"] .hx-logo__mark { color: #f1f5f9; }
body[data-theme="dark"] .hx-switcher {
  background: rgba(255, 255, 255, 0.06);
}
body[data-theme="dark"] .hx-switcher__link {
  color: rgba(226, 232, 240, 0.78);
}
body[data-theme="dark"] .hx-switcher__link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}
body[data-theme="dark"] .hx-switcher__link[aria-current="page"] {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
body[data-theme="dark"] .hx-hamburger span { background: #f1f5f9; }
body[data-theme="dark"] .hx-site-footer {
  background: rgba(10, 10, 20, 0.6);
  border-top-color: rgba(255, 255, 255, 0.08);
  color: rgba(226, 232, 240, 0.65);
}
body[data-theme="dark"] .hx-foot-col__title { color: #f1f5f9; }
body[data-theme="dark"] .hx-foot-col__list a { color: rgba(226, 232, 240, 0.7); }
body[data-theme="dark"] .hx-foot-brand__desc { color: rgba(226, 232, 240, 0.6); }
body[data-theme="dark"] .hx-foot-sns a {
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(226, 232, 240, 0.78);
}
body[data-theme="dark"] .hx-site-footer__legal {
  border-top-color: rgba(255, 255, 255, 0.08);
  color: rgba(226, 232, 240, 0.55);
}

/* ── 6. prefers-reduced-motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .hx-cta, .hx-switcher__link, .hx-foot-sns a, .hx-hamburger span {
    transition: none !important;
    transform: none !important;
  }
}

/* ── 7. 라이트 타겟 진입 보강 박스 3종 (15초 요약 · 용어 · 단서) ──────────
 * Parker PM 스타일 — 페이지 본문 어디서나 재사용 가능한 일반 컴포넌트.
 * Usage:
 *   <div class="hx-summary"><span class="hx-summary-label">⏱ 15초 요약</span><p>...</p></div>
 *   <div class="hx-glossary"><span class="hx-glossary-label">📖 알아두면 좋은 용어</span><dl>...</dl></div>
 *   <div class="hx-caveat"><span class="hx-caveat-label">근데 말이죠</span><h3 class="hx-caveat-title">...</h3><ul>...</ul></div>
 * ────────────────────────────────────────────────────────────────────────── */
.hx-summary,
.hx-glossary,
.hx-caveat {
  max-width: 760px;
  margin: 0 auto;
  border-radius: var(--radius-card, 12px);
  line-height: var(--line-height-body, 1.75);
  letter-spacing: var(--letter-spacing-body, -0.011em);
  font-family: var(--font-body-sans);
}
.hx-summary {
  margin-top: 48px;
  margin-bottom: 48px;
  padding: 28px 32px;
  background: var(--color-bg-subtle, #f3f0ea);
  border-left: 4px solid var(--color-brand-orange, #c8623a);
}
.hx-summary-label {
  display: inline-block;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--color-brand-orange, #c8623a);
  margin-bottom: 12px;
  text-transform: uppercase;
}
.hx-summary p {
  margin: 0;
  font-size: 17px;
  color: var(--color-text-secondary, #3d3830);
}
.hx-summary strong { color: var(--color-text-primary, #1a1a2e); }

.hx-glossary {
  margin: 0 auto 64px;
  padding: 28px 32px;
  background: var(--color-bg-elevated, #ffffff);
  border: 1px solid var(--color-border, #e8e3d8);
}
.hx-glossary-label {
  display: inline-block;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--color-text-muted, #7a7068);
  margin-bottom: 16px;
  text-transform: uppercase;
}
.hx-glossary dl { margin: 0; display: grid; gap: 14px; }
.hx-glossary dt {
  font-weight: 700;
  color: var(--color-text-primary, #1a1a2e);
  font-size: 14px;
}
.hx-glossary dd {
  margin: 4px 0 0;
  color: var(--color-text-secondary, #3d3830);
  font-size: 14px;
}

.hx-caveat {
  margin: 64px auto;
  padding: 28px 32px;
  background: #fdf6f3;
  border: 1px solid #e8c4b3;
}
.hx-caveat-label {
  display: inline-block;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #b04a26;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.hx-caveat-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-primary, #1a1a2e);
}
.hx-caveat ul {
  margin: 0;
  padding-left: 18px;
  color: var(--color-text-secondary, #3d3830);
  font-size: 15px;
}
.hx-caveat li { margin-bottom: 8px; }
.hx-caveat li:last-child { margin-bottom: 0; }

@media (max-width: 720px) {
  .hx-summary, .hx-glossary, .hx-caveat { padding: 22px 20px; }
  .hx-summary p { font-size: 15px; }
}
