/**
 * THE ONE DOLLAR ORACLE
 * Black + gold. Subtle grain. Occasional glitch.
 * 1890s carnival × 1970s arcade × 1990s GeoCities × 2060 Guff
 */

:root {
  --bg: #0a0a0a;
  --bg-warm: #0f0e0c;
  --gold: #c9a227;
  --gold-dim: #8b7312;
  --gold-bright: #e8c547;
  --text: #e8e4dc;
  --text-dim: #8a8578;
  --grain: rgba(201, 162, 39, 0.03);
  --glow-gold: rgba(201, 162, 39, 0.25);
  --glow-subtle: rgba(201, 162, 39, 0.08);
}

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

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  font-family: 'Cormorant Garamond', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  position: relative;
}

.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.32;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Landing */
.landing {
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
}

.landing::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, rgba(201, 162, 39, 0.04) 0%, transparent 60%);
  pointer-events: none;
}

.machine-frame {
  max-width: 420px;
  text-align: center;
  border: 1px solid var(--gold-dim);
  padding: 3rem 2.5rem;
  background: linear-gradient(180deg, rgba(18,17,14,0.98) 0%, rgba(10,10,10,0.99) 100%);
  box-shadow:
    0 0 80px var(--glow-subtle),
    0 0 0 1px rgba(201, 162, 39, 0.06),
    inset 0 1px 0 rgba(201, 162, 39, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(16px);
  position: relative;
}

.machine-frame.animate-in {
  animation: machineReveal 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes machineReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.what-you-get {
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid rgba(139, 115, 18, 0.25);
  text-align: left;
}

.what-you-get .what-title {
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  color: var(--gold-dim);
  text-transform: uppercase;
  margin-bottom: 0.9rem;
  opacity: 0.9;
}

.what-you-get ul {
  list-style: none;
  font-size: 0.98rem;
  color: var(--text-dim);
  line-height: 1.9;
}

.what-you-get li {
  padding-left: 0.25rem;
  transition: color 0.2s ease;
}

.what-you-get li:hover {
  color: rgba(232, 228, 220, 0.7);
}

.what-you-get li::before {
  content: '—';
  color: var(--gold-dim);
  margin-right: 0.5rem;
  opacity: 0.8;
}

.sound-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  font-family: inherit;
  font-size: 0.82rem;
  background: rgba(10, 10, 10, 0.6);
  border: 1px solid rgba(139, 115, 18, 0.4);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.05em;
}

.sound-toggle:hover {
  color: var(--gold-dim);
  border-color: rgba(139, 115, 18, 0.6);
}

.sound-toggle.playing {
  color: var(--gold);
  border-color: rgba(201, 162, 39, 0.4);
  box-shadow: 0 0 15px var(--glow-subtle);
}

.sound-toggle .sound-icon {
  font-size: 0.9rem;
  opacity: 0.85;
}

.sound-toggle.playing .sound-icon {
  animation: soundPulse 2s ease-in-out infinite;
}

@keyframes soundPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.sound-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.landing-hook {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.25em;
  color: var(--gold-dim);
  margin-bottom: 1rem;
  text-transform: uppercase;
  opacity: 0.85;
}

.title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.9rem, 5.5vw, 2.6rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: 0.5rem;
  text-shadow: 0 0 50px var(--glow-subtle);
}

.tagline {
  font-size: 1.12rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}

.slot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.slot-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  color: var(--gold-dim);
  text-transform: uppercase;
  opacity: 0.6;
}

.cta-hook {
  font-size: 0.96rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.slot {
  width: 70px;
  height: 10px;
  margin: 0;
  background: linear-gradient(180deg,
    rgba(201, 162, 39, 0.15) 0%,
    rgba(139, 115, 18, 0.4) 30%,
    rgba(139, 115, 18, 0.5) 50%,
    rgba(139, 115, 18, 0.4) 70%,
    rgba(201, 162, 39, 0.1) 100%
  );
  border-radius: 2px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5), 0 0 12px rgba(201, 162, 39, 0.1);
}

.consult-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  padding: 1.1rem 2rem;
  font-family: inherit;
  font-size: 1.1rem;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  letter-spacing: 0.06em;
}

.consult-btn:hover:not(:disabled) {
  background: rgba(201, 162, 39, 0.08);
  box-shadow: 0 0 30px var(--glow-subtle), 0 0 0 1px rgba(201, 162, 39, 0.15);
  transform: translateY(-1px);
}

.consult-btn:active:not(:disabled) {
  transform: translateY(0);
}

