/* ============================================================
   contextspa — main.css
   Minimal design system. Dark-first, spa aesthetic.
   Bubble animation lives in bubbles.css (protected — ADR-012).
   ============================================================ */

/* --- Design tokens ----------------------------------------- */
:root {
  --bg:         #0a0a0f;
  --surface:    #12121a;
  --surface-2:  #1a1a24;
  --border:     #2a2a3a;
  --border-lt:  #3a3a4e;

  --text:       #e8e8f0;
  --text-muted: #8888a0;
  --text-faint: #5a5a70;

  --accent:     #7c6af7;
  --accent-hover: #9484ff;
  --accent-glow: rgba(124, 106, 247, 0.12);
  --teal:       #3ecfcf;
  --teal-glow:  rgba(62, 207, 207, 0.10);
  --danger:     #f05050;

  --font-sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:  'Cascadia Code', 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  --radius:     6px;
  --radius-lg:  12px;
  --transition: 150ms ease;
  --max-w:      1080px;
  --nav-h:      56px;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
code, pre { font-family: var(--font-mono); }

/* --- Typography -------------------------------------------- */
h1, h2, h3 { line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.1rem; }
p { color: var(--text-muted); max-width: 56ch; }

/* --- Layout ------------------------------------------------ */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }

/* --- Navigation -------------------------------------------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  display: flex;
  align-items: center;
  border-bottom: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.nav.scrolled {
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  border-color: var(--border);
}
.nav__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav__logo {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
}
.nav__logo span { color: var(--accent); }
.nav__links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav__links a {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}
.nav__links a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav__links a.active { color: var(--accent); }

/* --- Buttons ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn--ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn--ghost:hover { border-color: var(--border-lt); color: var(--text); text-decoration: none; }
.btn--sm { padding: 7px 14px; font-size: 0.82rem; }
.btn--lg { padding: 13px 28px; font-size: 1rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* --- Custom dropdown --------------------------------------- */
.dropdown { position: relative; }
.dropdown__trigger { cursor: pointer; }
.dropdown__chevron { margin-left: 4px; transition: transform var(--transition); }
.dropdown.open .dropdown__chevron { transform: rotate(180deg); }
.dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  list-style: none;
  margin: 0;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dropdown.open .dropdown__menu { display: block; }
.dropdown__item {
  padding: 8px 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.dropdown__item:hover { background: var(--accent-glow); color: var(--text); }
.dropdown__item.active { color: var(--accent); }

/* --- Hero -------------------------------------------------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.hero__content {
  position: relative;
  z-index: 2;
  padding: 80px 0;
  max-width: var(--max-w);
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}
.hero__eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 16px;
}
.hero h1 { margin-bottom: 16px; }
.hero h1 .hero__lead { display: block; font-size: 0.95em; color: var(--text); opacity: 0.85; margin-bottom: 4px; }
.hero h1 em { color: var(--accent); font-style: normal; }
.hero__sub {
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.7;
  margin-bottom: 32px;
  max-width: 50ch;
}
.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* --- Footer ------------------------------------------------ */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
}
.footer__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.footer__logo { font-size: 0.9rem; font-weight: 700; color: var(--text-faint); }
.footer__logo span { color: var(--accent); }
.footer__links { display: flex; gap: 20px; }
.footer__links a { font-size: 0.82rem; color: var(--text-faint); }
.footer__links a:hover { color: var(--text-muted); }
.footer__copy { font-size: 0.78rem; color: var(--text-faint); }

/* --- Sandbox layout ---------------------------------------- */
.sandbox {
  padding-top: var(--nav-h);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.sandbox__bar {
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.sandbox__panels {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}
.sandbox__panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}
.sandbox__panel:last-child { border-right: none; }
.sandbox__panel-head {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface);
  min-height: 36px;
}
.sandbox__badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-faint);
}
.sandbox__badge--accent {
  background: var(--accent-glow);
  border-color: rgba(124, 106, 247, 0.2);
  color: var(--accent);
}
.sandbox__textarea {
  width: 100%;
  flex: 1;
  resize: none;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  padding: 16px;
  outline: none;
  min-height: 400px;
}
.sandbox__textarea::placeholder { color: var(--text-faint); }
.sandbox__output {
  flex: 1;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text);
  overflow-y: auto;
  min-height: 400px;
  white-space: pre-wrap;
  word-break: break-word;
}
.sandbox__output--empty { color: var(--text-faint); font-family: var(--font-sans); }
.sandbox__output--error { color: var(--danger); }

/* --- Sandbox metrics --------------------------------------- */
.sandbox__metrics {
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  background: var(--surface);
}
.sandbox__metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sandbox__metric-val {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
}
.sandbox__metric-val--accent { color: var(--accent); }
.sandbox__metric-lbl {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

/* --- Settings drawer --------------------------------------- */
.sandbox__settings {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.sandbox__settings label {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sandbox__settings select,
.sandbox__settings input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.82rem;
  padding: 4px 8px;
}
.sandbox__settings input[type="checkbox"] { accent-color: var(--accent); }
.sandbox__settings small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-top: 2px;
  font-weight: 400;
}
.sandbox__refresh {
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  transition: transform 0.2s;
}
.sandbox__refresh:hover { transform: rotate(180deg); }

/* --- Auth gate --------------------------------------------- */
.auth-gate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
}
.auth-gate__card {
  text-align: center;
  max-width: 400px;
}
.auth-gate__card h2 { margin-bottom: 12px; }
.auth-gate__card p { margin: 0 auto 24px; }
.auth-gate__card .btn { margin-top: 8px; }

/* --- Responsive -------------------------------------------- */
@media (max-width: 768px) {
  .sandbox__panels { grid-template-columns: 1fr; }
  .sandbox__panel { border-right: none; border-bottom: 1px solid var(--border); }
  .sandbox__textarea, .sandbox__output { min-height: 280px; }
  .hero__content { padding-top: calc(var(--nav-h) + 40px); }
}
