/*
 * ROOT4 디자인시스템 토큰
 * 값과 이름의 설명은 DESIGN.md에 있습니다. 이 파일과 DESIGN.md는 항상 같이 고칩니다.
 *
 * 쓰는 법
 *   1. 앱 진입점에서 이 파일을 한 번 가져옵니다.
 *   2. 화면과 컴포넌트에서는 Semantic 토큰(--surface-*, --text-*, --border-* ...)만 씁니다.
 *      --palette-* 는 이 파일 안에서만 참조합니다.
 *   3. 다크 테마는 <html data-theme="dark"> 로 켭니다.
 */

:root {
  /* ───────────── Atomic: palette (화면에서 직접 쓰지 않음) ───────────── */
  --palette-white: #ffffff;
  --palette-gray-25: #f9fafb;
  --palette-gray-50: #f0f2f4;
  --palette-gray-75: #eceeef;
  --palette-gray-150: #dfe3e7;
  --palette-gray-500: #89929c;
  --palette-gray-600: #6b7280; /* 결정: 측정값 #777c87은 대비 4.5:1 미달이라 한 단계 진하게 */
  --palette-gray-900: #303944;

  --palette-slate-950: #272b31;
  --palette-slate-925: #2c3138;
  --palette-slate-900: #343941;
  --palette-slate-850: #373e47;
  --palette-slate-700: #454d58;
  --palette-slate-400: #9ba7b5;
  --palette-slate-200: #c3ccd6; /* 결정: 다크 보조 글자, 측정값 없음 */
  --palette-slate-100: #e1e6ec;

  --palette-purple-50: #f0eaf7;
  --palette-purple-300: #bfadd2;
  --palette-purple-400: #a48ef0; /* 결정: 다크 위 강조 글자, 측정값 없음 */
  --palette-purple-500: #7f65e9;
  --palette-purple-600: #7c64cb;
  --palette-purple-800: #695181;
  --palette-purple-eyebrow: #8b779f;

  --palette-scrim: rgb(19 16 25 / 0.66);

  /* ───────────── Semantic: surface ───────────── */
  --surface-page: var(--palette-gray-75);          /* 캔버스·본문 바탕 */
  --surface-panel: var(--palette-white);           /* 헤더, 패널, 카드, 다이얼로그 */
  --surface-rail: var(--palette-gray-25);          /* 왼쪽 레일 */
  --surface-control: var(--palette-gray-50);       /* 칩, 선택된 레일, 입력칸 바탕 */
  --surface-accent: var(--palette-purple-500);     /* 점, 표시 마크 (글자 올리지 않음) */
  --surface-action-primary: var(--palette-purple-600); /* 주 버튼 (흰 글자) */
  --surface-accent-subtle: var(--palette-purple-50);   /* 선택된 칩, 강조 배경 */
  --surface-scrim: var(--palette-scrim);           /* 다이얼로그 뒤 */

  /* ───────────── Semantic: border ───────────── */
  --border-default: var(--palette-gray-150);
  --border-accent: var(--palette-purple-300);      /* 선택된 칩 테두리 */
  --border-focus: var(--palette-purple-500);

  /* ───────────── Semantic: text ───────────── */
  --text-primary: var(--palette-gray-900);         /* 제목, 본문 */
  --text-secondary: var(--palette-gray-600);       /* 설명 문단 */
  --text-tertiary: var(--palette-gray-500);        /* 시간, 개수, 보조 라벨 (14px 이상이거나 읽지 않아도 되는 정보만) */
  --text-accent: var(--palette-purple-800);        /* 선택 상태 글자 */
  --text-eyebrow: var(--palette-purple-eyebrow);   /* 아이브로우 */
  --text-inverse: var(--palette-white);            /* 주 버튼 위 글자 */

  /* ───────────── Typography ───────────── */
  --font-sans: "DM Sans", "Noto Sans KR", sans-serif;
  --font-logo-weight: 800;

  --type-display-lg-size: 50px;  --type-display-lg-weight: 500; --type-display-lg-line: 1.35; --type-display-lg-tracking: -2.5px;
  --type-display-md-size: 40px;  --type-display-md-weight: 500; --type-display-md-line: 1.25; --type-display-md-tracking: -2px;
  --type-heading-lg-size: 30px;  --type-heading-lg-weight: 500; --type-heading-lg-line: 1.3;  --type-heading-lg-tracking: -1.5px;
  --type-heading-md-size: 16px;  --type-heading-md-weight: 500; --type-heading-md-line: 1.4;  --type-heading-md-tracking: 0;
  --type-heading-sm-size: 14px;  --type-heading-sm-weight: 500; --type-heading-sm-line: 1.4;  --type-heading-sm-tracking: 0;
  --type-body-lg-size: 14px;     --type-body-lg-weight: 400;    --type-body-lg-line: 1.95;    --type-body-lg-tracking: -0.35px;
  --type-body-md-size: 13px;     --type-body-md-weight: 400;    --type-body-md-line: 1.85;    --type-body-md-tracking: 0;
  --type-body-sm-size: 12px;     --type-body-sm-weight: 400;    --type-body-sm-line: 1.9;     --type-body-sm-tracking: 0;
  --type-label-md-size: 12px;    --type-label-md-weight: 500;   --type-label-md-line: 1.3;    --type-label-md-tracking: 0;
  --type-label-sm-size: 11px;    --type-label-sm-weight: 400;   --type-label-sm-line: 1.3;    --type-label-sm-tracking: 0.1px;
  --type-eyebrow-size: 11px;     --type-eyebrow-weight: 400;    --type-eyebrow-line: 1.3;     --type-eyebrow-tracking: 2px;

  /* ───────────── Spacing (4 배수) ───────────── */
  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;
  --space-40: 40px;
  --space-56: 56px;

  /* ───────────── Layout ───────────── */
  --layout-header-h: 68px;
  --layout-header-h-mobile: 56px;
  --layout-rail-w: 82px;
  --layout-tabbar-h: 62px;
  --layout-panel-w: 316px;
  --layout-content-max: 1140px;
  --touch-min: 40px;

  /* ───────────── Radius ───────────── */
  --radius-chip: 6px;      /* 칩, 필터, 아이콘 버튼 */
  --radius-control: 8px;   /* 버튼, 레일 아이템, 입력칸, 탭 */
  --radius-card: 12px;     /* 카드, 컴포저 */
  --radius-dialog: 16px;   /* 다이얼로그, 큰 패널 */
  --radius-pill: 999px;    /* 줌 컨트롤, 힌트, 멤버 칩 */
  --radius-round: 50%;     /* 아바타, 닫기 버튼, 점 */

  /* ───────────── Elevation ───────────── */
  --shadow-sm: 0 2px 8px 0 rgb(40 49 61 / 0.07);    /* 떠 있는 작은 컨트롤 */
  --shadow-card: 0 3px 9px 0 rgb(34 50 72 / 0.07);  /* 보드 카드 */
  --shadow-md: 0 5px 18px 0 rgb(40 49 61 / 0.07);   /* 컴포저, 떠 있는 입력 */
  --shadow-lg: 0 10px 55px 0 rgb(52 66 93 / 0.10);  /* 큰 떠 있는 패널 */
  --shadow-dialog: 0 30px 100px 0 rgb(0 0 0 / 0.27);
  --blur-scrim: 10px;

  /* ───────────── Motion ───────────── */
  --motion-fast: 0.2s;   /* 배경색, 글자색 */
  --motion-base: 0.3s;   /* 투명도 */
  --motion-slow: 0.4s;   /* 이동, 그림자 */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* ───────────── Focus ───────────── */
  --focus-ring-width: 2px;
  --focus-ring-offset: 2px;
}

