/* ============================================================
   MythForge — Papyrus & Lapis design system
   Warm sand surfaces, deep lapis-blue accent, Egyptian gold
   ============================================================ */

:root,
[data-theme='light'] {
  /* Surfaces — deep lapis night */
  --color-bg: #0a1a33;
  --color-surface: #12284a;
  --color-surface-2: #183359;
  --color-surface-offset: #1b3a5c;
  --color-surface-offset-2: #234766;
  --color-divider: rgba(255, 215, 106, 0.18);
  --color-border: rgba(255, 215, 106, 0.28);

  /* Ink — cream & gold on lapis */
  --color-text: #F2E6C8;
  --color-text-muted: #C9C0A7;
  --color-text-faint: #93a4c0;
  --color-text-inverse: #0a1a33;

  /* Accent — bright gold (swapped role with primary so gold drives CTAs) */
  --color-primary: #FFD76A;
  --color-primary-hover: #FFE089;
  --color-primary-active: #F4CB68;
  --color-primary-highlight: rgba(255, 215, 106, 0.18);

  /* Gold — Egyptian sun */
  --color-gold: #FFD76A;
  --color-gold-hover: #FFE089;
  --color-gold-active: #F4CB68;
  --color-gold-highlight: #FFD76A;

  /* Accent red — sunset */
  --color-ember: #e07847;
  --color-ember-hover: #f08d5c;

  /* Turquoise — Nile accent */
  --color-nile: #6fc2bb;
  --color-nile-hover: #8fd4ce;

  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  --transition-interactive: 220ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 600ms cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.35);
  --shadow-md: 0 6px 18px oklch(0 0 0 / 0.45);
  --shadow-lg: 0 20px 48px oklch(0 0 0 / 0.55);
  --shadow-gold: 0 0 0 1px rgba(255, 215, 106, 0.4), 0 8px 24px rgba(232, 181, 74, 0.3);

  --content-narrow: 640px;
  --content-default: 1040px;
  --content-wide: 1280px;

  --font-display: 'Cinzel', 'Fraunces', Georgia, serif;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --text-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.85rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.3vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.4rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.5rem + 2.2vw, 3.25rem);
  --text-hero: clamp(2.5rem, 1.2rem + 4.5vw, 5rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
}

[data-theme='dark'] {
  /* Deeper lapis midnight — a sleep-mode variant of the lapis palette */
  --color-bg: #050d1c;
  --color-surface: #0b1a33;
  --color-surface-2: #102345;
  --color-surface-offset: #142c52;
  --color-surface-offset-2: #1a375f;
  --color-divider: rgba(255, 215, 106, 0.14);
  --color-border: rgba(255, 215, 106, 0.22);

  --color-text: #F2E6C8;
  --color-text-muted: #C4B891;
  --color-text-faint: #7d8ea8;
  --color-text-inverse: #050d1c;

  --color-primary: #FFD76A;
  --color-primary-hover: #FFE089;
  --color-primary-active: #F4CB68;
  --color-primary-highlight: rgba(255, 215, 106, 0.16);

  --color-gold: #FFD76A;
  --color-gold-hover: #FFE089;
  --color-gold-active: #F4CB68;
  --color-gold-highlight: #FFD76A;

  --color-ember: #e07847;
  --color-nile: #6fc2bb;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.5);
  --shadow-md: 0 6px 18px oklch(0 0 0 / 0.6);
  --shadow-lg: 0 20px 48px oklch(0 0 0 / 0.7);
  --shadow-gold: 0 0 0 1px rgba(255, 215, 106, 0.4), 0 8px 24px rgba(232, 181, 74, 0.35);
}

/* ============================================================
   Base stylesheet
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.65;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  position: relative;
  overflow-x: hidden;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}
button {
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
}
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-wrap: balance;
  color: var(--color-text);
}

p {
  text-wrap: pretty;
  max-width: 68ch;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-interactive);
}
a:hover {
  color: var(--color-primary-hover);
}

:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--color-gold-highlight);
  color: var(--color-text);
}

em {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-primary);
}
[data-theme='dark'] em {
  color: var(--color-gold);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Papyrus background texture (pure CSS)
   ============================================================ */
