/* =============================================
   전기삼촌 문서/블로그 스타일시트 (docs.css)
   — docs/index.html 목록 + docs/posts/*.html 글
   ============================================= */

/* ============================================================
   1. 목록 페이지 — 히어로
   ============================================================ */
.docs-hero {
  background: var(--bg-alt);
  padding: 48px 0 32px;
  text-align: center;
}
.docs-hero h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}
.docs-hero p {
  font-size: 1.05rem;
  color: var(--text-sec);
  max-width: 560px;
  margin: 0 auto;
}

/* ============================================================
   2. 카테고리 필터 필(pills)
   ============================================================ */
.docs-filters {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 24px 24px 0;
  max-width: 900px;
  margin: 0 auto;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-sec);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
  min-height: 44px;
}
.filter-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.filter-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ============================================================
   3. 검색
   ============================================================ */
.docs-search {
  max-width: 480px;
  margin: 20px auto 0;
  padding: 0 24px;
  position: relative;
}
.docs-search input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  min-height: 44px;
}
.docs-search input::placeholder { color: var(--text-sec); }
.docs-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
.docs-search .search-icon {
  position: absolute;
  left: 38px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-sec);
  pointer-events: none;
}

/* ============================================================
   4. 카드 그리드
   ============================================================ */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 1200px;
  margin: 32px auto 0;
  padding: 0 24px 64px;
}

/* ============================================================
   5. 카드
   ============================================================ */
