/**
 * CSS 변수 기반 다크 테마 시스템
 * 일본어 독해 앱용 커스텀 테마
 */

:root {
  /* ===== 배경색 ===== */
  --bg-primary: #1e1e1e;
  --bg-secondary: #252526;
  --bg-tertiary: #2d2d30;
  --bg-elevated: #3e3e42;
  --bg-hover: #2a2d2e;

  /* ===== 텍스트 색상 ===== */
  --text-primary: #d4d4d4;
  --text-secondary: #969696;
  --text-tertiary: #6a6a6a;
  --text-highlight: #ffffff;
  --text-muted: #808080;

  /* ===== 액센트 색상 ===== */
  --accent-primary: #007acc;
  --accent-hover: #1e90ff;
  --accent-active: #005a9e;
  --accent-light: #4fc3f7;

  /* ===== 후리가나 색상 ===== */
  --furigana-text: #4fc3f7;
  --furigana-bg: rgba(79, 195, 247, 0.1);
  --furigana-border: #007acc;

  /* ===== 한자 하이라이트 ===== */
  --kanji-hover-bg: rgba(0, 122, 204, 0.15);
  --kanji-active-bg: rgba(0, 122, 204, 0.25);
  --kanji-border: #007acc;

  /* ===== 단어 하이라이트 (TOEIC 스타일) ===== */
  --highlight-bg: rgba(255, 235, 59, 0.25);
  --highlight-text: #ffd54f;
  --highlight-hover: rgba(255, 235, 59, 0.35);

  /* ===== 장르 색상 ===== */
  --genre-news: #2196f3;
  --genre-story: #9c27b0;
  --genre-business: #ff5722;
  --genre-culture: #009688;

  /* ===== 상태 색상 ===== */
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
  --info: #2196f3;

  /* ===== 테두리 ===== */
  --border-primary: #3e3e42;
  --border-secondary: #2d2d30;
  --border-focus: #007acc;

  /* ===== 간격 ===== */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* ===== 폰트 크기 ===== */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;

  /* ===== 폰트 두께 ===== */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* ===== 라인 높이 ===== */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  --line-height-loose: 2;

  /* ===== Border Radius ===== */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* ===== 그림자 ===== */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);

  /* ===== 애니메이션 ===== */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* ===== Z-Index ===== */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal: 400;
  --z-popover: 500;
  --z-tooltip: 600;

  /* ===== 레이아웃 ===== */
  --sidebar-width: 300px;
  --header-height: 60px;
  --container-max-width: 900px;
}

/* ===== 기본 스타일 리셋 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Noto Sans JP', 'Noto Sans KR', -apple-system, BlinkMacSystemFont,
    'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow-x: hidden;
}

/* ===== 스크롤바 스타일링 ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: #4e4e52;
}

/* ===== 선택 영역 스타일 ===== */
::selection {
  background-color: var(--accent-primary);
  color: var(--text-highlight);
}

::-moz-selection {
  background-color: var(--accent-primary);
  color: var(--text-highlight);
}

/* ===== 포커스 스타일 ===== */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ===== 버튼 기본 스타일 ===== */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--transition-fast);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ===== 링크 기본 스타일 ===== */
a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ===== 인풋 기본 스타일 ===== */
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  transition: border-color var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* ===== 유틸리티 클래스 ===== */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ===== 애니메이션 키프레임 ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideOutLeft {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
