/* ==========================================================================
   gallery.css — 저장소 전체 프리뷰 갤러리
   프레임워크 없음. 이 파일은 슬라이드용 CSS와 완전히 분리되어 있다.
   변수명이 겹치지 않는다: 여기는 --bg/--text/--accent, 슬라이드는 --color-bg/--color-text
   ========================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0c0d10;
  --panel: #16181d;
  --panel-2: #1e2128;
  --line: #2a2e37;
  --text: #e8eaed;
  --muted: #8b909b;
  --accent: #6ea8fe;
  --done: #4ade80;
  --wip: #fbbf24;
  --card-w: 380px;      /* = L. gallery.js의 thumbW와 항상 같이 움직인다 (S/M/L 토글) */
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.9em;
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 4px;
}

a { color: var(--accent); }

/* --- 헤더 ------------------------------------------------------------ */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(12, 13, 16, 0.94);
  border-bottom: 1px solid var(--line);
  padding: 20px 32px 14px;
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }

.sub { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* 진척 표시 + 빌더 링크를 한 줄에. 링크가 진척 막대 위로 겹치지 않게 세로 정렬한다 */
.head-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 조합 빌더로 가는 문 — 갤러리에서 유일하게 다른 페이지로 나가는 버튼 */
.to-builder {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid rgba(110, 168, 254, .4);
  border-radius: 999px;
  padding: 7px 16px;
  white-space: nowrap;
}

.to-builder:hover { background: var(--accent); color: #0c0d10; border-color: var(--accent); }

.progress {
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 180px;
}

.progress #count-done  { font-size: 24px; font-weight: 700; color: var(--done); }
.progress .slash       { font-size: 18px; color: var(--muted); margin: 0 2px; }
.progress #count-total { font-size: 18px; color: var(--muted); }
.progress-label        { font-size: 13px; color: var(--muted); margin-left: 6px; }

.bar {
  height: 4px;
  background: var(--panel-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.bar-fill { height: 100%; width: 0; background: var(--done); border-radius: 2px; }

/* --- 컨트롤 ---------------------------------------------------------- */
.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.filters button,
.sizer button {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}

.filters button:hover,
.sizer button:hover { color: var(--text); border-color: #3a3f4a; }

.filters button[aria-pressed="true"],
.sizer button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c0d10;
  font-weight: 600;
}

.n { opacity: 0.6; margin-left: 5px; font-weight: 400; }

/* 썸네일 크기 토글 — L(380)이 기본. 값은 트랙 최소폭의 절반이다(.grid-wide 참고) */
.sizer {
  display: flex;
  gap: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.sizer button { border-radius: 6px; padding: 6px 12px; min-width: 38px; }

#search {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  width: 240px;
  margin-left: auto;
}

#search:focus { outline: none; border-color: var(--accent); }
#search::placeholder { color: var(--muted); }

/* --- 섹션 / 그룹 헤더 ------------------------------------------------- */
main { padding: 8px 32px 32px; }

.section-head {
  font-size: 19px;
  font-weight: 700;
  padding: 36px 0 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.group-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 24px 0 12px;
}

/* 슬라이드 템플릿 섹션의 스타일 탭 — .filters 버튼과 톤을 맞춘다 */
.style-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 4px;
}

.style-tabs button {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}

.style-tabs button:hover { color: var(--text); border-color: #3a3f4a; }

.style-tabs button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c0d10;
  font-weight: 600;
}

.empty,
.empty-group {
  color: var(--muted);
  font-size: 14px;
  padding: 24px 0;
}

.empty { text-align: center; padding: 64px 0; }

/* --- 그리드 ---------------------------------------------------------- */
/* 기본은 고정 폭 — 이미지(media) 카드처럼 늘려도 얻는 게 없는 경우용. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--card-w));
  gap: 20px;
  margin-bottom: 8px;
}

/* HTML 미리보기 카드는 트랙을 넓히고 남는 폭까지 채운다.
   늘려도 흰 여백이 없는 이유: 슬라이드든 다이어그램이든 파일이 self-fit
   스크립트로 컨테이너에 맞춰 스스로 축소한다. 갤러리는 비율만 정해준다.
   min(100%, …)로 감싸 좁은 화면에서 가로 스크롤이 생기지 않게 한다.

   배수가 다른 이유 — 기준은 "미리보기 1장의 폭"이다.
   .grid-wide(다이어그램·컴포넌트)는 카드 = 미리보기 1장 → 2배.
   .grid-pair(슬라이드)는 카드 하나가 표지·전역 2장을 품으므로 3배로 더 넓힌다.
   (4배로 하면 1920 화면에서 M·L이 둘 다 1열이 되어 토글이 무의미해진다) */
.grid-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--card-w) * 2)), 1fr));
}

.grid-pair {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--card-w) * 3)), 1fr));
}

