/* =========================================================================
   API 투자전략센터 — Base / Reset / Typography / Utilities
   ========================================================================= */

*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; padding: 0; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
/* ---------- scrollbar (shared, all pages/panels) ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-inactive); background-clip: content-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

/* scale down all rem-based font sizes on mobile */
@media (max-width: 480px) {
  html { font-size: 91.875%; } /* 16px -> 14.7px base */
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
ul { list-style: none; }
::selection { background: rgba(52, 225, 255, 0.28); color: var(--text); }

/* mouse-follow ambient spotlight (shared, all pages) — see common.js */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg-grad);
  z-index: -2;
  pointer-events: none;
}

/* ambient background texture — sparse dot mesh (replaces old fine grid) */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(var(--grid-line) 1.1px, transparent 1.1px);
  background-size: 34px 34px;
  background-position: -8px -8px;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 30%, transparent 74%);
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 30%, transparent 74%);
  z-index: -1;
  pointer-events: none;
}

/* ----------  Type scale  ---------- */
.display {
  font-size: clamp(2rem, 4.4vw, 5rem);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -0.035em;
}
.h1 { font-size: clamp(2.1rem, 4vw, 3.1rem); line-height: 1.4; font-weight: 800; letter-spacing: -0.03em; }
/* subpage top titles (Figma node 606-7898): 44px / Bold / Text-strong, only applies to actual <h1> tags —
   index.html reuses .h1 on <h2> section headers, which stay untouched */
h1.h1 { font-size: clamp(2.1rem, 4vw, var(--fs-h1)); font-weight: 800; line-height: 1.45; letter-spacing: 0; color: var(--text); }
.h2 { font-size: clamp(1.7rem, 3vw, 2.5rem); line-height: 1.14; font-weight: 700; letter-spacing: -0.026em; }
.h3 { font-size: clamp(1.2rem, 1.8vw, 1.45rem); line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; }
.lead { font-size: var(--fs-text-md); line-height: var(--lh-text-md); color: var(--text-2); font-weight: 400; }

/* subpage hero title/description — mobile size (Figma 853:685: 24px title / 14px desc) */
@media (max-width: 640px) {
  h1.h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); }
  .lead { font-size: var(--fs-text-md); line-height: var(--lh-text-md); }
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 1.2rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--chip-text);
}
.mono { font-family: var(--font-mono); }

/* gradient text */
.grad-text {
  color: var(--text-accent);
}

/* ----------  Layout helpers  ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--space-section); position: relative; }
.section-head { max-width: 720px; margin-bottom: clamp(40px, 5vw, 64px); }
.section-head.center { margin-inline: auto; text-align: center; }
.section-head .lead { margin-top: 18px; max-width: 620px; }
.section-head.center .lead { margin-inline: auto; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: var(--r-pill);
  background: var(--chip-bg); color: var(--chip-text);
  border: 1px solid var(--chip-border);
  font-size: var(--fs-badge); line-height: var(--lh-badge); font-weight: 600; letter-spacing: 0.01em;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-cyan); box-shadow: 0 0 10px var(--glow-cyan); }

/* ----------  Tab — 공용 pill 탭  ----------
   자료실·공지 카테고리 필터, API가이드 언어탭, 스튜디오 서브탭이 공유한다.
   컨텍스트 클래스(.board-tab/.lang-tab/.sub-tab/.top-tab)는 JS 훅과 국소 오버라이드용으로
   함께 붙여 두고, 모양은 여기서 한 번만 정의한다.
   .api-type 은 pill 이 아니라 토글이고 .top-tabs 는 밑줄 탭이라 각자 base 를 덮는다. */
.tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 20px; border-radius: var(--r-pill);
  font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); font-weight: 600; white-space: nowrap; flex-shrink: 0;
  color: var(--text-dim); background: rgba(68,70,77,0.2); border: 1px solid rgba(117,120,125,0.32);
  transition: color 0.18s, background-color 0.18s, border-color 0.18s, box-shadow 0.18s;
}
:root[data-theme="light"] .tab { background: #ffffff; border-color: rgba(68,70,77,0.2); }
.tab:hover { color: var(--text-2); background: var(--surface-blue); }
.tab.active { color: #ffffff; background: #1d78f0; border-color: transparent; box-shadow: none; }
:root[data-theme="light"] .tab.active { background: #2250e3; }

/* 맨바닥에 놓이는 탭 — 비활성은 투명하고 활성만 채운다. 현재 사용처는 API가이드 언어탭.
   원본은 이 초기화를 컨텍스트마다 `.X .tab:not(.active){background:none;border:none}` 로
   반복하는데, 같은 개념이라 모디파이어 하나로 모았다.
   (게시판 탭·전략 서브탭은 비활성도 테두리가 있는 pill 이라 이 모디파이어를 쓰지 않는다.) */
.tab--plain:not(.active) { background: none; border-color: transparent; }
.tab--plain:not(.active):hover { background: var(--surface-hover); border-color: transparent; }

/* ----------  Board search — 목록 위 필터 행에 들어가는 컴팩트 pill 입력  ----------
   공지·자료실이 공유한다. 히어로에 놓이는 큰 .search-field(chrome.css)와 달리
   탭과 한 줄에 서도록 폭·높이가 고정돼 있다. */
.board-search { display: flex; align-items: center; gap: 10px; width: 273px; max-width: 100%; height: 40px; padding: 5px 8px 5px 20px; border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--surface-2); flex-shrink: 0; transition: border-color 0.2s, box-shadow 0.2s; }
.board-search:focus-within { border-color: var(--border-glow); }
.board-search__input { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; background: none; border: none; outline: none; color: var(--text); font-size: var(--fs-input); line-height: var(--lh-input); font-family: var(--font-sans); }
.board-search__input::placeholder { color: var(--text-dim); }
.board-search__btn { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: none; color: var(--text-dim); flex-shrink: 0; transition: color 0.18s; }
.board-search__btn:hover { color: var(--text); }
.board-search__btn svg { width: 18px; height: 18px; }

/* 모바일: pill 탭 라벨과 btn-sm 을 한 크기로 통일한다.
   `html body` 접두어는 나중에 로드되는 페이지 CSS(studio/start)가 같은 셀렉터를
   다시 선언해도 이 규칙이 이기게 하려고 붙인다. */
@media (max-width: 640px) {
  /* 터치에는 진짜 hover 가 없어 탭 뒤에 들뜸·그림자가 그대로 남는다 — 모바일에서는 끈다 */
  .btn:hover, .btn-primary:hover, .btn-white:hover, .btn-ghost:hover { box-shadow: none; transform: none; }
  html body .tab,
  html body .code-lang,
  html body .btn-sm { font-size: var(--fs-text-md); line-height: var(--lh-text-md); }

  /* 밑줄형 상단 탭(체험하기/전략샘플 등)은 16px 유지 */
  html body .top-tabs .tab,
  html body .gstep-tab { font-size: var(--fs-title-sub); line-height: var(--lh-title-sub); }
}

/* ----------  Buttons  ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 14px 26px; border-radius: var(--r-pill);
  font-weight: 600; font-size: var(--fs-text-md); line-height: var(--lh-text-md); letter-spacing: -0.01em;
  border: 1px solid transparent; white-space: nowrap;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease),
    background-color 0.25s var(--ease), border-color 0.25s var(--ease), opacity 0.2s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px) scale(0.99); }

.btn-primary {
  background: var(--btn-primary-bg); color: var(--btn-primary-text);
 
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 44px -12px var(--glow-cyan), 0 1px 0 rgba(255,255,255,0.3) inset; }

.btn-ghost {
  color: var(--text);
  border-color: var(--border-strong);
  backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: var(--surface-hover); transform: translateY(-2px); }

.btn-white { background: #fff; color: #323232; }
.btn-white:hover { transform: translateY(-2px); box-shadow: 0 16px 36px -14px rgba(0,0,0,0.4); color: var(--accent-prime); }
.btn-outline {
  background: transparent; color: var(--text); border-color: var(--border-strong);
}
.btn-outline:hover { border-color: var(--border-glow); background: var(--surface); }

.btn-lg { padding: 17px 34px; font-size: var(--fs-text-md); line-height: var(--lh-text-md); }
.btn-sm { padding: 10px 18px; font-size: var(--fs-text-sm); line-height: var(--lh-text-sm); }

/* ----------  Reveal on scroll  ---------- */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
.reveal--instant { transition: none !important; }
.reveal[data-d="1"] { transition-delay: 0.08s; }
.reveal[data-d="2"] { transition-delay: 0.16s; }
.reveal[data-d="3"] { transition-delay: 0.24s; }
.reveal[data-d="4"] { transition-delay: 0.32s; }
.reveal[data-d="5"] { transition-delay: 0.40s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
