/* Entry 022 — The prayer box
   Series: Soulware.
   Scene art direction: the hour no one is awake. Warm light rakes low through window
   blinds across a deep oxblood wall (a real photograph); the room becomes a chapel
   without anyone deciding it should. A field of small flames burns mid-depth — each
   one someone's released words. One frosted-glass box floats in front, where you speak.
   One accent: candle-gold. The whole frame is warm — until the box is told to answer,
   and a cool wash drains the light away.
   Display voices, scoped to this entry: Cormorant (the soul) + Spline Sans (the machine).
   New recipe vs 021 (cool slate / rose / Lora+Jakarta / pillowy) and 020 (cool water /
   copper / DM Serif+Sora / soft): warm oxblood world, candle-gold, devotional serif,
   sharper radii. */

.prayer-scene {
  --gold: #ecb24f;
  --gold-glow: #f7d488;
  --oxblood: #3c0e00;
  --ember: #c8741f;
  --on-warm: #fbecd6;
  --cool: #93acc6;

  position: relative;
  display: grid;
  place-items: center;
  min-height: 780px;
  padding: 120px 32px;
  overflow: hidden;
  border-color: rgba(28, 9, 2, 0.7);
  /* background-first: a real photograph (warm light through blinds on an oxblood wall);
     a warm scrim + a pooled darkening keep the glass and type legible. */
  background-image:
    radial-gradient(120% 90% at 50% 64%, rgba(20, 6, 1, 0.62) 0%, rgba(20, 6, 1, 0.18) 42%, rgba(20, 6, 1, 0.0) 70%),
    linear-gradient(184deg, rgba(28, 9, 2, 0.46) 0%, rgba(28, 9, 2, 0.10) 40%, rgba(18, 6, 1, 0.58) 100%),
    url("../../public/media/backgrounds/dark-warm-05-bliss.jpg");
  background-size: cover, cover, cover;
  background-position: center, center, center 38%;
  background-repeat: no-repeat;
  transition: filter 1100ms ease;
}

/* mid layer — the warm spill of the unseen flame-field, blurred into the wall */
.halo {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 60%;
  width: min(820px, 92%);
  height: 460px;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(58% 58% at 50% 50%, rgba(236, 178, 79, 0.20), transparent 72%);
  filter: blur(60px);
  pointer-events: none;
  transition: opacity 1100ms ease, background 1100ms ease;
}

/* ------------------------------------------------------------------ */
/* MID LAYER — the field of flames (each one someone's released words) */
/* ------------------------------------------------------------------ */

.field {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 8%;
  width: min(900px, 96%);
  height: 230px;
  transform: translateX(-50%);
  pointer-events: none;
}

.flame {
  position: absolute;
  width: 7px;
  height: 11px;
  border-radius: 50% 50% 50% 50% / 64% 64% 36% 36%;
  background: radial-gradient(60% 70% at 50% 64%, var(--gold-glow), var(--gold) 52%, rgba(196, 116, 31, 0.0) 82%);
  box-shadow: 0 0 9px 2px rgba(236, 178, 79, 0.55), 0 0 18px 6px rgba(196, 116, 31, 0.22);
  transform: translate(-50%, -50%) scale(var(--s, 1));
  opacity: var(--o, 0.85);
  animation: flicker var(--fd, 2.6s) ease-in-out infinite;
  animation-delay: var(--dl, 0s);
}

.flame.kindled {
  animation: kindle 900ms cubic-bezier(0.2, 0.7, 0.2, 1) both, flicker var(--fd, 2.6s) ease-in-out 900ms infinite;
}

@keyframes flicker {
  0%, 100% { opacity: var(--o, 0.85); transform: translate(-50%, -50%) scale(var(--s, 1)); }
  44%      { opacity: calc(var(--o, 0.85) * 0.74); transform: translate(-50%, -52%) scale(calc(var(--s, 1) * 1.08)); }
  70%      { opacity: var(--o, 0.85); transform: translate(-51%, -50%) scale(calc(var(--s, 1) * 0.96)); }
}

@keyframes kindle {
  0%   { opacity: 0; transform: translate(-50%, -36%) scale(0.2); }
  60%  { opacity: 1; transform: translate(-50%, -54%) scale(1.5); }
  100% { opacity: var(--o, 0.92); transform: translate(-50%, -50%) scale(var(--s, 1)); }
}

