/* ==========================================================================
   Sehyeog Kim Personal Blog — Light/Dark Theme (gitfolio-inspired)
   Generated by AI Agent: 2026-02-25 22:30 KST
   Rewritten by AI Agent: 2026-02-25 23:30 KST — 3그룹 계층
   Updated by AI Agent: 2026-02-26 07:55 KST — Dark/Light 토글 복원
   ========================================================================== */

/* --- Theme Variables --- */
:root, [data-theme="light"] {
  --bg: #ffffff; --surface: #f6f8fa; --elevated: #eaeef2;
  --border: #d0d7de; --border-h: #afb8c1;
  --fg: #1f2328; --fg2: #656d76; --fg3: #8b949e;
  --accent: #0969da; --accent-h: #0550ae; --accent-bg: rgba(9,105,218,0.08);
  --card-shadow: rgba(9,105,218,0.08); --overlay: rgba(0,0,0,0.3);
}
[data-theme="dark"] {
  --bg: #0d1117; --surface: #161b22; --elevated: #21262d;
  --border: #30363d; --border-h: #484f58;
  --fg: #e6edf3; --fg2: #8b949e; --fg3: #6e7681;
  --accent: #58a6ff; --accent-h: #79c0ff; --accent-bg: rgba(31,111,235,0.13);
  --card-shadow: rgba(88,166,255,0.1); --overlay: rgba(0,0,0,0.6);
}

/* Reset & Base */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-h); }
img { max-width: 100%; height: auto; }

.site-wrapper { display: flex; min-height: 100vh; }

/* --- Theme Toggle Button --- */
.theme-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 150;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; color: var(--fg2);
  transition: all 0.2s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: scale(1.05); }
.theme-toggle svg { width: 20px; height: 20px; transition: transform 0.3s; }
.theme-toggle:hover svg { transform: rotate(15deg); }
[data-theme="light"] .icon-sun, [data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-moon, [data-theme="dark"] .icon-sun { display: block; }

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  width: 300px;
  min-width: 300px;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-bg {
  position: relative;
  height: 180px;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-bg img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.sidebar-bg::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 70px;
  background: linear-gradient(transparent, var(--surface));
}

.sidebar-profile {
  text-align: center;
  padding: 0 20px 16px;
  margin-top: -55px;
  position: relative; z-index: 2;
  flex-shrink: 0;
}

.profile-photo {
  width: 110px; height: 110px;
  border-radius: 50%;
  border: 4px solid var(--surface);
  object-fit: cover;
  background: var(--elevated);
}

.profile-name {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 10px;
  color: var(--fg);
}

.profile-bio {
  color: var(--fg2);
  font-size: 0.88rem;
  margin-top: 4px;
  line-height: 1.4;
}

.profile-links {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.profile-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg2);
  font-size: 0.82rem;
  transition: all 0.2s;
}

.profile-links a:hover {
  background: var(--elevated);
  color: var(--fg);
  border-color: var(--border-h);
}

.profile-links svg { width: 15px; height: 15px; fill: currentColor; }

/* Sidebar Navigation */
.sidebar-nav {
  padding: 12px 12px 20px;
  border-top: 1px solid var(--border);
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav .nav-group-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
  padding: 12px 10px 4px;
  margin-top: 4px;
}

.sidebar-nav .nav-group-label:first-child {
  margin-top: 0;
  padding-top: 4px;
}

.sidebar-nav .nav-item {
  display: block;
  padding: 6px 10px;
  color: var(--fg2);
  border-radius: 6px;
  font-size: 0.84rem;
  transition: all 0.15s;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav .nav-item:hover {
  background: var(--elevated);
  color: var(--accent);
}

.sidebar-nav .nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav .nav-home {
  font-weight: 600;
  color: var(--fg);
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.nav-post-count {
  font-size: 0.7rem;
  color: var(--fg3);
  margin-left: 4px;
}

/* Mobile */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  align-items: center;
  padding: 0 16px;
  justify-content: space-between;
}

.mobile-header .site-title {
  font-size: 1rem; font-weight: 700; color: var(--fg);
}

.menu-toggle {
  background: none; border: none;
  color: var(--fg); font-size: 1.4rem;
  cursor: pointer; padding: 4px 8px;
}

/* ==========================================================================
   Main Content
   ========================================================================== */
.main-content {
  margin-left: 300px;
  padding: 40px 48px 60px;
  flex: 1;
  min-width: 0;
}

.page-header { margin-bottom: 36px; }

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
}

.page-header .page-desc {
  color: var(--fg2);
  font-size: 0.95rem;
  margin-top: 6px;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 0.88rem;
  color: var(--fg2);
  flex-wrap: wrap;
}

.breadcrumb a { color: var(--accent); }
.breadcrumb .sep { color: var(--border-h); }

