/* =========================================================
   Should I Ape? — Mystic skin (default + only launched skin)
   Dark mode only.
   ========================================================= */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font: inherit; }

/* ---- Mystic skin variables ---- */
.skin-mystic {
  --bg:           #0c0918;
  --surface:      #13102a;
  --surface-2:    #1c1838;
  --accent:       #9b5de5;
  --accent-glow:  rgba(155, 93, 229, 0.25);
  --gold:         #e8b84b;
  --gold-dim:     rgba(232, 184, 75, 0.15);
  --text:         #ddd4f0;
  --text-muted:   #7a6e99;
  --border:       #2a2050;
  --card-bg:      #18143a;
  --card-border:  #3d2f70;
  --danger:       #e05252;
  --radius:       12px;
  --font-serif:   'Cinzel', Georgia, serif;
  --font-ui:      'Inter', system-ui, sans-serif;
}

/* ---- Degen / Builder: placeholder — vars will be defined post-launch ---- */
.skin-degen  { --accent: #00ff88; --bg: #050505; }
.skin-builder { --accent: #39d353; --bg: #0d1117; }
.skin-degen, .skin-builder {
  /* Inherit Mystic as fallback until skins are built */
  --surface: #13102a; --surface-2: #1c1838; --gold: #e8b84b;
  --text: #ddd4f0; --text-muted: #7a6e99; --border: #2a2050;
  --card-bg: #18143a; --card-border: #3d2f70; --danger: #e05252;
  --radius: 12px; --font-serif: 'Cinzel', Georgia, serif;
  --font-ui: 'Inter', system-ui, sans-serif; --bg: #0c0918;
  --accent-glow: rgba(155, 93, 229, 0.25); --gold-dim: rgba(232, 184, 75, 0.15);
}

/* ---- Base ---- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Header ---- */
.site-header {
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.logo-img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
}

.site-nav {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-nav a { color: var(--text-muted); }
.site-nav a:hover { color: var(--text); }

/* ---- Footer ---- */
.site-footer {
  padding: 2rem 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 1rem;
  line-height: 1.7;
}

.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-nav a { color: var(--text-muted); }
.footer-nav a:hover { color: var(--text); }

/* ---- Honeypot (spam prevention) — visually and spatially absent ---- */
.honeypot {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  aria-hidden: true;
}

/* ---- Setup page ---- */
.setup-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.setup-intro { text-align: center; margin-bottom: 2.5rem; }

.setup-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.setup-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

.setup-section {
  border: none;
  margin-bottom: 2rem;
}

.setup-label {
  display: block;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Intent grid */
.intent-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 480px) {
  .intent-grid { grid-template-columns: repeat(4, 1fr); }
}

.intent-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.9rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}

.intent-option:hover { border-color: var(--accent); }
.intent-option--selected,
.intent-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.intent-option input { position: absolute; opacity: 0; pointer-events: none; }

.intent-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.intent-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Coin grid */
.coin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

@media (min-width: 480px) {
  .coin-grid { grid-template-columns: repeat(6, 1fr); }
}

.coin-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}

.coin-option:hover { border-color: var(--gold); }
.coin-option--selected,
.coin-option:has(input:checked) {
  border-color: var(--gold);
  background: var(--gold-dim);
}

.coin-option input { position: absolute; opacity: 0; pointer-events: none; }

.coin-symbol {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gold);
}

.coin-name {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Zodiac section */
.setup-section--optional .setup-label { color: var(--text-muted); }

.optional-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.setup-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.zodiac-inputs {
  display: flex;
  gap: 0.75rem;
}

.zodiac-select {
  flex: 1;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  appearance: none;
  cursor: pointer;
}

.zodiac-select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.zodiac-legend {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
}

.zodiac-sign-hint {
  font-size: 0.8rem;
  color: var(--accent);
  font-family: var(--font-serif);
  letter-spacing: 0.03em;
  font-weight: 400;
  text-transform: none;
}

/* Draw button */
.draw-button {
  display: block;
  width: 100%;
  padding: 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: opacity 0.15s, transform 0.1s;
  margin-top: 0.5rem;
}

.draw-button:hover { opacity: 0.9; }
.draw-button:active { transform: scale(0.98); }

.setup-disclaimer {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 1rem;
  margin-bottom: 0;
}

/* ---- Reading page ---- */
.reading-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* Draw note — shown at the bottom when this isn't the first draw */
.draw-note {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2rem;
  margin-bottom: 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Context line */
.reading-context {
  text-align: center;
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.reading-context strong {
  color: var(--gold);
  font-weight: 600;
}

/* ---- Card spread ---- */
.card-fan {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.card-slot {
  position: relative;
  width: calc(33.333% - 1rem);
  min-width: 200px;
  border-radius: 10px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  animation: card-pulse 3s ease-in-out infinite;
  color: var(--text);
}

.card-slot--affinity {
  border-color: var(--gold);
  animation-name: card-pulse-gold;
}

@media (max-width: 640px) {
  .card-fan {
    flex-direction: column;
    align-items: stretch;
    gap: 2rem;
  }
  .card-slot {
    width: 100%;
    min-width: 0;
  }
}

@keyframes card-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,0.6); }
  50%       { box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 28px 6px rgba(155,93,229,0.55); }
}

@keyframes card-pulse-gold {
  0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,0.6); }
  50%       { box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 28px 6px rgba(232,184,75,0.6); }
}

