/* =========================================================================
   API 투자전략센터 — 전략 스튜디오 (Strategy Studio)
   Top tabs (샘플 페이지 / 전략 샘플) · sub-tabs (OPEN API / xingAPI)
   card grid + modal · board table + pagination
   ========================================================================= */

/* ---------- page hero (compact) ---------- */
.studio-hero { padding-top: 113px; padding-bottom: 40px; position: relative; overflow: hidden; }
.studio-hero__glow { position: absolute; width: 460px; height: 460px; border-radius: 50%; filter: blur(90px); pointer-events: none; z-index: 0; background: radial-gradient(circle, var(--glow-navy), transparent 66%); top: -180px; right: 6%; opacity: 0.6; }
.studio-hero__inner { position: relative; z-index: 1; }
.studio-hero h1 { margin: 0 0 10px; }
/* 부제는 공용 .lead(base.css) 를 쓴다 — 폭만 제한한다. */
.studio-hero .lead { max-width: 640px; }
@media (max-width: 640px) {
  .studio-hero { padding-top: 93px; }
}

/* ---------- top tabs (big segmented) ---------- */
/* 상단 탭은 공용 .gstep-tabs / .gstep-tab (chrome.css) 을 그대로 쓴다 — sticky 밑줄형.
   .top-tabs / .top-tab 은 studio.js 훅으로만 남아 있고 별도 모양 규칙은 없다. */

/* panes */
.studio-pane { display: none; }
.studio-pane.active { display: block; animation: studioFade 0.4s var(--ease-out); }
@keyframes studioFade { from { transform: translateY(10px); } to { transform: none; } }

/* =====================  TAB 1 — sample page  ===================== */
.sample-section { padding: 40px var(--gutter-wide); max-width: 1920px; padding-inline: var(--gutter-wide); }
.sample-bar { display: flex; align-items: end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.sample-bar__tx h3 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 700; }
.sample-bar__tx p { color: var(--text-2); font-size: var(--fs-text-md); line-height: var(--lh-text-md); margin-top: 3px; }
.btn-download { display: inline-flex; align-items: center; gap: 9px; }
.btn-download svg { width: 17px; height: 17px; }

.sample-canvas {
  position: relative; border-radius: var(--r-lg); border: 1px dashed var(--border-strong);
  background: var(--surface); min-height: calc(100vh - 300px); display: grid; place-items: center; overflow: hidden;
}

.sample-canvas--frame { border-style: solid; padding: 0; display: block; overflow: hidden; }
.sample-canvas__iframe { width: 100%; height: calc(100vh - 240px); min-height: 640px; border: 0; display: block; background: #eef2f7; border-radius: calc(var(--r-lg) - 1px); }

/* =====================  TAB 2 — strategy samples  ===================== */
.strat-section { padding-top: 40px; padding-bottom: 3rem; }


/* sub-tabs — 트랙 없는 segmented pill 2개.
   모양·활성색은 공용 .tab(base.css) 이 준다 → 비활성도 테두리+배경이 있는 pill 이다.
   (예전엔 surface-2 트랙 안에 넣고 비활성을 투명 처리했다 — 원본과 형태가 달랐다.) */
.sub-tabs { display: inline-flex; gap: 6px; margin-bottom: 24px; }
.sub-tab .b { font-family: var(--font-sans); font-size: var(--fs-badge); line-height: var(--lh-badge); padding: 1px 5px; border-radius: 4px; background: var(--chip-bg); color: var(--chip-text); border: 1px solid var(--chip-border); }
.sub-tab.active .b { background: rgba(255,255,255,0.18); color: rgba(255,255,255,0.82); border-color: transparent; }
.sub-pane { display: none; }
.sub-pane.active { display: block; animation: studioFade 0.35s var(--ease-out); }

/* filter bar (now: search + count) */
.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.strat-search { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 240px; max-width: 420px; padding: 11px 18px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border-strong); transition: border-color 0.18s; }
.strat-search:focus-within { border-color: var(--border-glow); }
.strat-search svg { width: 18px; height: 18px; color: var(--text-dim); flex-shrink: 0; }
.strat-search input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text); font-size: var(--fs-input); line-height: var(--lh-input); font-family: var(--font-sans); }
.strat-search input::placeholder { color: var(--text-dim); }
.filter-count { font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); color: var(--text-dim); white-space: nowrap; }
.filter-count b { color: var(--text); font-family: var(--font-sans); font-weight: 700; }
/* ---------- 지연 로딩 자리 ----------
   탭을 열 때 비로소 조회하므로, 데이터가 오기 전 자리가 비어 있으면(높이 0) 콘텐츠가
   들어오는 순간 화면이 튄다. 그래서 실제 높이만큼 자리를 미리 잡고 스피너를 보여준다.
   htmx 가 outerHTML 로 통째로 교체하므로 응답이 오면 이 블록은 그냥 사라진다.
   문구·스피너 규격은 API 가이드의 .detail-loading 과 같게 맞췄다.
   spin 키프레임이 apiguide.css 에만 있어서 이 페이지에서는 회전이 죽어 있었다 —
   여기 두면 백테스팅 버튼·다운로드 버튼 스피너도 같이 살아난다. */
