/* ============================================================
   Contexell design language v2 "Context to Commerce" — SINGLE SOURCE OF TRUTH.

   >>> Every visual decision is governed by docs/Contexell-Design-Language-v2.md.
   >>> Page stylesheets may ONLY consume the tokens below. Never write
   >>> raw hex values, new font stacks, off-scale sizes, or new shadows
   >>> in page CSS/HTML/JS. New need? Add a token here AND document it
   >>> in docs/Contexell-Design-Language-v2.md first.

   Meaning system, not decoration:
     Teal senses. Blue understands. Amber acts. Green confirms.
   Live context (teal) flows into intelligence (blue), surfaces a timely
   commercial action (amber), and confirms an outcome (green).
   Fonts: Manrope (display) + Inter (body). No build step.
   ============================================================ */

:root {
  /* Core neutrals (v2 §3.2) — enterprise slate, no pure black */
  --ink: #0f172a;
  --ink-2: #162033;
  --ink-soft: #334155;
  --body: #475569;         /* default paragraph / UI text */
  --muted: #64748b;        /* lightest permissible body text on paper/surface */
  --paper: #f7f9fc;
  --paper-deep: #f1f5f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --line: #dce3ed;
  --line-strong: #cbd5e1;
  --track: #e8edf4;
  --on-dark: #ffffff;

  /* Primary — intelligence (v2 §3.3). Solid blue, never a gradient button. */
  --primary: #3157d5;
  --primary-hover: #2545b8;
  --primary-deep: #1e3a8a;
  --primary-soft: #eef4ff;
  --primary-line: #c9d8ff;
  --primary-ring: rgba(49, 87, 213, 0.28);
  --primary-glow: rgba(49, 87, 213, 0.18);
  --focus-ring: var(--primary-ring);
  /* legacy aliases kept so existing page CSS resolves to the v2 blue */
  --accent-soft: var(--primary-soft);
  --accent-soft-hover: #e0eaff;
  --dark-muted: #a9bef5;   /* muted / eyebrow text on dark panels */

  /* Live signal — teal (v2 §3.4). Means context arriving, never generic success. */
  --signal: #0d9488;
  --signal-deep: #0f766e;  /* small text on white */
  --signal-soft: #ecfdf9;
  --signal-line: #99f6e4;
  --signal-bright: #2dd4bf; /* live dot / one hero emphasis on dark */

  /* Opportunity — amber (v2 §3.5). Means "a commercial action is available now". */
  --opportunity: #f59e0b;
  --opportunity-deep: #b45309;
  --opportunity-soft: #fffbeb;
  --opportunity-line: #fde68a;
  --on-opportunity: #0f172a; /* never white text on amber */

  /* Outcome & semantic states (v2 §3.6) — always use base + deep + soft + line together */
  --good: #16a34a;
  --good-soft: #f0fdf4;
  --good-line: #bbf7d0;
  --good-deep: #166534;
  --good-bright: #4ade80;  /* positive accent on dark */
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --warn-line: #fde68a;
  --warn-deep: #92400e;
  --bad: #e11d48;
  --bad-soft: #fff1f2;
  --bad-line: #fecdd3;
  --bad-deep: #9f1239;

  /* Signal categories (v2 §3.7) — chips, markers, timelines, signal chart series only */
  --sig-rain: #3b82f6;     /* weather */
  --sig-heat: #f97316;
  --sig-uv: #facc15;
  --sig-cold: #38bdf8;
  --sig-pollen: #84cc16;   /* environment / nature */
  --sig-wind: #64748b;     /* neutral physical */
  --sig-holiday: #d97706;
  --sig-weekend: #9333ea;  /* calendar / weekend */
  --sig-events: #7c3aed;

  /* Code samples */
  --code-bg: #0f172a;
  --code-fg: #d6e0ff;
  --code-green: #8be9a8;
  --code-blue: #9db1ff;
  --code-amber: #f0c98d;

  /* The one approved gradient (v2 §3.8): context becoming intelligence.
     Signal-flow moments only (hero flow, ingestion, brand mark) — never buttons. */
  --grad: linear-gradient(135deg, #0d9488 0%, #3157d5 100%);
  --grad-signal-flow: var(--grad);
  --grad-soft: linear-gradient(135deg, rgba(13, 148, 136, 0.12), rgba(49, 87, 213, 0.12));

  /* Shape (v2 §6.1) */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius: 16px;          /* = --radius-lg (cards, panels) */
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* Elevation (v2 §6.3) — exactly three, no coloured shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.14);

  /* Type scale tokens (v2 §4.2) — semantic sizes for new/refactored surfaces */
  --type-hero: clamp(42px, 6vw, 72px);
  --type-display-xl: clamp(34px, 4vw, 52px);
  --type-display: 32px;
  --type-title: 24px;
  --type-heading: 18px;
  --type-lead: 17px;
  --type-body: 15px;
  --type-body-sm: 14px;
  --type-caption: 13px;
  --type-micro: 12px;

  /* Motion (v2 §10.1) */
  --motion-fast: 120ms;
  --motion-base: 180ms;
  --motion-slow: 240ms;
  --ease-standard: cubic-bezier(.2, .8, .2, 1);
  --ease-enter: cubic-bezier(.16, 1, .3, 1);
  --ease-exit: cubic-bezier(.4, 0, 1, 1);

  /* Typography (v2 §4): Manrope 600-800 display, Inter 400-700 UI, mono for code/keys */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Manrope", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .display { font-family: var(--font-display); }

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

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 22px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.15s;
  text-decoration: none !important;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Primary = intelligence. Solid blue, dependable, no gradient (v2 §8.1). */
.btn-primary {
  background: var(--primary);
  color: var(--on-dark);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost, .btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover, .btn-secondary:hover { border-color: var(--line-strong); }

.btn-ghost-dark {
  background: rgba(255, 255, 255, 0.07);
  color: var(--on-dark);
  border-color: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
}
.btn-ghost-dark:hover { background: rgba(255, 255, 255, 0.14); }

/* Opportunity = a timely commercial action ("Promote today"). Amber, dark text. */
.btn-opportunity { background: var(--opportunity); color: var(--on-opportunity); }
.btn-opportunity:hover { background: var(--opportunity-deep); color: var(--on-dark); }

.btn-lg { padding: 15px 28px; font-size: 16px; border-radius: 14px; }
.btn-sm { padding: 8px 15px; font-size: 13.5px; border-radius: 10px; }
.btn-danger { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.btn-danger:hover { background: var(--bad-line); }

/* ---------- Nav ---------- */

.nav { position: sticky; top: 0; z-index: 60; }
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 28px;
  max-width: 1200px;
  margin: 0 auto;
}
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { font-size: 14.5px; font-weight: 500; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  text-decoration: none !important;
}
.brand-dot {
  /* The Contexell symbol — single source shared with the favicon and logo lockups */
  width: 26px;
  height: 26px;
  background: url("/static/brand/symbol.svg") center / contain no-repeat;
  display: inline-block;
  flex: none;
}

/* ---------- Signal chips (shared identity element) ---------- */

.sig-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
}
.sig-chip .sig-ico { font-size: 14px; line-height: 1; }
.sig-chip[data-sig="rain"]    { border-color: rgba(59,130,246,.45);  background: rgba(59,130,246,.1);  color: #1d4ed8; }
.sig-chip[data-sig="heat"]    { border-color: rgba(249,115,22,.45);  background: rgba(249,115,22,.1);  color: #c2410c; }
.sig-chip[data-sig="uv"]      { border-color: rgba(250,204,21,.55);  background: rgba(250,204,21,.14); color: #a16207; }
.sig-chip[data-sig="cold"]    { border-color: rgba(56,189,248,.5);   background: rgba(56,189,248,.12); color: #0369a1; }
.sig-chip[data-sig="pollen"]  { border-color: rgba(132,204,22,.5);   background: rgba(132,204,22,.12); color: #4d7c0f; }
.sig-chip[data-sig="wind"]    { border-color: rgba(100,116,139,.5);  background: rgba(100,116,139,.14);color: #334155; }
.sig-chip[data-sig="holiday"] { border-color: rgba(217,119,6,.45);   background: rgba(217,119,6,.1);   color: #92400e; }
.sig-chip[data-sig="weekend"] { border-color: rgba(147,51,234,.45);  background: rgba(147,51,234,.12); color: #6b21a8; }
.sig-chip[data-sig="events"]  { border-color: rgba(124,58,237,.45);  background: rgba(124,58,237,.1);  color: #5b21b6; }

/* dark-surface variant */
.on-dark .sig-chip { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.07); color: rgba(255,255,255,.92); }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.field input {
  width: 100%;
  padding: 12px 15px;
  font-size: 15px;
  font-family: var(--font);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

.form-error, .form-success {
  display: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.form-error { background: var(--bad-soft); border: 1px solid var(--bad-line); color: var(--bad); }
.form-success { background: var(--good-soft); border: 1px solid var(--good-line); color: var(--good-deep); }
.form-error.visible, .form-success.visible { display: block; }

/* ---------- Misc ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--primary-deep);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
}

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--on-dark);
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--on-dark);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

/* Live dot = live context refreshing → teal (v2 §3.4) */
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.35); }
  70% { box-shadow: 0 0 0 9px rgba(45, 212, 191, 0); }
  100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0); }
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--signal-bright);
  animation: pulse-ring 2.2s ease-out infinite;
  display: inline-block;
}

/* ---------- Accessibility (Contexell-Design-Language-v2 §12) ---------- */

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

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  html { scroll-behavior: auto; }
}

/* the hidden attribute must always win over component display rules */
[hidden] { display: none !important; }
