/* 안보냄 — Phase 1 프로토타입 스타일. 토큰·수치는 DESIGN.md 그대로. */

:root {
  --canvas: #0d0b0a;
  --surface-1: #16130f;
  --surface-2: #1c1815;
  --surface-3: #221d19;
  --hairline: #2a2420;
  --hairline-strong: #3a322c;
  --ink: #ece4dc;
  --ink-muted: #a89e94;
  --ink-subtle: #786e64;
  --ink-faint: #574f48;
  --fire: #ff6b35;
  --fire-hot: #ffb300;
  --fire-dim: #c44e22;
  --fire-glow: rgba(255, 107, 53, 0.22);
  --care: #6ea8a1;
  --care-soft: rgba(110, 168, 161, 0.14);
  --on-fire: #1a0f06;
  --danger: #c4553a;

  --font: Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', system-ui, sans-serif;
  --numeric: 'SF Mono', ui-monospace, monospace;

  --r-card: 18px;
  --r-button: 15px;
  --r-banner: 14px;

  --page-x: 22px;
  --page-y: 24px;
  --max-width: 440px;

  --hold: 1800ms;
  --burn: 1500ms;
  --ease: cubic-bezier(.2, .8, .2, 1);

  color-scheme: dark;                 /* 라이트 모드 없음. 밤에 쓰는 서비스다 */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100dvh; }

/* ---- 페이지 골격: 라벨 → 제목 → 콘텐츠(flex:1) → 하단 액션. 화면이 바뀌어도 버튼 자리는 같다 */
.app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100dvh;
  padding: var(--page-y) var(--page-x) calc(var(--page-y) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  will-change: transform;
}
.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  animation: fadeUp 500ms var(--ease) both;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
}
.content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 0;
}
.content-write { justify-content: flex-start; }
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row-center { display: flex; justify-content: center; }