/* ==========================================================================
   Group Cards (Home) + Sub-category Cards (Group Page)
   ========================================================================== */
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.group-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.group-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px var(--accent-bg);
}

.group-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 8px;
}

.group-card .card-desc {
  color: var(--fg2);
  font-size: 0.9rem;
  margin-bottom: 12px;
  line-height: 1.5;
}

.group-card .card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg3);
  font-size: 0.82rem;
}

.group-card .badge {
  display: inline-block;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* Sub-category cards (inside a group page) */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.category-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.category-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 16px var(--card-shadow);
}

.category-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.category-card .card-meta {
  color: var(--fg3);
  font-size: 0.82rem;
}

.category-card .post-count-badge {
  display: inline-block;
  background: var(--surface);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
}

/* ==========================================================================
   Post List
   ========================================================================== */
.post-list { list-style: none; }

.post-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--elevated);
}

.post-item:first-child { padding-top: 0; }
.post-item a { display: block; }

.post-item .post-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
  transition: color 0.2s;
}

.post-item:hover .post-title { color: var(--accent); }

.post-item .post-date {
  color: var(--fg3);
  font-size: 0.82rem;
  margin-top: 3px;
}

/* ==========================================================================
   Post Content
   ========================================================================== */
.post-content {
  max-width: 800px;
  line-height: 1.8;
}

.post-content h1 {
  font-size: 1.7rem; font-weight: 700;
  margin-top: 32px; margin-bottom: 14px;
  color: var(--fg);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--elevated);
}

.post-content h2 {
  font-size: 1.4rem; font-weight: 600;
  margin-top: 28px; margin-bottom: 10px;
  color: var(--fg);
}

.post-content h3 {
  font-size: 1.15rem; font-weight: 600;
  margin-top: 24px; margin-bottom: 8px;
  color: var(--fg);
}

.post-content h4, .post-content h5, .post-content h6 {
  margin-top: 20px; margin-bottom: 8px; color: var(--fg);
}

.post-content p { margin-bottom: 16px; }

.post-content img {
  border-radius: 8px;
  margin: 18px 0;
  border: 1px solid var(--border);
}

.post-content ul, .post-content ol {
  margin-bottom: 16px; padding-left: 24px;
}

.post-content li { margin-bottom: 5px; }

.post-content blockquote {
  border-left: 4px solid var(--accent);
  padding: 10px 18px;
  margin: 16px 0;
  background: var(--surface);
  border-radius: 0 6px 6px 0;
  color: var(--fg);
}

.post-content blockquote p { margin-bottom: 0; }

.post-content code {
  background: var(--surface);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.88em;
  color: var(--fg);
  border: 1px solid var(--elevated);
}

.post-content pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 16px 0;
}

.post-content pre code {
  background: none; padding: 0;
  border-radius: 0; border: none;
  font-size: 0.86rem; line-height: 1.6;
}

.post-content table {
  width: 100%; border-collapse: collapse;
  margin: 18px 0; font-size: 0.93rem;
}

.post-content th, .post-content td {
  border: 1px solid var(--border);
  padding: 9px 13px; text-align: left;
}

.post-content th {
  background: var(--surface);
  font-weight: 600; color: var(--fg);
}

.post-content tr:nth-child(even) { background: var(--surface)80; }

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(var(--accent), 0.3);
  text-underline-offset: 3px;
}

.post-content a:hover { text-decoration-color: var(--accent); }
.post-content strong { color: var(--fg); font-weight: 600; }

/* Post meta */
.post-meta {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 28px;
  font-size: 0.85rem;
  color: var(--fg2);
}

.post-meta .meta-item { display: flex; align-items: center; gap: 5px; }
.post-meta .meta-label { font-weight: 600; color: var(--fg); }

/* Back link */
.back-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--fg2); font-size: 0.88rem;
  margin-bottom: 20px; transition: color 0.2s;
}

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

/* Footer */
.site-footer {
  margin-top: 60px; padding-top: 20px;
  border-top: 1px solid var(--elevated);
  color: var(--fg3); font-size: 0.82rem;
  text-align: center;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .main-content { padding: 40px 28px 60px; }
  .group-grid, .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .theme-toggle { top: 68px; right: 12px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 280px; min-width: 280px;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--overlay);
    z-index: 99;
  }

  .sidebar-overlay.open { display: block; }

  .main-content {
    margin-left: 0;
    padding: 64px 16px 40px;
  }

  .page-header h1 { font-size: 1.4rem; }
  .group-grid, .category-grid { grid-template-columns: 1fr; }
  .post-content { font-size: 0.93rem; }
  .post-content h1 { font-size: 1.3rem; }
  .post-content h2 { font-size: 1.15rem; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-h); }

::selection { background: var(--accent-bg); color: var(--fg); }
