/* PAREIDOLIA — porcelain séance. Near-black porcelain, candlelit amber, bone
   serif. Film grain, vignette, hairlines, lowercase labels. The wall must feel
   like a candlelit gallery of things that are quietly watching you — never a
   default gradio app. Mobile-first: the phone IS the instrument. */

:root {
  --porcelain: #0b0a09;
  --porcelain-2: #121009;
  --amber: #e8a849;
  --amber-soft: rgba(232, 168, 73, 0.62);
  --amber-faint: rgba(232, 168, 73, 0.16);
  --bone: #efe6d4;
  --bone-dim: rgba(239, 230, 212, 0.58);
  --bone-faint: rgba(239, 230, 212, 0.32);
  --hairline: rgba(232, 168, 73, 0.22);
  --hairline-dim: rgba(232, 168, 73, 0.1);
  --card-bg: #11100d;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --label: 0.14em;
}

@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("./vendor/fonts/cormorant-garamond-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("./vendor/fonts/cormorant-garamond-latin-italic.woff2") format("woff2");
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* the HTML hidden attribute always wins — no display rule may resurrect a
   hidden section (the empty-wall state haunted a populated wall once) */
[hidden] { display: none !important; }

html {
  background: var(--porcelain);
  scrollbar-color: rgba(232, 168, 73, 0.25) transparent;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -8%, rgba(232, 168, 73, 0.085), transparent 60%),
    var(--porcelain);
  color: var(--bone);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: rgba(232, 168, 73, 0.3); }

/* ------------------------------------------------ cinematic overlays */
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 40;
  background:
    radial-gradient(130% 100% at 50% 38%, transparent 58%, rgba(4, 3, 2, 0.5) 100%),
    linear-gradient(to bottom, rgba(4, 3, 2, 0.32), transparent 14%, transparent 84%, rgba(4, 3, 2, 0.42));
}
.grain {
  position: fixed; inset: -60%; pointer-events: none; z-index: 41; opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='0.9'/%3E%3C/svg%3E");
  animation: grain 1.7s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1.8%, 1.2%); }
  50% { transform: translate(1.4%, -0.9%); }
  75% { transform: translate(-0.9%, -1.6%); }
  100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
}

/* ------------------------------------------------ masthead */
.masthead {
  position: relative; z-index: 5;
  padding: clamp(28px, 5vh, 56px) 22px 8px;
  text-align: center;
}
.masthead__mark {
  font-weight: 500;
  font-size: clamp(34px, 6.2vw, 58px);
  letter-spacing: 0.34em;
  text-indent: 0.34em; /* optically recenters the letterspacing */
  text-transform: lowercase;
  color: var(--bone);
  text-shadow: 0 0 34px rgba(232, 168, 73, 0.28);
}
.masthead__tag {
  margin-top: 10px;
  font-style: italic;
  font-size: clamp(16px, 2.6vw, 20px);
  color: var(--amber-soft);
}
.masthead__meta {
  margin-top: 12px;
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 11.5px;
  font-family: var(--serif);
  letter-spacing: var(--label);
  text-transform: lowercase;
  color: var(--bone-faint);
}
.masthead__meta .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px 2px rgba(232, 168, 73, 0.45);
  animation: pulse 3.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.12); }
}

/* the call to action — candle-lit pill */
.cta {
  display: inline-block;
  margin-top: 16px;
  padding: 13px 34px 14px;
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  color: var(--amber);
  background: linear-gradient(to bottom, rgba(232, 168, 73, 0.07), rgba(232, 168, 73, 0.025));
  border: 1px solid var(--hairline);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s, box-shadow 0.3s, background 0.3s;
}
.cta:hover, .cta:focus-visible {
  color: #f5c87e;
  border-color: rgba(232, 168, 73, 0.55);
  box-shadow: 0 0 28px rgba(232, 168, 73, 0.16), inset 0 0 18px rgba(232, 168, 73, 0.06);
  outline: none;
}