.docs-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  display: flex;
  flex-direction: column;
  padding: 20px;
  text-decoration: none;
}
.docs-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.docs-card-thumb {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--bg-alt);
  display: block;
}
.docs-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.docs-card-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
  width: fit-content;
}
.docs-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.45;
  margin-bottom: 8px;
}
.docs-card-excerpt {
  font-size: 0.9rem;
  color: var(--text-sec);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
  flex: 1;
}
.docs-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-sec);
  margin-top: auto;
}
.docs-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ===== 자세히 보기 링크 ===== */
.docs-card-link {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent, #2563EB);
  margin-top: 12px;
  transition: color 0.2s var(--ease);
}
.docs-card:hover .docs-card-link {
  color: var(--accent-hover, #1D4ED8);
}

/* ============================================================
   6. 빈 상태
   ============================================================ */
.docs-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-sec);
}
.docs-empty svg,
.docs-empty img {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.docs-empty p {
  font-size: 1rem;
  margin-bottom: 4px;
}
.docs-empty .docs-empty-sub {
  font-size: 0.875rem;
  color: var(--text-light, #94a3b8);
}

/* ============================================================
   카테고리 색상 — data-cat 속성
   ============================================================ */
/* 누전 */
.docs-card-category[data-cat="\ub204\uc804"],
.article-category[data-cat="\ub204\uc804"],
.filter-pill.active[data-cat="\ub204\uc804"] { background: #fee2e2; color: #dc2626; }
.filter-pill.active[data-cat="\ub204\uc804"] { border-color: #dc2626; }

/* 배선공사 */
.docs-card-category[data-cat="\ubc30\uc120\uacf5\uc0ac"],
.article-category[data-cat="\ubc30\uc120\uacf5\uc0ac"],
.filter-pill.active[data-cat="\ubc30\uc120\uacf5\uc0ac"] { background: #dbeafe; color: #2563eb; }
.filter-pill.active[data-cat="\ubc30\uc120\uacf5\uc0ac"] { border-color: #2563eb; }

/* 전기팁 */
.docs-card-category[data-cat="\uc804\uae30\ud301"],
.article-category[data-cat="\uc804\uae30\ud301"],
.filter-pill.active[data-cat="\uc804\uae30\ud301"] { background: #d1fae5; color: #059669; }
.filter-pill.active[data-cat="\uc804\uae30\ud301"] { border-color: #059669; }

/* 안전 */
.docs-card-category[data-cat="\uc548\uc804"],
.article-category[data-cat="\uc548\uc804"],
.filter-pill.active[data-cat="\uc548\uc804"] { background: #EFF6FF; color: #2563EB; }
.filter-pill.active[data-cat="\uc548\uc804"] { border-color: #2563EB; }

/* 요금정보 */
.docs-card-category[data-cat="\uc694\uae08\uc815\ubcf4"],
.article-category[data-cat="\uc694\uae08\uc815\ubcf4"],
.filter-pill.active[data-cat="\uc694\uae08\uc815\ubcf4"] { background: #e0e7ff; color: #4f46e5; }
.filter-pill.active[data-cat="\uc694\uae08\uc815\ubcf4"] { border-color: #4f46e5; }

/* 태양광발전 */
.docs-card-category[data-cat="\ud0dc\uc591\uad11\ubc1c\uc804"],
.article-category[data-cat="\ud0dc\uc591\uad11\ubc1c\uc804"],
.filter-pill.active[data-cat="\ud0dc\uc591\uad11\ubc1c\uc804"] { background: #fce7f3; color: #db2777; }
.filter-pill.active[data-cat="\ud0dc\uc591\uad11\ubc1c\uc804"] { border-color: #db2777; }


/* ============================================================
   ARTICLE PAGE
   ============================================================ */

/* ============================================================
   A-1. 글 헤더
   ============================================================ */
.article-header {
  background: var(--primary);
  color: #fff;
  padding: 48px 24px;
  text-align: center;
}
.article-header .container {
  max-width: 800px;
  margin: 0 auto;
}
.article-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.article-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 16px;
}
.article-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 0.875rem;
  opacity: 0.85;
  flex-wrap: wrap;
}
.article-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ============================================================
   A-2. 두 컬럼 레이아웃 (본문 + TOC)
   ============================================================ */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 48px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  align-items: start;
}

/* ============================================================
   A-3. 본문 산문 스타일
   ============================================================ */
.article-content {
  min-width: 0; /* grid overflow 방지 */
}
.article-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2.5rem;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.article-content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}
.article-content p {
  font-size: 1rem;
  line-height: 1.8;
  margin-bottom: 1.25rem;
  color: var(--text);
}
.article-content ul,
.article-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1.25rem;
  line-height: 1.8;
}
.article-content li {
  margin-bottom: 0.4rem;
}
.article-content li::marker {
  color: var(--text-sec);
}
.article-content blockquote {
  border-left: 4px solid var(--accent);
  background: rgba(245, 158, 11, 0.05);
  padding: 16px 20px;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.95rem;
  color: var(--text);
}
.article-content blockquote p:last-child {
  margin-bottom: 0;
}
.article-content img {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
  display: block;
}
.article-content strong {
  color: var(--primary);
  font-weight: 700;
}
.article-content a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
.article-content a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
.article-content pre {
  background: var(--primary);
  color: #e2e8f0;
  padding: 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.7;
}
.article-content code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.875em;
}
.article-content p code,
.article-content li code {
  background: var(--bg-alt);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.85em;
}
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.925rem;
}
.article-content th,
.article-content td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}
.article-content th {
  background: var(--bg-alt);
  font-weight: 700;
  color: var(--primary);
}

/* ============================================================
   A-4. 목차 (Table of Contents)
   ============================================================ */
.article-toc {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  padding: 20px;
}
.toc-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sec);
  margin-bottom: 12px;
}
.toc-toggle {
  display: none; /* 데스크톱에서는 숨김 */
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-sec);
  margin-left: auto;
}
.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc-list .toc-list {
  padding-left: 12px;
}
.toc-link {
  display: block;
  font-size: 0.875rem;
  padding: 6px 12px;
  color: var(--text-sec);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all 0.15s var(--ease);
  text-decoration: none;
  line-height: 1.5;
}
.toc-link:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.03);
}
.toc-link.active {
  border-left-color: var(--accent);
  color: var(--primary);
  font-weight: 600;
  background: rgba(245, 158, 11, 0.06);
}

/* ============================================================
   A-5. 이전글/다음글 내비게이션
   ============================================================ */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--border);
  padding-top: 32px;
  margin-top: 48px;
}
.article-nav-item {
  flex: 1;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 44px;
}
.article-nav-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.article-nav-item.next {
  text-align: right;
}
.article-nav-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.article-nav-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.4;
}

