/* writing-room.css — 寫作室（直接說）波 1
   載入順序：tokens → chrome → writing-room
   scope：body.wr-active
*/

/* ── 基礎 surface 切換 ── */
body.wr-active #messages-log,
body.wr-active .typing { display: none; }

body.wr-active #wr-thread { display: block; }

#wr-thread { display: none; }

/* ── 寫入流 blk（明體人聲 + sans 系統聲部）── */
.wr-blk {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  font-family: var(--serif);
  font-size: var(--u-0);
  line-height: 32px;
  color: var(--ink);
  font-weight: 600;
}

/* §B1 降階：前句加 .wr-blk--filed → 黑體密排 + 墨色三階退場 */
.wr-blk.wr-blk--filed {
  font-family: var(--sans);
  font-size: var(--t--1);
  line-height: 22px;
  color: var(--ink-3);
  font-weight: 400;
}

.wr-blk.wr-blk--filed .wr-body { font-family: var(--sans); }
.wr-blk.wr-blk--filed .wr-ts   { line-height: 22px; }

/* §B2 分隔線：已整理 / 最新句 之間 */
.wr-filed-divider {
  font-family: var(--sans);
  font-size: var(--t--2);
  color: var(--ink-3);
  text-align: center;
  padding: 6px 0;
  line-height: 24px;
}

.wr-ts {
  font-family: var(--sans);
  font-size: var(--t--2);
  color: var(--ink-3);
  flex-shrink: 0;
  line-height: 32px;
}

.wr-body {
  flex: 1;
  font-family: var(--serif);
}

/* ── 系統行 ── */
.wr-sys {
  font-family: var(--sans);
  font-size: var(--t--2);
  color: var(--ink-3);
  padding: 4px 0 4px 0;
  line-height: 24px;
}

/* ── AI 回應（格一缺口提示）── */
.wr-ai-pre {
  font-family: var(--sans);
  font-size: var(--u-0);
  color: var(--ink);
  line-height: 32px;
  padding: 8px 0;
}

/* ── 草稿卡（格二 has-review 同語彙）── */
.wr-draft-card {
  border-left: 2px solid var(--signal);
  padding: 12px 16px;
  margin: 8px 0;
  background: transparent;
}

.wr-draft-card .kq-text {
  font-family: var(--sans);
  font-size: var(--u-0);
  line-height: 32px;
  color: var(--ink);
}

/* ── Loading indicator ── */
.wr-loading {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  align-items: center;
}

.wr-loading::before,
.wr-loading::after,
.wr-loading > span {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: var(--r-pill);
  background: var(--ink-3);
  animation: wr-blink 1.2s infinite both;
}

.wr-loading::after { animation-delay: .2s; }
.wr-loading::before { animation-delay: .4s; }

@keyframes wr-blink {
  0%, 100% { opacity: .2; }
  50%       { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .wr-loading::before,
  .wr-loading::after { animation: none; opacity: .4; }
}

/* ── kq-rec 按鈕 ── */
.kq-rec {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r-xs);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--signal);
  flex-shrink: 0;
  position: relative;
}

.kq-rec:disabled { opacity: .4; cursor: default; }

.kq-rec-dot {
  display: block;
  width: 10px; height: 10px;
  border-radius: var(--r-pill);
  background: var(--signal);
  animation: wr-pulse 1.8s ease-in-out infinite;
}

@keyframes wr-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}

@media (prefers-reduced-motion: reduce) {
  .kq-rec-dot { animation: none; }
}

/* ── 進入漣漪（兩圈 ~2.4s）── */
.kq-rec--ripple .kq-rec-dot::before,
.kq-rec--ripple .kq-rec-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--signal);
  animation: wr-ripple 1.2s ease-out both;
}

.kq-rec--ripple .kq-rec-dot::after { animation-delay: .4s; }

@keyframes wr-ripple {
  from { transform: scale(1); opacity: .7; }
  to   { transform: scale(2.8); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .kq-rec--ripple .kq-rec-dot::before,
  .kq-rec--ripple .kq-rec-dot::after { animation: none; display: none; }
}

/* ── 提示泡（signal 橘底，錨在 REC 上方，尖角指向 REC）── */
.wr-hint-tip {
  position: fixed;
  z-index: 200;
  background: var(--signal);
  color: var(--paper);
  font-family: var(--sans);
  font-size: var(--t--1);
  line-height: 20px;
  padding: 6px 12px;
  border-radius: var(--r-xs);
  white-space: nowrap;
  bottom: 72px;
  right: 16px;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}

.wr-hint-tip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 14px;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--signal);
}

.wr-hint-tip--visible {
  opacity: 1;
  animation: wr-hint-bob 2.4s ease-in-out infinite;
}

.wr-hint-tip--out {
  opacity: 0;
  animation: none;
}

@keyframes wr-hint-bob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .wr-hint-tip { transition: none; }
  .wr-hint-tip--visible { animation: none; }
}

/* ── keyboard-open mbar（取代 masthead，supersede home-v3.css v3 驗收 #1）── */
.wr-mbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px 12px;
  flex-shrink: 0;
  height: 44px;
}

.wr-mbar-count {
  font-family: var(--sans);
  font-size: var(--t--2);
  color: var(--teal-ink);
  background: var(--teal);
  border-radius: var(--r-xs);
  padding: 3px 10px;
}

/* supersede home-v3.css: body.home.keyboard-open .masthead { display: flex }
   寫作室 keyboard-open 時改顯示 mbar，masthead 收起 */
body.home.wr-active.keyboard-open .masthead { display: none; }
body.home.wr-active.keyboard-open .wr-mbar  { display: flex; }

/* +1 count flash */
@keyframes wr-count-flash {
  0%   { transform: translateY(0); opacity: 1; }
  30%  { transform: translateY(-3px); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}

.wr-mbar-count--flash {
  animation: wr-count-flash .3s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .wr-mbar-count--flash { animation: none; }
}

/* ── SEALED 態：隱藏輸入列 ── */
body.wr-sealed .log-input { display: none; }
