/* ── Global ── */
html {
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  background-color: #0a0a0a;
  /* Ambient top glow */
  background-image: radial-gradient(ellipse 80% 35% at 50% -5%, rgba(62,207,142,0.07), transparent);
}

/* ── Custom scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #242424; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(62,207,142,0.35); }

/* ── Text selection ── */
::selection { background: rgba(62,207,142,0.18); color: #fff; }

/* ── Skip link (a11y) ── */
.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 100;
  transform: translateY(-6rem);
  padding: 0.75rem 1.25rem;
  background: #3ECF8E;
  color: #0c0c0c;
  font-weight: 600;
  border-radius: 0.5rem;
  text-decoration: none;
  transition: transform 0.2s ease;
}
.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid #3ECF8E;
  outline-offset: 2px;
}

/* ── Post cards (blog listing) ── */
.post-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(255,255,255,0.08);
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.post-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(62,207,142,0.04) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  border-radius: inherit;
}
.post-card:hover {
  border-color: rgba(62,207,142,0.25);
  background-color: #121212;
  box-shadow:
    0 8px 40px -12px rgba(62,207,142,0.14),
    0 0 0 1px rgba(62,207,142,0.06) inset;
}
.post-card:hover::before {
  opacity: 1;
}

/* ── Generic card glow (툴 페이지 등) ── */
.card-glow {
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.card-glow:hover {
  box-shadow: 0 8px 40px -12px rgba(62,207,142,0.14), 0 0 0 1px rgba(62,207,142,0.07) inset;
}

/* ── Line clamp utilities ── */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Prose table fix ── */
.prose table {
  border-collapse: collapse;
  width: 100%;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.prose thead {
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.prose th,
.prose td {
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(255,255,255,0.07);
  white-space: nowrap;
}

/* ── Code block ── */
.highlight {
  border-radius: 0.5rem;
  overflow: hidden;
}

/* ── Nav active link ── */
.nav-link-active {
  color: #fff !important;
  font-weight: 600 !important;
}

/* ── Section label (brand accent bar) ── */
.section-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #3ECF8E;
}
.section-label::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 2px;
  background: #3ECF8E;
  border-radius: 1px;
}

/* ── TOC (Table of Contents) ── */
.toc-chevron {
  transition: transform 0.2s ease;
  color: #71717a;
}
.toc-list {
  list-style: none;
  padding: 0 1.25rem 0.875rem;
  margin: 0;
}
.toc-list li { margin: 0; }
.toc-list a {
  display: block;
  padding: 0.3rem 0;
  font-size: 0.8125rem;
  color: #71717a;
  text-decoration: none;
  transition: color 0.15s ease;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
}
.toc-list a:hover { color: #d4d4d8; }
.toc-list a.active {
  color: #3ECF8E;
  border-left-color: #3ECF8E;
}
.toc-list a.toc-h3 { padding-left: 1.5rem; font-size: 0.75rem; }

/* ── Related posts ── */
.related-posts {
  margin-top: 2rem;
}
.related-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .related-grid { grid-template-columns: repeat(3, 1fr); }
}
.related-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  background: #111111;
  transition: border-color 0.2s, background-color 0.2s;
  text-decoration: none;
  display: block;
}
.related-card:hover {
  border-color: rgba(62,207,142,0.25);
  background: #141414;
}
.related-card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #e4e4e7;
  line-clamp: 2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.related-card-meta {
  margin-top: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: #71717a;
}

/* ── Theme toggle button ── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.375rem;
  color: #a1a1aa;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  background: transparent;
  border: none;
}
.theme-toggle:hover { background: rgba(255,255,255,0.06); color: #fff; }
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { width: 18px; height: 18px; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ── Glossary ── */
.glossary-search {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 1px solid rgba(255,255,255,0.1);
  background: #111111;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: #e4e4e7;
  outline: none;
  transition: border-color 0.2s;
}
.glossary-search:focus { border-color: rgba(62,207,142,0.4); }
.glossary-search::placeholder { color: #52525b; }
.glossary-item {
  padding: 1.25rem;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 0.75rem;
  background: #111111;
  transition: border-color 0.2s;
}
.glossary-item:hover { border-color: rgba(62,207,142,0.2); }

/* ── Fade-in animation ── */
.fade-in-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.fade-in-up.visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .fade-in-up {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ── Scroll progress bar ── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: #3ECF8E;
  z-index: 51;
  width: 0%;
  transition: none;
}

/* ── Featured post card ── */
.featured-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(62,207,142,0.15);
  border-radius: 0.75rem;
  background: linear-gradient(135deg, rgba(62,207,142,0.04), transparent);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.featured-card:hover {
  border-color: rgba(62,207,142,0.35);
  box-shadow: 0 8px 40px -12px rgba(62,207,142,0.18);
}
.featured-thumb {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}
@media (min-width: 640px) {
  .featured-thumb { height: 280px; }
}
.featured-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.25rem;
  background: linear-gradient(to top, rgba(10,10,10,0.85), transparent);
}

