/* melon.css - shared design system for melon.lat
   Dual-theme (dark default / day cream), GitHub-dark structure in melon brand.
   Single source of truth; mirrored to /var/www/league/public/melon.css */

/* ============ TOKENS ============ */
:root {
  /* surfaces */
  --surface-canvas: #0b120a;
  --surface-default: #11190f;
  --surface-raised: #16201a;
  --surface-border: rgba(138, 200, 130, .16);
  --surface-border-emphasis: rgba(138, 200, 130, .34);
  --surface-glass: rgba(11, 18, 10, .72);
  --hover: rgba(138, 200, 130, .07);

  /* foreground */
  --fg-muted: #7d8a74;
  --fg-default: #9fb097;
  --fg-strong: #c2d0ba;
  --fg-bright: #dfe8d9;
  --fg-pure: #f3f8f0;

  /* accent (melon green) */
  --accent: #8ac882;
  --accent-2: #6fae62;
  --accent-soft: rgba(138, 200, 130, .13);
  --accent-line: rgba(138, 200, 130, .34);

  /* status */
  --good: #5fb96a;
  --warn: #d6a64a;
  --bad: #e0685a;

  /* status tints (theme-aware backgrounds for pills/badges) */
  --good-soft: rgba(95, 185, 106, .14);
  --good-line: rgba(95, 185, 106, .34);
  --warn-soft: rgba(214, 166, 74, .14);
  --warn-line: rgba(214, 166, 74, .34);
  --bad-soft: rgba(224, 104, 90, .14);
  --bad-line: rgba(224, 104, 90, .34);

  /* legacy aliases - keep existing inline page CSS working */
  --bg: var(--surface-canvas);
  --forest: var(--surface-default);
  --mid: var(--surface-raised);
  --line: var(--surface-border);
  --green: var(--accent);
  --green-2: var(--accent-2);
  --ink: var(--fg-pure);
  --ink-dim: var(--fg-default);
  --ink-mute: var(--fg-muted);
  --cream: var(--fg-pure);

  /* type + shape */
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --r-card: 12px;
  --r-btn: 8px;
  --r-pill: 999px;
  --maxw: 1280px;
}

html[data-theme="day"] {
  --surface-canvas: #f0ede8;
  --surface-default: #faf8f4;
  --surface-raised: #ffffff;
  --surface-border: rgba(45, 90, 39, .16);
  --surface-border-emphasis: rgba(45, 90, 39, .32);
  --surface-glass: rgba(240, 237, 232, .8);
  --hover: rgba(45, 90, 39, .05);

  --fg-muted: #8a8070;
  --fg-default: #5b6a54;
  --fg-strong: #34492f;
  --fg-bright: #1a3018;
  --fg-pure: #16280f;

  --accent: #2d5a27;
  --accent-2: #4a7c40;
  --accent-soft: rgba(45, 90, 39, .08);
  --accent-line: rgba(45, 90, 39, .3);

  --good: #2d5a27;
  --warn: #b07d1f;
  --bad: #b3402e;

  --good-soft: rgba(45, 90, 39, .1);
  --good-line: rgba(45, 90, 39, .3);
  --warn-soft: rgba(176, 125, 31, .12);
  --warn-line: rgba(176, 125, 31, .34);
  --bad-soft: rgba(179, 64, 46, .1);
  --bad-line: rgba(179, 64, 46, .32);
}

/* ============ BASE ============ */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--surface-canvas);
  color: var(--fg-default);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  position: relative;
  min-height: 100vh;
  transition: background .35s ease, color .35s ease;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { color: var(--fg-pure); font-weight: 700; line-height: 1.15; margin: 0; }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }
.accent { color: var(--accent); }

/* ambient layers */
.orb {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 18% 12%, var(--accent-soft), transparent 70%),
    radial-gradient(50% 45% at 85% 80%, var(--accent-soft), transparent 70%);
  opacity: .8;
}
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.wrap { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ============ TOPBAR (restyles .site-head) ============ */
.site-head {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; gap: 16px;
  padding: 10px clamp(16px, 4vw, 28px);
  background: var(--surface-glass);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--surface-border);
  transition: background .35s ease, border-color .35s ease;
}
.site-head .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.site-head .brand svg, .site-head .brand img, .site-head .brand .m-mark { width: 28px; height: auto; display: block; flex: none; }
.site-head .brand b { font-weight: 700; font-size: 15px; color: var(--fg-pure); letter-spacing: -.01em; }
.site-head .brand b i { font-style: normal; color: var(--accent-2); }
.site-nav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.site-nav > a {
  padding: 8px 12px; border-radius: var(--r-btn);
  color: var(--fg-default); font-size: 13px; font-weight: 600;
  transition: background .18s, color .18s;
}
.site-nav > a:hover { background: var(--hover); color: var(--fg-bright); }
.site-nav > a.active { color: var(--accent); }

