/* 안심이음 어르신용 웹 데모 (AI-023)
   디자인 토큰: CLAUDE.md 4절 / backend/app/cards/__init__.py DESIGN_TOKENS
   외부 폰트·외부 자원 없음. 시스템 한글 폰트만 쓴다. */
:root {
  --primary: #2E5E8C;
  --panel: #EAF1F8;
  --panel2: #DCE8F4;
  --cream: #FDF6E3;
  --danger: #E74C3C;
  --warning: #E67E22;
  --safe: #1E8E5A;
  --ink: #1F2D3A;
  --muted: #5B6670;  /* 크림 바탕 위 대비 5.4:1 */
  --line: #D9CFB8;
  --focus: #1F2D3A;
  /* 세 화면 공통 이름(home.css, train.css 와 같은 값) */
  --primary-press: #234A70;  /* 주 버튼 눌림 */
  --sub-press: #E3EDF6;      /* 부 버튼 눌림 */
  --on-primary: #FFFFFF;
  --radius: 14px;
  --masthead-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕",
    "Noto Sans KR", "Noto Sans CJK KR", "NanumGothic", "나눔고딕", sans-serif;
  font-size: 22px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

.wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* 공통 머리말 띠: 방패 + 안심이음, 오른쪽 처음으로 (train.css 와 같은 규칙) */
.masthead { background: var(--primary); color: var(--on-primary); }
.masthead-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 560px;
  height: var(--masthead-h);
  margin: 0 auto;
  padding: 0 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.brand-logo { width: 30px; height: 30px; flex: none; }
.home-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  color: var(--on-primary);
  font-size: 20px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  white-space: nowrap;
}
.home-link:active { opacity: 0.8; }
.home-link:focus-visible { outline: 4px solid var(--cream); outline-offset: 2px; }

