/* ============================================
   Jiwon.dev - Dark Minimal Design System
   Vercel-inspired aesthetic
   ============================================ */

/* CSS Variables - Dark First */
:root {
  /* Core Colors */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-elevated: #1c2128;
  
  /* Text Colors */
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-tertiary: #6e7681;
  --text-muted: #484f58;
  
  /* Accent Colors - Blue/Purple/Emerald mix */
  --accent-blue: #58a6ff;
  --accent-purple: #a371f7;
  --accent-emerald: #3fb950;
  --accent-cyan: #39c5cf;
  
  /* Semantic Colors */
  --accent: var(--accent-blue);
  --accent-hover: #79b8ff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  
  /* Borders */
  --border-primary: #30363d;
  --border-secondary: #21262d;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Monaco, monospace;
  --font-serif: 'IBM Plex Serif', Georgia, serif;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  
  /* Layout */
  --max-width: 1200px;
  --header-height: 64px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* Shadows */
  --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);
}

/* Light Mode Override */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eaeef2;
  --bg-elevated: #ffffff;
  
  --text-primary: #1f2328;
  --text-secondary: #656d76;
  --text-tertiary: #8c959f;
  --text-muted: #b7bdc4;
  
  --accent: #0969da;
  --accent-hover: #0550ae;
  
  --border-primary: #d0d7de;
  --border-secondary: #eaeef2;
  
  --shadow-sm: 0 1px 2px 0 rgba(31, 35, 40, 0.04);
  --shadow-md: 0 3px 6px 0 rgba(31, 35, 40, 0.08);
  --shadow-lg: 0 8px 16px 0 rgba(31, 35, 40, 0.12);
}

/* ============================================
   Base Styles
   ============================================ */

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* Selection */
::selection {
  background-color: var(--accent);
  color: var(--bg-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-tertiary);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  color: var(--accent-cyan);
}

pre {
  font-family: var(--font-mono);
  background: var(--bg-secondary);
  padding: var(--space-md);
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid var(--border-primary);
}

pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

/* ============================================
   Layout
   ============================================ */

.main-layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

@media (max-width: 768px) {
  .main-layout {
    padding: var(--space-lg) var(--space-md);
  }
}

/* ============================================
   Header
   ============================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-primary);
}

[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.8);
}

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

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.logo:hover {
  text-decoration: none;
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  margin-left: auto;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--space-sm) 0;
  position: relative;
}

.nav-links a:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.nav-links a.active {
  color: var(--text-primary);
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-primary);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

@media (max-width: 640px) {
  .nav-links {
    gap: var(--space-lg);
  }
  
  .nav-links a {
    font-size: 0.8125rem;
  }
}

/* ============================================
   Hero Section
   ============================================ */

.hero-section {
  padding: var(--space-3xl) 0;
  text-align: center;
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: var(--space-sm);
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: var(--space-lg);
  letter-spacing: 0.05em;
}

.hero-description {
  font-size: 1.25rem;
  color: var(--text-tertiary);
  max-width: 500px;
  margin: 0 auto var(--space-xl);
  line-height: 1.6;
}

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

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

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

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-primary);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-tertiary);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: rgba(248, 81, 73, 0.1);
}

/* ============================================
   Philosophy Section
   ============================================ */

.philosophy-section {
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--border-primary);
  border-bottom: 1px solid var(--border-primary);
  margin-bottom: var(--space-2xl);
}

.philosophy-content {
  max-width: 700px;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: var(--space-md);
}

.philosophy-text {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ============================================
   Filter Section
   ============================================ */

.filter-section {
  margin-bottom: var(--space-xl);
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.filter-tabs {
  display: flex;
  gap: var(--space-xs);
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-primary);
}

.filter-tab {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.filter-tab.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.search-box {
  position: relative;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.625rem 1rem 0.625rem 2.5rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

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

/* ============================================
   Posts Grid
   ============================================ */

.posts-section {
  margin-bottom: var(--space-3xl);
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-lg);
}

.post-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  padding: var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  opacity: 0;
  transition: opacity var(--transition-base);
}

.post-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-secondary);
  box-shadow: var(--shadow-md);
}

