/* Shared chrome for every MonsteRanch page — tokens, nav, footer, embers.
   Page-specific layout (hero, devlog, legal article) stays inline per page. */

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

:root {
  --rust:      #C0440A;
  --amber:     #E8891A;
  --amber-dim: #A8650F;
  --cream:     #F5EAD0;
  --cream-dim: #C9BB9C;
  --shadow:    #120800;
  --panel:     #2A1608;
  --panel-line: rgba(245,234,208,0.10);

  --r-common:    #8CD98C;
  --r-uncommon:  #FFCC1A;
  --r-rare:      #A6D9FF;
  --r-mythical:  #FF80D9;

  --container: 1180px;
  --gap-lg: clamp(2.5rem, 6vw, 5rem);
}

html { scroll-behavior: smooth; }
html, body { width: 100%; }

body {
  font-family: 'Cabin', sans-serif;
  color: var(--cream);
  background:
    url("https://raw.githubusercontent.com/Asteria-Devs/monsteranch/main/bg.png") center/cover no-repeat fixed,
    #14210f;
  background-blend-mode: overlay;
  position: relative;
  overflow-x: hidden;
}

body::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='1'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.035;
  pointer-events: none;
  z-index: 0;
  animation: grainShift 0.15s steps(1) infinite;
}

@keyframes grainShift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-3px, 2px); }
  50%  { transform: translate(3px, -2px); }
  75%  { transform: translate(-2px, -3px); }
  100% { transform: translate(2px, 3px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body::before { animation: none; }
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}

a { color: inherit; }

/* ── Nav ─────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(18,8,0,0.62);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--panel-line);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.25rem;
}

.wordmark {
  font-family: 'Rye', serif;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--cream);
  white-space: nowrap;
}
.wordmark span { color: var(--amber); }

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.25rem);
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream-dim);
  transition: color 0.2s ease;
}
.nav-links a:hover { color: var(--amber); }

.nav-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1.15rem;
  border-radius: 3px;
  background: var(--rust);
  color: var(--cream) !important;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-decoration: none !important;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
  transition: background 0.2s ease, transform 0.2s ease;
}
.nav-cta:hover { background: var(--amber); transform: translateY(-1px); }

@media (max-width: 720px) {
  .nav-links a:not(.nav-cta) { display: none; }
  .nav-row { height: 3.75rem; }
}

/* ── Embers ──────────────────────────────────────────────────────────── */
.embers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.ember {
  position: absolute;
  bottom: -10px;
  border-radius: 50%;
  opacity: 0;
  animation: float var(--dur) var(--delay) ease-in infinite;
}

@keyframes float {
  0%   { transform: translateY(0); opacity: 0; }
  10%  { opacity: 0.9; }
  80%  { opacity: 0.4; }
  100% { transform: translateY(-100vh) translateX(var(--drift)) scale(0.3); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ember { animation: none; display: none; }
}

/* ── Footer ──────────────────────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 2;
  padding-block: 2.25rem;
  border-top: 1px solid var(--panel-line);
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--cream-dim);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}
.footer-links a { text-decoration: none; color: var(--cream-dim); transition: color 0.2s ease; }
.footer-links a:hover { color: var(--amber); }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* Mythic rainbow items share one source sprite, tinted here rather than
   needing a separate rainbow-painted asset per creature. */
.rainbow-tint {
  filter: hue-rotate(0deg) saturate(1.7);
  animation: rainbowShift 5s linear infinite;
}
@keyframes rainbowShift {
  to { filter: hue-rotate(360deg) saturate(1.7); }
}
@media (prefers-reduced-motion: reduce) {
  .rainbow-tint { animation: none; filter: hue-rotate(140deg) saturate(1.7); }
}

/* ── Legal pages (terms / privacy) ──────────────────────────────────────── */
.legal-hero {
  position: relative;
  z-index: 2;
  padding-block: clamp(2.5rem, 6vw, 4rem) clamp(1.5rem, 4vw, 2rem);
}

.legal-eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 0.9rem;
}

h1.legal-title {
  font-family: 'Rye', serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  text-wrap: balance;
  line-height: 1.1;
}

.legal-updated {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--cream-dim);
}

.legal-notice {
  position: relative;
  z-index: 2;
  margin: 0 auto clamp(2rem, 5vw, 3rem);
  max-width: 68ch;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-left: 3px solid var(--amber);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--cream-dim);
}

.legal-body {
  position: relative;
  z-index: 2;
  padding-bottom: clamp(3rem, 8vw, 5rem);
}

.legal-body .container {
  max-width: 68ch;
}

.legal-body h2 {
  font-family: 'Rye', serif;
  font-size: 1.35rem;
  color: var(--amber);
  margin-top: 2.4rem;
  margin-bottom: 0.9rem;
}
.legal-body h2:first-child { margin-top: 0; }

.legal-body p, .legal-body li {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--cream-dim);
}

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

.legal-body strong { color: var(--cream); font-weight: 600; }

