/* NEED USER GUIDE — Desktop First (>=1200px 기준 최적화) */

:root {
  --bg:            #0f1319;
  --bg-panel:      #151b24;
  --bg-panel-2:    #1a222d;
  --bg-row:        #141a23;
  --bg-row-hover:  #212c3c;

  --line:          #262f3d;
  --line-soft:     #1e2632;

  --text:          #dfe6ef;
  --text-strong:   #f4f8fc;
  --text-dim:      #8b98a9;
  --text-faint:    #66727f;

  --accent:        #e8b45a;
  --accent-dim:    #a9803a;
  --accent-soft:   rgba(232, 180, 90, 0.12);

  --radius:        4px;
  --content-max:   1560px;
  --sidebar-w:     236px;
  --topbar-h:      56px;

  --font: "Segoe UI", "Malgun Gothic", "맑은 고딕", Meiryo, system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Mono", Consolas, "D2Coding", monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 420px at 50% -160px, rgba(232, 180, 90, 0.07), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  background: rgba(15, 19, 25, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  /* 스크롤로 목록이 상단바 아래를 지날 때 경계가 분명하게 보이도록 */
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.topbar-inner {
  max-width: var(--content-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 0 0 auto;
}

.wordmark-mark {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.wordmark-sub {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--text-dim);
}

/* search */
.search {
  position: relative;
  margin-left: auto;
  width: 460px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  font-size: 12px;
  opacity: 0.7;
  pointer-events: none;
}

#search-input {
  width: 100%;
  height: 36px;
  padding: 0 62px 0 32px;
  background: var(--bg-panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-strong);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 100ms linear, box-shadow 100ms linear;
}

#search-input::placeholder { color: var(--text-faint); }

#search-input:hover { border-color: #35414f; }

#search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #202939;
  box-shadow: 0 0 0 4px rgba(232, 180, 90, 0.16);
}

.search:focus-within .search-icon { opacity: 1; }

#search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
  position: absolute;
  right: 34px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
}
.search-clear:hover { background: var(--line); color: var(--text-strong); }

.search-hint {
  position: absolute;
  right: 9px;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-panel);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
  pointer-events: none;
}

.search:focus-within .search-hint { opacity: 0; }

/* ----------------------------------------------------------------- intro */
.intro {
  max-width: var(--content-max);
  margin: 18px auto 0;
  padding: 0 28px;
  color: var(--text-dim);
  font-size: 13px;
}
.intro strong { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- layout */
.layout {
  max-width: var(--content-max);
  margin: 16px auto 0;
  padding: 0 28px 48px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

/* --------------------------------------------------------------- sidebar */
/* 목록이 길어져도 카테고리를 바로 바꿀 수 있게 스크롤 시 고정한다.
   카테고리가 늘어나 사이드바가 화면보다 길어지면 사이드바 안에서만 스크롤된다. */
.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.category-nav {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.category-nav::-webkit-scrollbar { width: 8px; }
.category-nav::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.cat-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 3px;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.cat-btn:hover { background: var(--bg-panel-2); color: var(--text); }

.cat-btn.is-active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--text-strong);
  font-weight: 600;
}

.cat-btn-icon { font-size: 13px; text-align: center; }

.cat-btn-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-btn-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.cat-btn.is-active .cat-btn-count { color: var(--accent); }

.cat-divider {
  height: 1px;
  margin: 6px 4px;
  background: var(--line-soft);
}

.sidebar-note {
  margin: 12px 4px 0;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.5;
}

/* --------------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  padding: 0 2px 10px;
  border-bottom: 1px solid var(--line);
}

.result-heading {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.result-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.toolbar-right { margin-left: auto; }

.sort { display: flex; align-items: center; gap: 7px; }

.sort-label { font-size: 12px; color: var(--text-faint); white-space: nowrap; }

#sort-select {
  height: 27px;
  padding: 0 6px;
  background: var(--bg-panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
#sort-select:focus { outline: none; border-color: var(--accent-dim); }

/* ------------------------------------------------------------ guide list */
.guide-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px 132px;
  align-items: center;
  gap: 18px;
  /* 제목을 키운 만큼 세로 패딩을 1px 줄여 행 높이를 유지한다 */
  padding: 10px 12px 10px 9px;
  border-bottom: 1px solid var(--line-soft);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background-color 100ms linear, border-left-color 100ms linear;
}