.papyrus-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(
      92deg,
      transparent 0 2px,
      oklch(0.75 0.04 80 / 0.03) 2px 3px
    ),
    repeating-linear-gradient(
      4deg,
      transparent 0 3px,
      oklch(0.7 0.05 75 / 0.025) 3px 4px
    ),
    radial-gradient(
      ellipse at 20% 10%,
      oklch(0.78 0.06 75 / 0.25) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse at 80% 90%,
      oklch(0.7 0.08 60 / 0.2) 0%,
      transparent 55%
    );
}
[data-theme='dark'] .papyrus-bg {
  opacity: 0.4;
  background-image:
    repeating-linear-gradient(
      92deg,
      transparent 0 2px,
      oklch(0.3 0.04 80 / 0.15) 2px 3px
    ),
    radial-gradient(
      ellipse at 30% 20%,
      oklch(0.35 0.08 70 / 0.3) 0%,
      transparent 60%
    );
}

main {
  position: relative;
  z-index: 1;
}
.site-header {
  position: relative;
  z-index: 50;
}
.site-footer {
  position: relative;
  z-index: 1;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) clamp(var(--space-4), 4vw, var(--space-10));
  max-width: var(--content-wide);
  margin: 0 auto;
  gap: var(--space-4);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text);
}
.logo svg {
  color: var(--color-gold);
  flex-shrink: 0;
}
.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.logo-primary {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.logo-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}
.site-nav a {
  color: var(--color-text);
  font-weight: 500;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  position: relative;
}
.site-nav a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 1px;
  background: var(--color-gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-interactive);
}
.site-nav a:hover::after {
  transform: scaleX(1);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-interactive);
}
.theme-toggle:hover {
  background: var(--color-surface-offset);
  color: var(--color-gold);
  border-color: var(--color-gold);
}

/* Hamburger button — hidden on desktop, shown on mobile */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--color-gold);
  transition: all var(--transition-interactive);
  z-index: 30;
  position: relative;
}
.nav-toggle:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-gold);
}
.nav-toggle__bar {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
  transform-origin: center;
}
.nav-toggle[aria-expanded='true'] .nav-toggle__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded='true'] .nav-toggle__bar:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded='true'] .nav-toggle__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 820px) {
  .site-header {
    position: relative;
  }
  .nav-toggle {
    display: flex;
  }
  .site-nav {
    position: absolute;
    top: 100%;
    right: clamp(var(--space-4), 4vw, var(--space-10));
    left: clamp(var(--space-4), 4vw, var(--space-10));
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-surface-2) 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    box-shadow: 0 16px 40px oklch(0 0 0 / 0.55);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 25;
  }
  .site-nav.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .site-nav a {
    display: block;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    letter-spacing: 0.04em;
  }
  .site-nav a::after { display: none; }
  .site-nav a:hover {
    background: var(--color-surface-offset);
    color: var(--color-gold);
  }
  .site-nav .nav-current {
    color: var(--color-gold);
    background: rgba(255, 215, 106, 0.08);
  }
  .site-nav .theme-toggle {
    align-self: flex-end;
    margin-top: var(--space-2);
  }
  .logo-sub {
    display: none;
  }
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative;
  padding: clamp(var(--space-10), 8vw, var(--space-24)) 0 clamp(var(--space-12), 8vw, var(--space-24));
  margin: 0;
  overflow: hidden;
  isolation: isolate;

  /* Deep lapis night sky */
  background:
    radial-gradient(ellipse 1200px 600px at 50% 0%,
      oklch(0.32 0.09 255 / 0.55) 0%,
      transparent 60%),
    radial-gradient(ellipse 800px 500px at 85% 90%,
      oklch(0.38 0.1 260 / 0.35) 0%,
      transparent 70%),
    linear-gradient(180deg,
      #0a1a33 0%,
      #12284a 35%,
      #1b3a5c 75%,
      #234766 100%);
  color: #F2E6C8; /* warm cream ink for lapis background */
}

