/* =============================================================================
   ysun.kr — Design System
   양 사이트(www / blog)가 공유하는 단일 소스입니다.
   편집은 이 파일(/shared/design-system.css)에서만 하고,
   반영은 `scripts/sync-shared.sh` 로 각 사이트에 복사합니다.

   원칙: Mobile First · 기본 폰트 크기 1rem · 사진(뉴질랜드 공원의 Pūkeko) 팔레트
   타이포는 Noto Serif KR(세리프) 기반, 배경은 차분한 블루그레이 톤.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   1. Design Tokens
   --------------------------------------------------------------------------- */
:root {
  /* ---- Raw palette (사진에서 추출) ---- */
  --pukeko-indigo: #33356e;   /* 새의 몸통 남보라 */
  --pukeko-blue:   #3c4e8c;   /* 어깨 깃 광택 */
  --pukeko-red:    #d6392e;   /* 부리 · 이마 방패 */
  --pukeko-coral:  #e4735a;   /* 다리 산호빛 */

  --fern-900: #22381f;
  --fern-700: #2e4b2c;
  --fern-600: #3e6b3a;
  --fern-500: #4f8449;
  --fern-300: #8fb884;

  --water-olive: #b4b287;     /* 흐린 올리브빛 물 */
  --sand:        #cfc6a4;

  --earth-900: #241d16;       /* 젖은 멀칭 흙 */
  --earth-800: #2c231c;
  --earth-700: #463527;
  --bark:      #5b4636;

  --autumn-rust:  #c4652e;    /* 가을 낙엽 */
  --autumn-amber: #d79a3f;
  --blush:        #d68a86;    /* 붉은 억새 */
  --straw:        #c7a868;    /* 마른 풀 */

  --cream: #f3f6fa;   /* 흐린 블루그레이 배경 */
  --paper: #fbfcfe;   /* 거의 흰 블루빛 표면 */
  --ink:   #1d2027;   /* 차분한 near-black */

  /* ---- Semantic colors (Light) ---- */
  --color-bg:          var(--cream);
  --color-surface:     var(--paper);
  --color-surface-2:   #e7ecf3;
  --color-fg:          var(--ink);
  --color-muted:       #5c6572;
  --color-border:      #dbe2ec;

  --color-brand:       var(--pukeko-indigo);
  --color-accent:      var(--pukeko-red);
  --color-accent-soft: var(--pukeko-coral);
  --color-link:        var(--fern-700);
  --color-link-hover:  var(--fern-600);
  --color-focus:       var(--pukeko-blue);
  --color-on-accent:   #fff8f2;

  /* ---- Typography ---- */
  /* 기본 폰트 크기 = 1rem (html 100% → 16px). 모든 크기는 rem 로 스케일. */
  --font-sans: "Noto Serif KR", "Apple SD Gothic Neo", "Nanum Myeongjo",
    Georgia, "Times New Roman", serif;
  --font-display: var(--font-sans); /* 제목용. 필요 시 다른 세리프로 교체 */
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;      /* 본문 기준 */
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;

  --leading-tight: 1.25;
  --leading-snug:  1.4;
  --leading-normal: 1.7;

  --weight-light:  300;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-bold:   700;

  /* ---- Spacing (4px 기준) ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  /* ---- Radius / Shadow / Layout ---- */
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(36, 29, 22, 0.08);
  --shadow:    0 4px 16px rgba(36, 29, 22, 0.10);

  --container: 46rem;      /* 읽기 편한 본문 폭 (~736px) */
  --container-wide: 60rem;

  /* ---- Breakpoints (참고용, min-width) ---- */
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
}

/* ---- Dark mode ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg:        #14171c;
    --color-surface:   #1b1f26;
    --color-surface-2: #242932;
    --color-fg:        #e6e9ef;
    --color-muted:     #9aa2af;
    --color-border:    #2c323c;

    --color-brand:       #9a9ce0;
    --color-accent:      #e85345;
    --color-accent-soft: #e88870;
    --color-link:        #86b87c;
    --color-link-hover:  #a6ce9c;
    --color-focus:       #7e90d6;
    --color-on-accent:   #1a0f0d;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:    0 4px 18px rgba(0, 0, 0, 0.5);
  }
}

/* ---------------------------------------------------------------------------
   2. Reset / Base (Mobile First)
   --------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html {
  font-size: 100%;               /* 1rem = 16px */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);   /* 1rem */
  font-weight: var(--weight-light);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, picture, svg, video {
  display: block;
  max-width: 100%;
  height: auto;
}

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

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-on-accent);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
  color: var(--color-fg);
  text-wrap: balance;
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p, ul, ol { line-height: var(--leading-normal); }

code, pre { font-family: var(--font-mono); font-size: 0.9em; }

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* 넓은 화면에서 디스플레이 타이포 확대 */
@media (min-width: 768px) {
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl); }
}

/* ---------------------------------------------------------------------------
   3. Layout
   --------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-4);
}
@media (min-width: 768px) {
  .container { padding-inline: var(--space-5); }
}

.section { padding-block: var(--space-6); }
.stack > * + * { margin-top: var(--space-4); }

/* ---------------------------------------------------------------------------
   4. Components
   --------------------------------------------------------------------------- */

/* Header / Nav */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  color: var(--color-fg);
}
.brand:hover { text-decoration: none; }
.brand__mark { width: 1.5rem; height: 1.5rem; }
.brand__sub { color: var(--color-muted); font-weight: var(--weight-medium); }

.nav {
  display: flex;
  gap: var(--space-4);
  font-size: var(--text-sm);
}
.nav a { color: var(--color-muted); }
.nav a:hover { color: var(--color-fg); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--color-fg); font-weight: var(--weight-medium); }

/* Hero */
.hero { padding-block: var(--space-7) var(--space-6); }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}
.lead {
  font-size: var(--text-lg);
  color: var(--color-muted);
  margin-top: var(--space-3);
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-fg);
  font: inherit;
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.button:hover { background: var(--color-surface-2); text-decoration: none; }
.button:active { transform: translateY(1px); }
.button--accent {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}
.button--accent:hover { background: var(--color-accent); filter: brightness(1.06); }

/* Card */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

/* Tag / chip */
.tag {
  display: inline-block;
  padding: 0.15rem var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

/* Blog post list */
.post-list { list-style: none; padding: 0; }
.post-item + .post-item { border-top: 1px solid var(--color-border); }
.post-item a {
  display: block;
  padding-block: var(--space-5);
  color: inherit;
}
.post-item a:hover { text-decoration: none; }
.post-item a:hover .post-title { color: var(--color-link); }
.post-title { font-size: var(--text-lg); margin-bottom: var(--space-1); }
.post-meta {
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}
.post-excerpt { color: var(--color-muted); }

/* Prose (article body) */
.prose { max-width: 38rem; }
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { margin-top: var(--space-6); }
.prose h3 { margin-top: var(--space-5); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose code {
  background: var(--color-surface-2);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}
.prose blockquote {
  border-left: 3px solid var(--color-accent-soft);
  padding-left: var(--space-4);
  color: var(--color-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-6);
  margin-top: var(--space-7);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* Utilities */
.muted { color: var(--color-muted); }
.text-center { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
