/* ═══════════════════════════════════════════════════════════════════════════
   ge.rs3.gg — Premium Design System
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg: #08080d;
  --bg-card: #111118;
  --bg-raised: #1a1a25;
  --text: #f0f0f4;
  --text-muted: #7c7c96;
  --accent: #6c78ff;
  --accent-hover: #5563e8;
  --accent-glow: rgba(108,120,255,0.15);
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.14);
  --glow-sm: 0 0 20px rgba(108,120,255,0.06);
  --glow-md: 0 4px 40px rgba(108,120,255,0.08);

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(108,120,255,0.05) 0%, transparent 60%);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ── Grain Overlay ─────────────────────────────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ── Navigation — Frosted Glass ────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: var(--nav-height);
  background: rgba(10,10,15,0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  transition: height 0.3s cubic-bezier(0.4,0,0.2,1),
              background 0.3s cubic-bezier(0.4,0,0.2,1);
}

.nav.scrolled {
  height: 52px;
  background: rgba(10,10,15,0.85);
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  background: linear-gradient(135deg, var(--accent), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.01em;
}

.nav-links { display: flex; gap: 1.5rem; }
.nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.2s ease;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--accent); font-weight: 500; }

/* ── Main container — offset for fixed nav ─────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 2rem) 1rem 2rem;
  flex: 1;
}

/* ── Card System ───────────────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--bg-card), rgba(14,14,22,0.8));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--glow-sm);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(108,120,255,0.25), transparent);
  transition: left 0.3s ease, right 0.3s ease, background 0.3s ease;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--glow-md), 0 8px 32px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}

.card:hover::before {
  left: 5%;
  right: 5%;
  background: linear-gradient(90deg, transparent, rgba(108,120,255,0.6), transparent);
}

.card h2 {
  font-family: var(--font-body);
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ── Grid ──────────────────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ── Hero — Cinematic ──────────────────────────────────────────────────── */
.hero {
  position: relative;
  margin: calc(-1 * (var(--nav-height) + 2rem)) -1rem 2rem;
  padding: calc(var(--nav-height) + 3.5rem) 2rem 3rem;
  text-align: center;
  overflow: hidden;
  border-bottom: 1px solid rgba(108,120,255,0.1);
  background: linear-gradient(180deg, #0c0c14, #08080d);
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 50% 40% at 50% 30%, rgba(108,120,255,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 30% 60%, rgba(52,211,153,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 70% 60%, rgba(248,113,113,0.04) 0%, transparent 70%);
  animation: hero-shift 10s ease-in-out infinite alternate;
}

@keyframes hero-shift {
  0% { opacity: 0.8; }
  100% { opacity: 1; }
}

.hero-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(108,120,255,0.22) 0%, rgba(108,120,255,0.05) 40%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  filter: blur(50px);
  animation: glow-pulse 6s ease-in-out infinite alternate;
}

@keyframes glow-pulse {
  0% { opacity: 0.7; transform: translateX(-50%) scale(1); }
  100% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

.hero > *:not(.hero-bg):not(.hero-glow) { position: relative; z-index: 1; }

.hero-eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  opacity: 0;
  animation: hero-fade-up 0.6s ease forwards 0.1s;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  font-weight: 400;
  background: linear-gradient(135deg, #8b94ff, #6c78ff, #34d399);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  opacity: 0;
  animation: hero-fade-up 0.6s ease forwards 0.2s, title-shimmer 8s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(108,120,255,0.2));
}

@keyframes title-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  opacity: 0;
  animation: hero-fade-up 0.6s ease forwards 0.3s;
}

@keyframes hero-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero .search-form {
  max-width: 600px;
  opacity: 0;
  animation: hero-fade-up 0.6s ease forwards 0.4s;
}
.hero #search-results { max-width: 600px; }

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
  opacity: 0;
  animation: hero-fade-up 0.6s ease forwards 0.5s;
}

.hero-stat { text-align: center; }

.hero-stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 20px var(--accent-glow);
}

.hero-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* ── Search ────────────────────────────────────────────────────────────── */
.search-box { text-align: center; margin-bottom: 2rem; }
.search-box h1 { font-size: 1.8rem; margin-bottom: 1rem; }

