:root {
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --script: "Snell Roundhand", "Apple Chancery", cursive;
  --bg: #12100e;
  --glow: #f6e7c8;
  --ink: #f4efe6;
  --muted: #a99f90;
  --accent: #e0a45c;
  --line: rgba(244, 239, 230, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% -10%, #241f19 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}

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

/* -------------------------------------------------------------- the wall */
#wall {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;   /* the layer ignores clicks... */
  z-index: 0;
}

.drift {
  position: absolute;
  margin: 0;
  color: var(--glow);
  line-height: 1.45;
  opacity: 0;
  overflow: hidden;
  text-shadow: 0 0 18px rgba(246, 231, 200, 0.25);
  will-change: opacity;
  animation: driftfade var(--dur, 12s) ease-in-out forwards;
  pointer-events: auto;   /* ...but individual prayers are tappable */
  cursor: pointer;
  padding: .35rem .5rem;
  box-sizing: border-box;
  border-radius: 8px;
  transition: background .25s ease;
}

/* Hold a prayer still and bright while it is being read, so it is not a
   moving target that fades out mid-click. */
.drift:hover,
.drift:focus-visible {
  animation-play-state: paused;
  opacity: .85 !important;
  background: rgba(246, 231, 200, 0.06);
}

.drift.amened {
  color: #ffe9c2;
  background: rgba(224, 164, 92, 0.12);
}

.amen-flash {
  display: block;
  margin-top: .35rem;
  font-family: var(--sans);
  font-size: .7rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}

@keyframes driftfade {
  0%   { opacity: 0; }
  18%  { opacity: var(--peak, 0.32); }
  72%  { opacity: var(--peak, 0.32); }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .drift { animation-duration: var(--dur, 12s); animation-timing-function: linear; }
}

/* ----------------------------------------------------------------- main */
main {
  position: relative;
  z-index: 1;
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.hero {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hero-inner {
  margin: auto 0;
  width: 100%;
  padding: 2rem 0;
}

header { text-align: center; margin-bottom: 2rem; }

html, body { overflow-x: hidden; }

h1 {
  font-size: clamp(2.1rem, 8vw, 3.2rem);
  margin: 0 0 .4rem;
  font-weight: 400;
  letter-spacing: .01em;
}

.tagline { margin: 0; color: var(--muted); font-size: 1.05rem; }

/* ----------------------------------------------------------------- form */
form { display: block; }

textarea {
  width: 100%;
  padding: 1rem;
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  resize: vertical;
  backdrop-filter: blur(6px);
}

textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea::placeholder { color: var(--muted); }

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

.private { color: var(--muted); font-size: .92rem; display: flex; align-items: center; gap: .45rem; }

button {
  font: inherit;
  font-size: 1rem;
  padding: .7rem 1.4rem;
  color: #21180d;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
}

button:disabled { opacity: .55; cursor: default; }

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

/* --------------------------------------------------------------- result */
#result {
  padding: 1rem 0;
  text-align: center;
  min-height: 9rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#prayer {
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  line-height: 1.75;
  margin: 0;
  max-width: 34rem;
  color: var(--glow);
  transition: opacity 1.4s ease;
}

#prayer.faded { opacity: 0; }

.again {
  opacity: 0;
  transition: opacity .9s ease;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.again.shown { opacity: 1; }
.again:hover { color: var(--ink); border-color: var(--accent); }
.note {
  font-size: .92rem;
  margin: 0 0 1rem;
  padding: .6rem .8rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.note.published {
  color: #d9f2d2;
  background: rgba(126, 200, 110, 0.1);
  border-color: rgba(126, 200, 110, 0.32);
}

.note.private {
  color: #f0e2c4;
  background: rgba(224, 164, 92, 0.1);
  border-color: rgba(224, 164, 92, 0.3);
}

.crisis {
  color: #ffd9a8;
  background: rgba(224, 164, 92, 0.12);
  border: 1px solid rgba(224, 164, 92, 0.35);
  border-radius: 10px;
  padding: .8rem 1rem;
  font-size: .95rem;
  margin-bottom: 1rem;
}

.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.counts { color: var(--muted); font-size: .9rem; margin: .9rem 0 0; }

.error {
  color: #ffbdbd;
  background: rgba(255, 120, 120, .1);
  border: 1px solid rgba(255, 120, 120, .3);
  border-radius: 10px;
  padding: .8rem 1rem;
  margin-top: 1rem;
}

footer {
  margin-top: 3rem;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}

@media (max-width: 480px) {
  main { padding-top: 2rem; }
  .row { flex-direction: column; align-items: stretch; }
  button { width: 100%; }
  .actions button { width: 100%; }
  .amen-btn { width: auto; }
}


/* ------------------------------------------------------- mobile prayer feed */
#feed { margin-top: 2.5rem; }

.feed-title {
  font-size: .8rem;
  font-weight: 400;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .9rem;
}

.feed-item {
  margin: 0 0 .85rem;
  padding: .9rem 1rem;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--glow);
  font-size: 1rem;
  line-height: 1.55;
}

.feed-text { margin: 0 0 .75rem; }

.feed-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.amen-btn {
  font-family: var(--sans);
  font-size: .82rem;
  padding: .4rem .9rem;
  min-height: 36px;
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(224, 164, 92, 0.45);
  cursor: pointer;
  width: auto;
}

.amen-btn.amened {
  background: rgba(224, 164, 92, 0.16);
  color: #ffe9c2;
  border-color: rgba(224, 164, 92, 0.6);
}

.feed-meta {
  font-size: .78rem;
  color: var(--muted);
  font-family: var(--sans);
}

/* When the feed is showing, the wall has no usable room anyway; hide the
   layer so it cannot intercept taps meant for the page. */
@media (max-width: 1000px) {
  #wall { display: none; }
}