/* ============================================================
   A-6. 관련 글
   ============================================================ */
.article-related {
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}
.article-related-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 24px;
}
.article-related-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

/* ============================================================
   A-7. CTA 박스
   ============================================================ */
.article-cta {
  margin-top: 48px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
}
.article-cta h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}
.article-cta p {
  font-size: 0.95rem;
  color: var(--text-sec);
  margin-bottom: 20px;
}
.article-cta .cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
  min-height: 44px;
}
.article-cta .cta-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}


/* ============================================================
   RESPONSIVE — TABLET (768px)
   ============================================================ */
@media (max-width: 1024px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* TOC → 접기 가능 */
  .article-toc {
    position: static;
    max-height: none;
    margin-bottom: 32px;
    border-radius: var(--radius-md);
  }
  .toc-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }
  .article-toc.collapsed .toc-list {
    display: none;
  }
}

@media (max-width: 768px) {
  /* 히어로 */
  .docs-hero {
    padding: 36px 24px 24px;
  }
  .docs-hero h1 {
    font-size: 1.5rem;
  }

  /* 필터: 가로 스크롤 */
  .docs-filters {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 20px 24px 0;
    gap: 8px;
    scrollbar-width: none;
  }
  .docs-filters::-webkit-scrollbar { display: none; }
  .filter-pill {
    scroll-snap-align: start;
    flex-shrink: 0;
  }

  /* 그리드: 2열 */
  .docs-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 0 16px 48px;
    margin-top: 24px;
  }

  /* 글 헤더 */
  .article-header {
    padding: 36px 20px;
  }
  .article-title {
    font-size: 1.5rem;
  }

  /* 본문 */
  .article-layout {
    padding: 32px 20px 48px;
  }
  .article-content h2 {
    font-size: 1.3rem;
    margin-top: 2rem;
  }
  .article-content h3 {
    font-size: 1.1rem;
  }

  /* 관련글: 1열 */
  .article-related-grid {
    grid-template-columns: 1fr;
  }

  /* 이전/다음 */
  .article-nav {
    flex-direction: column;
    gap: 12px;
  }
  .article-nav-item.next {
    text-align: left;
  }
}


/* ============================================================
   RESPONSIVE — MOBILE (480px)
   ============================================================ */
@media (max-width: 480px) {
  /* 그리드: 1열 */
  .docs-grid {
    grid-template-columns: 1fr;
  }

  /* 카드 썸네일 줄임 */
  .docs-card-thumb {
    height: 160px;
  }

  /* 히어로 */
  .docs-hero h1 {
    font-size: 1.35rem;
  }
  .docs-hero p {
    font-size: 0.95rem;
  }

  /* 글 헤더 */
  .article-header {
    padding: 28px 16px;
  }
  .article-title {
    font-size: 1.35rem;
  }
  .article-meta {
    font-size: 0.8rem;
    gap: 10px;
  }

  /* 본문 폰트 최소 16px */
  .article-content p {
    font-size: 1rem;
    min-font-size: 16px;
    /* iOS Safari 확대 방지 */
  }
  .article-content ul,
  .article-content ol {
    margin-left: 1.25rem;
  }

  /* 레이아웃 패딩 */
  .article-layout {
    padding: 24px 16px 40px;
  }

  /* CTA */
  .article-cta {
    padding: 24px 20px;
  }
  .article-cta h3 {
    font-size: 1.1rem;
  }
}
