/**
 * SCM Labs - Apple-Style Design System
 * 미니멀리즘, 여백의 미, 타이포그래피 중심
 */

/* ============================================
   1. CSS Custom Properties (Design Tokens)
   ============================================ */

:root {
  /* Color System - Light Mode (Default) */
  --gray-50: #fafafa;
  --gray-100: #f5f5f7;
  --gray-200: #e8e8ed;
  --gray-300: #d2d2d7;
  --gray-400: #86868b;
  --gray-500: #6e6e73;
  --gray-600: #1d1d1f;

  /* Semantic Colors - Light Mode */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #ffffff;
  --bg-elevated: #ffffff;

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;

  --border-color: #d2d2d7;
  --border-color-light: #e8e8ed;

  /* Accent Colors */
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-active: #006edb;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --purple: #af52de;
  --cyan: #5ac8fa;
  --yellow: #ffcc00;

  /* Typography Scale */
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1.0625rem;  /* 17px - Apple's base */
  --text-lg: 1.1875rem;    /* 19px */
  --text-xl: 1.3125rem;    /* 21px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 2rem;        /* 32px */
  --text-4xl: 2.5rem;      /* 40px */
  --text-5xl: 3rem;        /* 48px */
  --text-6xl: 3.5rem;      /* 56px */
  --text-7xl: 4.5rem;      /* 72px */
  --text-8xl: 6rem;        /* 96px */

  /* Font Weights */
  --font-light: 300;
  --font-regular: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Line Heights */
  --leading-tight: 1.1;
  --leading-snug: 1.2;
  --leading-normal: 1.4;
  --leading-relaxed: 1.6;
  --leading-loose: 1.8;

  /* Letter Spacing */
  --tracking-tighter: -0.03em;
  --tracking-tight: -0.015em;
  --tracking-normal: 0;
  --tracking-wide: 0.01em;

  /* Spacing Scale (8px grid) */
  --space-0: 0;
  --space-1: 0.25rem;      /* 4px */
  --space-2: 0.5rem;       /* 8px */
  --space-3: 0.75rem;      /* 12px */
  --space-4: 1rem;         /* 16px */
  --space-5: 1.25rem;      /* 20px */
  --space-6: 1.5rem;       /* 24px */
  --space-8: 2rem;         /* 32px */
  --space-10: 2.5rem;      /* 40px */
  --space-12: 3rem;        /* 48px */
  --space-16: 4rem;        /* 64px */
  --space-20: 5rem;        /* 80px */
  --space-24: 6rem;        /* 96px */
  --space-32: 8rem;        /* 128px */

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 980px;    /* Pill shape */

  /* Shadows - Light Mode */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index Scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;

  /* Layout */
  --container-max: 980px;
  --container-wide: 1200px;
  --header-height: 48px;
  --header-height-scrolled: 44px;
}

/* ============================================
   2. Dark Mode Colors (Default - Always Dark)
   ============================================ */

/* Dark theme applied by default */
:root {
  /* Override Light Mode with Dark Mode */
  --bg-primary: #000000;
  --bg-secondary: #121212;
  --bg-tertiary: #1a1a1a;
  --bg-elevated: #1c1c1e;

  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #6e6e73;

  --border-color: #2a2a2a;
  --border-color-light: #1f1f1f;

  /* Shadows - Dark Mode */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
}

/* Light theme when data-theme="light" */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #ffffff;
  --bg-elevated: #ffffff;

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;

  --border-color: #d2d2d7;
  --border-color-light: #e8e8ed;

  /* Shadows - Light Mode */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
}

/* Keep media query for system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Semantic Colors - Dark Mode */
    --bg-primary: #000000;
    --bg-secondary: #121212;
    --bg-tertiary: #1a1a1a;
    --bg-elevated: #1c1c1e;

    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;

    --border-color: #2a2a2a;
    --border-color-light: #1f1f1f;

    /* Shadows - Dark Mode */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
  }
}

/* Theme Toggle Button Styles */
.theme-toggle {
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: color var(--transition-fast), background-color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}
.theme-toggle svg {
  width: 20px;
  height: 20px;
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}
/* Show sun icon in dark mode (to switch to light) */
:root:not([data-theme="light"]) .theme-toggle .icon-sun {
  display: block;
}
/* Show moon icon in light mode (to switch to dark) */
[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

/* ============================================
   3. Base Styles
   ============================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: var(--text-base);
  font-weight: var(--font-regular);
  line-height: var(--leading-relaxed);
  letter-spacing: var(--tracking-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ============================================
   4. Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

.headline-1 {
  font-size: var(--text-8xl);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-tighter);
  line-height: 1.05;
}

.headline-2 {
  font-size: var(--text-6xl);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-tighter);
  line-height: var(--leading-tight);
}

.headline-3 {
  font-size: var(--text-4xl);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-tight);
}

.title-1 {
  font-size: var(--text-3xl);
  font-weight: var(--font-semibold);
}

.title-2 {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
}

.title-3 {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

.body-large {
  font-size: var(--text-xl);
  line-height: var(--leading-relaxed);
}

.body {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.body-small {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.caption {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

/* Text Colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-blue { color: var(--blue); }

/* ============================================
   5. Layout Utilities
   ============================================ */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.container-wide {
  max-width: var(--container-wide);
}

.section {
  padding-top: var(--space-24);
  padding-bottom: var(--space-24);
}

.section-sm {
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
}

/* Flexbox */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Grid */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

/* Text Alignment */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* ============================================
   6. Components - Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  min-height: 50px;
}

.btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Primary Button */
.btn-primary {
  background-color: var(--blue);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--blue-hover);
}

.btn-primary:active {
  background-color: var(--blue-active);
  transform: scale(0.98);
}

/* Secondary Button */
.btn-secondary {
  background-color: transparent;
  color: var(--blue);
  border: 1px solid var(--blue);
}

.btn-secondary:hover {
  background-color: var(--blue);
  color: #ffffff;
}

/* Ghost Button */
.btn-ghost {
  background-color: transparent;
  color: var(--blue);
}

.btn-ghost:hover {
  background-color: rgba(0, 113, 227, 0.1);
}

/* Button Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  min-height: 36px;
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
  min-height: 56px;
}

/* ============================================
   7. Components - Cards
   ============================================ */

.card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-elevated {
  background-color: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}

.card-bordered {
  border: 1px solid var(--border-color-light);
}

/* ============================================
   8. Components - Header/Navigation
   ============================================ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  z-index: var(--z-fixed);
  border-bottom: 1px solid var(--border-color-light);
}

/* Light mode header */
[data-theme="light"] .header {
  background-color: rgba(255, 255, 255, 0.8);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  list-style: none;
}

.nav-link {
  font-size: var(--text-sm);
  font-weight: var(--font-regular);
  color: var(--text-primary);
  text-decoration: none;
  opacity: 0.8;
  transition: opacity var(--transition-fast);
}

.nav-link:hover {
  opacity: 1;
}

/* Light mode specific styles */
[data-theme="light"] .nav-link {
  color: #1d1d1f;
  opacity: 1;
}

[data-theme="light"] .nav-link:hover {
  color: var(--blue);
}

/* Mobile Navigation */
@media (max-width: 768px) {
  .nav-menu {
    display: none;
  }

  .nav-menu.active {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: auto;
    background-color: var(--bg-primary);
    padding: var(--space-2) 0;
    gap: 0;
    z-index: var(--z-fixed);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color);
  }

  .nav-menu.active .nav-link {
    display: block;
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    border-bottom: 1px solid var(--border-color-light);
    opacity: 1;
    color: var(--text-primary);
  }

  .nav-menu.active .nav-link:last-child {
    border-bottom: none;
  }

  .nav-menu.active .nav-link:active,
  .nav-menu.active .nav-link:hover {
    background-color: var(--bg-secondary);
    color: var(--blue);
  }

  .nav-link {
    font-size: var(--text-base);
  }
}

/* ============================================
   9. Components - Forms
   ============================================ */

.form-group {
  margin-bottom: var(--space-6);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  padding: var(--space-4);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
  outline: 2px solid transparent;
}

.form-input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

textarea.form-input {
  min-height: 120px;
  resize: vertical;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-10);
}

/* ============================================
   10. Components - Hero Section
   ============================================ */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: calc(100vh - var(--header-height));
  padding: var(--space-16) var(--space-6);
  padding-top: calc(var(--header-height) + var(--space-16));
}

.hero-title {
  font-size: clamp(var(--text-4xl), 8vw, var(--text-7xl));
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-tighter);
  line-height: 1.05;
  margin-bottom: var(--space-6);
  max-width: 900px;
}

.hero-subtitle {
  font-size: clamp(var(--text-lg), 3vw, var(--text-2xl));
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: var(--space-10);
}

.hero-cta {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
}

/* ============================================
   11. Responsive Breakpoints
   ============================================ */

@media (max-width: 1024px) {
  :root {
    --text-7xl: 3.5rem;
    --text-8xl: 4.5rem;
  }

  .section {
    padding-top: var(--space-16);
    padding-bottom: var(--space-16);
  }
}

@media (max-width: 768px) {
  :root {
    --text-6xl: 2.5rem;
    --text-7xl: 3rem;
    --text-8xl: 3.5rem;
    --header-height: 44px;
  }

  .container {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .section {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
  }

  .grid-cols-2,
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: calc(var(--header-height) + var(--space-12));
    padding-bottom: var(--space-12);
  }

  .btn {
    width: 100%;
    max-width: 280px;
  }
}

@media (max-width: 480px) {
  :root {
    --text-5xl: 2rem;
    --text-6xl: 2.25rem;
  }

  .hero-cta {
    flex-direction: column;
    width: 100%;
    max-width: 280px;
  }
}

/* ============================================
   12. Utilities
   ============================================ */

.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;
}

.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }

.w-full { width: 100%; }
.max-w-sm { max-width: 24rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }

.mx-auto { margin-left: auto; margin-right: auto; }
.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-8 { margin-bottom: var(--space-8); }

.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-100 { opacity: 1; }

/* Link Styles */
a {
  color: var(--blue);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

a:hover {
  text-decoration: underline;
}

/* Image Styles */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Selection */
::selection {
  background-color: rgba(0, 113, 227, 0.3);
  color: var(--text-primary);
}

/* Focus Visible */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ============================================
   13. Animation Utilities
   ============================================ */

.fade-in {
  animation: fadeIn var(--transition-slow) ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.transition-opacity {
  transition: opacity var(--transition-base);
}

.transition-transform {
  transition: transform var(--transition-base);
}

.transition-all {
  transition: all var(--transition-base);
}