/* Starfield + gold dust particles on the lapis hero */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #E8B54A 40%, transparent 50%),
    radial-gradient(1px 1px at 28% 72%, #F4CB68 40%, transparent 50%),
    radial-gradient(1.5px 1.5px at 45% 30%, #F4CB68 40%, transparent 50%),
    radial-gradient(1px 1px at 63% 15%, #E8B54A 40%, transparent 50%),
    radial-gradient(2px 2px at 78% 62%, #F4CB68 45%, transparent 55%),
    radial-gradient(1px 1px at 8%  82%, #F4CB68 40%, transparent 50%),
    radial-gradient(1.5px 1.5px at 92% 22%, #E8B54A 45%, transparent 55%),
    radial-gradient(1px 1px at 36% 8%,  #F4CB68 40%, transparent 50%),
    radial-gradient(1px 1px at 54% 88%, #E8B54A 40%, transparent 50%),
    radial-gradient(1.5px 1.5px at 72% 40%, #F4CB68 45%, transparent 55%);
  opacity: 0.7;
  animation: hero-twinkle 7s ease-in-out infinite;
}
@keyframes hero-twinkle {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.85; }
}

/* Faint hieroglyphic watermark on the lapis */
.hero::after {
  content: "𓃢 𓅃 𓆣";
  position: absolute;
  right: 4%;
  top: 55%;
  transform: translateY(-50%);
  font-size: clamp(6rem, 14vw, 14rem);
  color: #E8B54A;
  opacity: 0.06;
  letter-spacing: 0.25em;
  pointer-events: none;
  z-index: -1;
  line-height: 1;
  white-space: nowrap;
}

.hero-inner {
  max-width: 920px;
  position: relative;
  padding: clamp(var(--space-6), 4vw, var(--space-10)) clamp(var(--space-5), 5vw, var(--space-16));
  margin: 0 auto;
  text-align: left;
}

/* Over-the-lapis typography overrides — high contrast on deep blue */
.hero .eyebrow {
  color: #FFD76A;
  letter-spacing: 0.18em;
  text-shadow: 0 1px 10px oklch(0.35 0.14 70 / 0.5);
}
.hero .hero-title {
  color: #FFFFFF;
  text-shadow: 0 2px 18px oklch(0.15 0.08 260 / 0.7);
}
.hero .hero-title em {
  color: #FFD76A;
  font-style: italic;
  text-shadow: 0 2px 16px oklch(0.4 0.16 70 / 0.55);
}
.hero .hero-lede {
  color: #F5EEDB;
  text-shadow: 0 1px 8px oklch(0.15 0.08 260 / 0.6);
}
.hero .btn-ghost {
  color: #F2E6C8;
  border-color: oklch(0.75 0.12 75 / 0.45);
}
.hero .btn-ghost:hover {
  background: oklch(0.75 0.12 75 / 0.12);
  border-color: var(--color-gold-highlight);
  color: #F6EBCE;
}
.hero .btn-primary {
  background: linear-gradient(180deg, #E8B54A 0%, #C89548 100%);
  color: #0a1a33;
  border-color: transparent;
  box-shadow: 0 4px 18px oklch(0.55 0.15 70 / 0.35);
}
.hero .btn-primary:hover {
  background: linear-gradient(180deg, #F4CB68 0%, #D8A85A 100%);
  color: #0a1a33;
}

/* Decorative Eye of Horus above the headline */
.hero-eye {
  width: clamp(64px, 8vw, 104px);
  height: auto;
  color: #FFD76A;
  display: block;
  margin-bottom: var(--space-6);
  filter:
    drop-shadow(0 0 16px oklch(0.82 0.18 75 / 0.75))
    drop-shadow(0 4px 10px oklch(0.3 0.1 260 / 0.4));
  animation: hero-eye-drift 9s ease-in-out infinite;
}
@keyframes hero-eye-drift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-4px) rotate(-1deg); }
}

/* Scarab-and-sun divider between headline and lede */
.hero-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-6) 0 var(--space-8);
  max-width: 42ch;
}
.hero-divider__line {
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    #FFD76A 40%,
    #FFD76A 60%,
    transparent
  );
  opacity: 0.85;
}
.hero-divider__glyph {
  font-size: 1.5rem;
  color: #FFD76A;
  opacity: 1;
  line-height: 1;
  filter: drop-shadow(0 0 10px oklch(0.82 0.18 75 / 0.7));
}

/* Running hieroglyphic marquee borders at top & bottom of hero */
.hiero-marquee {
  position: relative;
  overflow: hidden;
  padding: var(--space-3) 0;
  mask-image: linear-gradient(
    90deg,
    transparent 0,
    #000 10%,
    #000 90%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0,
    #000 10%,
    #000 90%,
    transparent 100%
  );
}
.hero .hiero-marquee--top {
  border-bottom: 1px solid oklch(0.78 0.14 75 / 0.45);
  margin-bottom: clamp(var(--space-6), 4vw, var(--space-10));
}
.hero .hiero-marquee--bottom {
  border-top: 1px solid oklch(0.78 0.14 75 / 0.45);
  margin-top: clamp(var(--space-8), 5vw, var(--space-12));
}
.hiero-track {
  display: flex;
  gap: 3ch;
  width: max-content;
  animation: hiero-scroll 120s linear infinite;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  color: #FFD76A;
  letter-spacing: 0.1em;
  opacity: 0.7;
  white-space: nowrap;
  line-height: 1.2;
}
.hiero-track span { display: inline-block; padding-right: 3ch; }
.hiero-track--reverse { animation-direction: reverse; animation-duration: 140s; }
@keyframes hiero-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .hiero-track { animation: none; }
  .hero-eye { animation: none; }
}
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-gold);
  font-weight: 600;
  margin-bottom: var(--space-5);
}
.hero-title {
  font-size: var(--text-hero);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-6);
}
.hero-lede {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 60ch;
  margin-bottom: var(--space-10);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all var(--transition-interactive);
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
[data-theme='dark'] .btn-primary {
  color: var(--color-bg);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  color: var(--color-text-inverse);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
[data-theme='dark'] .btn-primary:hover {
  color: var(--color-bg);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-ghost:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-gold);
  color: var(--color-text);
}

/* Legacy hero-hieroglyphs rule kept for backward compatibility (no-op if element removed) */

/* ============================================================
   Section heads
   ============================================================ */
.section-head {
  max-width: var(--content-default);
  margin: 0 auto var(--space-12);
  padding: 0 clamp(var(--space-4), 4vw, var(--space-10));
  text-align: center;
}
.section-head h2 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-4);
}
.section-head .eyebrow {
  margin-bottom: var(--space-3);
}
.section-lede {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  margin: 0 auto;
}