@keyframes spin { to { transform: rotate(360deg); } }
.studio-skel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-dim); font-size: 0.85rem; }
.studio-skel .spin { width: 24px; height: 24px; border: 2.5px solid var(--border-strong); border-top-color: var(--accent-cyan); border-radius: 50%; animation: spin 0.7s linear infinite; }
/* 카드 한 줄(343px) 높이만 잡는다 — 그 아래로 늘어나는 건 화면 밖이라 눈에 띄지 않는다. */
.studio-skel--grid { grid-column: 1 / -1; min-height: 343px; }
/* 표 6행 + 페이지네이션 실측 높이. */
.studio-skel--board { min-height: 526px; }

.strat-empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-dim); }
.strat-empty svg { width: 42px; height: 42px; color: var(--text-inactive); margin-bottom: 14px; }
.strat-empty p { font-size: var(--fs-text-md); line-height: var(--lh-text-md); }

/* strategy card grid */
.strat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.scard {
  display: flex; flex-direction: column; border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card);
  cursor: pointer; transition: transform 0.28s var(--ease), border-color 0.28s, box-shadow 0.28s;
}
.scard:hover { transform: translateY(-6px); border-color: var(--border-glow); box-shadow: var(--shadow-float); }
.scard__thumb { position: relative; aspect-ratio: 16 / 10; overflow: hidden; border-bottom: 1px solid var(--border); background: linear-gradient(150deg, var(--surface-2), var(--surface)); }
.scard__ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.scard__ph::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px); background-size: 22px 22px; -webkit-mask-image: radial-gradient(80% 80% at 50% 45%, #000, transparent 78%); mask-image: radial-gradient(80% 80% at 50% 45%, #000, transparent 78%); }
.scard__ph::after { content: ""; position: absolute; inset: 0; background: radial-gradient(90% 80% at 50% 30%, var(--sc-glow, rgba(52,225,255,0.18)), transparent 62%); }
.scard__glyph { position: relative; width: 84px; height: auto; color: var(--sc-accent, var(--accent-cyan)); filter: drop-shadow(0 4px 14px var(--sc-glow, rgba(52,225,255,0.3))); }
.scard__ph-label { position: relative; font-family: var(--font-sans); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); padding: 4px 12px; border-radius: var(--r-pill); background: var(--surface-solid); border: 1px solid var(--border); }
.scard__thumb--ma   { --sc-accent: #5ba8ff; --sc-glow: rgba(91,168,255,0.22); }
.scard__thumb--rsi  { --sc-accent: var(--accent-cyan); --sc-glow: rgba(52,225,255,0.22); }
.scard__thumb--bb   { --sc-accent: #9f7aea; --sc-glow: rgba(159,122,234,0.24); }
.scard__thumb--macd { --sc-accent: var(--color-success); --sc-glow: rgba(43,214,110,0.22); }
.scard__thumb--auto { --sc-accent: var(--color-warning); --sc-glow: rgba(240,176,114,0.24); }
.scard__badge { position: absolute; z-index: 2; top: 12px; left: 12px; font-family: var(--font-sans); font-size: var(--fs-badge); line-height: var(--lh-badge); padding: 4px 10px; border-radius: var(--r-pill); background: rgba(6,8,15,0.66); border: 1px solid var(--border-strong); color: #cdd6f4; backdrop-filter: blur(6px); }
:root[data-theme="light"] .scard__badge { background: rgba(255,255,255,0.9); color: var(--text-2); }
.scard__body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.scard__name { font-size: var(--fs-title-sub); line-height: var(--lh-title-sub); font-weight: 700; letter-spacing: -0.02em; }
.scard__desc { color: var(--text-dim); font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

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

/* =====================  MODAL  ===================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(4,7,15,0.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  position: relative;
  width: min(720px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-float); overflow: hidden; transform: translateY(18px) scale(0.98);
  transition: transform 0.32s var(--ease);
}
.modal-overlay.open .modal { transform: none; }
.modal__close { position: absolute; top: 16px; right: 16px; z-index: 5; width: 38px; height: 38px; display: grid; place-items: center; color: var(--text-2); transition: color 0.2s, background-color 0.2s, border-color 0.2s; }
.modal__close svg { width: 24px; height: 24px; }

/* responsive: stack to single column, keep X inside the dialog */
@media (max-width: 820px) {
  .modal-overlay { padding: 0; align-items: stretch; justify-content: stretch; }
  .modal { width: 100%; max-height: 100vh; height: 100%; border-radius: 0; overflow-y: auto; }
  .modal__body { flex: 0 0 auto; overflow-y: visible; }
  .modal__close { position: fixed; top: 14px; right: 14px; background: var(--surface-solid); }
}

/* modal body — 단일 컬럼. 좌측 썸네일·통계는 두지 않는다(마크업도 없다). */
.modal__conds { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.cond { padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); }
.cond__h { display: flex; align-items: center; gap: 8px; font-size: var(--fs-text-md); line-height: var(--lh-text-md); font-weight: 700; margin-bottom: 8px; }
.cond__h .ic { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; }
.cond--enter .ic { background: rgba(43,214,110,0.15); color: var(--color-success); } .cond--enter .ic svg { width: 13px; height: 13px; }
.cond--exit .ic { background: rgba(255,107,129,0.15); color: var(--color-rose); } .cond--exit .ic svg { width: 13px; height: 13px; }
.cond ul { display: flex; flex-direction: column; gap: 6px; }
.cond li { position: relative; padding-left: 16px; font-size: var(--fs-text-sm); color: var(--text-2); line-height: var(--lh-text-sm); }
.cond li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--text-inactive); }

.modal__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 30px 28px; }
.modal__tags { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }
.modal__tag { font-family: var(--font-sans); font-size: var(--fs-badge); line-height: var(--lh-badge); color: var(--chip-text); padding: 4px 10px; border-radius: var(--r-pill); background: var(--chip-bg); border: 1px solid var(--chip-border); }
.modal__title { font-size: var(--fs-h2); font-weight: 800; letter-spacing: -0.025em; line-height: var(--lh-h2); margin-bottom: 12px; }
.modal__desc { color: var(--text-2); font-size: var(--fs-text-md); line-height: var(--lh-text-md); margin-bottom: 22px; }
.modal__sec-title { display: flex; align-items: center; gap: 9px; font-size: var(--fs-title-sub); line-height: var(--lh-title-sub); font-weight: 700; margin: 22px 0 12px; }
.modal__sec-title .bar { width: 3px; height: 15px; border-radius: 2px; background: var(--accent-prime); }

.param-table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); }
.param-table th, .param-table td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--border); }
.param-table thead th { background: var(--surface-2); font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-2); }
.param-table tbody tr:last-child td { border-bottom: none; }
.param-table .pn { font-family: var(--font-mono); font-weight: 600; color: var(--text); }
.param-table .pv { font-family: var(--font-mono); color: var(--code-num); }
.param-table .pd { color: var(--text-dim); }