.search-form {
  display: flex;
  max-width: 500px;
  margin: 0 auto;
}

.search-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: rgba(0,0,0,0.4);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.search-form input:focus {
  border-color: var(--accent);
  background: rgba(0,0,0,0.6);
  box-shadow: 0 0 0 3px rgba(108,120,255,0.15), 0 0 30px rgba(108,120,255,0.1);
  outline: none;
}

.search-form button {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 16px rgba(108,120,255,0.2);
}

.search-form button:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 24px rgba(108,120,255,0.3);
}

#search-results {
  max-width: 500px;
  margin: 0.5rem auto 0;
  text-align: left;
}

#search-results a {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s ease;
}

#search-results a:hover { background: var(--bg-raised); text-decoration: none; }
#search-results .price { color: var(--text-muted); }

#search-results.search-active {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
}

/* ── Market Grid ───────────────────────────────────────────────────────── */
.market-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ── Tables ────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.5rem 0.75rem; text-align: left; }
th {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
td {
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 0.9rem;
}

tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: rgba(108,120,255,0.04); }

.change-up { color: var(--green); }
.change-down { color: var(--red); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Card title dots ───────────────────────────────────────────────────── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.5rem; vertical-align: middle; }
.dot-green { background: var(--green); box-shadow: 0 0 8px rgba(52,211,153,0.5); }
.dot-red { background: var(--red); box-shadow: 0 0 8px rgba(248,113,113,0.5); }
.dot-blue { background: var(--accent); box-shadow: 0 0 8px rgba(108,120,255,0.5); }
.dot-amber { background: var(--amber); box-shadow: 0 0 8px rgba(251,191,36,0.5); }

/* ── Item Icons ────────────────────────────────────────────────────────── */
.item-icon-sm {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
  vertical-align: middle;
  margin-right: 0.4rem;
}

.item-icon-lg {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
}

/* ── Item Hero ─────────────────────────────────────────────────────────── */
.item-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.item-hero-info { flex: 1; min-width: 0; }

.item-hero-info h1 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 400;
  margin-bottom: 0.25rem;
}

.item-hero-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.item-hero-change {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}

.item-hero-change .big-change {
  font-size: 1.8rem;
  font-weight: 700;
}

.item-hero-change .change-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Item header (legacy compat) ───────────────────────────────────────── */
.item-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.item-header h1 { font-size: 1.6rem; }
.wiki-link { font-size: 0.9rem; color: var(--text-muted); }

/* ── Price Grid / Stats ────────────────────────────────────────────────── */
.price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stat-label { display: block; font-size: 0.8rem; color: var(--text-muted); }
.stat-value { display: block; font-size: 1.1rem; font-weight: 600; }

/* ── Street Prices ─────────────────────────────────────────────────────── */
.attr-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.attr-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1rem;
  text-align: right;
}

.street-table { font-size: 0.85rem; }
.street-table th { font-size: 0.75rem; }
.street-table td { padding: 0.35rem 0.5rem; }

.no-data { color: var(--text-muted); font-size: 0.9rem; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge-members {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent);
  font-weight: 600;
}

.badge-health {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}

.badge-bullish { background: rgba(52,211,153,0.15); color: var(--green); }
.badge-mixed { background: rgba(251,191,36,0.15); color: var(--amber); }
.badge-bearish { background: rgba(248,113,113,0.15); color: var(--red); }

/* ── Charts ────────────────────────────────────────────────────────────── */
.chart-card { position: relative; }
.chart-card canvas { width: 100% !important; }

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.chart-card-header h2 { margin-bottom: 0; }
.chart-card-header .chart-controls { margin-bottom: 0; }

.chart-controls { display: flex; gap: 0.5rem; margin-bottom: 1rem; }

.chart-btn {
  padding: 0.4rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

.chart-btn:hover {
  border-color: rgba(255,255,255,0.15);
  color: var(--text);
  background: var(--bg-raised);
}

.chart-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(108,120,255,0.3);
}

.chart-btn.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* ── Loading / Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto;
}

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

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,15,0.8);
  border-radius: var(--radius);
  z-index: 2;
}

#search-results.search-loading::before {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0.75rem auto;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem 1rem;
  font-size: 0.9rem;
}

