/* ===========================================================
   MONGOLIE — App styles (shell, pages, components)
=========================================================== */

/* =============== TOP NAV =============== */
.mg-topnav {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--border);
}
.mg-topnav-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
  padding: 14px 24px;
}
.mg-brand { display: flex; align-items: center; gap: 10px; }
.mg-brand-name { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.08em; font-size: 18px; }
.mg-brand-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; color: var(--ink-mute); text-transform: uppercase; }

.mg-nav { display: flex; align-items: center; gap: 4px; justify-content: center; }
.mg-nav-link {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500;
  color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.mg-nav-link:hover { background: var(--surface-2); color: var(--ink); }
.mg-nav-link.active { background: var(--primary); color: var(--primary-ink); }

.mg-icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink-soft);
  border: 1px solid var(--border);
  background: var(--surface-1);
  position: relative;
  transition: background .15s;
}
.mg-icon-btn:hover { background: var(--surface-2); }
.mg-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: var(--mg-gold-500); border-radius: 50%; box-shadow: 0 0 0 2px var(--bg); }

.mg-user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface-1);
}
.mg-user-chip:hover { background: var(--surface-2); }
.mg-user-avatar { width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: var(--mg-blue-100); border: 1px solid var(--border);
}
.mg-user-avatar.sm { width: 26px; height: 26px; }
[data-theme="dark"] .mg-user-avatar { background: var(--surface-2); }
.mg-user-name { font-size: 13px; font-weight: 600; line-height: 1.1; }
.mg-user-role { font-size: 10.5px; color: var(--ink-mute); font-family: var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }

/* =============== APP SHELL (sidebar) =============== */
.mg-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.mg-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface-1);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.mg-brand-side { padding: 4px 6px 14px; border-bottom: 1px dashed var(--border); }
.mg-side-section { display: flex; flex-direction: column; gap: 2px; }
.mg-side-label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-mute); padding: 4px 10px 8px; }
.mg-side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: calc(var(--r-md) * var(--radius-scale));
  color: var(--ink-soft);
  font-size: 13.5px; font-weight: 500;
  text-align: left; width: 100%;
}
.mg-side-link svg { opacity: 0.8; }
.mg-side-link:hover { background: var(--surface-2); color: var(--ink); }
.mg-side-link.active {
  background: linear-gradient(90deg, var(--mg-blue-800), var(--mg-blue-700));
  color: var(--mg-gold-200);
  box-shadow: inset 0 0 0 1px var(--mg-blue-700);
}
.mg-side-link.admin.active { background: linear-gradient(90deg, var(--mg-gold-700), var(--mg-gold-600)); color: var(--mg-gold-50); }

.mg-side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 16px; border-top: 1px dashed var(--border); }
.mg-status-live {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px; margin-bottom: 4px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.mg-pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--mg-success); box-shadow: 0 0 0 0 var(--mg-success); animation: mg-pulse 2s infinite; }
@keyframes mg-pulse { 0% { box-shadow: 0 0 0 0 rgba(47,158,91,0.6);} 70%{box-shadow: 0 0 0 10px rgba(47,158,91,0);} 100%{box-shadow:0 0 0 0 rgba(47,158,91,0);} }

/* =============== APP BAR =============== */
.mg-main { display: flex; flex-direction: column; min-height: 100vh; }
.mg-appbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.mg-crumbs { display: flex; align-items: center; gap: 8px; color: var(--ink-mute); font-size: 13px; }
.mg-crumb { color: var(--ink); text-transform: capitalize; font-weight: 500; }
.mg-search {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-1);
  min-width: 380px;
  color: var(--ink-mute);
}
.mg-search input { border: 0; background: transparent; flex: 1; outline: none; font-size: 13px; color: var(--ink); }
.mg-search kbd { font-family: var(--font-mono); font-size: 10.5px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; color: var(--ink-mute); }
.mg-main-scroll { flex: 1; padding: 28px; }

