/* drawer.css — 🏆 추천 종목 서랍 (templates/_pick_drawer.html, static/js/pick-drawer.js).
 * 색은 전부 tokens.css. 뒤 가림막은 모달과 같은 --scrim 토큰을 쓴다.
 * 배포 순서 주의: 이 파일은 merge 순간 살아나지만 서랍·헤더 버튼 마크업은 재시작 뒤에야 나온다 —
 * 아래 규칙은 새 마크업에만 있는 클래스(.pd*, .pick-drawer-*)에만 걸어 옛 페이지에 영향이 없다. */

/* 헤더 버튼 — 테마 토글(.theme-toggle)과 같은 모양, 글자가 함께 들어가서 폭만 자동 */
.pick-drawer-btn {
    background: var(--bg-inset); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: 6px;
    min-width: 36px; height: 36px; padding: 0 10px;
    font-size: 14px; line-height: 1; white-space: nowrap;
    cursor: pointer; flex: 0 0 auto;
}
.pick-drawer-btn:hover { background: var(--bg-hover); }

/* 서랍이 열린 동안 뒤 페이지는 스크롤하지 않는다 */
body.pd-lock { overflow: hidden; }

/* hidden 속성이 아래 display 규칙에 덮이지 않게 */
.pd[hidden], .pd-backdrop[hidden] { display: none; }

.pd-backdrop {
    position: fixed; inset: 0; z-index: 900;
    background: var(--scrim);
    opacity: 0; transition: opacity .2s;
}
.pd-backdrop.open { opacity: 1; }

.pd {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 910;
    width: min(360px, 92vw);
    display: flex; flex-direction: column;
    background: var(--bg-secondary); color: var(--text-primary);
    border-left: 1px solid var(--border); box-shadow: var(--shadow);
    transform: translateX(100%); transition: transform .2s;
    outline: none;
}
.pd.open { transform: translateX(0); }

.pd-top {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.pd-top h2 { margin: 0; font-size: 16px; color: var(--text-strong); }
.pd-close {
    width: 36px; height: 36px; flex: none; border-radius: 6px; cursor: pointer;
    background: var(--bg-inset); color: var(--text-primary); border: 1px solid var(--border);
    font-size: 14px; line-height: 1;
}
.pd-close:hover { background: var(--bg-hover); }

.pd-tabs { display: flex; gap: 4px; padding: 10px 16px 0; }
.pd-tabs button {
    flex: 1; min-height: 36px; border-radius: 6px; cursor: pointer;
    background: var(--bg-inset); color: var(--text-secondary);
    border: 1px solid var(--border); font-size: 13px; font-weight: 600;
}
.pd-tabs button:hover { background: var(--bg-hover); }
.pd-tabs button[aria-selected="true"] {
    background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent);
}

.pd-list { list-style: none; margin: 0; padding: 10px 16px; flex: 1; overflow-y: auto; }
.pd-list li { margin-bottom: 8px; }
.pd-list li a {
    display: grid; grid-template-columns: 24px 1fr auto; column-gap: 8px; row-gap: 2px; align-items: center;
    padding: 10px 12px; border-radius: var(--radius);
    background: var(--bg-card); border: 1px solid var(--border-soft);
    color: inherit; text-decoration: none;
}
.pd-list li a:hover { background: var(--bg-hover); }
.pd-rank {
    grid-row: 1 / span 2; width: 24px; height: 24px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-inset); color: var(--text-secondary); font-size: 12px; font-weight: 700;
}
.pd-name { font-weight: 700; font-size: 14px; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-score {
    padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
    background: var(--accent-soft); color: var(--accent-text);
}
.pd-engines { font-size: 12px; color: var(--text-muted); }
.pd-price { font-size: 13px; color: var(--text-primary); text-align: right; font-variant-numeric: tabular-nums; }
.pd-loading, .pd-empty { padding: 16px 8px; text-align: center; font-size: 13px; color: var(--text-muted); }

.pd-perf {
    display: block; margin: 0 16px; padding: 10px 12px; border-radius: var(--radius);
    background: var(--accent-soft); color: var(--accent-text);
    font-size: 13px; font-weight: 700; text-align: center; text-decoration: none;
}
.pd-perf:hover { background: var(--bg-hover); }
.pd-note { margin: 0; padding: 10px 16px 16px; font-size: 11px; line-height: 1.5; color: var(--text-muted); }

/* 좁은 화면 — 헤더가 빠듯해서 🏆 만 둔다 */
@media (max-width: 480px) {
    .pick-drawer-label { display: none; }
    .pick-drawer-btn { padding: 0; width: 36px; }
    /* 매매 페이지는 시계·새로고침 버튼이 같은 줄에 있어 🏆 이 더해지면 390px 를 넘는다 — 넘칠 때만 줄바꿈.
       새 마크업(🏆 버튼이 있는 줄)에만 걸어 옛 헤더는 건드리지 않는다 */
    .site-actions:has(.pick-drawer-btn) { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .pd, .pd-backdrop { transition: none; }
}
