/* ============================================================
   디자인 토큰 — 색상/폰트/간격을 여기서 한 번에 바꾸면 전체 사이트에 적용됩니다.
   ============================================================ */
:root {
  /* 색상 (라이트) */
  --bg:            #f6f7f9;
  --surface:       #ffffff;
  --surface-2:     #f0f2f5;
  --border:        #e3e6eb;
  --text:          #1a1d23;
  --text-muted:    #6b7280;
  --accent:        #2f6feb;
  --accent-hover:  #1f54c4;
  --danger:        #e04848;
  --success:       #2ea043;

  /* 타이포 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR",
               "맑은 고딕", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;

  /* 간격 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-8: 48px;

  /* 레이아웃 */
  --container: 1200px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);

  /* 헤더 높이 */
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg:            #14161a;
  --surface:       #1c1f24;
  --surface-2:     #23272e;
  --border:        #2e333b;
  --text:          #e6e8eb;
  --text-muted:    #8b919c;
  --accent:        #4f8bf0;
  --accent-hover:  #6a9ff3;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
}

/* ============================================================
   리셋 + 기본
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ============================================================
   레이아웃
   ============================================================ */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

/* 상단 광고 배너 슬롯 */
.banner-top {
  background: repeating-linear-gradient(
    45deg, var(--surface-2), var(--surface-2) 10px,
    var(--bg) 10px, var(--bg) 20px
  );
  border-bottom: 1px solid var(--border);
  text-align: center;
  padding: var(--sp-3);
  color: var(--text-muted);
  font-size: 12px;
}
.banner-top::before { content: "▣ 광고 배너 영역 (728x90) — assets/img/banner-top.jpg 로 교체"; }