/* thumb-reach CTA on phones */
.cta--floating { display: none; }
@media (max-width: 720px), (pointer: coarse) {
  .masthead .cta { display: none; }
  .cta--floating {
    display: block;
    position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 45;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    background: rgba(11, 10, 9, 0.66);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 22px rgba(232, 168, 73, 0.1);
  }
}

/* ------------------------------------------------ the menagerie wall */
.wall {
  position: relative; z-index: 4;
  padding: clamp(14px, 2.5vh, 28px) clamp(14px, 3.5vw, 48px) 140px;
  columns: 2;
  column-gap: clamp(12px, 2vw, 22px);
  max-width: 1680px;
  margin: 0 auto;
}
@media (min-width: 760px)  { .wall { columns: 3; } }
@media (min-width: 1100px) { .wall { columns: 4; } }
@media (min-width: 1500px) { .wall { columns: 5; } }

.card {
  break-inside: avoid;
  margin: 0 0 clamp(12px, 2vw, 22px);
  background: var(--card-bg);
  border: 1px solid var(--hairline-dim);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px);
  animation: cardIn 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: var(--enter-delay, 0s);
  transition: border-color 0.4s, box-shadow 0.4s, transform 0.4s;
}
@keyframes cardIn { to { opacity: 1; transform: none; } }
@media (pointer: fine) {
  .card:hover {
    border-color: var(--hairline);
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5), 0 0 30px rgba(232, 168, 73, 0.07);
    transform: translateY(-3px);
  }
}
.card--new {
  border-color: rgba(232, 168, 73, 0.5);
  box-shadow: 0 0 36px rgba(232, 168, 73, 0.2);
}

.card__photo { position: relative; overflow: hidden; }
.card__photo img {
  display: block; width: 100%; height: auto;
  /* candlelight grade: warms and unifies wildly different source photos */
  filter: sepia(0.14) saturate(0.92) contrast(1.04) brightness(0.93);
}
.card__warm {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 30%, transparent 52%, rgba(8, 6, 3, 0.42) 100%),
    linear-gradient(to top, rgba(11, 10, 9, 0.36), transparent 38%);
}

/* container-nap shimmer — while a card photo retries (the Space recycles
   itself ~90s), a quiet porcelain breath holds its seat; the browser's
   broken-image glyph never shows */