section {
  padding-block: clamp(var(--space-12), 6vw, var(--space-24));
}

/* ============================================================
   Animal grid (learn)
   ============================================================ */
.learn {
  max-width: var(--content-wide);
  margin: 0 auto;
}
.animal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  padding: 0 clamp(var(--space-4), 4vw, var(--space-10));
}

.animal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: all var(--transition-interactive);
  position: relative;
  overflow: hidden;
}
.animal-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, oklch(from var(--color-gold) l c h / 0.08));
  opacity: 0;
  transition: opacity var(--transition-interactive);
}
.animal-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-gold);
  box-shadow: var(--shadow-md);
}
.animal-card:hover::before {
  opacity: 1;
}
.animal-card > * {
  position: relative;
}
.animal-hiero {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--color-gold);
  margin-bottom: var(--space-2);
}
.animal-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text);
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}
.animal-deity {
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-primary);
  font-weight: 600;
}
[data-theme='dark'] .animal-deity {
  color: var(--color-gold);
}
.animal-virtue {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ============================================================
   Forge
   ============================================================ */
.forge {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding-inline: clamp(var(--space-4), 4vw, var(--space-10));
}

.forge-stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-6);
  align-items: stretch;
  margin-bottom: var(--space-10);
}
@media (max-width: 820px) {
  .forge-stage {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  .slot[data-slot='a'] { order: 1; }
  .forge-center { order: 2; }
  .slot[data-slot='b'] { order: 3; }
  .slot-frame { min-height: 180px; }
}

.slot {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.slot-frame {
  background: var(--color-surface);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition-interactive);
  overflow: hidden;
}
.slot.filled .slot-frame {
  border-style: solid;
  border-color: var(--color-gold);
  box-shadow: var(--shadow-gold);
  background: linear-gradient(
    140deg,
    var(--color-surface) 0%,
    var(--color-surface-2) 100%
  );
}
.slot.filled .slot-frame::after {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid oklch(from var(--color-gold) l c h / 0.3);
  border-radius: calc(var(--radius-xl) - 10px);
  pointer-events: none;
}
.slot-empty {
  text-align: center;
  color: var(--color-text-faint);
}
.slot-empty p {
  font-size: var(--text-sm);
  margin: 0 auto;
  max-width: 20ch;
}
.slot-number {
  display: inline-flex;
  width: 3rem;
  height: 3rem;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-surface-offset);
  color: var(--color-gold);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-3);
}

.slot-filled-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.slot-filled-content .animal-hiero {
  font-size: 3.5rem;
  margin-bottom: var(--space-2);
  color: var(--color-gold);
  text-shadow: 0 2px 12px oklch(from var(--color-gold) l c h / 0.3);
}
.slot-filled-content .animal-name {
  font-size: var(--text-xl);
  letter-spacing: 0.04em;
}
.slot-filled-content .animal-deity {
  letter-spacing: 0.2em;
}
.slot-filled-content .animal-virtue {
  font-size: var(--text-base);
}

