/* ==========================================================================
   카오스월드 데이터베이스 아카이브 - 공용 스타일시트
   디자인 방향: 흰 배경, 파란 포인트, 넓은 여백, 그림자/애니메이션 최소화
   ========================================================================== */

:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f7f9fc;
  --color-text: #1b1f27;
  --color-text-muted: #6b7280;
  --color-border: #e3e7ee;
  --color-accent: #1d4fd6;
  --color-accent-dark: #163ea8;
  --color-accent-soft: #eef3fd;
  --color-tag-boss: #d6431c;
  --color-tag-boss-soft: #fdece6;

  --font-body: "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;

  --max-width: 1040px;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

img {
  max-width: 100%;
  display: block;
}

ul { list-style: none; margin: 0; padding: 0; }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 헤더 ---------- */

.site-header {
  border-bottom: 1px solid var(--color-border);
}

.site-footer {
  padding: 20px 0 28px;
  text-align: center;
}

.site-footer .container {
  display: flex;
  justify-content: center;
}

.site-header .header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  width: 100%;
  flex-wrap: nowrap;
}

.site-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--color-text);
  white-space: nowrap;
}

.site-header .brand .logo-mark {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--color-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-brand {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 16px;
  font-weight: 800;
  color: var(--color-text);
  padding: 8px 10px;
  white-space: nowrap;
  flex: 0 0 auto;
  margin-right: 8px;
}

.category-brand:hover {
  color: var(--color-accent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}

/* header regions */
.header-left { flex: 0 0 auto; }
.header-center { flex: 1 1 auto; display:flex; justify-content:center; min-width:0; }
.header-right { flex: 0 0 auto; display:flex; align-items:center; gap:8px; }

.site-nav a {
  padding: 6px 8px;
  font-size: 13.5px;
  color: var(--color-text-muted);
  border-radius: var(--radius);
}

.site-nav a { white-space: nowrap; }

.site-nav a:hover,
.site-nav a.active {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

.header-search {
  display: none !important;
}

.header-search input {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  width: 100%;
  background: transparent;
  color: var(--color-text);
}

.header-search button {
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
}

/* ---------- 메인 검색 섹션 (홈) ---------- */

.home-search-section {
  padding: 64px 24px 40px;
  text-align: center;
  width: 100%;
}

.home-search-section--page {
  padding: 36px 24px 24px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--color-border);
}

.home-logo {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--color-accent);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.home-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--color-text);
}

.home-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  margin: 0 0 28px;
}

.main-search-box {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--color-accent);
  border-radius: 999px;
  padding: 12px 20px;
  background: #fff;
}

.main-search-box:focus-within {
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.header-search:focus-within {
  border-color: var(--color-accent);
}

.main-search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  color: var(--color-text);
  background: transparent;
}

.main-search-box button {
  border: none;
  background: var(--color-accent);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.main-search-box button:hover {
  background: var(--color-accent-dark);
}

/* 검색 자동완성 */
.search-suggest-wrap {
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

.search-suggest {
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-align: left;
  max-height: 320px;
  overflow-y: auto;
  z-index: 20;
}

.search-suggest.hidden { display: none; }

.search-suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13.5px;
}

.search-suggest-item:last-child { border-bottom: none; }

.search-suggest-item:hover { background: var(--color-bg-alt); }

.search-suggest-item .thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}

.search-suggest-item .name { font-weight: 600; }

.search-suggest-item .cat {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ---------- 카테고리 메뉴 ---------- */

.category-menu {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  max-width: 900px;
  margin: 32px auto 0;
  flex-wrap: nowrap;
}

.home-search-section--page .category-menu {
  margin-top: 24px;
}

.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  border-radius: var(--radius);
  color: var(--color-text);
  flex: 0 0 auto;
}

.category-item:hover {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.category-item:hover .icon,
.category-item:hover .label {
  color: var(--color-accent);
}

.category-item .icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
}

.category-item .icon svg {
  width: 22px;
  height: 22px;
}

.category-item .label {
  font-size: 12.5px;
  text-align: center;
  color: var(--color-text);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 10px;
  flex: 0 0 auto;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-alt);
  color: var(--color-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.theme-toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--color-border);
  display: inline-flex;
  align-items: center;
  padding: 2px;
}

.theme-toggle-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.theme-toggle.is-dark .theme-toggle-track {
  background: var(--color-accent);
}

.theme-toggle.is-dark .theme-toggle-thumb {
  transform: translateX(16px);
}

body.dark {
  background: #0f172a;
  color: #f8fafc;
}

body.dark .site-header,
body.dark .home-search-section--page,
body.dark .site-footer,
body.dark .category-item,
body.dark .category-brand,
body.dark .theme-toggle {
  border-color: #334155;
}

body.dark .category-item:hover,
body.dark .category-item:hover .icon,
body.dark .category-item:hover .label,
body.dark .category-brand,
body.dark .theme-toggle {
  color: #93c5fd;
}

body.dark .category-item:hover {
  background: rgba(29, 79, 214, 0.16);
}