/* the cool wash that drains the warmth when the box is told to answer */
.cool-wash {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(120% 100% at 50% 40%, rgba(30, 44, 64, 0.30), transparent 64%),
    linear-gradient(180deg, rgba(22, 32, 48, 0.52), rgba(14, 20, 32, 0.60));
  transition: opacity 1100ms ease;
}

/* ------------------------------------------------------------------ */
/* THE COMPONENT — one frosted-glass box                               */
/* ------------------------------------------------------------------ */

.prayerbox {
  position: relative;
  z-index: 3;
  width: min(560px, 100%);
  display: grid;
  gap: 18px;
  padding: 46px 44px 30px;
  border-radius: 18px;
  font-family: "Spline Sans", var(--ui-sans);
  /* warm frosted glass: a film of candle-light over the photograph */
  background:
    linear-gradient(166deg, rgba(255, 232, 196, 0.12), rgba(48, 18, 6, 0.30));
  border: 1px solid rgba(247, 212, 136, 0.26);
  box-shadow:
    0 1px 0 rgba(255, 234, 200, 0.26) inset,
    0 0 0 1px rgba(24, 8, 2, 0.22),
    0 60px 130px rgba(16, 5, 1, 0.66),
    0 16px 50px rgba(120, 60, 14, 0.26);
  backdrop-filter: blur(26px) saturate(1.25);
  -webkit-backdrop-filter: blur(26px) saturate(1.25);
  color: var(--on-warm);
  transition: border-color 1000ms ease, box-shadow 1000ms ease, background 1000ms ease;
}

/* machine chrome — small, sans, recessive */
.box-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(245, 220, 186, 0.6);
}

.box-meta .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(236, 178, 79, 0.9);
  transition: background 800ms ease, box-shadow 800ms ease;
}

/* the soul voice — devotional serif, large, light, never pure white */
.prompt {
  margin: 0;
  font-family: "Cormorant", "Newsreader", Georgia, serif;
  font-weight: 500;
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 1.06;
  letter-spacing: 0.004em;
  color: #fdf3e2;
  text-wrap: balance;
}

.field-label {
  margin: 2px 0 -8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(245, 220, 186, 0.42);
}

.utterance {
  width: 100%;
  resize: none;
  border: 1px solid rgba(247, 212, 136, 0.20);
  border-radius: 12px;
  background: rgba(28, 12, 4, 0.34);
  color: #fbeede;
  font-family: "Cormorant", "Newsreader", Georgia, serif;
  font-size: 21px;
  line-height: 1.4;
  padding: 13px 16px;
  outline: none;
  transition: border-color 220ms ease, background 220ms ease;
}

.utterance::placeholder { color: rgba(238, 210, 176, 0.36); font-style: italic; }
.utterance:focus {
  border-color: rgba(247, 212, 136, 0.5);
  background: rgba(34, 15, 5, 0.42);
}

/* choice — the only button: release */
.box-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 2px; }

.btn {
  font-family: "Spline Sans", var(--ui-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 999px;
  padding: 13px 26px;
  cursor: pointer;
  transition: transform 180ms ease, background 220ms ease, border-color 220ms ease, color 220ms ease, box-shadow 220ms ease, opacity 220ms ease;
}

.btn-release {
  border: 1px solid rgba(247, 212, 136, 0.5);
  background: linear-gradient(180deg, #f7d488, #e6a23e);
  color: #2a1402;
  box-shadow: 0 12px 30px rgba(196, 116, 31, 0.34);
}

.btn-release:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(196, 116, 31, 0.46); }
.btn-release:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }

/* the witness — the one warm line the box ever offers */
.witness {
  margin: 4px 0 0;
  font-family: "Cormorant", "Newsreader", Georgia, serif;
  font-style: italic;
  font-size: clamp(19px, 2.4vw, 25px);
  line-height: 1.32;
  color: var(--gold-glow);
  text-wrap: balance;
  animation: rise 700ms cubic-bezier(0.2, 0.6, 0.2, 1) both;
}