/* Card inner content */
.card-inner { padding: 0; }

.card-face {
  position: relative;
  width: 100%;
}

.card-img {
  width: 100%;
  aspect-ratio: 2 / 3.5;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: block;
}

.card-reversed .card-img {
  transform: rotate(180deg);
  filter: hue-rotate(95deg) saturate(1.4) brightness(0.88);
}

.card-affinity-signal {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  padding: 0.35rem 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(232, 184, 75, 0.25);
  background: rgba(232, 184, 75, 0.07);
}

/* Card narrative needs its own padding */
.card-narrative { padding: 1rem; }

.card-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.card-placeholder-num {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--gold);
  opacity: 0.7;
}

.card-placeholder-name {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  line-height: 1.3;
}

.card-reversed-badge {
  font-size: 0.65rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}

/* Card narrative — hidden until revealed */

.card-position-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.card-name {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.15rem;
}

.reversed-marker { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }

.card-traditional {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.75rem;
}

.card-narrative-text {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.65;
}

/* Pulse glow on unrevealed cards */
.card-slot:not([aria-expanded="true"]) {
  animation: card-pulse 3s ease-in-out infinite;
}

@keyframes card-pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(0,0,0,0.55); }
  50%       { box-shadow: 0 8px 24px rgba(0,0,0,0.55), 0 0 18px 2px rgba(155,93,229,0.35); }
}

/* ---- Verdict ---- */
.verdict-section {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.verdict-label {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.verdict-asterisk {
  color: var(--text-muted);
  font-size: 1rem;
  vertical-align: super;
  font-family: var(--font-ui);
  font-weight: 400;
}

.verdict-text {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
  max-width: 480px;
  margin: 0 auto 1rem;
}

.verdict-disclaimer {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- Idle nudge ---- */

.verdict-label,
.verdict-text {
  transition: opacity 1s ease;
}

.verdict-section--idle .verdict-label,
.verdict-section--idle .verdict-text {
  opacity: 0.1;
}

.idle-nudge {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.8s ease, opacity 0.8s ease;
  margin: 0 auto;
  max-width: 440px;
}

.verdict-section--idle .idle-nudge {
  max-height: 300px;
  opacity: 1;
  margin-bottom: 0.5rem;
}

.idle-nudge p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.idle-nudge p:first-child {
  font-style: italic;
}

.idle-nudge a {
  color: var(--text);
  text-decoration: underline;
  white-space: nowrap;
}

.idle-nudge-dismiss {
  margin-top: 0.25rem;
  background: none;
  border: none;
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.5;
  cursor: pointer;
  padding: 0.25rem 0;
  font-family: var(--font-ui);
  transition: opacity 0.15s;
}

.idle-nudge-dismiss:hover {
  opacity: 1;
}

/* ---- Verdict actions (share + new reading) ---- */
.verdict-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.25rem 0 0.75rem;
}

.share-button {
  padding: 0.65rem 1.5rem;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.share-button:hover {
  background: var(--accent);
  color: #fff;
}

.new-reading-button {
  display: inline-block;
  padding: 0.65rem 1.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: var(--font-ui);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.new-reading-button:hover {
  border-color: var(--text-muted);
  color: var(--text);
  text-decoration: none;
}

.when-it-stops-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0.6;
  text-decoration: none;
  transition: opacity 0.15s, color 0.15s;
}

.when-it-stops-link:hover {
  opacity: 1;
  color: var(--text-muted);
  text-decoration: underline;
}

/* ---- CTA ---- */
.cta-button {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
}

.cta-button:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  text-decoration: none;
}


/* ---- Ad slot ---- */
.ad-slot {
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
}

.ad-slot--preview {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 6px,
    color-mix(in srgb, var(--border) 40%, transparent) 6px,
    color-mix(in srgb, var(--border) 40%, transparent) 7px
  );
}

.ad-slot-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ---- Out page ---- */
.out-backdrop {
  min-height: calc(100vh - 120px);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.25rem;
}

.out-page {
  max-width: 460px;
  width: 100%;
  text-align: center;
  background: rgba(10, 8, 20, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 2.5rem 2rem 1.5rem;
}

.out-title {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  color: var(--gold);
  margin-bottom: 1rem;
}

.out-message {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.out-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
  line-height: 1.6;
}

.out-helpline {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.out-helpline a {
  color: var(--text-muted);
}

.out-link {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
  margin-bottom: 1.5rem;
}

.out-link:hover {
  border-color: var(--text-muted);
  color: var(--text);
  text-decoration: none;
}

.out-credit {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 1rem;
  margin-bottom: 0;
}

.out-credit a {
  color: rgba(255, 255, 255, 0.3);
  text-decoration: none;
}

.out-credit a:hover {
  color: rgba(255, 255, 255, 0.5);
}

/* ---- 404 ---- */
.error-page {
  max-width: 480px;
  margin: 4rem auto;
  padding: 0 1.25rem;
  text-align: center;
}

.error-code {
  font-family: var(--font-serif);
  font-size: 5rem;
  color: var(--border);
  margin-bottom: 1rem;
}

.error-message {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
  font-style: italic;
}

/* =========================================================
   Decay system — draw_count 2–6 progressive degradation
   All CSS, zero JS, zero performance cost.
   ========================================================= */

/* Level 2 — barely noticeable desaturation */
body[data-decay="2"] {
  filter: saturate(0.8);
}

/* Level 3 — desaturation + scan lines */
body[data-decay="3"] {
  filter: saturate(0.55);
}
body[data-decay="3"]::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.12) 3px,
    rgba(0, 0, 0, 0.12) 4px
  );
  pointer-events: none;
  z-index: 9000;
}
body[data-decay="3"] .verdict-label {
  letter-spacing: 0.09em; /* subtle font shift */
}