.post-card:hover::before {
  opacity: 1;
}

.post-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-category {
  color: var(--accent);
  font-weight: 600;
}

.post-series {
  color: var(--accent-blue);
  font-weight: 600;
}

.post-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  line-height: 1.4;
}

.post-excerpt {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-md);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.post-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.post-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-top: var(--space-md);
}

.tag {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 4px;
  border: 1px solid var(--border-primary);
  transition: all var(--transition-fast);
}

.tag:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

.empty-state {
  text-align: center;
  padding: var(--space-3xl);
  color: var(--text-tertiary);
}

/* ============================================
   Now Section
   ============================================ */

.now-section {
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--border-primary);
}

.now-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.now-link {
  font-size: 0.875rem;
  color: var(--accent);
}

.now-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.now-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  padding: var(--space-lg);
  position: relative;
}

.now-indicator {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  width: 8px;
  height: 8px;
  background: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
}

.now-indicator.learning {
  background: var(--accent-purple);
  box-shadow: 0 0 8px var(--accent-purple);
}

.now-card h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-md);
}

.now-card ul {
  list-style: none;
}

.now-card li {
  font-size: 0.9375rem;
  color: var(--text-primary);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-primary);
  position: relative;
  padding-left: var(--space-md);
}

.now-card li:last-child {
  border-bottom: none;
}

.now-card li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.75rem;
}

/* ============================================
   Reader Modal
   ============================================ */

.reader-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.reader-modal.active {
  display: flex;
}

.reader-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.reader-content {
  position: relative;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.3s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.reader-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-primary);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all var(--transition-fast);
}

.reader-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

.reader-scroll {
  overflow-y: auto;
  padding: var(--space-2xl);
}

.reader-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border-primary);
}

.reader-meta-top {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-md);
}

.reader-category {
  color: var(--accent);
  font-weight: 600;
}

.reader-title {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
}

.reader-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.reader-body {
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.reader-body h1,
.reader-body h2,
.reader-body h3,
.reader-body h4 {
  color: var(--text-primary);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.reader-body p {
  margin-bottom: var(--space-lg);
}

.reader-body ul,
.reader-body ol {
  margin-bottom: var(--space-lg);
  padding-left: var(--space-xl);
}

.reader-body li {
  margin-bottom: var(--space-sm);
}

.reader-body pre {
  margin: var(--space-lg) 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.reader-body code {
  font-size: 0.875em;
}

.reader-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: var(--space-lg) 0;
}

.reader-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border-primary);
}

/* ============================================
   Footer
   ============================================ */

.site-footer {
  border-top: 1px solid var(--border-primary);
  padding: var(--space-2xl) 0;
  margin-top: var(--space-2xl);
}

.footer-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  text-align: center;
}

.footer-brand {
  margin-bottom: var(--space-lg);
}

.footer-name {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.footer-tagline {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.footer-links a {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-copy {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 768px) {
  .hero-section {
    padding: var(--space-2xl) var(--space-lg);
  }
  
  .hero-title {
    font-size: 2.5rem;
  }
  
  .hero-description {
    font-size: 1rem;
  }
  
  .filter-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }
  
  .filter-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .posts-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .post-card {
    padding: var(--space-lg);
  }
  
  .header-container {
    padding: 0 var(--space-md);
  }
  
  .nav-links {
    gap: var(--space-md);
    font-size: 0.875rem;
  }
  
  .main-layout {
    padding: 0 var(--space-md);
  }
  
  .footer-content {
    padding: 0 var(--space-md);
  }
  
  .footer-links {
    flex-wrap: wrap;
    gap: var(--space-md);
    font-size: 0.875rem;
  }
}

/* ============================================
   Utility Classes
   ============================================ */

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

/* Status indicators */
.status-line {
  font-size: 0.875rem;
  padding: var(--space-sm) var(--space-md);
  border-radius: 6px;
  margin-bottom: var(--space-md);
}

.status-line.success {
  color: var(--success);
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.2);
}

.status-line.error {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.2);
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl);
  color: var(--text-tertiary);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-primary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: var(--space-sm);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