.card__photo.is-waiting { aspect-ratio: 4 / 5; }
.card__photo.is-waiting img { visibility: hidden; }
.card__photo.is-waiting::before {
  content: "";
  position: absolute; inset: 0; z-index: 1;
  background:
    linear-gradient(110deg, transparent 34%, rgba(239, 230, 212, 0.05) 50%, transparent 66%),
    var(--card-bg);
  background-size: 220% 100%, auto;
  animation: shimmer 2.6s ease-in-out infinite;
}
@keyframes shimmer {
  from { background-position: 135% 0, 0 0; }
  to   { background-position: -135% 0, 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .card__photo.is-waiting::before { animation: none; }
}

/* whisper bubble — the idle mutter, text only */
.card__whisper {
  position: absolute; left: 10px; right: 10px; top: 10px;
  z-index: 3;
  padding: 8px 12px 9px;
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.3;
  color: var(--bone);
  background: rgba(10, 8, 5, 0.72);
  border: 1px solid var(--hairline-dim);
  border-radius: 3px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  pointer-events: none;
}
.card__whisper.is-on { opacity: 1; transform: none; }

.card__caption { position: relative; padding: 12px 14px 14px; }
.card__name {
  font-weight: 500;
  font-style: italic;
  font-size: 18px;
  letter-spacing: 0.015em;
  color: var(--amber);
  text-transform: lowercase;
}
.card__grudge {
  margin-top: 5px;
  font-size: 14.5px;
  line-height: 1.42;
  color: var(--bone-dim);
}
.card__voice {
  margin-top: 8px;
  padding-right: 30px; /* room for the share link, bottom-right */
  font-size: 10px;
  letter-spacing: var(--label);
  text-transform: lowercase;
  color: var(--bone-faint);
}

/* quiet share affordance — a hairline link, bottom-right of the caption,
   only whispered into view on hover (always faintly present for touch) */
.card__share {
  position: absolute; right: 8px; bottom: 8px;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  padding: 0;
  color: var(--bone-faint);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.35s ease, color 0.25s ease;
}
.card__share svg { display: block; width: 15px; height: 15px; }
.card:hover .card__share, .card__share:focus-visible { opacity: 1; outline: none; }
.card__share:hover, .card__share:focus-visible { color: var(--amber); }
@media (pointer: coarse) { .card__share { opacity: 0.55; } }

/* dev-only fallback markers (only painted when overlay.js is absent) */
.devmark {
  position: absolute; z-index: 2; pointer-events: none;
  border-radius: 50%;
  border: 1px solid rgba(232, 168, 73, 0.65);
  background: radial-gradient(circle, rgba(232, 168, 73, 0.32), rgba(232, 168, 73, 0.05) 70%);
  box-shadow: 0 0 14px rgba(232, 168, 73, 0.35);
  transform: translate(-50%, -50%);
}
.devmark--mouth { border-radius: 999px; }

/* ------------------------------------------------ empty wall */
.empty {
  position: relative; z-index: 4;
  min-height: 46vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 0 28px 90px;
}
.empty__eyes {
  font-size: 30px;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--amber-soft);
  animation: emptyBlink 5.5s ease-in-out infinite;
}
@keyframes emptyBlink {
  0%, 91%, 100% { opacity: 0.8; }
  93.5%, 95.5% { opacity: 0.08; }
}
.empty__line {
  font-style: italic;
  font-size: clamp(22px, 4.4vw, 32px);
  font-weight: 400;
  color: var(--bone);
  max-width: 22ch;
}
.empty__sub {
  font-size: 12px;
  letter-spacing: var(--label);
  text-transform: lowercase;
  color: var(--bone-faint);
  max-width: 30ch;
  line-height: 1.7;
}

/* ------------------------------------------------ desktop QR
   lives in footer flow (never position:fixed over the cards) */
.qr {
  position: relative; z-index: 4;
  display: none;
  width: 124px;
  margin: 26px auto 0;
  padding: 13px 13px 11px;
  text-align: center;
  background: rgba(13, 11, 8, 0.82);
  border: 1px solid var(--hairline);
  border-radius: 4px;
}
@media (min-width: 900px) and (pointer: fine) { .qr { display: block; } }
.qr svg { display: block; width: 96px; height: auto; margin: 0 auto; opacity: 0.92; }
.qr p {
  margin-top: 9px;
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--bone-faint);
}

/* ------------------------------------------------ full screens (capture / reveal) */
.screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  background: var(--porcelain);
  overflow: hidden;
}
.screen[hidden] { display: none; }

.screen__bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 12;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 18px 12px;
  background: linear-gradient(to bottom, rgba(11, 10, 9, 0.85), transparent);
}
.screen__title {
  font-style: italic;
  font-size: 16px;
  color: var(--amber-soft);
  letter-spacing: 0.04em;
}
.ghostbtn {
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--bone-dim);
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 4px 2px;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
.ghostbtn:hover { color: var(--bone); border-color: var(--hairline); }