/* ---- 타이포 (DESIGN.md §4) */
.label   { font-size: 11px;   line-height: 1.4;  font-weight: 500; letter-spacing: .04em; color: var(--ink-subtle); }
.display { font-size: 25px;   line-height: 1.45; font-weight: 700; letter-spacing: -.02em;  margin: 0 0 12px; }
.title   { font-size: 19px;   line-height: 1.5;  font-weight: 600; letter-spacing: -.015em; margin: 0 0 16px; }
.letter  { font-size: 15.5px; line-height: 1.85; font-weight: 400; letter-spacing: -.01em;  margin: 0;
           white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
.body    { font-size: 14px;   line-height: 1.7;  margin: 0 0 8px; }
.caption { font-size: 12.5px; line-height: 1.6; }
.muted   { color: var(--ink-muted); }
.subtle  { color: var(--ink-subtle); }
.hint    { font-size: 12.5px; line-height: 1.6; color: var(--ink-subtle); text-align: center; margin: 0; }

/* ---- 버튼. 불(fire)은 여기 없다 — 태우기 버튼에만 */
.btn {
  height: 56px;
  border: 0;
  border-radius: var(--r-button);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms var(--ease), opacity 180ms var(--ease);
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-ink   { background: var(--ink); color: var(--canvas); }
.btn-ghost { background: transparent; color: var(--ink-muted); border: 1px solid var(--hairline-strong); height: 48px; font-weight: 500; }
.btn-care  { background: linear-gradient(135deg, var(--care), #4f8a83); color: #0b1513; }
.btn-care:disabled { opacity: 1; }        /* "전해졌습니다 ✓"는 흐려지지 않는다 */

.link {
  background: none;
  border: 0;
  padding: 8px 4px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-subtle);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--hairline-strong);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.link:disabled { opacity: .4; }

/* ---- 받은 반응 배너. 화면에서 유일하게 스스로 숨쉬는 요소 */
.banner {
  background: var(--care-soft);
  border: 1px solid rgba(110, 168, 161, .3);
  border-radius: var(--r-banner);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 28px;
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 rgba(110, 168, 161, 0); }
  50%      { box-shadow: 0 0 22px rgba(110, 168, 161, .35); }
}

/* ---- 편지 카드 (남의 글). 상단 34×2px 불 자국이 카드의 유일한 채도 */
.card {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 24px 22px;
}
.card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 22px;
  width: 34px;
  height: 2px;
  background: linear-gradient(90deg, var(--fire), transparent);
}

/* ---- 입력창 */
.input-wrap {
  position: relative;
  flex: 1;
  min-height: 220px;
  display: flex;
}
.input, .fx-layer.box {
  flex: 1;
  width: 100%;
  min-height: 220px;
  padding: 22px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
  line-height: 1.85;
  letter-spacing: -.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.input {
  resize: none;
  outline: none;
  transition: border-color 180ms var(--ease);
}
.input:focus { border-color: rgba(255, 107, 53, .4); }   /* 불이 아직 켜지지 않은 상태의 예고 */
.input::placeholder { color: var(--ink-faint); }
.counter {
  margin-top: 8px;
  text-align: right;
  font-family: var(--numeric);
  font-size: 12.5px;
  color: var(--ink-subtle);
  font-variant-numeric: tabular-nums;
}
.counter.warn { color: var(--fire); }

/* ---- 꾹 누르기 버튼 — 이 서비스의 핵심 컴포넌트 (DESIGN.md §6-2)
   대기: 어두운 표면 + 불 테두리 + 불 글자(오렌지 면적 5% 규칙 때문에 면을 칠하지 않는다)
   누르는 동안: 불 게이지가 좌→우로 차오르고, 게이지 안의 글자는 on-fire, 밖의 글자는 ink */
.hold {
  position: relative;
  overflow: hidden;
  height: 56px;
  border-radius: var(--r-button);
  background: var(--surface-2);
  border: 1px solid rgba(255, 107, 53, .45);
  color: var(--fire);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
  padding: 0;
  cursor: pointer;
  touch-action: none;                 /* 누르는 중 스크롤 금지 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;        /* 길게 눌러도 메뉴 없음 */
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 180ms var(--ease), border-color 180ms var(--ease), opacity 180ms var(--ease);
}
.hold:disabled { opacity: .4; cursor: default; }
.hold.done:disabled { opacity: 1; border-color: var(--fire-hot); }
.hold .base, .hold .fill {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hold .base { color: var(--fire); }
.hold.holding .base { color: var(--ink); }
.hold .gauge {
  position: absolute;
  inset: 0;
  width: 0%;
  overflow: hidden;
}
.hold .fill {
  width: 100%;                        /* JS가 버튼 실제 폭(px)으로 고정한다 — 글자가 base와 정확히 겹치도록 */
  background: linear-gradient(135deg, var(--fire), var(--fire-hot));
  color: var(--on-fire);
}
.hold.hot {
  border-color: var(--fire-hot);
  box-shadow: 0 0 28px var(--fire-glow), 0 0 6px var(--fire-glow);
}
.hold.hot .fill { background: linear-gradient(135deg, var(--fire-hot), #ffd36b); }

/* 불은 태우기에만. 나머지 방식은 흰색 · 재색 계열로 (DESIGN.md §2-1) */
.hold:not([data-effect="burn"]) { border-color: rgba(236, 228, 220, .3); }
.hold:not([data-effect="burn"]) .base { color: var(--ink-muted); }
.hold:not([data-effect="burn"]).holding .base { color: var(--ink); }
.hold:not([data-effect="burn"]).hot { border-color: var(--ink); box-shadow: 0 0 28px rgba(236, 228, 220, .18), 0 0 6px rgba(236, 228, 220, .18); }
.hold[data-effect="smash"] .fill   { background: linear-gradient(135deg, #cfc6bd, #ffffff); }
.hold[data-effect="smash"].hot .fill { background: #ffffff; }
.hold[data-effect="wind"] .fill    { background: linear-gradient(135deg, var(--ink-muted), var(--ink)); }
.hold[data-effect="crumple"] .fill { background: linear-gradient(135deg, #8f8479, #cfc6bd); }
.hold.done:disabled:not([data-effect="burn"]) { border-color: var(--ink); }

/* ---- 버리는 방식 칩 */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--ink-subtle);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 180ms var(--ease), border-color 180ms var(--ease), background 180ms var(--ease);
}
.chip[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--surface-2); }

/* ---- 버리기 연출 4종 (DESIGN.md §7). 글자는 .ch 하나씩, 방식은 .fx-* 클래스 */
.fx-layer { white-space: pre-wrap; overflow: visible; transform-origin: 50% 50%; }
.fx-layer .ch { display: inline-block; will-change: transform, opacity; }

/* 🔥 태우기 — 불티가 되어 위로 */
.fx-burn .ch { animation: burnUp var(--burn) ease-in forwards; animation-delay: var(--d, 0ms); }
@keyframes burnUp {
  0%   { opacity: 1;  transform: none; color: var(--ink); }
  30%  { color: var(--fire); }
  60%  { opacity: .9; color: var(--fire-hot); }
  100% { opacity: 0;  transform: translate(var(--dx, 0), -90px) rotate(var(--rot, 0)); color: var(--fire-hot); }
}
.glow {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 55vh;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 60% at 50% 100%, rgba(255, 107, 53, .55), rgba(255, 107, 53, 0) 70%);
  opacity: 0;
  z-index: 4;
}
.glow.on { animation: glowPulse 1800ms ease-in-out forwards; }
@keyframes glowPulse { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; } }

#fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.ember {
  position: absolute;
  bottom: 12vh;
  left: var(--x, 50vw);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--fire-hot);
  box-shadow: 0 0 6px var(--fire);
  animation: rise var(--t, 2s) ease-out forwards;
}
@keyframes rise {
  0%   { transform: translate(0, 0) scale(1); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translate(var(--drift, 0), var(--h, -50vh)) scale(.3); opacity: 0; }
}

/* 💥 뿌수기 — 섬광 · 사방으로 폭발 · 파편 */
.fx-smash .ch { animation: smashOut 1100ms cubic-bezier(.15, .6, .3, 1) forwards; animation-delay: var(--d, 0ms); }
@keyframes smashOut {
  0%   { opacity: 1; transform: none; color: var(--ink); }
  8%   { color: #ffffff; }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0), calc(var(--dy, 0) + 160px)) rotate(var(--rot, 0)); color: var(--ink-muted); }
}
.flash {
  position: absolute;
  inset: 0;
  background: rgba(236, 228, 220, .28);
  animation: flashOut 220ms ease-out forwards;
}
@keyframes flashOut { 0% { opacity: 1; } 100% { opacity: 0; } }
.shard {
  position: absolute;
  left: var(--x, 50vw); top: var(--y, 50vh);
  width: var(--w, 5px); height: var(--h, 3px);
  background: var(--ink);
  opacity: .9;
  animation: shardOut var(--t, 900ms) cubic-bezier(.15, .6, .3, 1) forwards;
}
@keyframes shardOut {
  0%   { transform: translate(0, 0) rotate(0); opacity: .9; }
  100% { transform: translate(var(--dx, 0), calc(var(--dy, 0) + 180px)) rotate(var(--rot, 0)); opacity: 0; }
}

/* 🌬 날리기 — 왼쪽에서 바람, 오른쪽 위로 */
.fx-wind .ch { animation: windAway 1500ms ease-in forwards; animation-delay: var(--d, 0ms); }
@keyframes windAway {
  0%   { opacity: 1; transform: none; color: var(--ink); }
  55%  { opacity: .85; color: var(--ink-muted); }
  100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--rot, 0)); color: var(--ink-subtle); }
}
.streak {
  position: absolute;
  left: -30vw; top: var(--y, 50vh);
  width: var(--w, 100px); height: 1px;
  background: linear-gradient(90deg, transparent, var(--ink-muted), transparent);
  opacity: .7;
  animation: sweep var(--t, 900ms) linear forwards;
  animation-delay: var(--d, 0ms);
}
@keyframes sweep { 0% { transform: translateX(0); } 100% { transform: translateX(170vw); } }

/* 🗑 구기기 — 공처럼 구겨져서 아래로 툭 */
.fx-crumple { animation: crumple 1500ms cubic-bezier(.4, 0, .6, 1) forwards; background: var(--surface-1); }
.fx-crumple .ch { animation: crumpleCh 600ms ease-in forwards; }
@keyframes crumple {
  0%   { transform: none; border-radius: var(--r-card); }
  40%  { transform: translateY(0) scale(.18) rotate(-18deg); border-radius: 50%; background: var(--surface-3); border-color: var(--hairline-strong); }
  56%  { transform: translateY(0) scale(.16) rotate(0deg); border-radius: 50%; background: var(--surface-3); }
  100% { transform: translateY(120vh) scale(.16) rotate(160deg); border-radius: 50%; background: var(--surface-3); opacity: .9; }
}
@keyframes crumpleCh {
  0%   { transform: none; }
  100% { transform: translate(var(--cx, 0), var(--cy, 0)) rotate(var(--rot, 0)); }
}

/* ---- 완료 화면 */
.moon { font-size: 40px; line-height: 1; margin-bottom: 20px; }

/* ---- 토스트 (배달 없음 · 오류) */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  max-width: calc(100vw - 44px);
  padding: 12px 16px;
  background: var(--surface-3);
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- 모션 */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .banner { animation: none; }
}