/* =============== LANDING =============== */
.mg-hero {
  position: relative;
  padding: 100px 0 120px;
  overflow: hidden;
}
.mg-hero-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(800px 500px at 20% 20%, rgba(36,100,212,0.22), transparent 55%),
    radial-gradient(700px 400px at 85% 70%, rgba(211,155,54,0.25), transparent 55%),
    linear-gradient(180deg, var(--mg-blue-950) 0%, #0a1630 55%, #1b2d5a 100%);
  z-index: 0;
}
.mg-hero-bg::after {
  /* steppe silhouette */
  content: '';
  position: absolute; inset: auto 0 0 0; height: 38%;
  background:
    linear-gradient(180deg, transparent, rgba(10,18,38,0.6)),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 400' preserveAspectRatio='none'><path d='M0 280 L120 240 L240 260 L360 210 L480 250 L600 200 L720 230 L840 180 L960 210 L1080 170 L1200 200 L1320 160 L1440 180 L1440 400 L0 400 Z' fill='%23081028'/><path d='M0 320 L180 290 L320 310 L480 270 L640 300 L820 260 L1000 290 L1200 250 L1440 280 L1440 400 L0 400 Z' fill='%2305091a'/></svg>");
  background-size: cover; background-position: center bottom;
}
.mg-hero-inner { position: relative; z-index: 1; color: var(--mg-gold-50); }
.mg-hero-eyebrow { color: var(--mg-gold-300); }
.mg-hero h1 {
  font-size: clamp(48px, 8vw, 112px); line-height: 0.95; letter-spacing: -0.04em;
  margin-top: 12px; max-width: 16ch;
  color: var(--mg-gold-50);
  text-wrap: pretty;
}
.mg-hero h1 em { font-style: normal; color: var(--mg-gold-400); }
.mg-hero p.lead { font-size: 20px; max-width: 56ch; margin-top: 18px; color: rgba(247,241,220,0.85); line-height: 1.6; }
.mg-hero-ctas { display: flex; gap: 14px; margin-top: 36px; }

.mg-hero-stats {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-top: 64px;
  border-top: 1px solid rgba(227,177,90,0.25);
  border-bottom: 1px solid rgba(227,177,90,0.25);
  background: rgba(7,20,43,0.5);
  backdrop-filter: blur(4px);
}
.mg-hero-stat {
  padding: 22px 28px;
  border-right: 1px solid rgba(227,177,90,0.12);
  color: var(--mg-gold-50);
}
.mg-hero-stat:last-child { border-right: 0; }
.mg-hero-stat .v { font-family: var(--font-display); font-size: 40px; font-weight: 700; color: var(--mg-gold-300); letter-spacing: -0.02em; }
.mg-hero-stat .l { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(247,241,220,0.7); }

.mg-hero-card {
  position: absolute;
  right: 32px; top: 120px; z-index: 2;
  width: 340px;
  background: rgba(15,26,54,0.85);
  border: 1px solid rgba(227,177,90,0.3);
  border-radius: var(--r-lg);
  padding: 18px;
  color: var(--mg-gold-50);
  backdrop-filter: blur(12px);
  box-shadow: var(--sh-xl);
}
.mg-hero-card .eyebrow { color: var(--mg-gold-300); }

/* Sections on landing */
.mg-section { padding: 96px 0; position: relative; }
.mg-section.alt { background: var(--surface-2); }
.mg-section h2 { font-size: clamp(32px, 4vw, 52px); letter-spacing: -0.03em; max-width: 22ch; }

