/* ── Wyrmhole Design System ─────────────────────────────────────────────────── */

:root {
  --bg-primary: #1a1a2e;
  --bg-panel: #16213e;
  --border-color: #0f3460;
  --border-light: #1e4a7a;
  --gold: #FFD700;
  --text-primary: #e2e8f0;
  --text-muted: #9ca3af;
  --shadow-border: 0 0 8px rgba(15, 52, 96, 0.5);
}

body {
  font-family: 'VT323', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ── Core components ──────────────────────────────────────────────────────── */

.pixel-border {
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-border);
}

.tab-active {
  border-bottom: 2px solid var(--gold);
  color: var(--gold);
}

/* ── Skeleton loading ─────────────────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--bg-panel) 25%, #1e3a5f 50%, var(--bg-panel) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Rarity colors ────────────────────────────────────────────────────────── */

.rarity-normal    { color: #e2e8f0; }
.rarity-uncommon  { color: #4ade80; }
.rarity-rare      { color: #60a5fa; }
.rarity-epic      { color: #c084fc; }
.rarity-legendary { color: #fbbf24; }
.rarity-ascended  { color: #f97316; }
.rarity-set       { color: #34d399; }
.rarity-forged    { color: #e2e8f0; }
.rarity-event     { color: #f472b6; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  cursor: pointer;
  padding: 4px 16px;
  border-radius: 4px;
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  border: 1px solid transparent;
  transition: opacity 0.2s;
}
.btn:hover:not(:disabled) { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-action {
  font-family: 'VT323', monospace;
  font-size: 1rem;
  padding: 2px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-green  { background: #166534; border: 1px solid #22c55e; color: #86efac; }
.btn-green:hover:not(:disabled) { background: #15803d; }

.btn-red    { background: #7f1d1d; border: 1px solid #ef4444; color: #fca5a5; }
.btn-red:hover:not(:disabled) { background: #991b1b; }

.btn-gold   { background: #713f12; border: 1px solid var(--gold); color: var(--gold); }
.btn-gold:hover:not(:disabled) { background: #92400e; }

.btn-purple { background: #4a1d96; border: 1px solid #a78bfa; color: #ddd6fe; }
.btn-purple:hover:not(:disabled) { background: #5b21b6; }

.btn-blue   { background: #2563eb; color: white; }
.btn-blue:hover:not(:disabled) { opacity: 0.85; }

.btn-retry {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--gold);
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
  padding: 4px 16px;
  border-radius: 4px;
  cursor: pointer;
}
.btn-retry:hover { background: var(--border-color); }

/* ── Form inputs ──────────────────────────────────────────────────────────── */

.pixel-input {
  background: var(--border-color);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
}
.pixel-input:focus { outline: 1px solid var(--gold); }
.pixel-input::placeholder { color: #6b7280; opacity: 1; }

input[type=number].pixel-input { width: 5rem; }

/* ── Toggle switch ────────────────────────────────────────────────────────── */

.toggle-track {
  width: 44px; height: 24px; border-radius: 12px;
  position: relative; cursor: pointer; transition: background 0.2s;
}
.toggle-thumb {
  width: 18px; height: 18px; border-radius: 9px;
  background: white; position: absolute; top: 3px; transition: left 0.2s;
}

/* ── Accessibility ────────────────────────────────────────────────────────── */

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

/* ── Mobile nav ───────────────────────────────────────────────────────────── */

.nav-mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gold);
  font-size: 2rem;
  cursor: pointer;
  font-family: 'VT323', monospace;
}

@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-links.open { display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-panel); border: 2px solid var(--border-color); padding: 1rem; gap: 0.75rem; z-index: 40; }
  .nav-mobile-toggle { display: block; }
}

/* ── Town Map ────────────────────────────────────────────────────────────── */

.town-map-container {
  position: relative;
  aspect-ratio: 16 / 10;
  max-height: 520px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-primary);
}

.town-map-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.building-slot {
  position: absolute;
  cursor: pointer;
  transform: translateX(-50%);
  transform-origin: bottom center;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.building-slot:hover {
  transform: translateX(-50%) scale(1.08);
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
  z-index: 30;
}
.building-slot.selected {
  filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.8));
  z-index: 30;
}
.building-slot img {
  width: 100%;
  height: auto;
  display: block;
}

.building-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: #fff;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 6px;
  border-radius: 3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 3;
}

.event-overlay {
  position: absolute;
  pointer-events: none;
  object-fit: contain;
}

.construction-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 1.5rem;
  animation: bounce-hammer 1s ease infinite;
}
@keyframes bounce-hammer {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Raid active overlay */
.town-map-container.raid-active {
  animation: raid-pulse 2s ease-in-out infinite;
}
.town-map-container.raid-active .town-map-bg {
  filter: brightness(0.85) saturate(1.3);
}
@keyframes raid-pulse {
  0%, 100% { box-shadow: inset 0 0 30px rgba(255, 50, 0, 0.3); }
  50% { box-shadow: inset 0 0 60px rgba(255, 50, 0, 0.5); }
}