/* ── Grid post card ── */
.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .post-grid { grid-template-columns: repeat(2, 1fr); }
}
.post-grid .ad-slot {
  grid-column: 1 / -1;
}
.post-card .card-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  border-radius: 0.75rem 0.75rem 0 0;
}
.card-thumb-placeholder {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem 0.75rem 0 0;
}

/* ── Editorial TOC ── */
.toc-editorial {
  border: none;
  background: transparent;
  border-left: 2px solid rgba(62,207,142,0.3);
  border-radius: 0;
  padding-left: 1.25rem;
  margin-bottom: 2rem;
}
.toc-editorial .toc-header {
  padding: 0 0 0.5rem;
}
.toc-editorial .toc-header:hover {
  background: transparent;
  border-radius: 0;
}
.toc-editorial .toc-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  color: #3ECF8E;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.toc-editorial .toc-list {
  padding: 0;
}
.toc-editorial .toc-list a {
  border-left: none;
  padding-left: 0;
}
.toc-editorial.collapsed .toc-list { display: none; }
.toc-editorial.collapsed .toc-chevron { transform: rotate(-90deg); }

/* ── Share circle buttons ── */
.share-circle-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 0.75rem;
}
.share-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: #a1a1aa;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  border: none;
}
.share-circle:hover {
  background: rgba(62,207,142,0.15);
  color: #3ECF8E;
}
.share-circle svg { width: 14px; height: 14px; }
.share-circle.share-copied {
  background: rgba(62,207,142,0.2);
  color: #3ECF8E;
}

/* ── Author byline ── */
.author-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3ECF8E, #2a9d6e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   Light Mode  [data-theme="light"]
   ══════════════════════════════════════ */