/* Level 4 — heavy desaturation + grain + 1px layout drift */
body[data-decay="4"] {
  filter: saturate(0.3) contrast(0.88);
}
body[data-decay="4"]::before {
  content: '';
  position: fixed;
  inset: 0;
  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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9001;
  opacity: 0.5;
}
body[data-decay="4"]::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.18) 2px,
    rgba(0, 0, 0, 0.18) 4px
  );
  pointer-events: none;
  z-index: 9000;
}
body[data-decay="4"] .reading-page {
  transform: translate(1px, -1px);
}
body[data-decay="4"] .card-fan {
  transform: skew(0.3deg, 0deg);
}

/* Level 5 — near-monochrome + shake + glitch flash */
@keyframes verdict-shake {
  0%, 85%, 100% { transform: none; }
  87%  { transform: translateX(-3px) rotate(-0.4deg); }
  89%  { transform: translateX(3px)  rotate(0.4deg); }
  91%  { transform: translateX(-2px); }
  93%  { transform: translateX(2px); }
}

body[data-decay="5"] {
  filter: saturate(0.1) contrast(0.82) blur(0.2px);
}
body[data-decay="5"]::before {
  content: '';
  position: fixed;
  inset: 0;
  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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.12'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9001;
  opacity: 0.7;
}
body[data-decay="5"]::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.22) 2px,
    rgba(0, 0, 0, 0.22) 4px
  );
  pointer-events: none;
  z-index: 9000;
}
body[data-decay="5"] .verdict-label {
  animation: verdict-shake 4s ease-in-out infinite;
}
body[data-decay="5"] .reading-page {
  transform: translate(-1px, 1px) skew(0.5deg, 0deg);
}

/* Level 6 — near-unreadable, corrupted */
@keyframes glitch-clip {
  0%, 90%, 100% { clip-path: none; transform: none; opacity: 1; }
  91% { clip-path: inset(20% 0 55% 0); transform: translateX(-3px); }
  92% { clip-path: inset(55% 0 15% 0); transform: translateX(3px); }
  93% { clip-path: inset(35% 0 35% 0); transform: translateX(-2px); opacity: 0.8; }
  94% { clip-path: none; transform: none; }
}

@keyframes bg-flicker {
  0%, 97%, 100% { opacity: 1; }
  98% { opacity: 0.7; }
  99% { opacity: 0.9; }
}

body[data-decay="6"] {
  filter: saturate(0) contrast(0.72) blur(0.5px);
  animation: bg-flicker 3s step-end infinite;
}
body[data-decay="6"]::before {
  content: '';
  position: fixed;
  inset: 0;
  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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.18'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9001;
  opacity: 0.9;
}
body[data-decay="6"]::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.3) 1px,
    rgba(0, 0, 0, 0.3) 3px
  );
  pointer-events: none;
  z-index: 9000;
}
body[data-decay="6"] .verdict-label {
  animation: glitch-clip 2.5s step-end infinite;
}
body[data-decay="6"] .verdict-text {
  animation: verdict-shake 2s ease-in-out infinite;
  opacity: 0.75;
}
body[data-decay="6"] .reading-page {
  transform: translate(2px, -2px) skew(1deg, 0.3deg);
}
body[data-decay="6"] .card-fan {
  transform: skew(-0.8deg, 0.3deg);
  opacity: 0.85;
}

