/* =========================================================================
   API 투자전략센터 — 자료실 (Downloads / Library)
   shares notice.css patterns; adds search-with-scope, 2-row filters,
   file table with download buttons.
   ========================================================================= */

/* ---------- hero (left-aligned, matches 공지사항) ---------- */
.lib-hero { padding-top: 113px; position: relative; overflow: hidden; }
.lib-hero__glow { position: absolute; width: 460px; height: 440px; border-radius: 50%; filter: blur(90px); pointer-events: none; z-index: 0; background: radial-gradient(circle, var(--glow-navy), transparent 66%); top: -170px; right: 5%; opacity: 0.6; }
.lib-hero__inner { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.lib-hero__tx .chip { margin-bottom: 16px; }
.lib-hero__tx h1 { margin: 0 0 10px; }
/* 부제는 공용 .lead(base.css) 를 쓴다 — 여기서 크기를 다시 정하지 않는다. */
/* 필터 행 — 좌:탭 / 우:검색 한 줄. 원본과 같이 목록 바로 위에 둔다. */
.lib-filter-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 1rem; }
.lib-filter-row .board-tabs { padding-bottom: 0; }

/* 좁은 화면에서는 탭 줄과 검색 줄을 위아래로 나눈다.
   한 줄에 같이 두면 탭이 늘어날수록 검색칸이 눌려 30px 짜리 껍데기만 남는다. */
@media (max-width: 640px) {
  .lib-hero { padding-top: 93px; }
  .lib-filter-row { gap: 10px; }
  .lib-filter-row .board-tabs { flex: 1 1 100%; min-width: 0; }
  .lib-filter-row .board-search { flex: 1 1 100%; width: auto; min-width: 0; }
}

/* ---------- body ---------- */
.lib-body { padding-block: clamp(28px, 3.5vw, 42px) var(--space-section); }

/* category tab row — uses shared .board-tabs/.board-tab (chrome.css) */

/* list top bar */
.lib-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 2px 10px; flex-wrap: wrap; }
.lib-total { font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); color: var(--text-dim); }
.lib-total b { color: var(--text); font-family: var(--font-sans); }

/* ---------- table ---------- */
.lib-table { width: 100%; border-collapse: separate; border-spacing: 0; border-top: 2px solid var(--border-strong); }
.lib-table thead th { font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); font-weight: 700; color: var(--text-dim); text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lib-table thead th.c-no, .lib-table thead th.c-cat, .lib-table thead th.c-date, .lib-table thead th.c-views, .lib-table thead th.c-dl { text-align: center; }
.lib-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); vertical-align: middle; }
.lib-table tbody tr { background-color: var(--bg); transition: background-color 0.16s; }
.lib-table tbody tr:not(.is-pinned):nth-child(even) { background: var(--surface); }
.lib-table tbody tr:hover { background: var(--surface-hover); }

.lib-table .c-no { text-align: center; font-family: var(--font-sans); color: var(--text-inactive); font-size: var(--fs-code-chip); line-height: var(--lh-code-chip); width: 64px; }
.lib-table .c-cat { text-align: center; width: 116px; }
.lib-table .c-date { text-align: center; font-family: var(--font-sans); font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); color: var(--text-dim); white-space: nowrap; width: 116px; }
.lib-table .c-views { text-align: center; font-family: var(--font-sans); font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); color: var(--text-dim); width: 86px; }
.lib-table .c-dl { text-align: center; width: 120px; }

/* category badge */
/* 분류 — 원본은 테두리·배경 없는 dim 텍스트다(색으로 구분하지 않는다). */
.lib-cat-badge { display: inline-block; font-size: var(--fs-code-chip); line-height: var(--lh-code-chip); font-weight: 400; color: var(--text-dim); white-space: nowrap; letter-spacing: -0.01em; }