/* ── Status Page ───────────────────────────────────────────────────────── */
.status-hero {
  position: relative;
  margin: calc(-1 * (var(--nav-height) + 2rem)) -1rem 2rem;
  padding: calc(var(--nav-height) + 2.5rem) 2rem 1.5rem;
  text-align: center;
  overflow: hidden;
  border-bottom: 1px solid rgba(108,120,255,0.1);
  background:
    radial-gradient(ellipse 50% 40% at 50% 30%, rgba(108,120,255,0.14) 0%, transparent 70%),
    linear-gradient(180deg, #0c0c14, #08080d);
}

.status-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2rem);
  font-weight: 400;
  margin-bottom: 0.25rem;
}

.status-hero-sub {
  font-size: 1rem;
  color: var(--text-muted);
}

.status-ok { color: var(--green); }
.status-error { color: var(--red); }
.status-pending { color: var(--text-muted); }

.status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.status-dot-ok {
  background: var(--green);
  box-shadow: 0 0 6px rgba(52,211,153,0.6);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot-error { background: var(--red); }
.status-dot-pending { background: var(--text-muted); }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px rgba(52,211,153,0.6); }
  50% { box-shadow: 0 0 12px rgba(52,211,153,0.9); }
}

.status-card-ok { border-color: rgba(52,211,153,0.2); }
.status-card-error { border-color: rgba(248,113,113,0.2); }

.freshness-ok { color: var(--green); }
.freshness-stale { color: var(--amber); }
.freshness-critical { color: var(--red); }

/* ── Arrow indicators ──────────────────────────────────────────────────── */
.arrow { font-size: 0.75rem; margin-right: 0.2rem; }
.arrow.up { color: var(--green); }
.arrow.down { color: var(--red); }

/* ── Table item cell ───────────────────────────────────────────────────── */
.item-cell {
  display: flex;
  align-items: center;
  gap: 0;
}

/* ── Footer ────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent, rgba(108,120,255,0.02));
}

.footer a { color: var(--text-muted); white-space: nowrap; transition: color 0.2s ease; }
.footer a:hover { color: var(--accent); }

/* ── Scroll-Reveal ─────────────────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.4,0,0.2,1),
              transform 0.6s cubic-bezier(0.4,0,0.2,1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s cubic-bezier(0.4,0,0.2,1),
              transform 0.5s cubic-bezier(0.4,0,0.2,1);
}

.reveal-stagger.visible > *:nth-child(1) { transition-delay: 0.05s; }
.reveal-stagger.visible > *:nth-child(2) { transition-delay: 0.1s; }
.reveal-stagger.visible > *:nth-child(3) { transition-delay: 0.15s; }
.reveal-stagger.visible > *:nth-child(4) { transition-delay: 0.2s; }

.reveal-stagger.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* ── Focus & Transitions ───────────────────────────────────────────────── */
a, .card, .chart-btn, button { transition: all 0.2s cubic-bezier(0.4,0,0.2,1); }

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

/* ── Skip Link ─────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 4px 4px;
  z-index: 200;
  font-size: 0.9rem;
}

.skip-link:focus { top: 0; outline: none; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .market-grid { grid-template-columns: 1fr; }
  .nav { padding: 0 1rem; }
  .container { padding: calc(var(--nav-height) + 1rem) 1rem 1rem; }
  .hero {
    padding: calc(var(--nav-height) + 2rem) 1rem 1.5rem;
    margin: calc(-1 * (var(--nav-height) + 1rem)) -1rem 1.5rem;
  }
  .hero-title { font-size: clamp(1.6rem, 5vw, 2.2rem); }
  .hero-stats { gap: 1rem; }
  .hero-glow { width: 300px; height: 300px; }
  .item-hero { flex-direction: column; align-items: flex-start; }
  .item-hero-change { margin-left: 0; text-align: left; }
  .status-hero {
    padding: calc(var(--nav-height) + 1.5rem) 1rem 1.5rem;
    margin: calc(-1 * (var(--nav-height) + 1rem)) -1rem 1.5rem;
  }
}

@media (max-width: 480px) {
  .col-price,
  .col-reporter { display: none; }

  button, a.chart-btn, .search-form button, .nav-links a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}