/* --- 카드 ------------------------------------------------------------ */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card:hover { border-color: #3a3f4a; }

.card[data-detail] { cursor: pointer; }
.card[data-detail]:hover { border-color: var(--accent); }

/* 썸네일 — 스크린샷 파이프라인 없이 실제 HTML을 미리보기한다.
   축소는 갤러리가 한다. 예전에는 HTML 파일마다 body.style.zoom 스크립트가 있었지만
   그 zoom이 html.to.design import를 깨서(좌표계가 갈린다) 전부 걷어냈다.
   16/9는 슬라이드 기본값. 다이어그램·컴포넌트는 캔버스 비율이 제각각이라
   gallery.js가 aspect-ratio를 인라인으로 덮는다. */
.thumb {
  position: relative;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid var(--line);
  aspect-ratio: 16 / 9;
}

/* width/height/scale은 gallery.js의 fitFrames()가 인라인으로 덮는다.
   position:absolute가 필수다 — fitFrames가 캔버스 원본 폭(예: 1920px)을 박으므로
   흐름에 남겨두면 그 폭이 grid의 min-content가 되어 .pair-thumbs의 1fr 컬럼이
   1920까지 늘어난다(측정→확대→재측정 되먹임). 흐름에서 빼면 그 고리가 끊긴다. */
.thumb iframe {
  position: absolute;
  top: 0;
  left: 0;
  border: none;
  transform-origin: top left;
  pointer-events: none;   /* 카드 클릭을 iframe이 가로채지 않게 */
}

/* --- 슬라이드 쌍 카드 ------------------------------------------------- */
/* 표지·전역을 2열로. gap 1px이 그대로 구분선이 된다. */
.pair-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
}

.pair-thumbs .shot { position: relative; cursor: zoom-in; }
.pair-thumbs .shot:hover .thumb { outline: 2px solid var(--accent); outline-offset: -2px; }

.pair-thumbs figcaption {
  padding: 4px 0;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.06em;
}

/* 설명 길이가 제각각이어도 카드 높이가 흔들리지 않게 2줄로 자른다 */
.card-pair .card-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.thumb.media {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: repeating-conic-gradient(#e4e4e7 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}

.thumb.media img { max-width: 100%; max-height: 100%; object-fit: contain; }

.thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-2);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}

.thumb-placeholder .dim {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
  opacity: 0.6;
}

.card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.card-head { display: flex; align-items: center; gap: 8px; }

.card-title { font-size: 15px; font-weight: 600; }

.status {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.status.todo { background: var(--panel-2); color: var(--muted); }
.status.wip  { background: rgba(251, 191, 36, .15); color: var(--wip); }
.status.done { background: rgba(74, 222, 128, .15); color: var(--done); }

.card-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }

.card-path {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 10px;
  color: #5a5f6a;
  word-break: break-all;
}

.card-actions { display: flex; gap: 8px; padding: 0 14px 12px; }

.card-actions button,
.card-actions a {
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  text-decoration: none;
  flex: 1;
  text-align: center;
}

.card-actions button:hover,
.card-actions a:hover { color: var(--text); border-color: #3a3f4a; }

.card-actions .primary { color: var(--accent); border-color: rgba(110, 168, 254, .35); }

/* --- 디자인 토큰 ------------------------------------------------------ */
.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* 폰트·타입·간격은 가로로 길어야 견본이 읽힌다 */
.token-grid.font,
.token-grid.fs,
.token-grid.sp { grid-template-columns: 1fr; }

.token {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.token .tname { font-size: 11px; background: none; padding: 0; color: var(--text); }
.token .tval  { font-size: 10px; background: none; padding: 0; color: var(--muted); }
.token .tval em { font-style: normal; opacity: 0.7; }

.token .chip {
  height: 56px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .08);
}

.token .box-sample {
  height: 56px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.token .sp-bar {
  height: 14px;
  background: var(--accent);
  border-radius: 3px;
  min-width: 2px;
}

.token .font-sample { font-size: 22px; line-height: 1.4; }

.token .plain-val {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 18px;
  color: var(--accent);
  word-break: break-all;
}

/* --- 상세 패널: 슬라이드 카드 클릭 시 폰트·색·바로가기만 보여준다 ------ */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.detail-overlay[hidden] { display: none; }

/* 확대 미리보기를 담아야 하므로 폭을 넓힌다. 1080p 화면에서 미리보기가 약 900px. */
.detail-panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: min(1100px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
}

.detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  font: inherit;
  font-size: 16px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.detail-close:hover { color: var(--text); border-color: #3a3f4a; }

.detail-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }

/* 제목 + 표지/전역 탭을 한 줄에. ✕ 버튼과 겹치지 않게 우측 여백을 둔다. */
.detail-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-right: 48px;
  margin-bottom: 12px;
}

.preview-tabs { display: flex; gap: 6px; margin-left: auto; }

.preview-tabs button {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
}

.preview-tabs button[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(110, 168, 254, .45);
}

/* 확대 미리보기 — 썸네일과 완전히 같은 iframe이고 폭만 다르다.
   축소는 gallery.js의 fitFrames()가 한다.
   16/9는 슬라이드 기본값 — 다이어그램은 gallery.js가 인라인으로 덮는다. */
.detail-preview {
  aspect-ratio: 16 / 9;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

.detail-preview { position: relative; }

/* .thumb iframe과 같은 이유로 absolute — 원본 폭이 레이아웃에 새면 안 된다 */
.detail-preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  border: 0;
  display: block;
  transform-origin: top left;
}

.detail-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.actions-label {
  min-width: 34px;
  font-size: 12px;
  color: var(--muted);
}

.detail-actions a,
.detail-actions button {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  flex: 1;
  text-align: center;
}

.detail-actions a:hover,
.detail-actions button:hover { color: var(--text); border-color: #3a3f4a; }

.detail-actions .primary { color: var(--accent); border-color: rgba(110, 168, 254, .35); }

/* --- 토스트 ---------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--accent);
  color: #0c0d10;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  transition: transform .2s ease;
  pointer-events: none;
  max-width: 80vw;
  word-break: break-all;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* --- 푸터 ------------------------------------------------------------ */
.foot {
  border-top: 1px solid var(--line);
  padding: 24px 32px 48px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