/* 머리 */
.top h1 {
  margin: 4px 0 8px;
  font-size: 32px;
  line-height: 1.3;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.lead { margin: 0 0 20px; font-size: 22px; font-weight: 600; }

/* 입력 */
.field-label { display: block; font-size: 24px; font-weight: 700; margin-bottom: 8px; }
textarea {
  display: block;
  width: 100%;
  min-height: 220px;
  padding: 14px;
  font: inherit;
  font-size: 22px;
  color: var(--ink);
  background: #FFFFFF;
  border: 3px solid var(--primary);
  border-radius: 14px;
  resize: vertical;
}
textarea::placeholder { color: var(--muted); opacity: 1; }

.help { margin: 10px 0 0; font-size: 22px; color: var(--ink); }
.help-warn { color: #B03A2E; font-weight: 700; }

.train-link { margin: 18px 0 0; font-size: 22px; }
.train-link a { color: var(--primary); text-decoration: underline; padding: 10px 0; display: inline-block; }

.dialect {
  margin: 20px 0 0;
  padding: 10px 14px 14px;
  border: 2px solid var(--panel2);
  border-radius: 14px;
  background: var(--panel);
}
.dialect legend { padding: 0 6px; font-size: 22px; font-weight: 700; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  font-size: 22px;
  cursor: pointer;
}
.choice input { width: 30px; height: 30px; margin: 0; accent-color: var(--primary); flex: none; }

/* 버튼 (모두 폭 100%, 높이 64px 이상). 주 버튼과 부 버튼은 세 화면이 같은 모양 */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  margin-top: 16px;
  padding: 12px 16px;
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s ease-out;
}
.btn:active { filter: brightness(0.92); }
.btn[disabled] { opacity: 0.45; cursor: wait; }
.btn-main { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-size: 24px; margin-top: 20px; }
.btn-main:active { background: var(--primary-press); border-color: var(--primary-press); filter: none; }
.btn-sub { background: #FFFFFF; color: var(--primary); border-color: var(--primary); font-size: 22px; }
.btn-sub:active { background: var(--sub-press); filter: none; }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-call { background: var(--primary); color: #FFFFFF; }
.btn-safe { background: var(--safe); color: #FFFFFF; }

/* 포커스 링: 언제나 보이게 */
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.btn:focus-visible, textarea:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; box-shadow: 0 0 0 7px #FFFFFF; }
#result:focus, #error:focus { outline: none; }

/* 기다림 카드 (train.css 와 같은 모양). demo.js 는 hidden 만 바꾼다.
   hidden 이 풀릴 때마다 애니메이션이 처음부터 다시 돌아, 3초가 넘으면 둘째 줄이 나타난다(JS 없음). */
.loading {
  margin: 24px 0 0;
  padding: 28px 16px 24px;
  text-align: center;
  background: #FFFFFF;
  border: 2px solid var(--line);
  border-radius: 18px;
}
.loading-shield {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  animation: shield-breathe 1.6s ease-in-out infinite alternate;
}
.loading-text { margin: 0; font-size: 22px; font-weight: 700; color: var(--ink); }
.loading-more {
  margin: 8px 0 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--muted);
  animation: loading-more-in 0.4s ease-out 3s both;
}
@keyframes shield-breathe { from { transform: scale(0.92); } to { transform: scale(1.06); } }
@keyframes loading-more-in { from { opacity: 0; visibility: hidden; } to { opacity: 1; visibility: visible; } }
@media (prefers-reduced-motion: reduce) {
  .loading-shield { animation: none; }
  .loading-more { animation-duration: 1ms; }  /* 움직임 없이 3초 뒤 바로 보인다 */
}

/* 상자 */
.box { margin: 20px 0 0; padding: 16px; border-radius: 14px; background: var(--panel); }
.box p { margin: 0 0 8px; }
.box-warn { background: #FFF1E0; border: 3px solid var(--warning); }
.error-head { font-size: 26px; font-weight: 800; }

/* 결과 */
#result { margin-top: 20px; }
.card-img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 18px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #FFFFFF;
}
.band {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  font-size: 32px;
  line-height: 1.3;
}
.band .shape { font-size: 36px; line-height: 1; flex: none; }
.band strong { font-weight: 800; }
.band.lv-danger { background: var(--danger); color: #FFFFFF; }
.band.lv-caution { background: var(--warning); color: var(--ink); }  /* 주황 위 흰 글자는 대비가 낮아 ink */
.band.lv-safe { background: var(--safe); color: #FFFFFF; }

.headline { margin: 16px 0 6px; font-size: 28px; font-weight: 800; line-height: 1.45; }

.panel { margin-top: 16px; padding: 14px 16px 6px; background: var(--panel); border-radius: 14px; }
.panel-title { margin: 0 0 6px; font-size: 24px; color: var(--primary); }
.reasons, .advice { margin: 0; padding: 0 0 8px 0; list-style: none; }
.reasons li, .advice li { position: relative; margin: 0 0 10px; font-size: 22px; font-weight: 600; }
.reasons li { padding-left: 26px; }
.reasons li::before { content: "·"; position: absolute; left: 4px; top: -2px; font-size: 28px; font-weight: 800; }
.advice { counter-reset: step; }
.advice li { padding-left: 52px; min-height: 42px; counter-increment: step; }
.advice li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary); color: #FFFFFF;
  font-size: 22px; font-weight: 800; line-height: 40px; text-align: center;
}

.notice {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 3px solid var(--line);
  font-size: 22px;
  color: #444444;
}

/* 전화·알리기 버튼 묶음. 안전(safe)일 때는 순서를 가족에게 알리기 → 1332 → 112 로 바꾸고
   112는 회색 테두리로 낮춘다(demo.js render). DOM 순서는 그대로, 보이는 순서만 order로 바꾼다. */
.actions { display: flex; flex-direction: column; margin-top: 10px; }
.actions .act-112 { order: 1; }
.actions .act-note { order: 1; margin: 2px 0 8px; font-size: 22px; color: #444444; }
.actions .act-1332 { order: 2; }
.actions .act-share { order: 3; }
.actions.actions-safe .act-share { order: 1; }
.actions.actions-safe .act-1332 { order: 2; }
.actions.actions-safe .act-112 { order: 3; }
.actions.actions-safe .act-note { order: 3; }
.btn-quiet {
  background: #FFFFFF;
  color: var(--ink);
  border-color: #767676;  /* 회색 테두리: 크림 바탕 대비 3:1 이상 */
  font-size: 24px;
  font-weight: 700;
}

.share-box { border: 3px solid var(--safe); background: #FFFFFF; }
.share-head { font-weight: 800; }
.share-text {
  font-size: 24px;
  font-weight: 600;
  white-space: pre-wrap;
  -webkit-user-select: text;
  user-select: text;
  padding: 10px;
  background: var(--panel);
  border-radius: 10px;
}

/* 알림 띠 */
.toast {
  position: fixed;
  left: 16px; right: 16px; bottom: 20px;
  max-width: 528px;
  margin: 0 auto;
  padding: 16px;
  font-size: 22px;
  font-weight: 800;
  color: #FFFFFF;
  background: var(--ink);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  text-align: center;
  z-index: 10;
}
.help a { color: var(--primary); font-size: 20px; text-underline-offset: 4px; }
