/* =========================================================================
   Arm's Length — cozy / painterly visual direction
   Warm cream paper, soft terracotta + sage, rounded everything, gentle motion.
   ========================================================================= */

:root {
  --paper:       #FBF3E9;
  --paper-2:     #F6E7D6;
  --ink:         #4A3B38;
  --ink-soft:    #7C6A63;
  --line:        #E7D4C2;

  --terracotta:  #E0997B;
  --terracotta-d:#C9745A;
  --rose:        #D98C7A;   /* connection meter */
  --sage:        #8FB996;   /* secure meter */
  --sage-d:      #6FA079;
  --amber:       #E6B664;   /* avoidant accent */
  --sky:         #9BB7D4;   /* relief feedback */

  --shadow:      0 18px 40px -22px rgba(94, 60, 45, 0.45);
  --shadow-sm:   0 8px 20px -12px rgba(94, 60, 45, 0.4);
  --radius:      22px;
  --radius-sm:   14px;

  --serif: 'Fraunces', 'Noto Serif TC', Georgia, serif;
  --sans:  'Nunito', 'Noto Sans TC', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 80% -10%, #FCE7D2 0%, rgba(252,231,210,0) 60%),
    radial-gradient(900px 600px at -10% 110%, #EAD9F0 0%, rgba(234,217,240,0) 55%),
    linear-gradient(160deg, var(--paper) 0%, var(--paper-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh; display: flex; flex-direction: column;
}

body.lang-zh { --serif: 'Noto Serif TC', 'Fraunces', serif; --sans: 'Noto Sans TC', 'Nunito', sans-serif; }
body.lang-zh .bodytext, body.lang-zh .narration, body.lang-zh .coach__text { line-height: 1.8; letter-spacing: .01em; }

.app { flex: 1 0 auto; display: flex; flex-direction: column; }

/* ---------------- publisher logo (bottom of every screen) ---------------- */
.sitelogo { flex: 0 0 auto; display: flex; justify-content: center; align-items: center; padding: 8px 16px 24px; }
.sitelogo .logo { height: 46px; width: auto; display: none; }
body.lang-zh .sitelogo .logo-zh { display: block; }
body:not(.lang-zh) .sitelogo .logo-en { display: block; }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(251, 243, 233, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand__mark { color: var(--terracotta-d); font-size: 20px; letter-spacing: -4px; }
.brand__title { font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--ink); white-space: nowrap; }

.meters { display: flex; gap: 18px; flex: 1 1 auto; justify-content: center; max-width: 620px; margin: 0 auto; }
.meter { position: relative; flex: 1 1 0; min-width: 130px; max-width: 280px; }
.meter__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.meter__label { font-size: 12.5px; font-weight: 700; letter-spacing: .02em; color: var(--ink-soft); }
.meter__val { font-family: var(--serif); font-size: 14px; font-weight: 600; color: var(--ink); }
.meter__track { height: 9px; border-radius: 999px; background: #EADBC9; overflow: hidden; box-shadow: inset 0 1px 2px rgba(120,80,60,.18); }
.meter__fill { height: 100%; border-radius: 999px; transition: width .9s cubic-bezier(.22,.61,.36,1); }
.meter--connection .meter__fill { background: linear-gradient(90deg, #E7A38F, var(--rose)); }
.meter--secure .meter__fill { background: linear-gradient(90deg, #A9CDAE, var(--sage-d)); }

.meter__float {
  position: absolute; right: 0; top: -16px; font-size: 11.5px; font-weight: 700;
  opacity: 0; pointer-events: none; transform: translateY(6px); white-space: nowrap;
}
.meter__float.is-show { animation: floatUp 1.6s ease forwards; }
.meter__float.is-relief { color: var(--sky); }
.meter__float.is-discomfort { color: var(--sage-d); }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(8px); }
  18% { opacity: 1; transform: translateY(-2px); }
  78% { opacity: 1; transform: translateY(-10px); }
  100% { opacity: 0; transform: translateY(-20px); }
}

.langtoggle { flex: 0 0 auto; display: flex; background: #EFE0CF; border-radius: 999px; padding: 3px; }
.langbtn { border: 0; background: transparent; color: var(--ink-soft); font-family: var(--sans);
  font-weight: 700; font-size: 12.5px; padding: 6px 12px; border-radius: 999px; cursor: pointer; transition: .2s; }
.langbtn.is-active { background: #fff; color: var(--terracotta-d); box-shadow: var(--shadow-sm); }

/* ---------------- screens & cards ---------------- */
.screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(20px, 4vw, 48px); gap: 28px; }

.card { background: rgba(255, 252, 247, 0.92); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(26px, 4vw, 44px);
  max-width: 680px; width: 100%; }
.card--intro { text-align: center; }
/* Even out centered Chinese welcome/intro paragraphs so a long line doesn't
   strand a single character on its own row. (English reads better full-width.)
   Excludes the left-aligned setting card — balancing it would leave a ragged
   right edge. */
body.lang-zh .card--intro .subtitle,
body.lang-zh .card--intro .bodytext:not(.bodytext--setting) { text-wrap: balance; }

.eyebrow { text-transform: uppercase; letter-spacing: .18em; font-size: 11.5px; font-weight: 800;
  color: var(--terracotta-d); margin: 0 0 10px; }
.display { font-family: var(--serif); font-weight: 600; font-size: clamp(32px, 6vw, 50px);
  line-height: 1.05; margin: 0 0 14px; color: var(--ink); }
.display--sm { font-size: clamp(24px, 4vw, 34px); }
.subtitle { font-size: 17px; color: var(--ink-soft); margin: 0 0 22px; font-weight: 600; }
.bodytext { font-size: 16px; line-height: 1.7; color: var(--ink); margin: 0 0 18px; }
.bodytext--scene { color: var(--ink-soft); font-style: italic; }
body.lang-zh .bodytext--scene { font-style: normal; }
.bodytext--setting { font-size: 15px; line-height: 1.75; color: var(--ink-soft); text-align: left;
  background: rgba(230, 182, 100, 0.10); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 15px 18px; margin: 4px 0 18px; }
.finenote { font-size: 12.5px; color: var(--ink-soft); margin: 18px 0 0; opacity: .85; }

/* ---------------- buttons ---------------- */
.btn { font-family: var(--sans); font-weight: 800; font-size: 15px; border: 0; cursor: pointer;
  padding: 13px 26px; border-radius: 999px; transition: transform .15s ease, box-shadow .2s ease, background .2s; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn--primary { background: linear-gradient(180deg, var(--terracotta), var(--terracotta-d)); color: #fff;
  box-shadow: 0 12px 22px -12px rgba(201,116,90,.9); margin-top: 8px; }
.btn--primary:hover { box-shadow: 0 16px 26px -12px rgba(201,116,90,1); transform: translateY(-1px); }
.btn--soft { background: #EFE0CF; color: var(--terracotta-d); margin-right: 10px; }
.btn--soft:hover { background: #E8D3BD; }

/* ---------------- stage / portraits ---------------- */
.stage { display: flex; justify-content: center; align-items: flex-end; gap: clamp(20px, 6vw, 80px); width: 100%; max-width: 720px; }
.actor { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .45s cubic-bezier(.22,.61,.36,1), opacity .45s, filter .45s; }
.actor .portrait { width: clamp(120px, 22vw, 184px); height: auto; display: block;
  filter: drop-shadow(0 16px 22px rgba(94,60,45,.28)); }
.actor .portrait--img { aspect-ratio: 320 / 340; object-fit: contain; } /* raster swaps in at SVG proportions */
.actor__name { font-family: var(--serif); font-weight: 600; font-size: 15px; color: var(--ink-soft); }
.actor.is-active { transform: translateY(-6px) scale(1.04); }
.actor.is-active .actor__name { color: var(--ink); }
.actor.is-dim { opacity: .72; filter: saturate(.88); }
.actor.is-dim .portrait { filter: drop-shadow(0 12px 18px rgba(94,60,45,.2)) saturate(.9); }

/* ---------------- dialogue ---------------- */
.dialogue { width: 100%; max-width: 680px; display: flex; flex-direction: column; gap: 16px; }
.bubble { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 16px 20px; font-size: 17px; line-height: 1.6; box-shadow: var(--shadow-sm); }
.bubble__who { display: block; font-family: var(--serif); font-size: 13px; font-weight: 600;
  color: var(--terracotta-d); margin-bottom: 4px; }
.bubble--partner { border-top-left-radius: 6px; background: linear-gradient(180deg,#fff, #FFF6EE); }
.bubble--you { border-top-right-radius: 6px; align-self: flex-end; background: linear-gradient(180deg,#fff,#F2F7F1); }
.bubble--you .bubble__who { color: var(--sage-d); }

.narration { font-size: 15.5px; line-height: 1.7; color: var(--ink-soft); font-style: italic;
  margin: 2px 4px 6px; padding-left: 14px; border-left: 3px solid var(--line); }
body.lang-zh .narration { font-style: normal; }

/* ---------------- choices ---------------- */
.choices { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.choice { text-align: left; background: rgba(255,252,247,.95); border: 1px solid var(--line);
  border-left: 5px solid var(--line); border-radius: var(--radius-sm); padding: 14px 18px;
  cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: transform .15s, box-shadow .2s, border-color .2s, background .2s; }
.choice:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); background: #fff; }
.choice__tag { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.choice__text { font-size: 16px; line-height: 1.5; color: var(--ink); font-weight: 600; }
.choice__action { color: #AD9F94; font-weight: 500; }
.choice--avoidant { border-left-color: var(--amber); }
.choice--avoidant .choice__tag { color: #BC8A2E; }
.choice--secure { border-left-color: var(--sage); }
.choice--secure .choice__tag { color: var(--sage-d); }
.choice--neutral { border-left-color: var(--ink-soft); }

/* ---------------- coach overlay ---------------- */
.coach-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(74, 59, 56, 0.42); backdrop-filter: blur(4px); }
.coach { background: #FFFCF7; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); max-width: 520px; width: 100%; padding: clamp(24px, 4vw, 36px); text-align: left; }
.coach__label { text-transform: uppercase; letter-spacing: .18em; font-size: 11px; font-weight: 800;
  color: var(--sage-d); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.coach__label::before { content: "✶"; color: var(--terracotta); }
.coach__text { font-size: 16.5px; line-height: 1.72; color: var(--ink); margin: 0 0 22px; }

/* ---------------- reflection & summary ---------------- */
.prompt { margin-bottom: 18px; }
.prompt__q { font-size: 16px; line-height: 1.6; color: var(--ink); font-weight: 600; margin: 0 0 8px; }
.prompt__input { width: 100%; resize: vertical; font-family: var(--sans); font-size: 15px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; line-height: 1.6; }
.prompt__input:focus { outline: none; border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(224,153,123,.18); }

.pills { display: flex; gap: 14px; margin: 4px 0 18px; flex-wrap: wrap; }
.pill { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px;
  background: #F4E7D8; font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.pill strong { font-family: var(--serif); font-size: 18px; }
.pill--up { background: #E7F0E5; color: var(--sage-d); }
.pill--down { background: #F6E6DE; color: var(--terracotta-d); }

/* ---------------- character creation ---------------- */
.card--create { text-align: center; max-width: 600px; }
.card--create .bodytext { color: var(--ink-soft); }
.preview { display: flex; align-items: flex-end; justify-content: center; gap: 18px; margin: 8px 0 22px; }
.preview .actor { gap: 4px; }
.preview-portrait { width: clamp(96px, 20vw, 132px); }
.preview-portrait .portrait { width: 100%; height: auto; filter: drop-shadow(0 12px 16px rgba(94,60,45,.24)); }
.preview-amp { font-family: var(--serif); font-size: 24px; color: var(--terracotta-d); padding-bottom: 30px; }

.field { text-align: left; margin-bottom: 18px; }
.field__label { font-size: 13px; font-weight: 800; letter-spacing: .02em; color: var(--ink-soft);
  text-transform: uppercase; margin: 0 0 10px; }
.name-input { width: 100%; font-family: var(--sans); font-size: 16px; font-weight: 600; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 16px; transition: border-color .2s, box-shadow .2s; }
.name-input::placeholder { color: var(--ink-soft); opacity: .55; font-weight: 500; }
.name-input:focus { outline: none; border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(224,153,123,.18); }

.chips-row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { font-family: var(--sans); font-weight: 700; font-size: 14.5px; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 9px 18px;
  cursor: pointer; transition: transform .14s, border-color .2s, background .2s, box-shadow .2s; }
.chip:hover { transform: translateY(-1px); border-color: var(--terracotta); }
.chip.is-selected { background: linear-gradient(180deg, var(--terracotta), var(--terracotta-d));
  color: #fff; border-color: var(--terracotta-d); box-shadow: var(--shadow-sm); }
.btn--back { display: inline-block; margin-top: 14px; font-size: 13.5px; padding: 9px 18px; }

/* ---------------- motion ---------------- */
.reveal { animation: reveal .55s cubic-bezier(.22,.61,.36,1) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, .reveal { animation: none !important; transition: none !important; }
}

/* ---------------- responsive ---------------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .meters { order: 3; width: 100%; max-width: none; }
  .brand { flex: 1; }
}