.guide-row:hover {
  background: var(--bg-row-hover);
  border-left-color: var(--accent);
  box-shadow: inset 0 1px 0 var(--line), inset 0 -1px 0 var(--line);
}

.guide-row:focus-visible {
  outline: none;
  background: var(--bg-row-hover);
  border-left-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-dim);
}

.guide-main {
  min-width: 0;
  overflow: hidden;      /* 좁은 폭에서 칩이 옆 컬럼으로 넘치지 않게 */
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.guide-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;          /* PC 가독성: 14.5px -> 16px */
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-strong);
}

.guide-row:hover .guide-title {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(232, 180, 90, 0.4);
  text-underline-offset: 3px;
}

.guide-cat {
  flex: 0 0 auto;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 11.5px;
  white-space: nowrap;
}

.guide-cat.is-uncategorized {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.guide-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--text-dim);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
}

.guide-author {
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-date::before {
  content: "·";
  margin-right: 7px;
  color: var(--text-faint);
}

.guide-date {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.guide-go {
  justify-self: end;
  color: var(--text-faint);
  font-size: 12.5px;
  white-space: nowrap;
  transition: color 100ms linear, transform 100ms linear;
}

.guide-row:hover .guide-go {
  color: var(--accent);
  transform: translateX(2px);
}

.guide-row:hover .guide-cat {
  border-color: var(--accent-dim);
  color: var(--text);
}

/* 애니메이션을 줄이도록 설정한 사용자에게는 이동 효과를 끈다 */
@media (prefers-reduced-motion: reduce) {
  .guide-row,
  .guide-go { transition: none; }
  .guide-row:hover .guide-go { transform: none; }
}

/* ---------------------------------------------------------------- states */
.empty-state,
.load-error {
  margin: 28px 2px;
  padding: 18px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent-dim);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
}

.load-error code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}

/* ---------------------------------------------------------------- footer */
.footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 14px 28px 26px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: 14px;
  color: var(--text-faint);
  font-size: 11.5px;
}

.footer-meta { margin-left: auto; font-family: var(--font-mono); }

/* ----------------------------------------------------- narrow fallbacks
   PC 우선. 좁은 화면에서 정보 밀도를 유지하되 깨지지 않게만 처리한다. */
@media (max-width: 1400px) {
  .guide-row { grid-template-columns: minmax(0, 1fr) 190px 122px; }
  .search { width: 360px; }
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); gap: 20px; }
  .guide-row { grid-template-columns: minmax(0, 1fr) 170px 40px; }
  .guide-go { font-size: 0; }
  .guide-go::after { content: "→"; font-size: 13px; }
  .search { width: 300px; }
}

/* 창을 크게 좁힌 경우: 한 줄에 밀어넣지 않고 2줄 구조로 전환해 겹침을 막는다.
   (실제 모바일 기기는 viewport width=1200 으로 PC 레이아웃이 축소 표시된다) */
@media (max-width: 900px) {
  .topbar-inner { padding: 0 16px; gap: 16px; }
  .intro, .layout, .footer { padding-left: 16px; padding-right: 16px; }

  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .sidebar { position: static; max-height: none; display: block; }
  .category-nav { display: flex; flex-wrap: wrap; gap: 2px; overflow: visible; }
  .cat-btn { width: auto; grid-template-columns: auto auto auto; }
  .cat-divider { display: none; }
  .sidebar-note { display: none; }

  .guide-row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 3px;
    column-gap: 12px;
    padding: 10px 10px 10px 7px;
  }
  .guide-main { grid-column: 1 / -1; }
  .guide-meta { grid-column: 1; }
  .guide-go { grid-column: 2; grid-row: 2; }

  .search { width: auto; flex: 1 1 auto; min-width: 0; }
  .search-hint { display: none; }
  #search-input { padding-right: 34px; }
}
