/* joypray — 조용하고 읽기 편한 화면.
   기도 제목을 꺼내놓는 자리라서, 시선을 끄는 요소를 최대한 줄였다. */

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --border: #e6e0d8;
  --text: #2b2723;
  --text-soft: #6b625a;
  --accent: #7a6a52;
  --accent-strong: #5d4f3c;
  /* 주 버튼 위에 얹는 글자색. 밝은/어두운 테마에서 배경이 뒤집히므로 함께 뒤집는다. */
  --on-accent: #fdfbf7;
  --danger: #a4453a;
  --radius: 14px;
  --maxw: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #201e1b;
    --border: #34302b;
    --text: #ece7e1;
    --text-soft: #a29a90;
    --accent: #c9b795;
    --accent-strong: #ded0b4;
    --on-accent: #201e1b;
    --danger: #e08b7f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR",
    system-ui, sans-serif;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* 헤더 */
.site-header {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 0 1.25rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--accent-strong);
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.lang-picker select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

/* 탭 */
.tabs {
  max-width: var(--maxw);
  margin: 0 auto 1.5rem;
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.tab {
  appearance: none;
  border: 0;
  background: none;
  padding: 0.65rem 0.2rem;
  margin-right: 1.25rem;
  font: inherit;
  font-size: 0.98rem;
  color: var(--text-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* 전역 알림 띠 */
.toast {
  max-width: var(--maxw);
  margin: 0 auto 1rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: rgba(164, 69, 58, 0.08);
  color: var(--danger);
  font-size: 0.9rem;
}

/* 레이아웃 */
main { max-width: var(--maxw); margin: 0 auto; }
.view { display: none; }
.view.is-active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* 작성 폼 */
.compose textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  padding: 0.9rem;
  font: inherit;
  line-height: 1.7;
  resize: vertical;
}

.compose textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* 방향 고정 속성 대신 논리 속성을 쓴다 — 아랍어(RTL)에서 자동으로 뒤집힌다. */
.notice {
  margin: 0.85rem 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
  background: var(--bg);
  border-inline-start: 3px solid var(--border);
  padding: 0.6rem 0.8rem;
  border-start-end-radius: 8px;
  border-end-end-radius: 8px;
}

.compose-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background 120ms ease, opacity 120ms ease;
}

.btn:hover:not(:disabled) { background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent); }

/* 지우기처럼 눈에 띄면 안 되는 동작 */
.btn-quiet {
  border-color: transparent;
  background: none;
  color: var(--text-soft);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
}

.btn-quiet:hover:not(:disabled) {
  background: none;
  color: var(--danger);
  text-decoration: underline;
}

.btn-ghost.is-recording {
  border-color: var(--danger);
  color: var(--danger);
}