/* nav.js injected: live pill + theme toggle */
.mln-live {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: var(--r-pill);
  border: 1px solid var(--good-line);
  background: var(--good-soft); color: var(--good);
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600;
}
.mln-live .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 8px var(--good); animation: mln-pulse 1.6s ease-in-out infinite;
}
@keyframes mln-pulse { 50% { opacity: .45; transform: scale(.7); } }
.mln-theme {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-btn);
  border: 1px solid var(--surface-border); background: transparent;
  color: var(--fg-default); cursor: pointer; font-size: 15px;
  transition: background .18s, color .18s, border-color .18s;
}
.mln-theme:hover { background: var(--hover); color: var(--fg-bright); border-color: var(--surface-border-emphasis); }
@media (max-width: 720px) { .mln-live { display: none; } }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--r-btn); line-height: 1;
  border: 1px solid var(--surface-border-emphasis); background: transparent;
  color: var(--fg-bright); font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .18s, border-color .18s, filter .18s, transform .12s;
}
.btn:hover { border-color: var(--surface-border-emphasis); background: var(--hover); }
.btn.primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 10px 15px;
}
.btn.primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn.success { border: 0; color: #fff; background: linear-gradient(135deg, var(--good), var(--accent-2)); }
.btn.ghost { border-color: var(--surface-border); color: var(--fg-default); }
.btn.ghost:hover { color: var(--fg-bright); }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* ============ SECTIONS ============ */
.section { max-width: var(--maxw); margin: 0 auto; padding: 80px 24px; position: relative; z-index: 1; }
.section.tight { padding: 56px 24px; }
.section-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--fg-default); margin-bottom: 12px;
}
.section-label .num { color: var(--accent); }
.section-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 32px; flex-wrap: wrap; margin-bottom: 36px;
  padding-bottom: 20px; border-bottom: 1px solid var(--surface-border);
}
.section-head h2 { font-size: clamp(26px, 3.4vw, 38px); letter-spacing: -.02em; line-height: 1.1; max-width: 720px; text-wrap: balance; }
.section-head .note { font-size: 13px; color: var(--fg-default); max-width: 340px; line-height: 1.55; }

/* ============ HERO ============ */
.hero {
  max-width: none; margin: 0;
  padding: 104px max(24px, calc((100% - var(--maxw)) / 2)) 72px;
  position: relative; z-index: 1;
}
@media (max-width: 980px) { .hero { padding-top: 72px; padding-bottom: 56px; } }
.hero-frequency {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line);
  padding: 6px 12px; border-radius: var(--r-pill); margin-bottom: 24px;
}
.hero-frequency .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: mln-pulse 1.6s ease-in-out infinite; }
.hero h1 { font-size: clamp(40px, 6.4vw, 74px); line-height: 1.02; letter-spacing: -.035em; text-wrap: balance; }
.hero h1 .accent { color: var(--accent); }
.hero h1 .strike { display: block; font-weight: 600; color: var(--fg-default); }
.hero-sub { font-size: 17px; line-height: 1.55; color: var(--fg-strong); margin: 22px 0 0; max-width: 56ch; }
.hero-sub b { color: var(--fg-bright); font-weight: 600; }
.hero-cta { margin-top: 28px; display: flex; gap: 10px; flex-wrap: wrap; }

.hero-stats {
  margin-top: 40px; display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface-default); border: 1px solid var(--surface-border);
  border-radius: var(--r-card); overflow: hidden;
}
@media (max-width: 720px) {
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-stats > div:nth-child(2n) { border-right: 0; }
  .hero-stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--surface-border); }
}
.hero-stats > div { padding: 16px 18px; border-right: 1px solid var(--surface-border); min-width: 0; overflow: hidden; }
.hero-stats > div:last-child { border-right: 0; }
.hero-stats .k {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg-default); display: flex; align-items: center; gap: 6px;
}
.hero-stats .k .ic { color: var(--accent); font-size: 11px; }
.hero-stats .v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; font-size: 26px; color: var(--fg-pure); margin-top: 6px; line-height: 1; }
.hero-stats .v small { display: block; font-family: var(--sans); font-weight: 500; font-size: 11px; color: var(--fg-default); margin-top: 5px; letter-spacing: 0; }