/* Placeholder image */
.mg-ph {
  position: relative;
  background:
    repeating-linear-gradient(135deg, var(--mg-blue-100) 0 10px, var(--mg-blue-50) 10px 20px);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: grid; place-items: center;
  color: var(--mg-blue-800);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  overflow: hidden;
}
[data-theme="dark"] .mg-ph { background: repeating-linear-gradient(135deg, rgba(77,135,232,0.1) 0 10px, rgba(77,135,232,0.04) 10px 20px); color: var(--mg-blue-300); }
.mg-ph.dark {
  background: repeating-linear-gradient(135deg, #0e1a3a 0 10px, #0a1430 10px 20px);
  color: var(--mg-gold-300); border-color: rgba(227,177,90,0.2);
}

/* =============== STATS grid =============== */
.mg-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.mg-stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: calc(var(--r-lg) * var(--radius-scale));
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.mg-stat::after { content: ''; position: absolute; right: -10px; top: -10px; width: 60px; height: 60px; opacity: 0.08;
  background: radial-gradient(circle, var(--accent) 30%, transparent 70%); }
.mg-stat-val { font-family: var(--font-display); font-size: 36px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; color: var(--ink); }
.mg-stat-unit { font-size: 14px; color: var(--ink-mute); margin-left: 4px; letter-spacing: 0; }
.mg-stat-label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-mute); margin-top: 6px; }
.mg-stat.gold { background: linear-gradient(180deg, var(--mg-gold-100), var(--mg-gold-50)); border-color: var(--mg-gold-300); }
.mg-stat.gold .mg-stat-val { color: var(--mg-gold-800); }
[data-theme="dark"] .mg-stat.gold { background: linear-gradient(180deg, rgba(211,155,54,0.15), rgba(211,155,54,0.05)); border-color: rgba(211,155,54,0.3); }
[data-theme="dark"] .mg-stat.gold .mg-stat-val { color: var(--mg-gold-300); }
.mg-stat.blue { background: linear-gradient(180deg, var(--mg-blue-900), var(--mg-blue-800)); border-color: var(--mg-blue-700); }
.mg-stat.blue .mg-stat-val, .mg-stat.blue .mg-stat-label { color: var(--mg-gold-50); }
.mg-stat.blue .mg-stat-label { color: rgba(247,241,220,0.7); }

/* =============== QUEST =============== */
.mg-quest {
  display: flex;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: calc(var(--r-lg) * var(--radius-scale));
  overflow: hidden;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.mg-quest:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--border-strong); }
.mg-quest-strip { width: 6px; flex-shrink: 0; }
.mg-quest-body { flex: 1; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.mg-quest-cat { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.mg-quest-title { font-size: 20px; letter-spacing: -0.01em; margin: 2px 0; }

/* =============== PROJECT =============== */
.mg-project {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: calc(var(--r-lg) * var(--radius-scale));
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.mg-project:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--mg-gold-400); }
.mg-project-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.mg-pct-chip {
  padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--mg-gold-100); color: var(--mg-gold-800);
  border: 1px solid var(--mg-gold-300);
  font-family: var(--font-display); font-weight: 700; font-size: 16px;
}
[data-theme="dark"] .mg-pct-chip { background: rgba(211,155,54,0.15); color: var(--mg-gold-300); border-color: rgba(211,155,54,0.35); }
.mg-needs { display: flex; flex-direction: column; gap: 10px; }
.mg-need { display: flex; flex-direction: column; gap: 6px; }

/* =============== TWEAKS PANEL =============== */
.mg-tweaks {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  width: 320px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--sh-xl);
}
.mg-tw-btn {
  position: fixed; right: 20px; bottom: 20px; z-index: 99;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: var(--primary); color: var(--primary-ink);
  font-size: 13px; font-weight: 600;
  box-shadow: var(--sh-lg);
  display: flex; align-items: center; gap: 8px;
}
.mg-tw-label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-mute); display: block; margin-bottom: 8px; }
.mg-tw-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: var(--r-md); border: 1px solid var(--border); }
.mg-tw-seg.vert { grid-auto-flow: row; grid-auto-columns: 1fr; }
.mg-tw-seg button {
  padding: 8px 10px; border-radius: calc(var(--r-md) - 2px);
  font-size: 12px; font-weight: 500; color: var(--ink-soft);
}
.mg-tw-seg button.active { background: var(--bg-elev); color: var(--ink); box-shadow: var(--sh-xs); }
.mg-tw-range { width: 100%; accent-color: var(--accent); }

/* =============== DASHBOARD Avatar theme =============== */
.mg-dash-hero {
  position: relative;
  border-radius: var(--r-xl);
  overflow: hidden;
  padding: 32px;
  color: var(--mg-gold-50);
  background:
    radial-gradient(900px 300px at 85% 50%, rgba(211,155,54,0.28), transparent 55%),
    radial-gradient(600px 300px at 10% 120%, rgba(36,100,212,0.35), transparent 60%),
    linear-gradient(135deg, #081432 0%, #0f2046 50%, #1a1810 100%);
  border: 1px solid rgba(227,177,90,0.35);
}
.mg-dash-hero .avatar-hero {
  position: absolute; right: 28px; bottom: 0; width: 180px;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.4));
}
.mg-skills-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.mg-skill {
  padding: 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex; flex-direction: column; gap: 10px;
}
.mg-skill-head { display: flex; justify-content: space-between; align-items: center; }
.mg-skill-name { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; }
.mg-skill-lv { font-family: var(--font-pixel); font-size: 22px; color: var(--mg-gold-700); letter-spacing: 0.05em; }
[data-theme="dark"] .mg-skill-lv { color: var(--mg-gold-300); }

