/* Prayfect: a quiet night, one candle. Warm near-black, one ember accent, cream text. */

:root {
  --bg: #14100c;
  --bg-raise: #1c1611;
  --surface: #241c15;
  --line: rgba(244, 233, 216, 0.12);
  --line-strong: rgba(244, 233, 216, 0.22);
  --text: #f4e9d8;
  --text-dim: #c4b6a0;
  --text-faint: #9a8c78;
  --ember: #e9893c;
  --ember-hot: #f5a25a;
  --ember-soft: rgba(233, 137, 60, 0.14);
  --paper: #f3e8d2;
  --paper-ink: #2a2017;
  --paper-ref: #8f4a14;
  --paper-mute: #6d5d49;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 20px;
  --app-h: 100dvh;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--ember-hot); text-underline-offset: 3px; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--ember-hot);
  outline-offset: 3px;
  border-radius: 8px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- the candle ---------- */
.glow {
  position: fixed; inset: 0 0 auto 0; z-index: 0; pointer-events: none;
  height: min(86vh, 760px);
  background:
    radial-gradient(46% 56% at 50% 0%, rgba(245, 150, 70, 0.36) 0%, rgba(233, 137, 60, 0.15) 40%, rgba(233, 137, 60, 0) 74%),
    radial-gradient(95% 72% at 50% -12%, rgba(255, 196, 130, 0.12), rgba(255, 196, 130, 0) 70%);
  transform-origin: 50% 0;
  animation: breathe 9s ease-in-out infinite, glowIn 2.4s ease-out both;
}
@keyframes breathe {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes glowIn { from { opacity: 0; } }

.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.06; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .7 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- shared bits ---------- */
.wordmark {
  font-family: var(--serif); font-weight: 420; font-size: 1.4rem; letter-spacing: -0.01em;
  color: var(--text); text-decoration: none; font-variation-settings: "opsz" 48;
  display: inline-flex; align-items: center; min-height: 44px;
}
.wordmark--btn { background: none; border: 0; padding: 0; }

.help-btn, .ghost-btn, .primary-btn {
  min-height: 44px; border-radius: 999px; padding: 0 18px;
  font: 600 14px/1 var(--sans); letter-spacing: 0.01em; transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.help-btn { background: transparent; border: 1px solid rgba(233, 137, 60, 0.55); color: var(--ember-hot); }
.help-btn:hover { background: var(--ember-soft); }
.ghost-btn { background: transparent; border: 1px solid var(--line-strong); color: var(--text-dim); }
.ghost-btn:hover { color: var(--text); border-color: var(--text-dim); }
.primary-btn { background: var(--ember); border: 1px solid var(--ember); color: #14100c; }
.primary-btn:hover { background: var(--ember-hot); }
.primary-btn:active, .send:active, .pill:active { transform: scale(0.97); }
.primary-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- views ---------- */
body[data-view="chat"] { overflow: hidden; }
body[data-view="chat"] .home { display: none; }

/* ---------- home ---------- */
.home { position: relative; z-index: 2; }
.topbar {
  max-width: 760px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) var(--gutter) 0;
  display: flex; align-items: center; justify-content: space-between;
}

.hero { max-width: 760px; margin: 0 auto; padding: clamp(34px, 9vh, 88px) var(--gutter) 20px; }
.hero-title {
  margin: 0 0 18px;
  font-family: var(--serif); font-weight: 330; font-variation-settings: "opsz" 144;
  font-size: clamp(2.7rem, 11vw, 5.4rem); line-height: 1.0; letter-spacing: -0.026em; word-spacing: 0.07em;
  text-wrap: balance; color: var(--text);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.hero-title em { font-style: italic; font-weight: 300; color: var(--ember-hot); padding-right: 0.04em; }
.hero-sub {
  margin: 0 0 30px; max-width: 30ch; color: var(--text-dim); font-size: clamp(1.05rem, 4.4vw, 1.3rem); line-height: 1.5;
  animation: rise 0.6s 0.08s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- composer (hero + chat) ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 24px;
  padding: 6px 6px 6px 18px;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.composer:focus-within {
  border-color: rgba(233, 137, 60, 0.75);
  box-shadow: 0 0 0 4px rgba(233, 137, 60, 0.12), 0 22px 60px -22px rgba(233, 137, 60, 0.4);
}
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent;
  color: var(--text); font: 400 17px/1.5 var(--sans);
  padding: 10px 0; min-height: 44px; max-height: 168px; overflow-y: auto;
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer--hero { padding: 8px 8px 8px 20px; border-radius: 28px; animation: rise 0.6s 0.16s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.composer--hero textarea { font-size: 18px; min-height: 64px; }

.send {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: var(--ember); color: #14100c;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity 0.2s, transform 0.15s, background 0.2s;
}
.composer--hero .send { width: 48px; height: 48px; }
.send:hover:not(:disabled) { background: var(--ember-hot); }
.send:disabled { opacity: 0.32; cursor: default; }

.pills { list-style: none; margin: 22px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; animation: rise 0.6s 0.24s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.pill {
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(36, 28, 21, 0.55);
  color: var(--text); font: 500 15px/1 var(--sans);
  transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.15s;
}
.pill:hover { border-color: var(--ember); color: var(--ember-hot); background: var(--ember-soft); }
.hero-note { margin: 22px 0 0; color: var(--text-faint); font-size: 14px; }

/* ---------- below the fold ---------- */
.manifesto { max-width: 760px; margin: 0 auto; padding: clamp(72px, 16vh, 150px) var(--gutter) 24px; display: grid; gap: clamp(56px, 11vh, 110px); }
.m-rule { display: block; width: 36px; height: 1px; background: var(--ember); margin-bottom: 22px; opacity: 0.9; }
.m-line {
  margin: 0; max-width: 17ch; text-wrap: balance;
  font-family: var(--serif); font-weight: 330; font-variation-settings: "opsz" 144;
  font-size: clamp(2.1rem, 8.6vw, 3.9rem); line-height: 1.06; letter-spacing: -0.02em; word-spacing: 0.07em; color: var(--text);
}
.sample-slot { margin-top: 30px; max-width: 520px; }
.honest { max-width: 760px; margin: 0 auto; padding: 48px var(--gutter) 8px; }
.honest p {
  margin: 0; max-width: 34ch; color: var(--text-dim); font-size: 1.02rem; line-height: 1.6;
  padding-top: 22px; border-top: 1px solid var(--line);
}
.foot { max-width: 760px; margin: 0 auto; padding: 36px var(--gutter) calc(48px + env(safe-area-inset-bottom)); color: var(--text-faint); font-size: 13px; }
.foot p { margin: 14px 0 0; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.foot-links a, .foot-links button {
  background: none; border: 0; padding: 0; min-height: 44px; display: inline-flex; align-items: center;
  color: var(--text-dim); font: 500 14px var(--sans); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px;
}
.foot-links a:hover, .foot-links button:hover { color: var(--ember-hot); }

/* scroll reveal: only when scripting is on, and only for people who accept motion */
@media (scripting: enabled) {
  .reveal { opacity: 0; transform: translateY(22px); transition: opacity 1.1s cubic-bezier(0.2, 0.7, 0.2, 1), transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .reveal.in { opacity: 1; transform: none; }
}

/* ---------- the signature: a verse on cream paper ---------- */
.verse {
  position: relative; margin: 2px 0; padding: 22px 22px 16px; border-radius: 16px;
  background: linear-gradient(178deg, #f7edd9 0%, #eee0c5 100%); color: var(--paper-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 28px 60px -26px rgba(233, 137, 60, 0.5), 0 10px 24px -14px rgba(0, 0, 0, 0.7);
  animation: verseIn 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes verseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.verse-text {
  margin: 0 0 14px; font-family: var(--serif); font-weight: 400; font-variation-settings: "opsz" 30;
  font-size: 1.2rem; line-height: 1.5; text-wrap: pretty; color: var(--paper-ink);
}
.verse-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid rgba(42, 32, 23, 0.16); }
.verse-ref { font: 600 0.78rem/1.2 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--paper-ref); }
.verse-tr { font: 500 0.7rem/1.2 var(--sans); letter-spacing: 0.14em; color: var(--paper-mute); }

/* ---------- chat ---------- */
.chat {
  position: fixed; top: 0; left: 0; right: 0; height: var(--app-h); z-index: 3;
  display: flex; flex-direction: column;
  animation: fadeIn 0.5s ease both;
}
@keyframes fadeIn { from { opacity: 0; } }

.chat-top { flex: none; padding: calc(env(safe-area-inset-top) + 6px) var(--gutter) 6px; max-width: 720px; width: 100%; margin: 0 auto; }
.chat-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-actions { display: flex; gap: 8px; }
.ai-line { margin: 0 0 4px; color: var(--text-dim); font-size: 13px; letter-spacing: 0.01em; }

.crisis-slot { flex: none; max-width: 720px; width: 100%; margin: 0 auto; padding: 0 var(--gutter); }
.crisis {
  position: relative; margin: 6px 0 10px; padding: 14px 16px 8px; border-radius: 18px; max-height: 44dvh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(233, 137, 60, 0.2), rgba(233, 137, 60, 0.1));
  border: 1px solid rgba(233, 137, 60, 0.6); animation: verseIn 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.crisis h2 { margin: 0 0 4px; padding-right: 40px; font: 400 1.15rem/1.25 var(--serif); font-variation-settings: "opsz" 36; color: var(--text); }
.crisis-x {
  position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: none;
  color: var(--text-dim); font: 300 28px/1 var(--sans); display: inline-flex; align-items: center; justify-content: center;
}
.crisis-x:hover { color: var(--text); background: rgba(244, 233, 216, 0.08); }
.help-danger { margin: 6px 0 8px; color: var(--text-dim); font-size: 13.5px; line-height: 1.45; }

.help-list { list-style: none; margin: 0 0 4px; padding: 0; display: grid; gap: 10px; }
.help-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.help-list li:first-child { border-top: 0; }
.help-where { font-size: 14.5px; color: var(--text); line-height: 1.35; }
.help-where small { display: block; color: var(--text-dim); font-size: 12.5px; }
.help-list--compact { gap: 0; }
.help-list--compact li { flex-wrap: nowrap; padding: 4px 0; }
.help-list--compact .help-acts { flex-wrap: nowrap; }
.help-list--compact .help-act { padding: 0 14px; font-size: 13.5px; }
.help-list--compact .help-where { font-size: 13.5px; }
.help-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.help-act {
  min-height: 44px; padding: 0 16px; border-radius: 999px; display: inline-flex; align-items: center;
  background: var(--ember); color: #14100c; font: 600 14px/1 var(--sans); text-decoration: none;
}
.help-act--quiet { background: transparent; color: var(--ember-hot); border: 1px solid rgba(233, 137, 60, 0.55); }
.help-act:hover { filter: brightness(1.08); }

.thread { position: relative; flex: 1; -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px); mask-image: linear-gradient(to bottom, transparent 0, #000 20px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: rgba(244, 233, 216, 0.18) transparent; }
.thread:focus-visible { outline-offset: -3px; }
.thread-inner { max-width: 720px; margin: 0 auto; padding: 14px var(--gutter) 28px; display: flex; flex-direction: column; gap: 24px; }

.msg-user {
  align-self: flex-end; max-width: 86%; white-space: pre-wrap; overflow-wrap: anywhere;
  padding: 12px 16px; border-radius: 20px 20px 6px 20px;
  background: var(--ember-soft); border: 1px solid rgba(233, 137, 60, 0.3); color: var(--text);
  font-size: 16.5px; line-height: 1.55; animation: verseIn 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.turn { display: flex; flex-direction: column; gap: 16px; max-width: 100%; }
.atext p { margin: 0 0 0.85em; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16.5px; line-height: 1.7; color: var(--text); }
.atext p:last-child { margin-bottom: 0; }

.typing { display: inline-flex; align-items: center; gap: 6px; height: 28px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ember); opacity: 0.35; animation: dot 1.3s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes dot { 0%, 70%, 100% { opacity: 0.3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line-strong); background: rgba(36, 28, 21, 0.7);
  color: var(--text-dim); font-size: 15px; line-height: 1.5;
}
.notice p { margin: 0; flex: 1 1 220px; }

.offer {
  padding: 22px 20px 18px; border-radius: 20px; border: 1px solid rgba(233, 137, 60, 0.45);
  background: linear-gradient(180deg, rgba(36, 28, 21, 0.95), rgba(28, 22, 17, 0.95));
  box-shadow: 0 24px 60px -30px rgba(233, 137, 60, 0.5); animation: verseIn 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.offer-text { margin: 0 0 16px; font: 400 1.22rem/1.4 var(--serif); font-variation-settings: "opsz" 30; color: var(--text); text-wrap: pretty; }
.offer-text strong { font-weight: 500; color: var(--ember-hot); }
.offer-form { display: grid; gap: 8px; }
.offer-actions { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.field {
  width: 100%; min-height: 48px; padding: 12px 16px; border-radius: 14px; resize: vertical;
  background: var(--bg); border: 1px solid var(--line-strong); color: var(--text); font-size: 16.5px; line-height: 1.5;
}
.field::placeholder { color: var(--text-faint); }
.field:focus { outline: 0; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(233, 137, 60, 0.18); }
.offer-skip { background: none; border: 0; min-height: 44px; padding: 0 6px; color: var(--text-dim); font: 500 14px var(--sans); text-decoration: underline; text-underline-offset: 4px; }
.form-msg { margin: 0; font-size: 14px; color: var(--text-dim); }
.form-msg:empty { display: none; }
.form-msg--bad { color: #ffb48a; }

.jump {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--jump-bottom, 120px));
  z-index: 5; min-height: 40px; padding: 0 16px 0 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-raise); border: 1px solid var(--line-strong); color: var(--text); font: 600 13px var(--sans);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.chat-bottom { flex: none; width: 100%; max-width: 720px; margin: 0 auto; padding: 8px var(--gutter) calc(env(safe-area-inset-bottom) + 6px); background: linear-gradient(to bottom, rgba(20, 16, 12, 0), var(--bg) 24%); }
.chat-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; margin-top: 2px; color: var(--text-faint); font-size: 12px; line-height: 1.35; }
.chat-foot button { background: none; border: 0; min-height: 44px; margin: -4px 0; padding: 0 2px; flex: none; color: var(--text-dim); font: 500 12.5px var(--sans); text-decoration: underline; text-underline-offset: 3px; }
.chat-foot button:hover { color: var(--ember-hot); }

/* ---------- sheets ---------- */
dialog.sheet {
  border: 0; padding: 0; width: min(100%, 540px); max-width: 100%; max-height: 92dvh; overflow: auto;
  background: var(--bg-raise); color: var(--text); margin: auto auto 0; border-radius: 26px 26px 0 0;
  box-shadow: 0 -30px 90px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--line) inset;
}
dialog.sheet[open] { animation: sheetIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
dialog.sheet::backdrop { background: rgba(10, 7, 5, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(24px); } }
.sheet-body { padding: 26px 22px calc(22px + env(safe-area-inset-bottom)); }
.sheet-title { margin: 0 0 10px; font: 400 1.7rem/1.15 var(--serif); font-variation-settings: "opsz" 72; letter-spacing: -0.015em; }
.sheet-lead { margin: 0 0 14px; color: var(--text-dim); font-size: 15px; line-height: 1.55; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.field-label { display: block; margin: 16px 0 8px; font-size: 14.5px; color: var(--text-dim); }
.stars { border: 0; margin: 8px 0 0; padding: 0; display: flex; gap: 2px; }
.star { width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; border-radius: 12px; color: rgba(244, 233, 216, 0.28); transition: color 0.15s, transform 0.15s; }
.star:hover { color: var(--ember-hot); }
.star.on { color: var(--ember); }
.star:active { transform: scale(0.92); }

@media (min-width: 640px) {
  dialog.sheet { margin: auto; border-radius: 26px; }
  .chat-top, .crisis-slot { padding-left: var(--gutter); padding-right: var(--gutter); }
}

.noscript { position: relative; z-index: 5; max-width: 560px; margin: 24px auto; padding: 0 var(--gutter); color: var(--text); }

/* ---------- plain pages (about) ---------- */
.doc { position: relative; z-index: 2; max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 14px) var(--gutter) calc(64px + env(safe-area-inset-bottom)); }
.doc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.doc h1 { margin: 0 0 14px; font: 330 clamp(2.2rem, 9vw, 3.4rem)/1.05 var(--serif); font-variation-settings: "opsz" 144; letter-spacing: -0.025em; }
.doc h2 { margin: 36px 0 8px; font: 400 1.35rem/1.25 var(--serif); font-variation-settings: "opsz" 48; color: var(--ember-hot); }
.doc p, .doc li { color: var(--text-dim); font-size: 16.5px; line-height: 1.7; }
.doc p { margin: 0 0 12px; }
.doc ul { margin: 0 0 12px; padding-left: 1.2em; }
.doc li { margin-bottom: 6px; }
.doc strong { color: var(--text); font-weight: 600; }
.doc .lead { color: var(--text); font-size: 1.12rem; }

/* ---------- people who ask for less motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .glow { animation: none; opacity: 0.9; }
  .hero-title, .hero-sub, .composer--hero, .pills, .verse, .msg-user, .chat, .crisis, .offer, dialog.sheet[open] { animation: none; }
  .typing i { animation: none; opacity: 0.7; }
  .reveal { transition: none; }
}

@media (min-width: 900px) {
  .hero { padding-top: clamp(60px, 13vh, 130px); }
  .verse-text { font-size: 1.28rem; }
}