.consult-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

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

.btn-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  opacity: 0.9;
}

.disclaimer {
  margin-top: 1.75rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.55;
  opacity: 0.9;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.85rem 1.6rem;
  background: rgba(15, 14, 12, 0.96);
  border: 1px solid rgba(139, 115, 18, 0.5);
  font-size: 0.9rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Reading phases */
.phase {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  padding-bottom: 1.5rem;
  transition: opacity 0.5s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.phase.hidden {
  display: none !important;
}

/* Enable sound phase (post-Stripe, before static) */
.enable-sound-phase {
  background: var(--bg);
}

.enable-sound-phase::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 50% at 50% 50%, rgba(201, 162, 39, 0.03) 0%, transparent 70%);
  pointer-events: none;
}

.enable-sound-container {
  text-align: center;
  max-width: 340px;
  position: relative;
  z-index: 1;
}

.enable-sound-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.85rem;
  letter-spacing: 0.04em;
}

.enable-sound-text {
  font-size: 0.98rem;
  color: var(--text-dim);
  margin-bottom: 1.75rem;
  font-style: italic;
}

.enable-sound-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  padding: 1rem 2rem;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  cursor: pointer;
  letter-spacing: 0.12em;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.enable-sound-btn:hover,
.enable-sound-btn:focus {
  background: var(--gold);
  color: var(--bg);
  box-shadow: 0 0 25px var(--glow-subtle);
  transform: translateY(-1px);
}

/* Static phase */
.static-phase {
  background: #000;
}

.static-phase .static-text {
  text-shadow: 0 0 20px rgba(201, 162, 39, 0.15);
}

.static-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.static-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 80% at 50% 50%, transparent 35%, rgba(0,0,0,0.4) 70%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
}

.static-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.3) 2px,
    rgba(0, 0, 0, 0.3) 4px
  );
  pointer-events: none;
}

.static-text {
  position: relative;
  z-index: 3;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--gold-dim);
  letter-spacing: 0.2em;
  animation: blink 1.5s ease-in-out infinite;
}

.sound-hint {
  position: relative;
  z-index: 3;
  margin-top: 1.5rem;
  font-size: 0.65rem;
  color: var(--gold-dim);
  letter-spacing: 0.15em;
  opacity: 0.7;
}

@keyframes static {
  0%, 100% { background-position: 0 0; }
  25% { background-position: 50px 50px; }
  50% { background-position: 100px 0; }
  75% { background-position: 0 100px; }
}

@keyframes blink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Reveal phase */
.reveal-phase {
  background: var(--bg);
  position: relative;
  justify-content: flex-start;
  padding-top: 2rem;
}

.reveal-phase::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 100% 80% at 50% 20%, rgba(201, 162, 39, 0.02) 0%, transparent 50%);
  pointer-events: none;
}

.reveal-phase .reveal-container {
  margin-bottom: 18rem; /* scroll space above footer */
  position: relative;
  z-index: 1;
}

.glitch-brief {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}

.glitch-brief.active {
  animation: glitchFlash 0.15s ease-out;
}

@keyframes glitchFlash {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 0; }
}

.reveal-container {
  max-width: 480px;
  text-align: center;
  animation: revealIn 1.3s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  position: relative;
  z-index: 2;
}

.rarity-badge {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--gold-bright);
  margin-bottom: 0.75rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(139, 115, 18, 0.5);
  box-shadow: 0 0 15px var(--glow-subtle);
}

@keyframes revealIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.sigil-wrap {
  margin-bottom: 2rem;
  position: relative;
}