.error {
  margin: 0.9rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

/* 격려 문구 */
.encouragement {
  margin: 0 0 1.25rem;
  padding: 1rem 1.15rem;
  border-inline-start: 3px solid var(--accent);
  background: var(--surface);
  border-start-end-radius: var(--radius);
  border-end-end-radius: var(--radius);
  color: var(--text-soft);
  font-size: 0.95rem;
}

.result-seq { margin: 0 0 0.5rem; font-weight: 600; }
.result-crisis {
  margin: 0 0 0.75rem;
  padding: 0.8rem;
  border-radius: 10px;
  background: rgba(164, 69, 58, 0.08);
  color: var(--danger);
  font-size: 0.92rem;
}

.result-crisis p {
  margin: 0 0 0.5rem;
}

.result-crisis a {
  color: var(--danger);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 요청 카드 */
.request-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.request-seq {
  font-size: 0.82rem;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.request-author { font-weight: 600; font-size: 0.95rem; }

.badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-soft);
}

/* 기도 본문만 세리프로 둔다.
   사람이 어렵게 꺼낸 고백이 버튼 라벨과 같은 무게로 보이면 안 된다. */
.request-body {
  margin: 0 0 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Nanum Myeongjo", "Noto Serif KR", Batang, 바탕, "Hiragino Mincho ProN",
    "Songti SC", SimSun, Georgia, "Times New Roman", serif;
  font-size: 1.06rem;
  line-height: 1.85;
  color: var(--text);
}

/* ---------- 등불 ----------
   기도 하나가 등불 하나. 아무도 기도하지 않았으면 꺼져 있고,
   기도가 쌓일수록 밝아진다. 숫자보다 불이 켜지는 편이 오래 남는다. */
.lamp {
  flex-shrink: 0;
  width: 22px;
  height: 30px;
  /* 0명일 때 0, 여덟 명쯤에서 최대. --lit 은 JS 가 넣는다. */
  --lit: 0;
}

.lamp .flame {
  transform-origin: 50% 78%;
  fill: #e8a13a;
  opacity: calc(0.12 + var(--lit) * 0.88);
  filter: drop-shadow(0 0 calc(1px + var(--lit) * 7px) rgba(232, 161, 58, calc(var(--lit) * 0.85)));
  transition: opacity 700ms ease, filter 700ms ease;
}

.lamp .bowl {
  fill: var(--text-soft);
  opacity: 0.55;
}

/* 불이 켜진 등만 아주 느리게 흔들린다. 꺼진 등은 가만히 있어야 한다. */
.lamp[data-lit="1"] .flame {
  animation: flicker 3.6s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .lamp .flame { animation: none; }
}

.request-foot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

.prayer-count {
  font-size: 0.88rem;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.praying-line {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--text-soft);
  font-style: italic;
}

/* 협력자 등록 바 */
.intercessor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
}

.intercessor-text { margin: 0; font-size: 0.95rem; }
.intercessor.is-on .intercessor-text { color: var(--text-soft); }

.intercessor-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.intercessor-lang {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.intercessor-lang select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

.intercessor-push {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-soft);
  cursor: pointer;
}

.intercessor-push input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent-strong);
}

.intercessor-interest {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.intercessor-interest input {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.match-bar {
  margin-bottom: 1rem;
}

.match-bar .btn.is-on {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

/* ---------- 지금 함께 기도하는 세계 ---------- */
.world {
  margin-bottom: 1.25rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.world-line {
  margin: 0;
  font-size: 0.98rem;
  color: var(--text);
}

.world-total {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.world-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 0.85rem;
}

.world-chip {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* ---------- 응답받은 기도 ---------- */
.card.is-answered {
  border-color: var(--accent);
}

.answer-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-strong);
  color: var(--on-accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.answer-note {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border-inline-start: 3px solid var(--accent);
  background: var(--bg);
  border-start-end-radius: 10px;
  border-end-end-radius: 10px;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.answer-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.answer-form input {
  flex: 1 1 14rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

/* ---------- 함께한 말 ---------- */
.comments {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
}

.comment {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}

.comment-author {
  flex-shrink: 0;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.comment-body {
  flex: 1;
  word-break: break-word;
}

.comment-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.comment-form input {
  flex: 1 1 12rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

/* 안 읽은 알림 배지 */
.tab-badge {
  display: inline-block;
  margin-inline-start: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-strong);
  color: var(--on-accent);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.empty {
  text-align: center;
  color: var(--text-soft);
  padding: 3rem 1rem;
}

.site-footer {
  max-width: var(--maxw);
  margin: 3rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 0.82rem;
  text-align: center;
}

/* 후원 링크는 눈에 띄지 않게 둔다. 기도하러 온 사람에게 먼저 보일 것이 아니다. */
.footer-support {
  margin: 0.75rem 0 0;
}

.footer-support a {
  color: var(--text-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-support a:hover {
  color: var(--accent-strong);
}

@media (max-width: 480px) {
  .site-header { flex-direction: column; padding-top: 1.75rem; }
  .compose-actions .btn { flex: 1; }
}

/* 문의 메일 */
.footer-contact { margin-top: 6px; font-size: 0.9em; }
.footer-contact a { color: inherit; }

/* 하단 안내 링크 — 문의 줄과 같은 크기로 조용히 */
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 0.9rem; margin: 0.4rem 0 0.2rem; font-size: 0.82rem; }
.footer-links a { color: var(--text-soft); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
