/* LocalFlux — "Silica & Trace" design system
   Palette + type scale from Gemini's response; layout, components and
   motion completed during the compile pass. */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-base: #0B0D10;
  --bg-surface: #14171C;
  --bg-elevated: #1F232B;

  --accent-copper: #D97757;
  --accent-copper-dim: rgba(217, 119, 87, 0.2);
  --accent-teal: #2DD4BF;
  --accent-teal-dim: rgba(45, 212, 191, 0.15);
  --accent-amber: #F5B544;
  --accent-red: #EF6461;

  --border-subtle: #2C313C;
  --border-focus: #444C5E;

  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-inverse: #0B0D10;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  --glow-copper: 0 4px 24px var(--accent-copper-dim);
  --glow-teal: 0 4px 24px var(--accent-teal-dim);
  --shadow-surface: 0 8px 32px rgba(0, 0, 0, 0.4);

  --maxw: 1180px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; margin: 0; }
code, .mono { font-family: var(--font-mono); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- trace background ---------- */
.trace-bg {
  position: fixed; inset: 0; z-index: -1; opacity: 0.5;
  background-image:
    linear-gradient(var(--border-subtle) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}

/* ---------- nav ---------- */
header.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 13, 16, 0.78);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar .wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 9px; }
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-copper); box-shadow: var(--glow-copper);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.topbar nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }

.navlink {
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  padding: 7px 12px; border-radius: var(--radius-sm);
  background: none; border: 1px solid transparent; cursor: pointer;
  font-family: var(--font-body); transition: 0.15s;
}
.navlink:hover { color: var(--text-main); background: var(--bg-elevated); text-decoration: none; }
.navlink.active { color: var(--accent-copper); border-color: var(--accent-copper-dim); background: var(--accent-copper-dim); }

/* ---------- hero ---------- */
.hero { padding: 90px 0 60px; text-align: center; }
.hero h1 {
  font-size: clamp(38px, 7vw, 68px); line-height: 1.02; font-weight: 700;
  background: linear-gradient(160deg, var(--text-main) 35%, var(--accent-copper));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.sub {
  max-width: 640px; margin: 22px auto 0; color: var(--text-muted);
  font-size: 17px; line-height: 1.6;
}
.hero .cta-row { margin-top: 32px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 11px 20px; border-radius: var(--radius-md); cursor: pointer;
  border: 1px solid var(--border-subtle); background: var(--bg-elevated);
  color: var(--text-main); transition: 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--border-focus); transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--accent-copper); color: var(--text-inverse);
  border-color: var(--accent-copper); box-shadow: var(--glow-copper);
}
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 12px; }

/* ---------- capability strip ---------- */
.caps {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-top: 34px; font-family: var(--font-mono); font-size: 12px;
}
.chip {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
  color: var(--text-muted); display: flex; align-items: center; gap: 7px;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.chip.ok { color: var(--accent-teal); border-color: var(--accent-teal-dim); }
.chip.ok::before { background: var(--accent-teal); box-shadow: 0 0 8px var(--accent-teal); }
.chip.bad { color: var(--accent-red); border-color: rgba(239,100,97,0.25); }
.chip.bad::before { background: var(--accent-red); }

/* ---------- module grid ---------- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; padding: 40px 0 80px;
}
.card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 22px; cursor: pointer;
  transition: 0.18s; position: relative; overflow: hidden;
}
.card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(400px circle at var(--mx,50%) var(--my,0%), rgba(217,119,87,0.09), transparent 45%);
  opacity: 0; transition: 0.3s;
}
.card:hover { border-color: var(--border-focus); transform: translateY(-3px); box-shadow: var(--shadow-surface); }
.card:hover::after { opacity: 1; }
.card h3 { font-size: 17px; margin-bottom: 8px; }
.card p { color: var(--text-muted); font-size: 14px; line-height: 1.55; margin: 0; }
.card .tag {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent-copper); margin-bottom: 12px; display: block;
}
.card .credit {
  margin-top: 14px; font-family: var(--font-mono); font-size: 11px; color: var(--border-focus);
}

/* ---------- panels ---------- */
.panel {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px;
}
.panel h2 { font-size: 22px; margin-bottom: 6px; }
.panel .desc { color: var(--text-muted); font-size: 14px; margin: 0 0 18px; line-height: 1.55; }

.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

label.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--text-muted); }
label.field span.val { float: right; font-family: var(--font-mono); color: var(--accent-teal); }
input[type=range] { width: 100%; margin-top: 7px; accent-color: var(--accent-copper); }
select, input[type=text], textarea {
  width: 100%; margin-top: 7px; padding: 9px 11px; font-family: var(--font-body); font-size: 14px;
  background: var(--bg-base); color: var(--text-main);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent-copper); }

canvas.stage {
  width: 100%; display: block; background: var(--bg-base);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
}
iframe.stage {
  width: 100%; height: 560px; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); background: #000; display: block;
}

.progress { height: 6px; background: var(--bg-elevated); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > i { display: block; height: 100%; width: 0%; background: var(--accent-copper); transition: width 0.25s; }

.metrics { display: flex; gap: 18px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.metrics b { color: var(--accent-teal); font-weight: 500; }

/* ---------- chat ---------- */
.chatlog { height: 380px; overflow-y: auto; padding: 4px; display: flex; flex-direction: column; gap: 12px; }
.msg { padding: 11px 14px; border-radius: var(--radius-md); font-size: 14px; line-height: 1.55; max-width: 84%; white-space: pre-wrap; }
.msg.user { background: var(--accent-copper-dim); border: 1px solid var(--accent-copper-dim); align-self: flex-end; }
.msg.bot { background: var(--bg-elevated); border: 1px solid var(--border-subtle); align-self: flex-start; }
.composer { display: flex; gap: 8px; margin-top: 12px; }
.composer textarea { resize: none; height: 44px; margin: 0; }

/* ---------- consent modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(5,6,8,0.8); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal {
  background: var(--bg-surface); border: 1px solid var(--border-focus);
  border-radius: var(--radius-lg); padding: 28px; max-width: 520px; box-shadow: var(--shadow-surface);
}
.modal h2 { font-size: 20px; margin-bottom: 12px; }
.modal ul { color: var(--text-muted); font-size: 14px; line-height: 1.7; padding-left: 20px; margin: 0 0 20px; }

/* ---------- load meter (Grok's "roast meter") ---------- */
.loadmeter {
  position: fixed; bottom: 16px; right: 16px; z-index: 100;
  font-family: var(--font-mono); font-size: 11px; padding: 8px 13px;
  background: rgba(20,23,28,0.9); border: 1px solid var(--border-subtle);
  border-radius: 999px; color: var(--text-muted); backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 8px; cursor: help;
}
.loadmeter .fan { display: inline-block; animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

footer.foot {
  border-top: 1px solid var(--border-subtle); padding: 28px 0 60px;
  color: var(--text-muted); font-size: 13px; line-height: 1.7;
}
.hidden { display: none !important; }