.witness .count { font-style: normal; font-variant-numeric: tabular-nums; color: #fdf3e2; }

/* the cold feed — what the machine does when told to answer */
.replies {
  margin-top: 2px;
  padding-top: 18px;
  border-top: 1px solid rgba(147, 172, 198, 0.22);
  animation: rise 600ms cubic-bezier(0.2, 0.6, 0.2, 1) both;
}

.replies-head {
  margin: 0 0 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(176, 194, 216, 0.62);
}

.replies ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }

.replies li {
  font-family: "Spline Sans", var(--ui-sans);
  font-size: 14px;
  line-height: 1.45;
  color: rgba(214, 226, 242, 0.9);
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(40, 56, 78, 0.42);
  border: 1px solid rgba(147, 172, 198, 0.18);
  animation: rise 460ms cubic-bezier(0.2, 0.6, 0.2, 1) both;
}

/* foot — the two switches */
.box-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid rgba(247, 212, 136, 0.14);
}

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle-track {
  width: 40px; height: 22px; border-radius: 999px; position: relative;
  background: rgba(247, 212, 136, 0.2);
  border: 1px solid rgba(247, 212, 136, 0.3);
  transition: background 260ms ease, border-color 260ms ease;
}
.toggle-knob {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--gold-glow);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transition: transform 260ms cubic-bezier(0.2, 0.7, 0.2, 1), background 260ms ease;
}
.toggle input:checked + .toggle-track { background: rgba(70, 96, 128, 0.5); border-color: rgba(147, 172, 198, 0.5); }
.toggle input:checked + .toggle-track .toggle-knob { transform: translateX(18px); background: var(--cool); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--gold); outline-offset: 2px; }

.toggle-text {
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em;
  color: rgba(245, 220, 186, 0.78);
}

.keepwhere {
  font-family: "Spline Sans", var(--ui-sans);
  font-size: 11px; letter-spacing: 0.04em;
  color: rgba(238, 210, 176, 0.5);
  border-bottom: 1px dashed rgba(238, 210, 176, 0.3);
  padding-bottom: 1px; cursor: pointer; transition: color 220ms ease, border-color 220ms ease;
}
.keepwhere:hover { color: rgba(245, 220, 186, 0.82); }
.keepwhere[data-kept="server"] {
  color: rgba(176, 194, 216, 0.72);
  border-bottom-color: rgba(176, 194, 216, 0.5);
  font-variant-numeric: tabular-nums;
}

/* unobtrusive photo attribution */
.scene-credit {
  position: absolute;
  right: 16px;
  bottom: 13px;
  z-index: 4;
  font-family: var(--ui-sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(245, 224, 196, 0.34);
  pointer-events: none;
}

/* ---- answering state: the warmth drains, the machine takes over ---- */
.prayer-scene[data-mode="answer"] { filter: saturate(0.82); }
.prayer-scene[data-mode="answer"] .cool-wash { opacity: 1; }
.prayer-scene[data-mode="answer"] .field { opacity: 0.12; transition: opacity 900ms ease; }
.prayer-scene[data-mode="answer"] .halo {
  opacity: 0.5;
  background: radial-gradient(58% 58% at 50% 50%, rgba(120, 150, 190, 0.18), transparent 72%);
}
.prayer-scene[data-mode="answer"] .prayerbox {
  border-color: rgba(147, 172, 198, 0.32);
  box-shadow:
    0 1px 0 rgba(214, 226, 242, 0.2) inset,
    0 0 0 1px rgba(14, 20, 32, 0.3),
    0 60px 130px rgba(8, 12, 20, 0.7),
    0 16px 50px rgba(40, 64, 100, 0.3);
}
.prayer-scene[data-mode="answer"] .box-meta .dot {
  background: var(--cool);
  box-shadow: 0 0 10px rgba(147, 172, 198, 0.9);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .flame, .flame.kindled { animation: none; }
  .witness, .replies, .replies li { animation: none; }
  .prayer-scene, .halo, .cool-wash, .field { transition: none; }
}

/* ---- small screens ---- */
@media (max-width: 720px) {
  .prayer-scene { padding: 76px 16px; min-height: 0; }
  .prayerbox { padding: 34px 26px 26px; border-radius: 16px; gap: 16px; }
  .field { height: 150px; bottom: 4%; }
  .box-foot { gap: 12px; }
  .btn { padding: 12px 22px; }
}