.slot-clear {
  align-self: center;
  font-size: var(--text-xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: var(--space-1) var(--space-3);
}
.slot-clear:hover {
  color: var(--color-ember);
}

.forge-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-width: 180px;
}
.fuse-btn,
[data-theme='dark'] .fuse-btn {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-full);
  background: radial-gradient(
    circle at 30% 30%,
    var(--color-gold-highlight),
    var(--color-gold) 60%,
    var(--color-gold-active) 100%
  );
  color: #0a1a33;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  position: relative;
  box-shadow: var(--shadow-lg), inset 0 0 0 3px oklch(from var(--color-gold-active) l c h / 0.4);
  transition: all var(--transition-interactive);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.fuse-btn:disabled {
  background: var(--color-surface-offset-2);
  color: var(--color-text-faint);
  cursor: not-allowed;
  box-shadow: none;
}
.fuse-btn:not(:disabled):hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg), 0 0 0 4px oklch(from var(--color-gold) l c h / 0.25);
}
.fuse-btn:not(:disabled):active {
  transform: scale(0.97);
}
.fuse-ring {
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-full);
  border: 2px dashed oklch(from var(--color-gold) l c h / 0.6);
  animation: spin 40s linear infinite;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-interactive);
}
.fuse-btn:not(:disabled) .fuse-ring {
  opacity: 1;
}
.fuse-btn.loading .fuse-ring {
  animation-duration: 1.2s;
}
.fuse-btn.loading {
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 0 0 oklch(from var(--color-gold) l c h / 0.4); }
  50% { box-shadow: var(--shadow-lg), 0 0 0 16px oklch(from var(--color-gold) l c h / 0); }
}

.fuse-label {
  position: relative;
  z-index: 1;
  color: #0a1a33;
}

.forge-hint {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  max-width: 24ch;
}

/* Picker — mini chips of all animals, click to place */
.picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  padding: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}
.picker-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  font-size: var(--text-sm);
  transition: all var(--transition-interactive);
  cursor: pointer;
}
.picker-chip:hover {
  border-color: var(--color-gold);
  background: var(--color-surface-offset);
  transform: translateY(-1px);
}
.picker-chip.selected,
[data-theme='dark'] .picker-chip.selected {
  background: var(--color-primary);
  color: #0a1a33;
  border-color: var(--color-primary);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(255, 215, 106, 0.4), 0 4px 12px rgba(255, 215, 106, 0.2);
}
.picker-chip.selected:hover {
  background: #FFE08A;
  transform: translateY(-1px);
}
.picker-chip .chip-hiero {
  font-size: 1.25rem;
  line-height: 1;
  color: var(--color-gold);
}
.picker-chip.selected .chip-hiero {
  color: #0a1a33;
}

/* ============================================================
   Gallery
   ============================================================ */
.gallery {
  max-width: var(--content-wide);
  margin: 0 auto;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
  padding: 0 clamp(var(--space-4), 4vw, var(--space-10));
}
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-text-muted);
  padding: var(--space-16) var(--space-4);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-xl);
}
.gallery-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-interactive);
}
.gallery-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-gold);
  box-shadow: var(--shadow-md);
}
.gallery-card-img {
  aspect-ratio: 1 / 1;
  background: var(--color-surface-offset);
  overflow: hidden;
  position: relative;
}
.gallery-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-card-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.gallery-card-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
}
.gallery-card-virtue {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.gallery-card-combo {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: var(--space-1);
}

/* ============================================================
   Epilogue
   ============================================================ */
.epilogue {
  max-width: var(--content-narrow);
  margin: 0 auto;
  padding: var(--space-16) clamp(var(--space-4), 4vw, var(--space-10));
  text-align: center;
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-16);
}
.epilogue h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-3);
  color: var(--color-gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.epilogue p {
  font-family: var(--font-serif);
  color: var(--color-text-muted);
  margin: 0 auto;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  padding: var(--space-6) clamp(var(--space-4), 4vw, var(--space-10));
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ============================================================
   Modals
   ============================================================ */
.modal {
  border: none;
  padding: 0;
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-xl);
  max-width: 580px;
  width: calc(100% - 2rem);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--color-border);
}
.modal-wide {
  max-width: 900px;
}
.modal::backdrop {
  background: oklch(0.1 0.02 60 / 0.7);
  backdrop-filter: blur(4px);
}
.modal-close-form {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;
  padding: var(--space-3);
  z-index: 2;
  pointer-events: none;
}
.modal-close {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-full);
  background: var(--color-surface-offset);
  color: var(--color-text);
  font-size: 1.5rem;
  line-height: 1;
  pointer-events: auto;
  transition: all var(--transition-interactive);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: var(--color-ember);
  color: var(--color-text-inverse);
}
.modal-body {
  padding: 0 var(--space-8) var(--space-8);
}

