/* ==========================================================================
   Design tokens — Supabase 스타일 (dark 기본, light 대응)
   ========================================================================== */
:root {
  --brand: #3ecf8e;
  --brand-strong: #24b47e;
  --brand-text: var(--brand);
  --brand-soft: rgba(62, 207, 142, 0.12);
  --brand-border: rgba(62, 207, 142, 0.4);

  --bg: #121212;
  --bg-alt: #171717;
  --surface: #1c1c1c;
  --surface-hover: #232323;
  --border: #2e2e2e;
  --border-strong: #3e3e3e;
  --text: #ededed;
  --text-muted: #a0a0a0;
  --text-subtle: #707070;
  --code-bg: #171717;
  --grid-line: rgba(255, 255, 255, 0.04);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);

  --font-sans: 'Inter', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --container: 1080px;
  --container-narrow: 740px;
  --gutter: 24px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: dark;
}

/* 라이트 테마 토큰: 시스템 설정(명시 선택이 없을 때) 또는 수동 선택 */
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --brand-strong: #1f9d68;
  --brand-text: #1a8a5b;
    --bg: #fcfcfc;
    --bg-alt: #f8f8f8;
    --surface: #ffffff;
    --surface-hover: #f5f5f5;
    --border: #e6e6e6;
    --border-strong: #d4d4d4;
    --text: #1c1c1c;
    --text-muted: #5f5f5f;
    --text-subtle: #8f8f8f;
    --code-bg: #f6f6f6;
    --grid-line: rgba(0, 0, 0, 0.045);
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
    color-scheme: light;
  }
}
:root[data-theme='light'] {
  --brand-strong: #1f9d68;
  --brand-text: #1a8a5b;
  --bg: #fcfcfc;
  --bg-alt: #f8f8f8;
  --surface: #ffffff;
  --surface-hover: #f5f5f5;
  --border: #e6e6e6;
  --border-strong: #d4d4d4;
  --text: #1c1c1c;
  --text-muted: #5f5f5f;
  --text-subtle: #8f8f8f;
  --code-bg: #f6f6f6;
  --grid-line: rgba(0, 0, 0, 0.045);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
  color-scheme: light;
}

/* ==========================================================================
   Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
}

::selection {
  background: var(--brand-soft);
  color: var(--brand-text);
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.center {
  text-align: center;
}

.text-brand {
  color: var(--brand-text);
}

.empty {
  color: var(--text-muted);
}

/* ==========================================================================
   Header / Footer
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--text);
  background: var(--surface-hover);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme='light'] .theme-toggle .icon-sun {
  display: block;
}
:root[data-theme='light'] .theme-toggle .icon-moon {
  display: none;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle .icon-sun {
    display: block;
  }
  :root:not([data-theme]) .theme-toggle .icon-moon {
    display: none;
  }
}

.site-footer {
  margin-top: 96px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text-subtle);
  font-size: 13px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 28px;
  padding-bottom: 28px;
}

.footer-inner p {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 18px;
}

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

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  padding: 96px 0 80px;
}

.hero::after {
  content: '';
  position: absolute;
  inset: auto 0 -40% 0;
  height: 80%;
  background: radial-gradient(ellipse at center, var(--brand-soft), transparent 65%);
  pointer-events: none;
}

.hero-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at top, #000 30%, transparent 75%);
}

.hero-inner {
  position: relative;
  z-index: 1;
  text-align: center;
}

.hero-title {
  margin: 20px auto 16px;
  max-width: 820px;
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.hero-desc {
  margin: 0 auto;
  max-width: 560px;
  color: var(--text-muted);
  font-size: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  animation: pulse 2s var(--ease) infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

/* ==========================================================================
   Sections / Cards
   ========================================================================== */
.section {
  padding-top: 64px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-header p {
  margin: 0;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 13px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

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

.card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.card-title {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.015em;
}

.card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 8px;
}

.card-footer .tag {
  position: relative;
  z-index: 2;
}

.card-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: var(--text-subtle);
  font-size: 13px;
  transition: color 0.2s, gap 0.2s;
}

.card:hover .card-more {
  color: var(--brand-text);
  gap: 10px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ==========================================================================
   Tags / Buttons / Pagination
   ========================================================================== */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-cloud {
  margin-bottom: 24px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.tag:hover,
.tag.is-active {
  color: var(--brand-text);
  border-color: var(--brand-border);
  background: var(--brand-soft);
}

.tag-count {
  color: var(--text-subtle);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-primary {
  border-color: var(--brand-strong);
  background: var(--brand-strong);
  color: #fff;
}

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

.btn-ghost {
  background: var(--surface);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 40px;
}

.pagination-info {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ==========================================================================
   Article
   ========================================================================== */
.article {
  max-width: var(--container-narrow);
  padding-top: 56px;
}

.article-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 32px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  color: var(--text-muted);
  font-size: 14px;
}

.back-link:hover {
  color: var(--brand-text);
}

.flip {
  display: inline-flex;
  transform: scaleX(-1);
}

.article-title {
  margin: 0;
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.article-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 18px;
}

.neighbors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.neighbor {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s;
}

.neighbor:hover {
  border-color: var(--brand-border);
}

.neighbor-right {
  grid-column: 2;
  text-align: right;
}

.neighbor-label {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 12px;
}

.neighbor-title {
  font-weight: 500;
}

/* ==========================================================================
   Prose (마크다운 본문)
   ========================================================================== */
.prose {
  color: var(--text);
  font-size: 16.5px;
  line-height: 1.8;
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose h2,
.prose h3,
.prose h4 {
  position: relative;
  margin-top: 2.2em;
  margin-bottom: 0.4em;
  line-height: 1.3;
  letter-spacing: -0.02em;
  scroll-margin-top: 80px;
}

.prose h2 {
  font-size: 26px;
}
.prose h3 {
  font-size: 20px;
}

.prose .anchor {
  position: absolute;
  left: -1em;
  color: var(--brand-text);
  opacity: 0;
  transition: opacity 0.2s;
}

.prose h2:hover .anchor,
.prose h3:hover .anchor,
.prose h4:hover .anchor {
  opacity: 1;
}

.prose p,
.prose ul,
.prose ol {
  margin-bottom: 0;
}

.prose a {
  color: var(--brand-text);
  text-decoration: underline;
  text-decoration-color: var(--brand-border);
  text-underline-offset: 3px;
}

.prose a:hover {
  text-decoration-color: var(--brand-text);
}

.prose strong {
  font-weight: 600;
}

.prose li + li {
  margin-top: 0.35em;
}

.prose li::marker {
  color: var(--text-subtle);
}

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 12px 20px;
  border-left: 3px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--brand-soft);
  color: var(--text-muted);
}

.prose blockquote p {
  margin: 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

.prose :not(pre) > code {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.prose th {
  background: var(--bg-alt);
  font-weight: 600;
}

.prose img {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.code-block {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow: hidden;
}

.code-block pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
}

.code-lang {
  position: absolute;
  top: 8px;
  left: 14px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.code-lang + .copy-btn + pre {
  padding-top: 34px;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}

.code-block:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--brand-text);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }

  .header-inner {
    gap: 12px;
  }

  .brand span {
    display: none;
  }

  .nav-link {
    padding: 6px 8px;
  }

  .hero {
    padding: 64px 0 56px;
  }

  .post-grid {
    grid-template-columns: 1fr;
  }

  .neighbors {
    grid-template-columns: 1fr;
  }

  .neighbor-right {
    grid-column: auto;
  }

  .copy-btn {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