/* 헤더 */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.site-header .inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  height: var(--header-h);
}
.logo {
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.logo span { color: var(--accent); }

.nav-main {
  display: flex;
  gap: var(--sp-4);
  flex: 1;
  list-style: none;
  padding: 0; margin: 0;
}
.nav-main a {
  color: var(--text);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.nav-main a:hover { background: var(--surface-2); }
.nav-main a.active { color: var(--accent); }

.header-actions { display: flex; gap: var(--sp-2); align-items: center; }
.search-box {
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 var(--sp-2);
}
.search-box input {
  background: transparent; border: 0; outline: 0;
  padding: var(--sp-2); width: 200px; color: var(--text);
}

/* 버튼 */
.btn {
  background: var(--accent); color: #fff;
  border: 0; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: 12px; }

/* 메인 레이아웃: 사이드바 + 컨텐츠 */
.layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--sp-5);
  margin-top: var(--sp-5);
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

/* 카드 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}
.card h2 { margin: 0 0 var(--sp-4); font-size: 18px; }

/* 게시판 그리드 (메인용) */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-3);
}
.board-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
  text-align: center;
  color: var(--text);
  transition: transform .15s, border-color .15s;
}
.board-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.board-tile .icon { font-size: 28px; margin-bottom: var(--sp-2); }
.board-tile .name { font-weight: 600; }
.board-tile .count { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* 글 목록 (테이블) */
.post-list { width: 100%; border-collapse: collapse; }
.post-list th, .post-list td {
  padding: var(--sp-3) var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  text-align: left;
}
.post-list th { color: var(--text-muted); font-weight: 500; background: var(--surface-2); }
.post-list tr:hover td { background: var(--surface-2); }
.post-list .col-no { width: 50px; color: var(--text-muted); text-align: center; }
.post-list .col-cat { width: 80px; }
.post-list .col-author { width: 100px; }
.post-list .col-date { width: 80px; color: var(--text-muted); }
.post-list .col-hits { width: 60px; text-align: right; color: var(--text-muted); }
.post-list .col-likes { width: 50px; text-align: right; color: var(--text-muted); }
.post-list a { color: var(--text); }
.post-list a:hover { color: var(--accent); }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-hot { background: #ffe4e6; color: #c0223a; border-color: #fbb6c2; }
[data-theme="dark"] .badge-hot { background: #3a1a20; color: #ff9aa8; border-color: #5a2a32; }

/* 사이드바 */
.sidebar { display: flex; flex-direction: column; gap: var(--sp-4); }
.ad-slot {
  background: var(--surface-2);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
.ad-slot small { display: block; margin-top: var(--sp-1); }

/* 카테고리 탭 */
.tabs {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
}
.tabs a {
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* 페이지네이션 */
.pagination {
  display: flex; justify-content: center;
  gap: var(--sp-1);
  margin-top: var(--sp-5);
}
.pagination a, .pagination span {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  min-width: 36px; text-align: center;
}
.pagination a:hover { background: var(--surface-2); }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 게시글 뷰 */
.post-header { border-bottom: 1px solid var(--border); padding-bottom: var(--sp-4); margin-bottom: var(--sp-4); }
.post-header h1 { font-size: 22px; margin: 0 0 var(--sp-3); }
.post-meta { color: var(--text-muted); font-size: 12px; display: flex; gap: var(--sp-3); }
.post-body { line-height: 1.8; min-height: 200px; padding: var(--sp-4) 0; }
.post-actions { display: flex; gap: var(--sp-2); justify-content: center; margin: var(--sp-5) 0; }
.post-actions button { display: flex; align-items: center; gap: var(--sp-2); }

/* 댓글 */
.comment-form { margin-top: var(--sp-5); }
.comment-form textarea {
  width: 100%; min-height: 80px; padding: var(--sp-3);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  resize: vertical;
}
.comment-form .row { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); justify-content: flex-end; }
.comment-list { margin-top: var(--sp-5); }
.comment {
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.comment-meta { font-size: 12px; color: var(--text-muted); margin-bottom: var(--sp-1); }
.comment-meta strong { color: var(--text); margin-right: var(--sp-2); }

/* 인증 폼 */
.auth-page { max-width: 420px; margin: var(--sp-8) auto; }
.auth-page h1 { text-align: center; margin-bottom: var(--sp-5); }
.form-group { margin-bottom: var(--sp-4); }
.form-group label { display: block; margin-bottom: var(--sp-1); font-size: 13px; color: var(--text-muted); }
.form-group input {
  width: 100%; padding: var(--sp-3);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: 0;
}
.form-group input:focus { border-color: var(--accent); }
.btn-block { width: 100%; padding: var(--sp-3); }
.auth-foot { text-align: center; margin-top: var(--sp-4); color: var(--text-muted); font-size: 13px; }

/* 푸터 */
.site-footer {
  margin-top: var(--sp-8);
  padding: var(--sp-5) 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* 다크모드 토글 */
.theme-toggle {
  background: transparent; border: 1px solid var(--border);
  border-radius: 999px; width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
}

/* ============================================================
   햄버거 버튼 — 기본 숨김, 모바일에서만 표시
   ============================================================ */
.hamburger {
  display: none;
  flex-shrink: 0;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-left: auto;
}
.hamburger span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .15s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   모바일 반응형 (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* 헤더 — 2줄 레이아웃
     1줄: 로고 + 햄버거
     2줄: 검색 + 다크모드 + 로그인 + 가입          */
  .site-header .inner {
    flex-wrap: wrap;
    height: auto;
    padding: var(--sp-2) var(--sp-3);
    gap: var(--sp-2);
    align-items: center;
  }
  .logo { flex: 1; font-size: 18px; }

  /* 햄버거 버튼 표시 */
  .hamburger { display: flex; margin-left: 0; }

  /* header-actions — 2번째 줄, 전체 너비 */
  .header-actions {
    order: 3;
    width: 100%;
    display: flex;
    gap: var(--sp-2);
    align-items: center;
  }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }

  /* 네비게이션 — 드롭다운으로 전환 */
  .nav-main {
    display: none;
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
    z-index: 48;
  }
  .nav-main.mobile-open { display: flex; }
  .nav-main li { list-style: none; }
  .nav-main > li > a {
    display: block;
    padding: 11px var(--sp-3);
    font-size: 15px;
    border-radius: var(--radius-sm);
  }
  .nav-main > li > a:hover { background: var(--surface-2); }

  /* 상단 배너 — 높이만 줄임 */
  .banner-top { padding: var(--sp-2); font-size: 11px; }
  .banner-top::before { content: "▣ 광고 배너 영역"; }

  /* 컨테이너 */
  .container { padding: 0 var(--sp-3); }

  /* 레이아웃 */
  .layout { margin-top: var(--sp-3); gap: var(--sp-3); }

  /* 카드 */
  .card { padding: var(--sp-4) var(--sp-3); }
  .card h2 { font-size: 16px; }

  /* 게시판 그리드 — 2열 */
  .board-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-2);
  }
  .board-tile { padding: var(--sp-3); }
  .board-tile .icon { font-size: 22px; }
  .board-tile .name { font-size: 13px; }

  /* 글 목록 테이블 — 핵심 컬럼만 유지 */
  .post-list .col-no,
  .post-list .col-author,
  .post-list .col-hits,
  .post-list .col-likes { display: none; }
  .post-list th, .post-list td {
    padding: var(--sp-2) var(--sp-1);
    font-size: 12px;
  }
  .post-list .col-cat { width: 58px; }
  .post-list .col-date { width: 64px; }

  /* 게시글 뷰 */
  .post-header h1 { font-size: 18px; line-height: 1.4; }
  .post-meta { flex-wrap: wrap; gap: var(--sp-2); font-size: 11px; }
  .post-actions { flex-wrap: wrap; gap: var(--sp-2); justify-content: center; }
  .post-actions button {
    flex: 1; min-width: 70px;
    font-size: 12px;
    padding: var(--sp-2) var(--sp-1);
  }

  /* 카테고리 탭 — 가로 스크롤 */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; padding: var(--sp-2) var(--sp-3); font-size: 13px; }

  /* 페이지네이션 */
  .pagination { flex-wrap: wrap; gap: 4px; }
  .pagination a, .pagination span {
    min-width: 32px;
    padding: var(--sp-1) var(--sp-2);
    font-size: 13px;
  }

  /* 인증 폼 */
  .auth-page { margin: var(--sp-5) auto; padding: 0 var(--sp-3); }

  /* 댓글 */
  .comment-form textarea { min-height: 70px; }
}

/* ============================================================
   초소형 (≤ 380px)
   ============================================================ */
@media (max-width: 380px) {
  .logo { font-size: 16px; }
  .post-header h1 { font-size: 16px; }
  .board-grid { grid-template-columns: repeat(2, 1fr); }
  .header-actions .btn-sm { padding: var(--sp-1) var(--sp-2); font-size: 11px; }
}