.modal__langs { display: flex; gap: 4px; margin: 4px 0 0; }
.modal__lang { padding: 7px 14px; border-radius: var(--r-pill); font-size: 0.8rem; font-weight: 600; color: var(--text-muted); transition: color 0.18s, background-color 0.18s; }
.modal__lang:hover { color: var(--text); background: var(--surface-2); }
.modal__lang.active { color: var(--on-accent); background: var(--accent-grad); }
.modal__code .codeblock { margin-top: 10px; }
.modal__code .codeblock__body { max-height: 280px; overflow: auto; }

@media (max-width: 820px) {
  .modal { max-height: 92vh; overflow-y: auto; }
  .modal__body { flex: 0 0 auto; overflow-y: visible; }
}

/* =====================  xingAPI board  =====================
   테이블(No·제목·카테고리·등록일·액션 5열)에서 파일 탐색기형 행 리스트로 개편.
   정렬 기능은 원본에서 제거돼 여기에도 없다(총건수만 남는다).
   행 전체가 다운로드 트리거라 <a>/<button> 이 .board-row 를 직접 쓴다.
   ========================================================== */
.board-toolbar { display: flex; align-items: center; margin-bottom: 12px; }
.board-count { margin-left: auto; font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); color: var(--text-dim); white-space: nowrap; }
.board-count b { color: var(--text); font-family: var(--font-sans); font-weight: 700; }