/* =========================================================
   Loading overlay — shown while the form submits
   ========================================================= */

/* ---- Card scatter & gather animation ---- */

.shuffle-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.shuffle-overlay--active {
  opacity: 1;
  pointer-events: all;
}

.shuffle-card {
  position: absolute;
  left: calc(50% - 34px);
  top: calc(50% - 60px);
  width: 68px;
  height: 120px;
  border-radius: 6px;
  background: url('/static/cards/mystic/back.webp') center / cover no-repeat, var(--bg);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.65);
  will-change: transform;
}

/* ---- Loading overlay (kept for other uses) ---- */

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
}

.loading-overlay--visible {
  display: flex;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-message {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 320px;
  line-height: 1.6;
  min-height: 3em;
  transition: opacity 0.3s;
}

/* =========================================================
   Disclaimer page
   ========================================================= */

.disclaimer-page {
  max-width: 600px;
  margin: 2rem auto;
  padding: 0 1.25rem 3rem;
}

.disclaimer-page h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--gold);
  margin-bottom: 1.5rem;
}

.disclaimer-page p,
.disclaimer-page li {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 1rem;
}

.disclaimer-page ul {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.disclaimer-page a { color: var(--accent); }

.disclaimer-callout {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  background: var(--surface);
  margin: 1.5rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.75;
}

/* =========================================================
   Card detail page
   ========================================================= */

.card-detail-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.card-detail-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin: 1.5rem 0 2rem;
}

.card-detail-img {
  width: 180px;
  aspect-ratio: 2 / 3.5;
  flex-shrink: 0;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7), 0 0 0 1px var(--card-border);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.card-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.card-detail-num {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--gold);
  opacity: 0.7;
}

.card-detail-header h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--text);
  line-height: 1.2;
}

.card-detail-traditional {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.card-detail-meanings {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.meaning-block h2 {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.meaning-block p {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text);
}

.meaning-block--reversed h2 { color: var(--accent); }

/* =========================================================
   Cards index page
   ========================================================= */

.cards-index-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.cards-index-page h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--gold);
  margin-bottom: 0.75rem;
}

.seo-intro {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.card-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}

.card-index-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: var(--surface);
  transition: border-color 0.2s, transform 0.2s;
  padding-bottom: 0.6rem;
}

.card-index-item:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
  text-decoration: none;
}

.card-index-img {
  width: 100%;
  display: block;
  aspect-ratio: 2 / 3.5;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.card-index-num {
  font-family: var(--font-serif);
  font-size: 0.7rem;
  color: var(--gold);
  opacity: 0.7;
}

.card-index-name {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  padding: 0 0.4rem;
  line-height: 1.3;
}

.card-index-traditional {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0 0.4rem;
}

/* =========================================================
   Glossary — index and detail pages
   ========================================================= */

/* Index page wrapper */
.glossary-index-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.glossary-index-page h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--gold);
  margin-bottom: 0.75rem;
}

/* Responsive term grid */
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
  margin-top: 1.5rem;
}

@media (min-width: 560px) {
  .glossary-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 800px) {
  .glossary-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Individual term card */
.gloss-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.18s, transform 0.18s;
}

.gloss-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.gloss-card-term {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gold);
  line-height: 1.3;
}

.gloss-card-short {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Inline glossary link (used by linkify_glossary filter) */
.gloss-link {
  color: var(--accent);
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 2px;
  font-weight: 400;
}

.gloss-link:hover {
  text-decoration: underline var(--accent);
}

/* ---- Glossary detail page ---- */

.glossary-detail-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.glossary-detail-page h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--gold);
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.glossary-definition {
  margin-bottom: 2rem;
}

.glossary-definition h2 {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.glossary-definition p {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
}

/* Oracle section — italicised, left accent border */
.glossary-oracle {
  border-left: 3px solid var(--accent);
  padding-left: 1.1rem;
  margin-bottom: 2rem;
}

.glossary-oracle h2 {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.glossary-oracle p {
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.75;
  color: var(--text-muted);
}

/* Related terms section */
.glossary-related {
  margin-bottom: 2rem;
}

.glossary-related h2 {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.glossary-related ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.glossary-related li a {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.glossary-related li a:hover {
  border-color: var(--accent);
  color: var(--accent);
}
