/* ============================================================================
   Tudu Design System — tokens + base components (single source of truth)
   ----------------------------------------------------------------------------
   설명·사용 규칙: docs/07_DesignSystem.md
   Flutter 앱은 --brand-600 (#4F46E5)을 AppTheme.brandColor seed로 쓴다.
   ============================================================================ */

@font-face {
  font-family: "Pretendard Variable";
  src: url("./fonts/PretendardVariable.woff2") format("woff2");
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
}

/* ---------- Primitive tokens ---------- */
:root {
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-800: #3730a3;
  --violet-500: #8b5cf6;

  --prio-high: #ef4444;
  --prio-med: #f59e0b;
  --prio-low: #3b82f6;
  --success: #10b981;

  --gradient-brand: linear-gradient(135deg, var(--brand-500) 0%, var(--violet-500) 100%);

  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --text-display: clamp(40px, 6.4vw, 76px);
  --text-h2: clamp(30px, 4vw, 48px);
  --text-h3: 20px;
  --text-lg: clamp(18px, 1.6vw, 20px);
  --text-base: 16px;
  --text-sm: 14px;
  --text-xs: 12.5px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --container: 1180px;
  --gutter: clamp(16px, 4vw, 32px);
  --section-gap: clamp(80px, 12vw, 144px);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 160ms;
  --dur: 220ms;
  --dur-enter: 600ms;
}

/* ---------- Semantic tokens: light ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;
  --primary: var(--brand-600);
  --primary-hover: var(--brand-700);
  --link: var(--brand-600);
  --chip-bg: var(--brand-50);
  --chip-text: var(--brand-700);
  --grid-line: rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 60px -20px rgba(30, 27, 75, 0.25), 0 8px 20px -8px rgba(15, 23, 42, 0.12);
  --glow: 0 0 0 1px rgba(79, 70, 229, 0.12), 0 8px 24px -6px rgba(79, 70, 229, 0.45);
  --hero-aura: radial-gradient(60% 50% at 50% 0%, rgba(99, 102, 241, 0.16), transparent 70%);
}

/* ---------- Semantic tokens: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b12;
    --bg-subtle: #10101a;
    --surface: rgba(255, 255, 255, 0.03);
    --surface-raised: #15151f;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #f1f5f9;
    --text-muted: #a1a1b5;
    --text-subtle: #6b6b80;
    --primary: var(--brand-500);
    --primary-hover: var(--brand-400);
    --link: var(--brand-300);
    --chip-bg: rgba(129, 140, 248, 0.14);
    --chip-text: var(--brand-200);
    --grid-line: rgba(255, 255, 255, 0.045);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
    --glow: 0 0 0 1px rgba(129, 140, 248, 0.3), 0 10px 40px -8px rgba(99, 102, 241, 0.65);
    --hero-aura: radial-gradient(55% 50% at 50% 0%, rgba(99, 102, 241, 0.28), transparent 70%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b12;
  --bg-subtle: #10101a;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-raised: #15151f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --text-muted: #a1a1b5;
  --text-subtle: #6b6b80;
  --primary: var(--brand-500);
  --primary-hover: var(--brand-400);
  --link: var(--brand-300);
  --chip-bg: rgba(129, 140, 248, 0.14);
  --chip-text: var(--brand-200);
  --grid-line: rgba(255, 255, 255, 0.045);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --glow: 0 0 0 1px rgba(129, 140, 248, 0.3), 0 10px 40px -8px rgba(99, 102, 241, 0.65);
  --hero-aura: radial-gradient(55% 50% at 50% 0%, rgba(99, 102, 241, 0.28), transparent 70%);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.65;
  font-weight: 450;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img {
  display: block;
  max-width: 100%;
  height: auto;
}
a {
  color: inherit;
  text-decoration: none;
}
h1, h2, h3, p {
  margin: 0;
}
:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: 3px;
  border-radius: 6px;
}
::selection {
  background: rgba(99, 102, 241, 0.3);
}

.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -48px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
}
.skip-link:focus {
  top: var(--space-4);
}

/* ---------- Type helpers ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--link);
}
.gradient-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.muted {
  color: var(--text-muted);
}
.link {
  color: var(--link);
  text-underline-offset: 3px;
}
.link:hover {
  text-decoration: underline;
}

/* ---------- Button ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.btn:active {
  transform: translateY(1px);
}
.btn-lg {
  height: 48px;
  padding: 0 var(--space-6);
  font-size: 15px;
}
.btn-primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: var(--glow);
}
.btn-primary:hover {
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.45), 0 14px 44px -8px rgba(99, 102, 241, 0.75);
}
.btn-secondary {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--brand-400);
}
.btn-ghost {
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text);
}
.btn .arrow {
  transition: transform var(--dur) var(--ease-out);
}
.btn:hover .arrow {
  transform: translateX(3px);
}

/* ---------- Badge / Chip / Kbd ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}
.badge-brand {
  border-color: rgba(129, 140, 248, 0.35);
  background: var(--chip-bg);
  color: var(--chip-text);
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip svg {
  width: 14px;
  height: 14px;
  flex: none;
}
.chip-prio-high {
  background: var(--prio-high);
  color: #fff;
}
.chip-prio-med {
  background: var(--prio-med);
  color: #1c1300;
}
.chip-prio-low {
  background: var(--prio-low);
  color: #fff;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Card / Frame ---------- */
.card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.frame {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.frame-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
.frame-bar i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}
.frame-bar .frame-url {
  margin-inline: auto;
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
}

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