/* ============ HERO TICKER ============ */
.hero-ticker {
  margin-top: 28px; position: relative; display: flex; align-items: center;
  background: var(--surface-default); border: 1px solid var(--surface-border);
  border-radius: var(--r-btn); overflow: hidden; height: 38px;
}
.hero-ticker .tick-pip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 11px; height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .1em;
  z-index: 3;
}
.hero-ticker .tick-pip .dot { width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 6px rgba(255,255,255,.9); animation: mln-pulse 1.2s ease-in-out infinite; }
.hero-ticker .tick-track {
  display: flex; align-items: center; gap: 18px; white-space: nowrap; flex-shrink: 0;
  padding-left: 18px; will-change: transform; animation: mln-ticker 50s linear infinite;
}
.hero-ticker:hover .tick-track { animation-play-state: paused; }
@keyframes mln-ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.hero-ticker .tick-item { font-family: var(--mono); font-size: 12px; color: var(--fg-bright); display: inline-flex; align-items: center; gap: 5px; }
.hero-ticker .tick-item b { color: var(--accent); font-weight: 500; }
.hero-ticker .tick-sep { color: var(--fg-muted); }
.hero-ticker .tick-edge { position: absolute; top: 0; bottom: 0; width: 46px; pointer-events: none; z-index: 2; }
.hero-ticker .tick-edge-l { left: 56px; background: linear-gradient(to right, var(--surface-default), transparent); }
.hero-ticker .tick-edge-r { right: 0; background: linear-gradient(to left, var(--surface-default), transparent); }
@media (prefers-reduced-motion: reduce) { .hero-ticker .tick-track, .hero-ticker .tick-pip .dot, .hero-frequency .dot, .mln-live .dot { animation: none; } }

/* ============ FACTION / SYSTEM CARDS ============ */
.faction-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 960px) { .faction-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .faction-grid { grid-template-columns: 1fr; } }
.faction {
  position: relative; background: var(--surface-default); border: 1px solid var(--surface-border);
  border-radius: var(--r-card); padding: 18px 18px 16px;
  display: flex; flex-direction: column; min-height: 230px;
  transition: border-color .16s, transform .16s, box-shadow .16s, background .16s;
}
.faction:hover { border-color: var(--surface-border-emphasis); transform: translateY(-2px); box-shadow: 0 8px 24px -10px rgba(0,0,0,.5); }
.faction .fheader { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.faction .ficon {
  width: 38px; height: 38px; border-radius: var(--r-btn);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: var(--accent-soft); border: 1px solid var(--surface-border); color: var(--accent); flex-shrink: 0;
}
.faction h3 { font-size: 16px; letter-spacing: -.01em; line-height: 1.2; }
.faction .ftag { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-default); margin-top: 2px; }
.faction .ftag .acc { color: var(--accent); }
.faction .motto { font-size: 12.5px; font-style: italic; color: var(--accent); margin-bottom: 10px; opacity: .9; }
.faction p { font-size: 13.5px; line-height: 1.55; color: var(--fg-strong); margin: 0 0 16px; flex: 1; }
.faction .ops {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 12px; border-top: 1px solid var(--surface-border);
  font-family: var(--mono); font-size: 10.5px; font-variant-numeric: tabular-nums;
  letter-spacing: .04em; text-transform: uppercase; color: var(--fg-default);
}
.faction .ops .lead { color: var(--fg-strong); }
.faction .ops .arr { color: var(--accent); }