.board-list { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.board-list__head { display: flex; align-items: center; gap: 30px; padding: 13px 22px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.board-list__head-cat { flex: 0 0 86px; text-align: center; font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); font-weight: 700; color: var(--text-2); letter-spacing: 0.01em; }
.board-list__head-main { flex: 1; font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); font-weight: 700; color: var(--text-2); letter-spacing: 0.01em; }

/* width:100%/text-align:left — <button> 이 행으로 쓰일 때 기본값을 <a> 와 맞춘다 */
.board-row {
  display: flex;
  align-items: center;
  gap: 30px;
  width: 100%;
  text-align: left;
  padding: 16px 22px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface-solid);
  cursor: pointer;
  transition: background-color 0.14s ease;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-decoration: none;
  float: none;
  -webkit-appearance: none;
  appearance: none;
}

.board-row:last-child { border-bottom: none; }
.board-list__body .board-row::before,.board-list__body .board-row::after{display: none}
.board-row:hover, .board-row:focus-visible { background: var(--surface-hover); }
.board-row:focus-visible { outline: 2px solid var(--border-glow); outline-offset: -2px; }
.board-row.done { background: var(--surface-blue); }
.board-row__cat { flex: 0 0 86px; display: flex; justify-content: center; }
.cat-pill { display: inline-block; width: 78px; box-sizing: border-box; text-align: center; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-sans); font-size: var(--fs-badge); line-height: var(--lh-badge); font-weight: 500; color: var(--chip-text); background: var(--chip-bg); border: 1px solid var(--chip-border); padding: 3px 10px; border-radius: var(--r-pill); white-space: nowrap; }
.board-row__main {flex: 1;  min-width: 0; }
/*.board-row__main { display:flex; flex: 1; align-items: center; min-width: 0; }*/
/*.board-row__title { display: flex; flex-direction: column; width: 100%; gap: 8px; font-size: var(--fs-text-md); line-height: var(--lh-text-sm); font-weight: 600; color: var(--text); margin-bottom: 3px; }*/
.board-row__title { display: flex; gap: 8px; font-size: var(--fs-text-md); line-height: var(--lh-text-sm); font-weight: 600; color: var(--text); margin-bottom: 3px; }
.board-row__title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-new { flex-shrink: 0; font-family: var(--font-sans); font-size: 0.6rem; font-weight: 700; color: var(--color-success); background: rgba(43,214,110,0.14); border: 1px solid rgba(43,214,110,0.3); padding: 1px 6px; border-radius: var(--r-pill); }
.board-row__meta { display: flex; align-items: center; gap: 8px; font-family: var(--font-sans); font-size: var(--fs-badge); line-height: var(--lh-badge); color: var(--text-dim); white-space: nowrap; }
.board-row__meta .sep { opacity: 0.5; }
.board-row__dl { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text); opacity: 1; transition: opacity 0.16s ease, transform 0.16s ease, background-color 0.16s ease, color 0.16s ease; }
.board-row:hover .board-row__dl, .board-row:focus-visible .board-row__dl { background: var(--surface-2); }
.board-row.done .board-row__dl { color: var(--chip-text); background: var(--chip-bg); }

/* 진짜 hover 가 있는 데스크톱에서만 "hover 전까지 숨김" 연출을 쓴다.
   터치 기기에서는 hover 가 없어 아이콘이 영영 안 보이므로 항상 노출한다. */
@media (hover: hover) and (pointer: fine) {
  .board-row__dl { opacity: 0; transform: translateX(-6px); }
  .board-row:hover .board-row__dl, .board-row:focus-visible .board-row__dl { opacity: 1; transform: translateX(0); }
  .board-row.done .board-row__dl { opacity: 1; transform: translateX(0); }
}
.board-row__dl svg { width: 17px; height: 17px; }

@media (max-width: 520px) {
  .board-toolbar { flex-wrap: wrap; row-gap: 6px; }
  .board-list__head, .board-row { gap: 14px; padding-inline: 14px; }
  .board-list__head-cat, .board-row__cat { flex-basis: 68px; }
  .cat-pill { width: 62px; padding: 3px 6px; }
  /* 좁은 화면에서는 메타의 카테고리를 지운다 — 왼쪽 pill 과 중복이다 */
  .board-row__meta span:first-child, .board-row__meta .sep { display: none; }
}
