/* ===========================================================
   The Gospel of Chase — styles
   A warm, candlelit, mock-ecclesiastical theme.
   =========================================================== */

:root {
  --bg-deep:   #120c0d;
  --bg-plum:   #2a1416;
  --gold:      #c9a44c;
  --gold-soft: #d8b96a;
  --gold-bright: #f0d896;
  --cream:     #f4ead6;
  --muted:     #b9a988;
  --shadow:    rgba(0, 0, 0, 0.55);

  --rotate-ms: 20000ms; /* matches ROTATE_MS in script.js */
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: clamp(1.25rem, 4vw, 3rem) 1.25rem 4.5rem;
  font-family: "EB Garamond", Georgia, serif;
  color: var(--cream);
  background:
    radial-gradient(120% 90% at 50% 0%, #3a1c1f 0%, var(--bg-plum) 38%, var(--bg-deep) 78%);
  background-attachment: fixed;
  text-align: center;
  overflow-x: hidden;
}

/* Soft vignette + faint candlelight grain over everything */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(70% 55% at 50% 28%, rgba(240, 216, 150, 0.10), transparent 60%),
    radial-gradient(120% 120% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.6) 100%);
}

body > *:not(.vignette):not(.lock-screen) { position: relative; z-index: 1; }

/* ---------- Header ---------- */
.site-header { max-width: 40rem; }

.eyebrow {
  margin: 0 0 0.4rem;
  font-size: clamp(0.7rem, 2.2vw, 0.85rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}

.title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  font-size: clamp(2.6rem, 9vw, 5rem);
  line-height: 1;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, #9c7a2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 18px rgba(201, 164, 76, 0.18);
}

.subtitle {
  margin: 0.5rem 0 0;
  font-style: italic;
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: var(--muted);
}

/* ---------- Stage / portrait ---------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
  width: min(46rem, 100%);
}

.portrait-frame {
  position: relative;
  margin: 0.5rem 0 0;
  width: min(280px, 64vw);
  aspect-ratio: 3 / 4;
}

/* Golden halo glow behind the head */
.halo {
  position: absolute;
  top: -8%;
  left: 50%;
  transform: translateX(-50%);
  width: 96%;
  height: 96%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, rgba(240, 216, 150, 0.55), rgba(240, 216, 150, 0) 62%);
  filter: blur(6px);
  z-index: -1;
  animation: halo-breathe 6s ease-in-out infinite;
}

.portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  /* Romanesque arched top */
  border-radius: 50% 50% 14px 14px / 42% 42% 9px 9px;
  border: 3px solid var(--gold);
  box-shadow:
    0 0 0 6px rgba(18, 12, 13, 0.9),
    0 0 0 8px rgba(201, 164, 76, 0.35),
    0 22px 50px var(--shadow);
  cursor: pointer;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.portrait:hover {
  transform: translateY(-4px) scale(1.012);
  box-shadow:
    0 0 0 6px rgba(18, 12, 13, 0.9),
    0 0 0 8px rgba(240, 216, 150, 0.5),
    0 28px 60px var(--shadow);
}

/* ---------- Quote ---------- */
.quote-card {
  position: relative;
  width: 100%;
  max-width: 38rem;
  padding: 0.5rem 0.5rem 0;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.quote-card.is-hidden {
  opacity: 0;
  transform: translateY(8px);
}

.quote-mark {
  display: block;
  font-family: "Cormorant Garamond", serif;
  font-size: 4.5rem;
  line-height: 0.4;
  color: rgba(201, 164, 76, 0.4);
  margin-bottom: 0.4rem;
  user-select: none;
}

.quote {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  line-height: 1.32;
  color: var(--cream);
  text-wrap: balance;
}

.context {
  margin-top: 1.1rem;
  font-size: clamp(0.78rem, 2.4vw, 0.95rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-soft);
}

.context::before { content: "\2014\00a0"; } /* em dash */
.context:empty { display: none; }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.25rem;
}

.next-btn {
  font-family: "EB Garamond", serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  background: transparent;
  border: 1px solid rgba(201, 164, 76, 0.55);
  border-radius: 999px;
  padding: 0.6rem 1.5rem;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.1s ease;
}

.next-btn:hover {
  background: rgba(201, 164, 76, 0.12);
  border-color: var(--gold-bright);
  color: var(--cream);
}

.next-btn:active { transform: scale(0.97); }

.next-btn:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.counter {
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.admin-remove {
  font-family: "EB Garamond", serif;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(226, 145, 120, 0.75);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  opacity: 0.7;
  transition: opacity 0.25s ease, color 0.25s ease;
}

.admin-remove[hidden] { display: none; }
.admin-remove:hover { opacity: 1; color: #e29178; }
.admin-remove:disabled { opacity: 0.4; cursor: progress; }

.admin-remove:focus-visible {
  outline: 2px solid #e29178;
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- Contribute a verse ---------- */
.contribute {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin-top: 1.5rem;
}

.contribute-toggle {
  font-family: "EB Garamond", serif;
  font-size: 0.9rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-soft);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  opacity: 0.8;
  transition: opacity 0.25s ease, color 0.25s ease;
}

.contribute-toggle:hover { opacity: 1; color: var(--gold-bright); }

.contribute-toggle:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
  border-radius: 6px;
}

.contribute-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(34rem, 100%);
  padding: 1.5rem 1.4rem;
  text-align: left;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(201, 164, 76, 0.32);
  border-radius: 14px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35), 0 18px 40px var(--shadow);
}