.legal-body ul, .legal-body ol {
  margin: 0 0 1rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legal-body a { color: var(--amber); }

.legal-cta-wrap {
  position: relative;
  z-index: 2;
  max-width: 68ch;
  margin: 0 auto 2.5rem;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}

/* ── Wiki ────────────────────────────────────────────────────────────── */
.wiki-hero {
  position: relative;
  z-index: 2;
  padding-block: clamp(2.5rem, 6vw, 4rem) clamp(1.5rem, 4vw, 2rem);
}

.wiki-toolbar {
  position: sticky;
  top: 4.25rem;
  z-index: 15;
  background: rgba(18,8,0,0.82);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--panel-line);
  padding-block: 1rem;
}

.search-wrap {
  position: relative;
  max-width: 32rem;
  margin: 0 auto 1rem;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.5rem;
  border-radius: 6px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  color: var(--cream);
  font-family: 'Cabin', sans-serif;
  font-size: 0.98rem;
}
.search-input::placeholder { color: var(--cream-dim); }
.search-input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }

.toggle-row, .chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}
.chip-row { margin-top: 0.75rem; }

.toggle-chip, .chip {
  border: 1px solid var(--panel-line);
  background: var(--panel);
  color: var(--cream-dim);
  font-family: 'Cabin', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip {
  font-size: 0.8rem;
  padding: 0.38rem 0.9rem;
  color: var(--cream-dim);
}
.toggle-chip:hover, .chip:hover { border-color: var(--amber-dim); color: var(--cream); }
.toggle-chip.active {
  background: var(--rust);
  border-color: var(--rust);
  color: var(--cream);
}
.chip.active {
  background: var(--amber-dim);
  border-color: var(--amber-dim);
  color: var(--cream);
}

.wiki-results {
  position: relative;
  z-index: 2;
  padding-block: clamp(2rem, 5vw, 3rem) clamp(4rem, 8vw, 6rem);
}

.result-count {
  text-align: center;
  font-size: 0.85rem;
  color: var(--cream-dim);
  margin-bottom: 1.5rem;
}

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

.wiki-card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.wiki-card:hover { transform: translateY(-2px); border-color: var(--amber-dim); }
.wiki-card.is-unreleased { opacity: 0.55; }

.card-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  border-radius: 8px;
  background: rgba(245,234,208,0.06);
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}
.card-icon img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
}

.card-name {
  font-family: 'Baloo 2', 'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--cream);
  line-height: 1.25;
}

.wiki-hero .legal-title {
  font-family: 'Baloo 2', 'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
}

.card-sub {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
}

.card-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.15rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--cream-dim);
}
.stat-row strong { color: var(--cream); font-weight: 600; }

.card-desc {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--cream-dim);
}

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(245,234,208,0.08);
  color: var(--cream-dim);
}
.badge.gem { background: rgba(255,128,217,0.15); color: var(--r-mythical); }
.badge.unreleased { background: rgba(245,234,208,0.08); color: var(--cream-dim); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--cream-dim);
  font-size: 0.95rem;
}

.gem-note {
  max-width: 46rem;
  margin: 0 auto 1.75rem;
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--cream-dim);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-left: 3px solid var(--r-mythical);
  border-radius: 4px;
  padding: 0.9rem 1.25rem;
}

/* ── Account widget (nav) ────────────────────────────────────────────────── */
.account-link {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream-dim);
  transition: color 0.2s ease;
}
.account-link:hover { color: var(--amber); }

.account-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(245,234,208,0.06);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  padding: 0.3rem 0.4rem 0.3rem 0.85rem;
  font-size: 0.85rem;
}

.account-name { color: var(--cream); font-weight: 600; white-space: nowrap; }
.account-gems { color: var(--r-mythical); font-weight: 600; white-space: nowrap; }

.account-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 1px solid var(--panel-line);
  background: rgba(10,4,0,0.35);
  color: var(--cream-dim);
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.account-logout:hover { color: var(--amber); border-color: var(--amber-dim); }

/* ── Modal (login) ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,4,0,0.72);
  backdrop-filter: blur(4px);
  padding: 1.25rem;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: var(--cream-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--amber); }

.modal-title {
  font-family: 'Rye', serif;
  font-size: 1.5rem;
  color: var(--amber);
  margin-bottom: 0.35rem;
}

.modal-sub {
  font-size: 0.85rem;
  color: var(--cream-dim);
  margin-bottom: 1.4rem;
}

.modal-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream-dim);
  margin-bottom: 0.4rem;
}

.modal-input {
  width: 100%;
  background: rgba(10,4,0,0.4);
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  color: var(--cream);
  font: inherit;
  font-size: 0.95rem;
  margin-bottom: 1.1rem;
}
.modal-input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }

.modal-error {
  font-size: 0.85rem;
  color: #FF9B9B;
  margin-bottom: 1rem;
}

.modal-submit {
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 4px;
  background: var(--rust);
  color: var(--cream);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
  transition: background 0.2s ease, transform 0.2s ease;
}
.modal-submit:hover { background: var(--amber); transform: translateY(-1px); }
.modal-submit:disabled { opacity: 0.6; cursor: default; transform: none; }