body.dark .theme-toggle {
  background: #111827;
}

body.dark .site-nav a,
body.dark .home-subtitle,
body.dark .site-footer p,
body.dark .category-item .label,
body.dark .category-brand {
  color: #cbd5e1;
}

body.dark .home-title {
  color: #f8fafc;
}

body.dark .site-nav a:hover,
body.dark .site-nav a.active,
body.dark .category-item .icon {
  color: #93c5fd;
}

@media (max-width: 720px) {
  .site-header .header-row {
    flex-wrap: wrap;
    justify-content: center;
  }

  .site-header .header-nav-group {
    justify-content: center;
    flex-wrap: wrap;
  }

  .theme-toggle {
    margin-left: 0;
  }

  .category-menu {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ---------- 섹션 공용 ---------- */

.section {
  padding: 32px 0;
  border-top: 1px solid var(--color-border);
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title .more-link {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--color-accent);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

@media (max-width: 680px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ---------- 리스트 (검색결과 / 최근 업데이트 등) ---------- */

.simple-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.simple-list-item:last-child { border-bottom: none; }

.simple-list-item .thumb {
  width: 36px;
  height: 36px;
  border-radius: 5px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--color-text-muted);
}

.simple-list-item .info { flex: 1; min-width: 0; }

.simple-list-item .name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.simple-list-item .sub {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  flex-shrink: 0;
}

.tag.boss {
  background: var(--color-tag-boss-soft);
  color: var(--color-tag-boss);
}

/* ---------- 목록/브라우즈 페이지 ---------- */

.page-header {
  padding: 32px 0 20px;
  border-bottom: 1px solid var(--color-border);
}

.page-header h1 {
  font-size: 19px;
  margin: 0 0 4px;
}

.page-header .count {
  font-size: 13px;
  color: var(--color-text-muted);
}

.filter-bar {
  display: flex;
  gap: 10px;
  padding: 16px 0;
  align-items: center;
}

.filter-bar input {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

.filter-bar input:focus { border-color: var(--color-accent); }

.filter-bar select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 9px 10px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
}

.list-wrap { padding-bottom: 40px; }

.empty-state {
  padding: 48px 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13.5px;
}

/* ---------- 상세 페이지 ---------- */

.detail-header {
  padding: 32px 0 20px;
}

.detail-header .cat-tag {
  font-size: 12px;
  color: var(--color-accent);
  font-weight: 600;
  margin-bottom: 6px;
}

.detail-header h1 {
  font-size: 22px;
  margin: 0;
}

.detail-header .note {
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.detail-image {
  width: 96px;
  height: 96px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg-alt);
  object-fit: contain;
  margin: 20px 0;
}

.detail-description {
  font-size: 14px;
  color: var(--color-text);
  padding: 4px 0 24px;
  border-bottom: 1px solid var(--color-border);
  white-space: pre-line;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 8px;
  font-size: 13.5px;
}

.info-table tr {
  border-bottom: 1px solid var(--color-border);
}

.info-table tr:last-child { border-bottom: none; }

.info-table th {
  width: 140px;
  text-align: left;
  padding: 10px 12px 10px 0;
  color: var(--color-text-muted);
  font-weight: 500;
  vertical-align: top;
}

.info-table td {
  padding: 10px 0;
  vertical-align: top;
}

.related-block { padding: 12px 0 40px; }

.related-group { margin-bottom: 20px; }

.related-group h3 {
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 600;
  margin: 0 0 8px;
}

/* ---------- 유틸 페이지 ---------- */

.util-item {
  display: flex;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--color-border);
}

.util-item:last-child { border-bottom: none; }

.util-item .shot {
  width: 120px;
  height: 76px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg-alt);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 11px;
}

.util-item .util-body h3 {
  font-size: 14.5px;
  margin: 0 0 6px;
}

.util-item .util-body p {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0 0 8px;
}

.util-item .util-body a {
  font-size: 12.5px;
  color: var(--color-accent);
  font-weight: 600;
}

/* ---------- 위키 / 패치노트 ---------- */

.doc-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
}

.doc-item:last-child { border-bottom: none; }

.doc-item .doc-date {
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.doc-item h3 {
  font-size: 14.5px;
  margin: 4px 0 6px;
}

.doc-item p {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
}

.doc-article h1 { font-size: 20px; margin-bottom: 6px; }
.doc-article .doc-date { font-size: 12px; color: var(--color-text-muted); }
.doc-article .doc-body { font-size: 14px; line-height: 1.8; padding: 20px 0 40px; }

/* ---------- 푸터 ---------- */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 24px 0;
  margin-top: 24px;
}

.site-footer p {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 0;
  text-align: center;
}

/* ---------- 반응형 ---------- */

@media (max-width: 640px) {
  .site-header .header-row { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 8px; }
  .site-nav { order: 3; width: 100%; }
  .home-search-section { padding: 40px 16px 24px; }
  .home-title { font-size: 19px; }
  .info-table th { width: 100px; }
}