.contribute-form[hidden] { display: none; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-label {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-soft);
}

.field-hint {
  letter-spacing: 0.08em;
  text-transform: none;
  color: rgba(185, 169, 136, 0.7);
  font-style: italic;
}

.field-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: "EB Garamond", serif;
  font-size: 1.02rem;
  color: var(--cream);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(201, 164, 76, 0.42);
  border-radius: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea.field-input { resize: vertical; min-height: 4.5rem; line-height: 1.4; }

.field-input::placeholder { color: rgba(185, 169, 136, 0.5); }

.field-input:focus {
  outline: none;
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(201, 164, 76, 0.16);
}

.contribute-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.contribute-submit {
  font-family: "EB Garamond", serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  background: transparent;
  border: 1px solid rgba(201, 164, 76, 0.55);
  border-radius: 999px;
  padding: 0.55rem 1.6rem;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.1s ease;
}

.contribute-submit:hover:not(:disabled) {
  background: rgba(201, 164, 76, 0.12);
  border-color: var(--gold-bright);
  color: var(--cream);
}

.contribute-submit:active:not(:disabled) { transform: scale(0.97); }

.contribute-submit:disabled { opacity: 0.5; cursor: progress; }

.contribute-submit:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.contribute-status {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
  min-height: 1.2em;
}

.contribute-status[data-kind="ok"]  { color: var(--gold-bright); font-style: normal; }
.contribute-status[data-kind="err"] { color: #e29178; }

/* ---------- Footer / congregation ---------- */
.site-footer {
  margin-top: 1rem;
  max-width: 42rem;
  width: 100%;
}

.congregation-label {
  margin: 0 0 0.7rem;
  font-style: italic;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.banner {
  width: 100%;
  max-width: 40rem;
  border-radius: 10px;
  border: 1px solid rgba(201, 164, 76, 0.4);
  box-shadow: 0 14px 34px var(--shadow);
  filter: sepia(0.25) saturate(0.9) brightness(0.96);
}

.fine-print {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: rgba(185, 169, 136, 0.7);
}

/* ---------- Rotation progress bar (fixed at viewport bottom) ---------- */
.progress {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: rgba(201, 164, 76, 0.12);
  z-index: 5;
}

.progress-bar {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  box-shadow: 0 0 10px rgba(240, 216, 150, 0.6);
}

.progress-bar.run {
  animation: progress var(--rotate-ms) linear forwards;
}

/* ---------- Keyframes ---------- */
@keyframes progress {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@keyframes halo-breathe {
  0%, 100% { opacity: 0.75; transform: translateX(-50%) scale(1); }
  50%      { opacity: 1;    transform: translateX(-50%) scale(1.05); }
}

/* ---------- Lock screen (password gate) ---------- */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(120% 90% at 50% 0%, #3a1c1f 0%, var(--bg-plum) 38%, var(--bg-deep) 82%);
  transition: opacity 0.5s ease;
}

.lock-screen.is-unlocked {
  opacity: 0;
  pointer-events: none;
}

.lock-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  width: min(22rem, 100%);
  text-align: center;
}

.lock-cross {
  margin: 0;
  font-size: 2.4rem;
  color: var(--gold);
  text-shadow: 0 0 22px rgba(240, 216, 150, 0.35);
}

.lock-title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1.05;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, #9c7a2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lock-sub {
  margin: 0 0 0.5rem;
  font-style: italic;
  color: var(--muted);
}

.lock-input {
  width: 100%;
  padding: 0.75rem 1.1rem;
  font-family: "EB Garamond", serif;
  font-size: 1.05rem;
  text-align: center;
  color: var(--cream);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(201, 164, 76, 0.5);
  border-radius: 999px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lock-input::placeholder { color: rgba(185, 169, 136, 0.55); }

.lock-input:focus {
  outline: none;
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(201, 164, 76, 0.16);
}

.lock-btn {
  font-family: "EB Garamond", serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  background: transparent;
  border: 1px solid rgba(201, 164, 76, 0.55);
  border-radius: 999px;
  padding: 0.6rem 1.8rem;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.1s ease;
}

.lock-btn:hover {
  background: rgba(201, 164, 76, 0.12);
  border-color: var(--gold-bright);
  color: var(--cream);
}

.lock-btn:active { transform: scale(0.97); }

.lock-btn:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.lock-error {
  margin: 0;
  min-height: 1.3em;
  font-size: 0.92rem;
  color: #e29178;
}

.lock-box.shake { animation: shake 0.36s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

/* ---------- Accessibility: reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .quote-card,
  .portrait,
  .halo,
  .progress-bar.run,
  .lock-screen,
  .lock-box.shake {
    transition: none !important;
    animation: none !important;
  }
  .quote-card.is-hidden { opacity: 1; transform: none; }
  .progress { display: none; }
}
