/* context.css — '대화의 비밀' 페이지 전용 스타일
   (패널·버튼 등 공용 부품은 components.css를 그대로 사용) */

:root {
  --user-color: #4f46e5;   /* indigo-600 — 내 메시지 */
  --ai-color: #10b981;     /* emerald-500 — AI 메시지 */
  --ok-color: #22c55e;     /* green-500  */
  --warn-color: #f59e0b;   /* amber-500  */
  --bad-color: #ef4444;    /* red-500    */
}

/* ── 2단 무대: 채팅 화면 ↔ 전송 묶음 ── */
.chat-stage {
  display: grid;
  grid-template-columns: 1.05fr auto 1fr;
  gap: 14px;
  align-items: stretch;
  margin-top: 36px;
}

/* ── 왼쪽: 채팅 화면 ── */
.panel-chat,
.panel-bundle {
  min-height: 520px;
  max-height: 620px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 6px 4px 2px;
}

.chat-placeholder,
.bundle-placeholder {
  margin: auto;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.95rem;
  white-space: pre-line;
}

.bubble {
  max-width: 88%;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.93rem;
  line-height: 1.55;
  animation: pop-in 0.3s ease backwards;
  position: relative;
}

.bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.bubble-ai {
  align-self: flex-start;
  background: var(--track);
  border: 1px solid var(--panel-border);
  border-bottom-left-radius: 4px;
}

.bubble-system {
  align-self: center;
  max-width: 96%;
  background: var(--accent-soft);
  border: 1.5px dashed var(--accent-border);
  color: var(--accent-deep);
  font-size: 0.88rem;
}

.bubble-text {
  margin: 0;
}

.bubble-tokens {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  opacity: 0.75;
  font-family: Consolas, "Courier New", monospace;
  text-align: right;
}

/* 긴 글 붙여넣기 칩 */
.paste-chip {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  font-size: 0.78rem;
  padding: 3px 10px;
  margin-bottom: 6px;
}

/* AI 생각 중… 말풍선 */
.bubble-typing .typing-dots {
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: var(--text-soft);
  animation: blink 1.1s infinite;
}

/* ── 오른쪽: 전송 묶음 패널 ── */
.req-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.req-tokens {
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.5rem;
  color: var(--accent);
}

.bundle-frame {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 2px dashed var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 26px 14px 14px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bundle-tag {
  position: absolute;
  top: -1px;
  left: -1px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid var(--accent-border);
  border-radius: 0 0 var(--radius-sm) 0;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 10px;
}

/* 전송 중: 묶음 전체가 강조되며 흔들림 */
.bundle-frame.sending {
  border-color: var(--accent);
  border-style: solid;
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: bundle-send 0.55s ease-in-out infinite;
}

@keyframes bundle-send {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-6px); }
}

.bundle-stack {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.msg-block {
  min-height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 1px 8px;
  animation: pop-in 0.3s ease backwards;
  flex-shrink: 0;
}

.block-user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--user-color) 14%, white);
  border: 1px solid color-mix(in srgb, var(--user-color) 45%, white);
}

.block-ai {
  align-self: flex-start;
  background: color-mix(in srgb, var(--ai-color) 14%, white);
  border: 1px solid color-mix(in srgb, var(--ai-color) 45%, white);
}

.block-system {
  align-self: center;
  background: var(--accent-soft);
  border: 1px dashed var(--accent-border);
}

.block-label {
  font-size: 0.72rem;
  font-family: Consolas, "Courier New", monospace;
  color: var(--text-dim);
  white-space: nowrap;
}

.send-caption {
  margin-top: 12px;
  min-height: 2.6em;
  font-size: 0.86rem;
  color: var(--text-dim);
  text-align: center;
}

/* ── 상태판: 게이지 두 줄 ── */
.status-board {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gauge-row {
  display: grid;
  grid-template-columns: 170px 1fr 96px;
  gap: 14px;
  align-items: center;
}

.gauge-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
}

.gauge-track {
  position: relative;
  height: 16px;
  background: var(--track);
  border-radius: 999px;
}

.gauge-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.3, 1), background 0.3s ease;
}

.gauge-fill.g-ok   { background: var(--ok-color); }
.gauge-fill.g-warn { background: var(--warn-color); }
.gauge-fill.g-bad  { background: var(--bad-color); }

/* 1만 토큰 표시선 (10000 / 13000 ≈ 76.9%) */
.gauge-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  left: 76.9%;
  width: 2px;
  background: var(--bad-color);
  opacity: 0.7;
}

.gauge-marker-label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.68rem;
  color: var(--bad-color);
  font-weight: 600;
}

.gauge-value {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: right;
}

.status-msg {
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 1.6em;
}

.status-msg.s-ok   { color: var(--text-dim); }
.status-msg.s-warn { color: var(--warn-color); }
.status-msg.s-bad  { color: var(--bad-color); }

.turn-label {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-soft);
  min-height: 1.4em;
}

/* ── 1만 토큰 경고 배너 ── */
.warn-banner {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  background: #fffbeb;               /* amber-50 */
  border: 1.5px solid #fcd34d;       /* amber-300 */
  border-radius: var(--radius);
  padding: 16px 22px;
  animation: pop-in 0.35s ease;
}

.warn-banner[hidden] {
  display: none;
}

.warn-banner p {
  flex: 1;
  min-width: 260px;
  font-size: 0.92rem;
}

.warn-banner strong {
  color: #b45309;                    /* amber-700 */
}

/* ── 연구 근거(논문 그래프) ── */
.evidence {
  margin-top: 88px;
}

.paper-figure {
  max-width: 860px;
  margin: 28px auto 0;
  min-height: 0;
  gap: 14px;
}

.paper-figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
}

.paper-figure figcaption {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.figure-source {
  display: block;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.evidence-more {
  max-width: 860px;
  margin: 16px auto 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ── 다음 페이지로 이어 주는 안내 카드 ── */
.next-teaser {
  margin: 88px auto 0;
  max-width: 720px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
}

.next-teaser h2 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.next-teaser p {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 18px;
}

/* 링크(<a>)에 버튼 모양을 입힐 때 필요한 정렬 */
.next-teaser .btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

/* ── 좁은 화면 ── */
@media (max-width: 1024px) {
  .chat-stage {
    grid-template-columns: 1fr;
    margin-top: 24px;
  }

  .panel-chat,
  .panel-bundle {
    min-height: 0;
    max-height: none;
  }

  .chat-log {
    max-height: 380px;
  }

  .bundle-stack {
    max-height: 320px;
  }

  .gauge-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .gauge-value {
    text-align: left;
  }
}

/* ── 모바일 ── */
@media (max-width: 640px) {
  .evidence,
  .next-teaser {
    margin-top: 56px;
  }

  .bubble {
    max-width: 94%;
  }

  .status-board {
    padding: 16px;
  }

  .warn-banner {
    padding: 14px 16px;
  }

  .warn-banner .btn {
    width: 100%;
  }

  .next-teaser {
    padding: 22px 18px;
  }
}