.sigil-wrap::before {
  content: '';
  position: absolute;
  inset: -20px;
  background: radial-gradient(ellipse at center, rgba(201, 162, 39, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.sigil {
  width: 200px;
  height: 200px;
  margin: 0 auto;
  position: relative;
  filter: drop-shadow(0 0 20px rgba(201, 162, 39, 0.15));
}

.sigil :global(svg) {
  width: 100%;
  height: 100%;
}

.mood-omen {
  font-size: 0.82rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
}

.message {
  font-size: 1.4rem;
  line-height: 1.75;
  font-style: italic;
  margin-bottom: 1.75rem;
  white-space: pre-line;
  color: var(--text);
  max-width: 28em;
  margin-left: auto;
  margin-right: auto;
}

.message .line {
  display: block;
  animation: lineIn 0.9s ease-out backwards;
}

.message .line:nth-child(1) { animation-delay: 0.3s; }
.message .line:nth-child(2) { animation-delay: 0.65s; }
.message .line:nth-child(3) { animation-delay: 1s; }
.message .line:nth-child(4) { animation-delay: 1.35s; }
.message .line:nth-child(5) { animation-delay: 1.7s; }

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

.reading-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  opacity: 0.9;
}

.actions {
  margin-top: 2.25rem;
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
}

.actions .share-btn.secondary {
  border-color: rgba(139, 115, 18, 0.45);
  font-size: 0.85rem;
}

.actions .share-btn.secondary:hover {
  border-color: var(--gold-dim);
  background: rgba(201, 162, 39, 0.04);
}

.share-btn {
  padding: 0.7rem 1.6rem;
  font-family: inherit;
  font-size: 0.9rem;
  background: transparent;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  letter-spacing: 0.05em;
}

.share-btn:hover {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.06);
  box-shadow: 0 0 20px var(--glow-subtle);
}

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

.back-link {
  font-size: 0.88rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.25s ease, opacity 0.25s ease;
}

.back-link:hover {
  color: var(--gold);
}

.back-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Rarity badges */
.rarity-mythic .mood-omen { color: #e8c547; }
.rarity-rare .mood-omen { color: #c9a227; }
.rarity-strange .mood-omen { color: #a68b1e; }
.rarity-common .mood-omen { color: #8b7312; }

/* Already consulted (reload) */
.already-consulted-phase {
  background: var(--bg);
}

.already-consulted-phase::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 50% at 50% 50%, rgba(201, 162, 39, 0.02) 0%, transparent 70%);
  pointer-events: none;
}

.already-consulted-container {
  max-width: 420px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.already-consulted-container .message {
  margin-bottom: 2.25rem;
}

.consult-again-btn {
  display: inline-block;
  padding: 1.1rem 2rem;
  font-family: inherit;
  font-size: 1.1rem;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  text-decoration: none;
  transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  letter-spacing: 0.06em;
}

.consult-again-btn:hover {
  background: rgba(201, 162, 39, 0.08);
  box-shadow: 0 0 30px var(--glow-subtle);
  transform: translateY(-1px);
}

.consult-again-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Error */
.error-phase {
  text-align: center;
}

.error-phase .back-link {
  transition: all 0.25s ease;
}

.error-text {
  font-size: 1.15rem;
  margin-bottom: 1.75rem;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.hidden {
  display: none !important;
}

/* Legal footer */
.legal-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.legal-footer p {
  margin: 0.25rem 0;
}

.footer-brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem !important;
}

.footer-brand a {
  color: var(--gold-dim);
  text-decoration: none;
}

.footer-brand a:hover {
  color: var(--gold);
  text-decoration: underline;
}

.legal-footer-fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(10,10,10,0.98));
  padding: 3rem 1.5rem 1.5rem;
}

.legal-footer-fixed .footer-brand {
  margin-bottom: 0.75rem !important;
}

.legal-footer-fixed .footer-lurking {
  margin-bottom: 2rem;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.65;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
  opacity: 0.9;
}

.legal-links {
  margin-top: 0.5rem !important;
}

.legal-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--gold-dim);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.legal-link:hover {
  color: var(--gold);
}

.legal-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Legal modal */
.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.legal-modal.hidden {
  display: none !important;
}

.legal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.legal-modal-content {
  position: relative;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(18,17,14,0.98) 0%, var(--bg-warm) 100%);
  border: 1px solid rgba(139, 115, 18, 0.5);
  padding: 2rem;
  box-shadow: 0 0 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(201, 162, 39, 0.05);
}

.legal-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.legal-modal-close:hover {
  color: var(--gold);
}

.legal-modal-title {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 1rem;
  padding-right: 2rem;
}

.legal-modal-body {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-dim);
}

.legal-modal-body p {
  margin-bottom: 1rem;
}

.legal-modal-body p:last-child {
  margin-bottom: 0;
}

.legal-modal-body a {
  color: var(--gold);
  text-decoration: underline;
}

.legal-modal-body a:hover {
  color: var(--gold-bright);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .machine-frame,
  .machine-frame.animate-in {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .message .line { animation: none; opacity: 1; }
  .reveal-container { animation: none; }
  .consult-btn:hover:not(:disabled),
  .consult-again-btn:hover,
  .share-btn:hover,
  .enable-sound-btn:hover,
  .enable-sound-btn:focus {
    transform: none;
  }
  .sound-toggle.playing .sound-icon {
    animation: none;
  }
}