/* ============ CONSOLE PANELS ============ */
.console {
  background: var(--surface-default); border: 1px solid var(--surface-border);
  border-radius: var(--r-card); overflow: hidden; box-shadow: 0 8px 32px -8px rgba(0,0,0,.5);
}
.console-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--surface-border); background: var(--surface-raised); }
.console-head .title { font-family: var(--mono); font-size: 13px; color: var(--fg-pure); letter-spacing: .04em; display: inline-flex; align-items: center; gap: 8px; }
.console-head .title .ic { color: var(--accent); }
.console-body { padding: 14px 16px; }
.console-row {
  display: flex; justify-content: space-between; align-items: center; padding: 7px 0;
  border-bottom: 1px dashed var(--surface-border);
  font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.console-row:last-child { border-bottom: 0; }
.console-row .k { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-default); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; font-size: 11px; }
.console-row .k .ic { width: 12px; color: var(--accent); }
.console-row .v { color: var(--fg-bright); font-weight: 500; }
.console-row .v.good { color: var(--good); }
.console-row .v.warn { color: var(--warn); }
.console-row .v.bad { color: var(--bad); }
.console-feed {
  border-top: 1px solid var(--surface-border); background: var(--surface-canvas);
  padding: 12px 16px; font-family: var(--mono); font-size: 12px; line-height: 1.85;
  max-height: 200px; overflow: hidden; position: relative;
}
.console-feed::after { content: ""; position: absolute; inset: auto 0 0 0; height: 50px; background: linear-gradient(180deg, transparent, var(--surface-canvas)); pointer-events: none; }
.console-feed .line { display: block; color: var(--fg-strong); }
.console-feed .line .ts { color: var(--fg-muted); margin-right: 8px; }
.console-feed .line .tag { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; margin-right: 8px; color: var(--accent); background: var(--accent-soft); }
.console-feed .line .tag.warn { color: var(--warn); background: var(--warn-soft); }
.console-feed .line .tag.bad { color: var(--bad); background: var(--bad-soft); }
.console-stamp { border-top: 1px solid var(--surface-border); padding: 10px 16px; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: var(--fg-muted); text-transform: uppercase; }

/* ============ PILLS ============ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600;
  border: 1px solid transparent;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.success { background: var(--good-soft); color: var(--good); border-color: var(--good-line); }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.pill.error { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.pill.info { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.pill.muted { background: var(--hover); color: var(--fg-default); border-color: var(--surface-border); }

/* ============ CARD GRID (generic) ============ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.card {
  border: 1px solid var(--surface-border); border-radius: var(--r-card);
  background: var(--surface-default); padding: 22px;
  transition: transform .16s, border-color .16s, background .16s;
}
.card:hover { transform: translateY(-3px); border-color: var(--surface-border-emphasis); background: var(--surface-raised); }
.card .ctag { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.card h3 { font-size: 18px; margin-bottom: 8px; }
.card p { color: var(--fg-default); font-size: 14px; margin: 0; }

/* ============ MARQUEE / WORDMARK STRIP ============ */
.marquee { overflow: hidden; border-top: 1px solid var(--surface-border); border-bottom: 1px solid var(--surface-border); background: var(--surface-default); padding: 10px 0; }
.marquee-track { display: flex; gap: 40px; white-space: nowrap; width: max-content; font-family: var(--mono); font-size: 12.5px; letter-spacing: .05em; color: var(--fg-default); animation: mln-marquee 40s linear infinite; }
.marquee-track .m-item { display: inline-flex; align-items: center; gap: 10px; }
.marquee-track .m-item::before { content: "//"; color: var(--accent); }
@keyframes mln-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ============ DIVIDERS / PROSE ============ */
.divider { height: 1px; background: repeating-linear-gradient(90deg, var(--surface-border) 0 6px, transparent 6px 12px); border: 0; margin: 0; }
.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.doc-head { font-size: clamp(28px, 4vw, 44px); letter-spacing: -.02em; margin-bottom: 12px; }
.prose { max-width: 72ch; color: var(--fg-default); }
.prose h2 { color: var(--fg-pure); font-size: 22px; margin: 36px 0 12px; }
.prose h3 { color: var(--fg-bright); font-size: 17px; margin: 26px 0 8px; }
.prose p, .prose li { font-size: 15px; line-height: 1.7; }
.prose a { color: var(--accent); border-bottom: 1px solid var(--accent-line); }

/* ============ FOOTER (restyles .site-foot) ============ */
.site-foot { border-top: 1px solid var(--surface-border); margin-top: 64px; background: var(--surface-default); position: relative; z-index: 1; }
.site-foot .wrap { padding: 40px 24px; display: flex; flex-wrap: wrap; gap: 28px; justify-content: space-between; }
.foot-links { display: flex; flex-wrap: wrap; gap: 24px; }
.foot-links a { color: var(--fg-default); font-size: 14px; }
.foot-links a:hover { color: var(--accent); }
.foot-legal { color: var(--fg-muted); font-family: var(--mono); font-size: 12px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 720px) {
  .site-nav { gap: 6px; }
  .section { padding: 56px 20px; }
}