/* --- capture --- */
.capture__stage {
  position: relative; flex: 1; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.capture__stage video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
  filter: sepia(0.1) contrast(1.03) brightness(0.95);
}
.capture__hint {
  position: absolute; left: 0; right: 0; bottom: 132px; z-index: 11;
  text-align: center;
  font-style: italic;
  font-size: 15.5px;
  color: var(--bone-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
  padding: 0 30px;
  pointer-events: none;
}
.capture__controls {
  position: absolute; left: 0; right: 0;
  bottom: max(26px, env(safe-area-inset-bottom)); z-index: 11;
  display: flex; align-items: center; justify-content: center; gap: 38px;
}
.shutter {
  width: 74px; height: 74px;
  border-radius: 50%;
  border: 2px solid var(--amber-soft);
  background: radial-gradient(circle, rgba(239, 230, 212, 0.92) 0 44%, transparent 46%);
  cursor: pointer;
  box-shadow: 0 0 30px rgba(232, 168, 73, 0.25), inset 0 0 14px rgba(232, 168, 73, 0.3);
  transition: transform 0.15s, box-shadow 0.3s;
}
.shutter:active { transform: scale(0.92); }

/* no-camera altar: a framed panel, never a black void */
.capture__fallback {
  position: relative; z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  text-align: center;
  width: min(520px, calc(100vw - 36px));
  max-width: 520px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 56px 48px;
  background: var(--card-bg);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), 0 0 44px rgba(232, 168, 73, 0.06);
}
@media (max-width: 560px) { .capture__fallback { padding: 44px 28px; } }
.capture__fallback .empty__eyes { animation-duration: 4.5s; }
.capture__fallback h2 {
  font-style: italic; font-weight: 400;
  font-size: clamp(21px, 4.5vw, 28px);
  max-width: 24ch;
}
.capture__fallback p { font-size: 13px; letter-spacing: 0.06em; color: var(--bone-faint); }

/* panel footer: the QR escape hatch for deskbound judges */
.capture__qrfoot {
  display: none;
  margin-top: 14px;
  padding-top: 22px;
  border-top: 1px solid var(--hairline-dim);
  align-items: center;
  gap: 18px;
  width: 100%;
  justify-content: center;
}
@media (min-width: 900px) and (pointer: fine) { .capture__qrfoot { display: flex; } }
.capture__qrfoot svg { display: block; width: 120px; height: auto; opacity: 0.92; flex: none; }
.capture__qrfoot p {
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--bone-dim);
  text-align: left;
  max-width: 15ch;
}

/* --- reveal / séance --- */
/* the reveal screen's bar line is theater debris — the séance captions carry
   the narration now; keep the node (state + tests read it), hide the paint */
#revealTitle { visibility: hidden; }

.reveal__stage {
  position: relative; flex: 1;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.reveal__photo {
  position: relative;
  max-width: 100%; max-height: 100%;
}
.reveal__photo img {
  display: block;
  max-width: 100vw; max-height: 100dvh;
  width: auto; height: auto;
  filter: sepia(0.12) saturate(0.94) contrast(1.04) brightness(0.94);
}
.reveal__seance { position: absolute; inset: 0; z-index: 5; }
.reveal__seance.is-done { opacity: 0; transition: opacity 1.2s ease; pointer-events: none; }

/* lower-third scrim — the name + grudge must survive a white toaster */
.reveal__scrim {
  position: absolute; left: 0; right: 0; bottom: 0; height: 38%; z-index: 10;
  pointer-events: none;
  background: linear-gradient(to top, rgba(4,3,2,0.82), rgba(4,3,2,0.4) 55%, transparent 100%);
  opacity: 0;
  transition: opacity 1.1s ease;
}
.reveal__scrim.is-on { opacity: 1; }

.reveal__name {
  position: absolute; left: 0; right: 0; bottom: 118px; z-index: 11;
  text-align: center; padding: 0 26px;
  pointer-events: none;
  opacity: 0; transform: translateY(8px);
  transition: opacity 1.1s ease, transform 1.1s ease;
}
.reveal__name.is-on { opacity: 1; transform: none; }
.reveal__name h2 {
  font-style: italic; font-weight: 500;
  font-size: clamp(22px, 5vw, 30px);
  color: var(--amber);
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.85);
}
.reveal__name p {
  margin-top: 6px;
  font-size: clamp(15px, 3.4vw, 18px);
  color: var(--bone);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9);
}