/* Modal — animal detail */
.animal-detail {
  text-align: center;
}
.animal-detail .detail-hiero {
  font-size: 5rem;
  color: var(--color-gold);
  line-height: 1;
  margin-bottom: var(--space-4);
}
.animal-detail h3 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}
.animal-detail .detail-deity {
  font-family: var(--font-display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-primary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}
[data-theme='dark'] .animal-detail .detail-deity {
  color: var(--color-gold);
}
.animal-detail .detail-virtue {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--color-gold);
  margin-bottom: var(--space-5);
}
.animal-detail .detail-meaning {
  text-align: left;
  margin-bottom: var(--space-5);
  color: var(--color-text);
}
.animal-detail .detail-lesson {
  background: var(--color-surface-offset);
  border-left: 3px solid var(--color-gold);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-serif);
  font-style: italic;
  text-align: left;
  color: var(--color-text);
  margin-bottom: var(--space-5);
}
.animal-detail .detail-traits {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-bottom: var(--space-6);
}
.trait-tag {
  background: var(--color-surface-offset-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
}
.detail-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* Modal — fusion result */
.fusion-result {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}
@media (min-width: 720px) {
  .fusion-result {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
.fusion-image {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface-offset);
  position: relative;
  border: 1px solid var(--color-border);
}
.fusion-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.fusion-image-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-text-muted);
  background: linear-gradient(
    120deg,
    var(--color-surface-offset) 0%,
    var(--color-surface) 50%,
    var(--color-surface-offset) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.fusion-text h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}
.fusion-combo {
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-gold);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.fusion-virtue {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}
[data-theme='dark'] .fusion-virtue {
  color: var(--color-gold);
}
.fusion-meaning {
  margin-bottom: var(--space-5);
}
.fusion-lesson {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-serif);
  font-style: italic;
  margin-bottom: var(--space-5);
}
[data-theme='dark'] .fusion-lesson {
  color: var(--color-bg);
}
.fusion-powers {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.fusion-power {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text);
}
.fusion-power::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--color-gold);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--color-gold);
}
.fusion-story {
  font-family: var(--font-serif);
  line-height: 1.7;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-divider);
  padding-top: var(--space-4);
}
.fusion-story strong {
  color: var(--color-gold);
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: var(--text-xs);
  font-weight: 600;
  display: block;
  margin-bottom: var(--space-2);
}

.fusion-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  border-top: 1px solid var(--color-divider);
  padding-top: var(--space-5);
}

.loading-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
}
.loading-state .loading-spinner {
  width: 64px;
  height: 64px;
  border: 3px solid var(--color-surface-offset-2);
  border-top-color: var(--color-gold);
  border-radius: 50%;
  margin: 0 auto var(--space-5);
  animation: spin 1s linear infinite;
}
.loading-state p {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-text-muted);
  margin: 0 auto;
}
.loading-state .loading-sub {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  margin-top: var(--space-2);
}

/* ============================================================
   Provider badge — small chip showing which AI painted a fusion
   ============================================================ */
.provider-badge {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.625rem;
  font-family: var(--font-sans, ui-sans-serif, system-ui);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f7eecf;
  background: rgba(10, 26, 51, 0.78);
  border: 1px solid rgba(255, 215, 106, 0.35);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.provider-badge.provider-openai {
  border-color: rgba(16, 163, 127, 0.55);
  color: #d6f5ea;
}
.provider-badge.provider-gemini {
  border-color: rgba(140, 164, 255, 0.55);
  color: #e3eaff;
}
.provider-badge.provider-replicate {
  border-color: rgba(255, 215, 106, 0.45);
  color: #f7eecf;
}
/* On compact gallery cards, shrink the badge a touch so it doesn't dominate */
.gallery-card-img .provider-badge {
  font-size: 0.625rem;
  padding: 0.2rem 0.5rem;
  bottom: 0.4rem;
  right: 0.4rem;
}