/* type badge (release / debug) */
.lib-type-badge { flex-shrink: 0; font-size: 0.68rem; font-weight: 700; padding: 3px 8px; border-radius: 5px; white-space: nowrap; margin-left: 2px; }
.lib-type-badge.release { color: var(--color-success); background: rgba(43,214,110,0.13); border: 1px solid rgba(43,214,110,0.3); }
.lib-type-badge.debug   { color: var(--text-dim); background: var(--surface-2); border: 1px solid var(--border-strong); }
.lib-type-badge.python     { color: #5ba8ff; background: rgba(91,168,255,0.13); border: 1px solid rgba(91,168,255,0.32); }
.lib-type-badge.java       { color: var(--color-warning); background: rgba(240,176,114,0.14); border: 1px solid rgba(240,176,114,0.34); }
.lib-type-badge.javascript { color: #e6cf5a; background: rgba(230,207,90,0.14); border: 1px solid rgba(230,207,90,0.34); }
:root[data-theme="light"] .lib-type-badge.python   { color: #0a4ba0; }
:root[data-theme="light"] .lib-type-badge.java     { color: #b9651b; }
:root[data-theme="light"] .lib-type-badge.javascript { color: #9a861f; }
:root[data-theme="light"] .lib-type-badge.release { color: #167c43; }

/* title cell */
.c-title { color: var(--text); }
.file-title { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; min-width: 0; background: none; border: none; padding: 0; text-align: left; font: inherit; color: var(--text); width: 100%; }
.file-title__chev { width: 17px; height: 17px; color: var(--text-inactive); flex-shrink: 0; transition: transform 0.28s var(--ease), color 0.18s; margin-left: 2px; }
.file-title.open .file-title__chev { transform: rotate(180deg); color: var(--accent-prime); }
.file-title.open .file-title__t { color: var(--chip-text); }
.file-title__t { font-weight: 500; font-size: var(--fs-text-md); line-height: var(--lh-text-md); transition: color 0.16s; }
.file-title:hover .file-title__t { color: var(--chip-text); }
.c-title .hl { background: rgba(52,225,255,0.26); color: var(--text); border-radius: 3px; padding: 0 2px; }

/* expandable detail row */
.lib-detail-row > td { padding: 0 !important; border-bottom: 1px solid var(--border); transition: background-color 0.3s var(--ease); }
.lib-detail { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s var(--ease); }
.lib-detail-row.open .lib-detail { grid-template-rows: 1fr; }
.lib-detail__inner { overflow: hidden; }
.lib-detail-row.open > td { background: var(--bg); }
.lib-detail__inner > div { display: flex; gap: 14px; align-items: flex-start; padding: 22px 26px; flex-wrap: wrap; }
.lib-detail__main { flex: 1; min-width: 0; }
.lib-detail__meta { display: flex; flex-wrap: wrap; gap: 5px 22px; }
.ldm { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); color: var(--text-2); }
.ldm b { font-weight: 600; color: var(--text-dim); font-size: var(--fs-badge); line-height: var(--lh-badge); }
.lib-detail__desc { font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); color: var(--text-2); max-width: 640px; margin: 0; }
@media (max-width: 620px) {
  .lib-detail__inner > div { padding: 12px; }
}

/* pinned rows */
.lib-table tr.is-pinned { background: var(--surface); }
.lib-table tr.is-pinned:hover { background: var(--surface-hover); }
.lib-table tr.is-pinned td { border-bottom-color: var(--border); }
.lib-table tr.is-pinned .file-title__t { font-weight: 500; }
.pin-ic { color: var(--chip-text); display: inline-flex; }
.pin-ic svg { width: 15px; height: 15px; }

/* download button */
.dl-btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: var(--r-pill); font-size: var(--fs-code-chip); line-height: var(--lh-code-chip); font-weight: 600; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); transition: color 0.18s, border-color 0.18s, transform 0.18s, background-color 0.18s; white-space: nowrap; }
.dl-btn:hover { border-color: var(--border-glow); background: var(--surface-hover); transform: translateY(-1px); }
.dl-btn.done { color: var(--chip-text); border-color: var(--chip-border); background: var(--chip-bg); }
.dl-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* empty */
.lib-empty { text-align: center; padding: 70px 20px; color: var(--text-dim); }
.lib-empty svg { width: 46px; height: 46px; color: var(--text-inactive); margin: 0 auto 16px; }
.lib-empty b { color: var(--text); }

/* pagination (reuse notice look) */

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .lib-hero__inner { flex-direction: column; align-items: stretch; }
  .lib-table .c-no, .lib-table thead .c-no,
  .lib-table .c-views, .lib-table thead .c-views { display: none; }
  /* 표가 화면 밖으로 나가던 원인은 제목 칸이다 — 칸 폭이 제목의 max-content 를 따라가고,
     그러면 안쪽 .file-title__t 의 width:100%·말줄임도 기준이 없어 안 먹는다.
     max-width:0 으로 이 칸의 최대콘텐츠 기여를 0 으로 만들면 남는 폭만 받아 간다.
     (table-layout:fixed 는 답이 아니다 — display:none 인 열도 auto 열로 남아 폭을 1/n 로 나눠 간다) */
  .lib-table .c-title, .lib-table thead .c-title { max-width: 0; width: 100%; }
  .file-title__t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
}
@media (max-width: 520px) {
  .lib-table .c-date, .lib-table thead .c-date { display: none; }
  .lib-table .c-cat, .lib-table thead .c-cat { display: none; }
  .lib-table td { padding: 12px; }
  .lib-table thead th { padding: 14px 12px; }
  .lib-table .c-dl, .lib-table thead .c-dl { width: 104px; }
  .dl-btn { padding: 9px 11px; gap: 5px; }
  .file-title { gap: 8px; }
  .file-title__t { font-size: 0.9375rem; }
  /* 종류 배지는 제목이 먹을 폭을 그만큼 뺏는다 — 좁은 화면에서는 내린다(분류·작성일과 같은 처리). */
  .lib-type-badge { display: none; }
}
