:root {
  --cream: #fdf6ea;
  --cream-deep: #f7ebd6;
  --paper: #fffaf2;
  --honey: #efb15f;
  --honey-deep: #e2913f;
  --amber-glow: #ffe6ad;
  --sky: #a9cdd9;
  --sky-deep: #7fb0c0;
  --sage: #aac3a3;
  --plum: #b98ca0;
  --ink: #4f4233;
  --ink-soft: #7c6c57;
  --line: #e9dcc3;
  --shadow: 32px 40px 80px -42px rgba(120, 88, 40, 0.45);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 12% 4%, #fff5e0 0%, transparent 55%),
    radial-gradient(120% 100% at 88% 0%, #eaf3f3 0%, transparent 50%),
    radial-gradient(140% 120% at 50% 120%, #f6e3c9 0%, transparent 60%),
    linear-gradient(180deg, #fdf6ea 0%, #faf0df 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ---------- atmosphere ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.firefly {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff3cf 0%, rgba(247, 197, 109, 0.7) 45%, transparent 70%);
  filter: blur(0.4px);
  opacity: 0;
  animation: drift 14s ease-in-out infinite;
}
.firefly--1 { left: 8%;  top: 22%; animation-delay: 0s;   }
.firefly--2 { left: 82%; top: 16%; animation-delay: 2.4s; transform: scale(0.7); }
.firefly--3 { left: 68%; top: 64%; animation-delay: 5s;   transform: scale(1.3); }
.firefly--4 { left: 22%; top: 72%; animation-delay: 7.6s; transform: scale(0.9); }
.firefly--5 { left: 46%; top: 34%; animation-delay: 10s;  transform: scale(0.6); }
.firefly--6 { left: 90%; top: 78%; animation-delay: 3.6s; transform: scale(1.1); }

@keyframes drift {
  0%   { opacity: 0; transform: translateY(0) scale(0.8); }
  20%  { opacity: 0.9; }
  50%  { opacity: 0.5; transform: translateY(-26px) scale(1); }
  80%  { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-52px) scale(0.8); }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

/* ---------- layout ---------- */
.page {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4rem) 1.25rem 4rem;
}

.masthead {
  text-align: center;
  margin-bottom: clamp(2rem, 5vw, 3rem);
}

.eyebrow {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--honey-deep);
  margin: 0.4rem 0 0.8rem;
  font-size: 1.15rem;
}

.title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: clamp(1.9rem, 5.5vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 1rem;
  color: var(--ink);
}

.lede {
  font-size: clamp(1rem, 2.4vw, 1.18rem);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 30em;
  margin: 0 auto;
}

/* ---------- lantern ---------- */
.lantern {
  width: 96px;
  margin: 0 auto;
  animation: sway 6s ease-in-out infinite;
  transform-origin: top center;
}
.lantern__svg { width: 100%; height: auto; overflow: visible; }
.lantern__handle { fill: none; stroke: #c89a5c; stroke-width: 3; stroke-linecap: round; }
.lantern__cap { fill: #c89a5c; }
.lantern__body {
  fill: rgba(255, 244, 222, 0.55);
  stroke: #d9ab68;
  stroke-width: 2.5;
}
.lantern__flame {
  transform-origin: 40px 56px;
  animation: flicker 3.4s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(244, 188, 104, 0.85));
}

@keyframes sway {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}
@keyframes flicker {
  0%, 100% { opacity: 0.95; transform: scale(1); }
  45%      { opacity: 0.78; transform: scale(0.94); }
  70%      { opacity: 1; transform: scale(1.04); }
}

/* ---------- cards ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.4rem, 4vw, 2.1rem);
  box-shadow: var(--shadow);
}

.card--ask {
  position: relative;
  overflow: hidden;
}
.card--ask::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 100% 0%, rgba(255, 230, 173, 0.4) 0%, transparent 55%);
  pointer-events: none;
}

.field-label {
  display: block;
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  position: relative;
}

.worry-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: #fffdf9;
  padding: 1rem 1.1rem;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink);
  resize: vertical;
  min-height: 116px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.worry-input::placeholder { color: #bcab8d; }
.worry-input:focus {
  outline: none;
  border-color: var(--honey);
  box-shadow: 0 0 0 4px rgba(239, 177, 95, 0.18);
}
.worry-input--nudge {
  animation: nudge 0.5s ease;
  border-color: var(--honey-deep);
}
@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.ask-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  max-width: 22em;
}

/* ---------- buttons ---------- */
.btn-glow {
  position: relative;
  border: none;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: #5a3d18;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd98a 0%, var(--honey) 55%, var(--honey-deep) 100%);
  box-shadow: 0 12px 26px -10px rgba(226, 145, 63, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.18s ease, box-shadow 0.25s ease, filter 0.25s ease;
  white-space: nowrap;
}
.btn-glow:hover { transform: translateY(-2px); filter: brightness(1.04); box-shadow: 0 18px 34px -12px rgba(226, 145, 63, 0.85), 0 0 28px -2px rgba(255, 214, 130, 0.6); }
.btn-glow:active { transform: translateY(0) scale(0.98); }
.btn-glow:disabled { cursor: default; filter: grayscale(0.25) brightness(0.97); opacity: 0.75; transform: none; }

.btn-soft, .btn-quiet {
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.7rem 1.3rem;
  font-size: 0.98rem;
  transition: transform 0.18s ease, background 0.25s ease, border-color 0.25s ease;
}
.btn-soft {
  border: none;
  color: #2f4b54;
  background: linear-gradient(135deg, #cfe6ec 0%, var(--sky) 100%);
  box-shadow: 0 10px 22px -12px rgba(127, 176, 192, 0.9);
}
.btn-soft:hover { transform: translateY(-2px); }
.btn-soft:active { transform: scale(0.98); }
.btn-quiet {
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
}
.btn-quiet:hover { border-color: var(--honey); color: var(--honey-deep); }

/* ---------- suggestions ---------- */
.suggestions {
  list-style: none;
  margin: 1.4rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  position: relative;
}
.chip {
  cursor: pointer;
  border: 1.5px solid var(--line);
  background: #fffdf8;
  color: var(--ink-soft);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  transition: transform 0.16s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chip:hover {
  transform: translateY(-1px);
  background: var(--amber-glow);
  border-color: var(--honey);
  color: #5a3d18;
}

/* ---------- answer area ---------- */
.answer { margin-top: 1.5rem; }

.card--loading { text-align: center; }
.skeleton {
  border-radius: 12px;
  background: linear-gradient(100deg, #f3e7d2 30%, #fbf3e3 50%, #f3e7d2 70%);
  background-size: 220% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  margin: 0 auto 0.9rem;
}
.skeleton--verse { height: 58px; max-width: 80%; }
.skeleton--line { height: 16px; width: 100%; }
.skeleton--line.short { width: 65%; }
.loading-note {
  margin: 1rem 0 0;
  font-family: 'Fraunces', serif;
  font-style: italic;
  color: var(--ink-soft);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.card--error { text-align: center; }
.error-text { margin: 0 0 1rem; color: #a85a4a; font-weight: 600; }

/* ---------- result ---------- */
.card--result {
  position: relative;
  overflow: hidden;
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.card--result::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(255, 230, 173, 0.5) 0%, transparent 65%);
  pointer-events: none;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

.verse {
  position: relative;
  padding: 1.2rem 1.3rem 1.2rem 1.6rem;
  margin-bottom: 1rem;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 244, 222, 0.85), rgba(250, 232, 205, 0.7));
  border: 1px solid #f0deba;
}
.verse::before {
  content: '';
  position: absolute;
  left: 0; top: 14%;
  width: 5px; height: 72%;
  border-radius: 4px;
  background: linear-gradient(var(--honey), var(--sage));
}
.verse__text {
  font-family: 'Fraunces', serif;
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  line-height: 1.4;
  margin: 0 0 0.5rem;
  color: #5a4327;
}
.verse__ref {
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--honey-deep);
}

.result__heading, .prayer__heading {
  font-family: 'Fraunces', serif;
  font-weight: 600;
}
.result__heading { font-size: 1.35rem; margin: 1.4rem 0 0.6rem; }
.result__encouragement {
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--ink);
  margin: 0;
}

.result__prayer {
  margin-top: 1.5rem;
  padding: 1.1rem 1.3rem;
  border-radius: 18px;
  background: rgba(169, 205, 217, 0.16);
  border: 1px dashed var(--sky-deep);
}
.prayer__heading { font-size: 1.1rem; margin: 0 0 0.5rem; color: #3c5a64; }
.prayer__text {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.55;
  color: #41555c;
}

.result__actions {
  margin-top: 1.7rem;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.footnote {
  margin-top: 2.5rem;
  text-align: center;
}
.footnote p {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 34em;
  margin: 0 auto;
}

/* ---------- share sheet ---------- */
.share-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.share-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(79, 66, 51, 0.34);
  backdrop-filter: blur(3px);
  animation: fade 0.3s ease both;
}
.share-sheet__panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 2rem 1.8rem;
  box-shadow: var(--shadow);
  animation: rise 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.share-sheet__close {
  position: absolute;
  top: 0.8rem; right: 1rem;
  border: none;
  background: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
}
.share-sheet__title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0 0 0.6rem;
}
.share-sheet__lede { margin: 0 0 1.1rem; color: var(--ink-soft); line-height: 1.55; }
.share-sheet__steps {
  margin: 0 0 1.4rem;
  padding-left: 1.2rem;
  line-height: 1.7;
  color: var(--ink);
}
.share-sheet__steps li { margin-bottom: 0.3rem; }
.share-sheet__buttons { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.share-sheet__copied {
  margin: 0.9rem 0 0;
  color: var(--sage);
  font-weight: 700;
  filter: brightness(0.85);
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

[hidden] { display: none !important; }

/* ---------- entrance ---------- */
.masthead, .card--ask { animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }
.card--ask { animation-delay: 0.12s; }

@media (max-width: 540px) {
  .ask-row { flex-direction: column; align-items: stretch; }
  .btn-glow { width: 100%; }
  .result__actions .btn-soft, .result__actions .btn-quiet { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