/* Leaderboard */
.mg-podium {
  display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end;
  gap: 16px; margin-bottom: 28px;
}
.mg-podium-cell {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.mg-podium-cell.first {
  background: linear-gradient(180deg, var(--mg-gold-100), var(--mg-gold-50));
  border-color: var(--mg-gold-400);
  padding-top: 28px;
  transform: translateY(-8px);
}
[data-theme="dark"] .mg-podium-cell.first {
  background: linear-gradient(180deg, rgba(211,155,54,0.22), rgba(211,155,54,0.06));
  border-color: rgba(211,155,54,0.45);
}
.mg-podium-rank { font-family: var(--font-display); font-size: 48px; font-weight: 700; color: var(--mg-gold-600); line-height: 1; }
.mg-podium-cell.first .mg-podium-rank { color: var(--mg-gold-700); font-size: 64px; }

/* Leader row */
.mg-leader-row {
  display: grid; grid-template-columns: 50px 50px 1fr 120px 120px 60px; gap: 16px; align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.mg-leader-row:last-child { border-bottom: 0; }
.mg-leader-row.head { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-mute); background: var(--surface-2); border-radius: var(--r-md) var(--r-md) 0 0; }
.mg-leader-rank { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--ink-mute); }
.mg-leader-rank.top { color: var(--mg-gold-600); }

/* Table (admin) */
.mg-table { width: 100%; border-collapse: collapse; }
.mg-table th {
  text-align: left; padding: 12px 14px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-mute); font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.mg-table td { padding: 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.mg-table tr:hover td { background: var(--surface-2); }

/* Drawer (admin edit) */
.mg-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 480px; z-index: 120;
  background: var(--bg-elev);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--sh-xl);
  padding: 22px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.mg-drawer.open { transform: translateX(0); }
.mg-drawer-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.mg-overlay { position: fixed; inset: 0; z-index: 110; background: rgba(10,18,38,0.45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }
.mg-overlay.open { opacity: 1; pointer-events: auto; }

/* Form row */
.mg-form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.mg-form-row label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-mute); }

/* Event card */
.mg-event {
  display: grid; grid-template-columns: 70px 1fr auto; gap: 14px; align-items: center;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-1);
}
.mg-event-date { text-align: center; padding: 8px; background: var(--mg-blue-900); color: var(--mg-gold-200); border-radius: var(--r-sm); }
.mg-event-date .d { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1; }
.mg-event-date .m { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.75; }

/* Footer */
.mg-footer {
  padding: 60px 0 30px;
  background: var(--mg-blue-950);
  color: rgba(247,241,220,0.75);
}
.mg-footer h4 { color: var(--mg-gold-200); font-family: var(--font-display); font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 14px; }
.mg-footer a { color: rgba(247,241,220,0.7); font-size: 13px; display: block; padding: 3px 0; }
.mg-footer a:hover { color: var(--mg-gold-300); }

/* Gallery */
.mg-gallery { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; grid-auto-rows: 140px; }
.mg-gallery .mg-ph { border-radius: var(--r-md); }

/* Utility */
.mg-pill { display: inline-flex; padding: 4px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); }

/* Responsive */
@media (max-width: 1024px) {
  .mg-shell { grid-template-columns: 1fr; }
  .mg-sidebar { display: none; }
  .mg-nav { display: none; }
  .mg-topnav-inner { grid-template-columns: auto 1fr; }
  .mg-hero-card { display: none; }
  .mg-hero-stats { grid-template-columns: repeat(2, 1fr); }
  .mg-hero-stat:nth-child(2) { border-right: 0; }
  .mg-search { min-width: 200px; }
  .mg-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .mg-skills-grid { grid-template-columns: repeat(2, 1fr); }
}