.reveal__choice {
  position: absolute; left: 0; right: 0;
  bottom: max(24px, env(safe-area-inset-bottom)); z-index: 11;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  opacity: 0; pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.reveal__choice.is-on { opacity: 1; pointer-events: auto; transform: none; }
.reveal__choice .cta { margin-top: 0; padding: 11px 26px 12px; font-size: 15.5px; }
.reveal__choice .ghostbtn { font-size: 15px; }

/* failure veil */
.reveal__fail {
  position: absolute; inset: 0; z-index: 10;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 0 30px;
  background: rgba(11, 10, 9, 0.78);
  backdrop-filter: blur(8px);
}
.reveal__fail.is-on { display: flex; }
.reveal__fail p {
  font-style: italic;
  font-size: clamp(19px, 4.2vw, 25px);
  max-width: 30ch;
  color: var(--bone);
}

/* busy state — a transient ZeroGPU quota/429 wall. NOT a broken app: the photo
   waits, the visitor gets an honest 'try again' (re-submits the same shot) and
   a quieter 'sign in for your own quota' door. Same candlelit hairline tongue
   as the toast/whisper chrome. */
.reveal__busy {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  margin-top: 6px;
}
.reveal__busy .reveal__retry.cta {
  margin-top: 0;
  padding: 11px 30px 12px;
  font-size: 16px;
  /* lifted a touch warmer than the resting CTA — it is the primary verb here */
  color: var(--amber);
  border-color: var(--hairline);
}
.reveal__busy .reveal__retry.cta:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}
/* 'the spirits gather…' — only while a retry is in flight */
.reveal__gathering {
  font-style: italic;
  font-size: 14px !important;
  letter-spacing: 0.04em;
  color: var(--amber-soft) !important;
  opacity: 0;
  height: 0; margin: -8px 0 0; overflow: hidden;
  transition: opacity 0.4s ease;
}
.reveal__busy.is-gathering .reveal__gathering {
  opacity: 1;
  height: auto;
  animation: pulse 2.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .reveal__busy.is-gathering .reveal__gathering { animation: none; }
}
/* the quieter door — a hairline link, never a shouting button */
.reveal__busy .reveal__signin {
  font-size: 13.5px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--bone-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--hairline-dim);
  padding-bottom: 1px;
  transition: color 0.25s, border-color 0.25s;
}
.reveal__busy .reveal__signin:hover,
.reveal__busy .reveal__signin:focus-visible {
  color: var(--amber);
  border-color: var(--hairline);
  outline: none;
}

/* ------------------------------------------------ toast (quiet, bottom) */
.toast {
  position: fixed; left: 50%; bottom: 92px; z-index: 60;
  transform: translateX(-50%) translateY(8px);
  max-width: min(86vw, 460px);
  padding: 10px 18px 11px;
  font-style: italic; font-size: 15px; text-align: center;
  color: var(--bone);
  background: rgba(13, 11, 8, 0.88);
  border: 1px solid var(--hairline-dim);
  border-radius: 3px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s, transform 0.5s;
}
.toast.is-on { opacity: 1; transform: translateX(-50%); }
.toast--action.is-on { pointer-events: auto; } /* clickable only while shown */
.toast__action {
  margin-left: 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14.5px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--amber);
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 0 1px 1px;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
.toast__action:hover, .toast__action:focus-visible {
  color: #f5c87e;
  border-color: rgba(232, 168, 73, 0.55);
  outline: none;
}

/* ------------------------------------------------ footer */
.colophon {
  position: relative; z-index: 4;
  padding: 10px 22px 120px;
  text-align: center;
  font-size: 11px;
  letter-spacing: var(--label);
  text-transform: lowercase;
  color: rgba(239, 230, 212, 0.22);
}
.colophon a { color: rgba(232, 168, 73, 0.45); text-decoration: none; }
.colophon a:hover { color: var(--amber); }
