/* Automatic reverse-decay discovery overlay. */

.discovery-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(30, 27, 21, 0.58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(.16, 1, .3, 1);
}

.discovery-overlay.is-visible { opacity: 1; }

.discovery-panel {
  position: relative;
  width: min(92vw, 440px);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--paper, #f4efe4);
  padding: 2.2rem 2rem 1.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.4s cubic-bezier(.16, 1, .3, 1);
}

.discovery-overlay.is-visible .discovery-panel { transform: translateY(0) scale(1); }

.discovery-panel::before,
.discovery-panel::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--terra, #b85c38);
  border-style: solid;
  pointer-events: none;
}

.discovery-panel::before { top: 0; left: 0; border-width: 2px 0 0 2px; }
.discovery-panel::after { right: 0; bottom: 0; border-width: 0 2px 2px 0; }

.discovery-close {
  position: absolute;
  z-index: 5;
  top: 0.65rem;
  right: 0.65rem;
  border: 0;
  padding: 0.3rem;
  background: transparent;
  color: rgba(30, 27, 21, 0.55);
  cursor: pointer;
}

.discovery-header { max-width: 360px; text-align: center; }

.discovery-kicker {
  display: block;
  margin-bottom: 0.22rem;
  color: var(--terra, #b85c38);
  font-family: 'IM Fell English', serif;
  font-size: 0.82rem;
  font-style: italic;
  letter-spacing: 0.06em;
}

.discovery-title {
  margin: 0;
  color: var(--ink, #1e1b15);
  font-family: 'Cinzel', serif;
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.discovery-explainer {
  margin: 0.55rem 0 0;
  color: rgba(30, 27, 21, 0.62);
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.9rem;
  line-height: 1.35;
}

.discovery-card {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(184, 92, 56, 0.09), transparent 58%),
    rgba(30, 27, 21, 0.06);
  isolation: isolate;
}

.discovery-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.discovery-card__img.is-visible { opacity: 1; }

.decay-reveal-canvas {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.45s ease;
}

.decay-reveal-canvas.is-complete { opacity: 0; }

.discovery-card__decay {
  position: absolute;
  z-index: 3;
  inset: auto 0 0;
  display: flex;
  justify-content: center;
  padding: 1.8rem 0.6rem 0.65rem;
  background: linear-gradient(transparent, rgba(30, 27, 21, 0.58));
  pointer-events: none;
}

.discovery-card__status {
  color: rgba(244, 239, 228, 0.86);
  font-family: 'IM Fell English', serif;
  font-size: 0.76rem;
  font-style: italic;
  letter-spacing: 0.05em;
}

.discovery-skip {
  border: 0;
  border-bottom: 1px solid rgba(30, 27, 21, 0.3);
  padding: 0.1rem 0;
  background: transparent;
  color: rgba(30, 27, 21, 0.62);
  font-family: 'IM Fell English', serif;
  font-size: 0.78rem;
  cursor: pointer;
}

.discovery-skip[hidden] { display: none; }

.discovery-result {
  max-width: 100%;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  pointer-events: none;
}

.discovery-result.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.discovery-result__name {
  color: var(--ink, #1e1b15);
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.discovery-result__mutation {
  margin-top: 0.15rem;
  color: var(--terra, #b85c38);
  font-family: 'IM Fell English', serif;
  font-size: 0.78rem;
  font-style: italic;
}

.discovery-result__btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.discovery-btn {
  border: 1.5px solid var(--ink, #1e1b15);
  padding: 0.62rem 1rem;
  background: transparent;
  color: var(--ink, #1e1b15);
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
}

.discovery-btn--profile {
  border-color: var(--terra, #b85c38);
  background: var(--terra, #b85c38);
  color: var(--paper, #f4efe4);
}

.discovery-btn--share { border-color: var(--terra, #b85c38); color: var(--terra, #b85c38); }
.discovery-btn--replay { flex-basis: 100%; border: 0; color: rgba(30, 27, 21, 0.62); }
.discovery-btn:hover { opacity: 0.78; }
.discovery-btn--share.is-copied { color: var(--moss, #52714a); border-color: var(--moss, #52714a); }
.discovery-btn--share.is-error { color: var(--terra, #b85c38); border-color: var(--terra, #b85c38); }
.discovery-btn--share:disabled { cursor: default; opacity: 1; }

@media (max-width: 680px) {
  .discovery-panel { padding: 2rem 1.4rem 1.4rem; }
  .discovery-card { max-width: 280px; }
  .discovery-title { font-size: 1.08rem; }
}

@media (max-width: 400px) {
  .discovery-panel { gap: 0.75rem; padding: 1.7rem 1rem 1rem; }
  .discovery-card { max-width: min(240px, 72vh); }
  .discovery-result__btns { flex-direction: column; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  .discovery-overlay,
  .discovery-panel,
  .discovery-card__img,
  .decay-reveal-canvas,
  .discovery-result { transition-duration: 0.15s; }
}