/* ───────────── Dark theme: Semantic만 바꿉니다 ───────────── */
:root[data-theme="dark"] {
  --surface-page: var(--palette-slate-950);
  --surface-panel: var(--palette-slate-900);
  --surface-rail: var(--palette-slate-925);
  --surface-control: var(--palette-slate-850);
  --surface-accent: var(--palette-purple-500);
  --surface-action-primary: var(--palette-purple-600);
  --surface-accent-subtle: rgb(127 101 233 / 0.18);

  --border-default: var(--palette-slate-700);
  --border-accent: rgb(164 142 240 / 0.5);
  --border-focus: var(--palette-purple-400);

  --text-primary: var(--palette-slate-100);
  --text-secondary: var(--palette-slate-200);
  --text-tertiary: var(--palette-slate-400);
  --text-accent: var(--palette-purple-400);
  --text-eyebrow: var(--palette-purple-400);
  --text-inverse: var(--palette-white);

  --shadow-sm: 0 2px 8px 0 rgb(0 0 0 / 0.2);
  --shadow-card: 0 3px 9px 0 rgb(0 0 0 / 0.2);
  --shadow-md: 0 5px 18px 0 rgb(0 0 0 / 0.2);
  --shadow-lg: 0 10px 55px 0 rgb(0 0 0 / 0.3);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0s;
    --motion-base: 0s;
    --motion-slow: 0s;
  }
}