[data-theme="light"] body {
  background-color: #fafafa;
  color: #1a1a1a;
  background-image: radial-gradient(ellipse 80% 35% at 50% -5%, rgba(62,207,142,0.06), transparent);
}
[data-theme="light"] ::-webkit-scrollbar-track { background: #fafafa; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #d4d4d8; }
[data-theme="light"] ::selection { background: rgba(62,207,142,0.2); color: #1a1a1a; }

/* Header & footer */
[data-theme="light"] header.sticky { background: rgba(250,250,250,0.85); border-color: #e5e5e5; }
[data-theme="light"] footer { border-color: #e5e5e5; }
[data-theme="light"] footer .border-t { border-color: #e5e5e5; }
[data-theme="light"] #mobile-menu { border-color: #e5e5e5; }

/* Text colors */
[data-theme="light"] .text-white { color: #1a1a1a; }
[data-theme="light"] .text-zinc-400 { color: #6b7280; }
[data-theme="light"] .text-zinc-500 { color: #6b7280; }
[data-theme="light"] .text-zinc-600 { color: #9ca3af; }
[data-theme="light"] .text-zinc-700 { color: #9ca3af; }
[data-theme="light"] .text-zinc-800 { color: #9ca3af; }

/* Borders & backgrounds */
[data-theme="light"] .border-white\/\[0\.06\],
[data-theme="light"] .border-white\/\[0\.08\] { border-color: #e5e5e5; }
[data-theme="light"] .bg-\[\#0a0a0a\] { background-color: #fafafa; }
[data-theme="light"] .bg-\[\#111111\] { background-color: #ffffff; }
[data-theme="light"] .bg-\[\#141414\] { background-color: #f9f9f9; }
[data-theme="light"] .bg-white\/\[0\.03\] { background-color: rgba(0,0,0,0.02); }
[data-theme="light"] .bg-white\/\[0\.05\] { background-color: rgba(0,0,0,0.04); }
[data-theme="light"] .bg-white\/\[0\.06\] { background-color: rgba(0,0,0,0.04); }

/* Nav */
[data-theme="light"] .nav-link-active { color: #1a1a1a !important; background-color: rgba(0,0,0,0.06) !important; }
[data-theme="light"] .theme-toggle:hover { background: rgba(0,0,0,0.06); color: #1a1a1a; }

/* Post card */
[data-theme="light"] .post-card { border-color: #e5e5e5; background: #ffffff; }
[data-theme="light"] .post-card:hover { border-color: rgba(62,207,142,0.35); background: #f7fdf9; }

/* Tags, badges */
[data-theme="light"] .border-white\/\[0\.08\].bg-white\/\[0\.03\] { border-color: #e5e5e5; background: #f3f4f6; }

/* TOC */
[data-theme="light"] .toc-list a { color: #6b7280; }
[data-theme="light"] .toc-list a:hover { color: #1a1a1a; }

/* Related */
[data-theme="light"] .related-card { border-color: #e5e5e5; background: #ffffff; }
[data-theme="light"] .related-card:hover { border-color: rgba(62,207,142,0.35); background: #f7fdf9; }
[data-theme="light"] .related-card-title { color: #1a1a1a; }

/* Disclaimer */
[data-theme="light"] .disclaimer-box { border-color: #e5e5e5; background: #f9fafb; }

/* Glossary */
[data-theme="light"] .glossary-search { border-color: #e5e5e5; background: #ffffff; color: #1a1a1a; }
[data-theme="light"] .glossary-search::placeholder { color: #9ca3af; }
[data-theme="light"] .glossary-item { border-color: #e5e5e5; background: #ffffff; }

/* Prose (post content) light mode */
[data-theme="light"] .prose { --tw-prose-body: #374151; --tw-prose-headings: #111827; --tw-prose-links: #3ECF8E; --tw-prose-bold: #1f2937; --tw-prose-counters: #6b7280; --tw-prose-bullets: #9ca3af; --tw-prose-hr: #e5e5e5; --tw-prose-quotes: #6b7280; --tw-prose-quote-borders: #3ECF8E; --tw-prose-code: #059669; --tw-prose-pre-bg: #f3f4f6; --tw-prose-th-borders: #e5e5e5; --tw-prose-td-borders: #e5e5e5; }
[data-theme="light"] .prose code { color: #059669; background: #f3f4f6; }
[data-theme="light"] .prose pre { background: #f3f4f6; border-color: #e5e5e5; }
[data-theme="light"] .prose table th,
[data-theme="light"] .prose table td { border-color: #e5e5e5; }
[data-theme="light"] .prose thead { border-color: #e5e5e5; }
[data-theme="light"] .prose p,
[data-theme="light"] .prose li { color: #374151; }
[data-theme="light"] .prose strong { color: #1f2937; }
[data-theme="light"] .prose h2,
[data-theme="light"] .prose h3,
[data-theme="light"] .prose h4 { color: #111827; }
[data-theme="light"] .prose blockquote { color: #6b7280; }

/* Card glow light */
[data-theme="light"] .card-glow { border-color: #e5e5e5; background: #ffffff; }
[data-theme="light"] .card-glow:hover { border-color: rgba(62,207,142,0.35); }

/* Featured card light */
[data-theme="light"] .featured-card { border-color: #e5e5e5; background: linear-gradient(135deg, rgba(62,207,142,0.04), #ffffff); }
[data-theme="light"] .featured-card:hover { border-color: rgba(62,207,142,0.4); }
[data-theme="light"] .featured-overlay { background: linear-gradient(to top, rgba(255,255,255,0.9), transparent); }
[data-theme="light"] .featured-overlay .text-white { color: #1a1a1a; }

/* Grid card thumb placeholder light — opacity now controlled by inline SVG stroke values */

/* Editorial TOC light */
[data-theme="light"] .toc-editorial { border-left-color: rgba(62,207,142,0.4); }

/* Share circle light */
[data-theme="light"] .share-circle-bar { background: rgba(0,0,0,0.02); border-color: #e5e5e5; }
[data-theme="light"] .share-circle { background: rgba(0,0,0,0.05); color: #6b7280; }
[data-theme="light"] .share-circle:hover { background: rgba(62,207,142,0.12); color: #059669; }

/* Scroll progress light */
[data-theme="light"] .scroll-progress { background: #059669; }

/* Author byline light */
[data-theme="light"] .author-avatar { background: linear-gradient(135deg, #059669, #047857); }
