/* ask.css — 💬 웹 물어보기 패널 (templates/_ask_panel.html, static/js/ask.js, docs/web-ask-design.md §1).
 * 모양은 🏆 추천 종목 서랍(drawer.css)과 같은 갈래: 오른쪽에서 나오는 판, 같은 머리·닫기 단추. 색은 전부 tokens.css.
 * PC 는 오른쪽 380px(뒤 페이지는 그대로 — 가림막 없음), 폰(≤768px)은 전체 화면.
 * 배포 순서 주의: 이 파일은 merge 순간 살아나지만 패널 마크업은 재시작 뒤에야 나온다 — 규칙은 새 마크업에만 있는 .ask-* 에만. */

.ask-panel[hidden], .ask-fab[hidden] { display: none; }

/* 떠 있는 단추 — 오른쪽 아래. 패널이 열린 동안은 숨긴다 */
.ask-fab {
    position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 890;
    min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer;
    background: var(--accent); color: var(--text-on-accent); border: 1px solid var(--accent);
    font-size: 14px; font-weight: 700; line-height: 1; white-space: nowrap;
    box-shadow: var(--shadow);
}
.ask-fab:hover { background: var(--accent-hover); }

.ask-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 920;
    width: 380px; max-width: 100vw;
    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;
}
.ask-panel.open { transform: translateX(0); }

.ask-top {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.ask-top h2 { margin: 0; font-size: 16px; color: var(--text-strong); min-width: 0; }
.ask-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;
}
.ask-close:hover { background: var(--bg-hover); }

/* 대화 목록 */
.ask-log {
    flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
    padding: 12px 16px; display: flex; flex-direction: column; gap: 10px;
}
.ask-empty { margin: auto 0; text-align: center; font-size: 13px; line-height: 1.6; color: var(--text-muted); }
.ask-msg {
    max-width: 88%; min-width: 0; padding: 9px 12px; border-radius: var(--radius-lg);
    font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; word-break: break-word;
}
.ask-me {
    align-self: flex-end; white-space: pre-wrap;
    background: var(--accent-soft); color: var(--text-strong); border: 1px solid var(--accent);
    border-bottom-right-radius: 4px;
}
.ask-bot {
    align-self: flex-start;
    background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-soft);
    border-bottom-left-radius: 4px;
}
.ask-bot a { color: var(--accent-text); }
.ask-bot .bf-box {
    margin: 4px 0; padding: 8px 10px; background: var(--bg-inset); border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.ask-bot .bf-foot { margin-top: 8px; color: var(--text-muted); font-size: 12px; }
.ask-wait { color: var(--text-secondary); font-size: 13px; }
.ask-wait::after { content: ' …'; }
.ask-fail { color: var(--text-secondary); }

/* 답 아래 링크 칩 — 같은 창에서 열린다(ask 칩은 그 글을 다시 묻는다) */
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ask-chip {
    display: inline-flex; align-items: center; min-height: 32px; padding: 4px 10px; border-radius: 999px;
    background: var(--bg-inset); color: var(--accent-text); border: 1px solid var(--border);
    font-size: 12.5px; font-weight: 600; text-decoration: none; max-width: 100%; overflow-wrap: anywhere;
}
.ask-chip:hover { background: var(--bg-hover); }

/* 입력 */
.ask-form { display: flex; gap: 8px; padding: 10px 16px 4px; border-top: 1px solid var(--border); }
.ask-input {
    flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: var(--radius);
    background: var(--bg-inset); color: var(--text-primary); border: 1px solid var(--border);
    font-size: 16px;            /* 16px 밑이면 iOS 가 입력할 때 화면을 확대한다 */
}
.ask-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.ask-send {
    flex: none; height: 40px; padding: 0 14px; border-radius: var(--radius); cursor: pointer;
    background: var(--accent); color: var(--text-on-accent); border: 1px solid var(--accent);
    font-size: 14px; font-weight: 700;
}
.ask-send:hover { background: var(--accent-hover); }
.ask-send:disabled { opacity: .5; cursor: not-allowed; }
.ask-hint { margin: 0; padding: 4px 16px calc(12px + env(safe-area-inset-bottom, 0px)); font-size: 11.5px; color: var(--text-muted); }

/* 비로그인 */
.ask-login {
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border);
    text-align: center; font-size: 14px;
}
.ask-login p { margin: 0 0 10px; color: var(--text-secondary); }
.ask-login-link {
    display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 20px;
    border-radius: var(--radius); background: var(--accent); color: var(--text-on-accent);
    font-weight: 700; text-decoration: none;
}
.ask-login-link:hover { background: var(--accent-hover); }

/* 폰 — 전체 화면, 뒤 페이지는 스크롤하지 않는다. 단추는 💬 만 남기지 않고 글자까지(엄지 대상) */
@media (max-width: 768px) {
    .ask-panel { width: 100vw; border-left: 0; }
    body.ask-lock { overflow: hidden; }
    /* 하단 고정 버튼 묶음(.fab-group — 시황 복사/새로고침)이 있는 화면은 그 위로 */
    body:has(.fab-group) .ask-fab { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
    .ask-panel { transition: none; }
}

@media print {
    .ask-fab, .ask-panel { display: none !important; }
}
