/* ============================================================
   Intellium Keyword Engine — Premium Light UI
   Design tokens + craft per CDIR-brief.md (Elevated Light)
   ============================================================ */

:root {
  /* Brand palette (GVC) */
  --bg: #f5f2fa;
  --surface: #ffffff;
  --surface-alt: #f9f7fd;
  --border: #e7dff5;
  --border-strong: #d4c8e8;
  --ink: #191128;
  --ink-mid: #3d2e55;
  --muted: #8a7aa0;
  --primary: #a875f0;
  --primary-dark: #7c4fc0;

  /* Intent / data-state colours */
  --c-question: #3b82f6;
  --c-buyer: #f59e0b;
  --c-local: #8b5cf6;
  --c-compare: #06b6d4;
  --c-prep: #64748b;
  --c-other: #a875f0;
  --signal-strong: #22c55e;
  --signal-mid: #f59e0b;
  --signal-weak: #94a3b8;

  /* Typography */
  --tracking-display: -0.04em;
  --tracking-h1: -0.03em;
  --tracking-h2: -0.02em;
  --lh-tight: 1.08;
  --lh-body: 1.6;

  /* Spacing (4/8) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px;
  --s8: 32px; --s12: 48px; --s16: 64px; --s24: 96px;

  /* Radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-pill: 9999px;

  /* Purple-tinted shadow stack */
  --shadow-sm: 0 1px 2px rgba(124,79,192,.06), 0 1px 1px rgba(25,17,40,.04);
  --shadow-md: 0 2px 4px rgba(124,79,192,.05), 0 4px 10px rgba(124,79,192,.07), 0 1px 2px rgba(25,17,40,.04);
  --shadow-lg: 0 1px 2px rgba(25,17,40,.04), 0 6px 14px rgba(124,79,192,.08), 0 16px 32px rgba(124,79,192,.10);
  --shadow-xl: 0 1px 2px rgba(25,17,40,.05), 0 10px 20px rgba(124,79,192,.10), 0 30px 60px rgba(124,79,192,.14);
  --shadow-btn: inset 0 1px 0 rgba(255,255,255,.5), 0 2px 6px rgba(124,79,192,.30);

  /* Motion */
  --ease-out: cubic-bezier(0.16,1,0.3,1);
  --ease-in-out: cubic-bezier(0.65,0,0.35,1);
  --dur-fast: 120ms; --dur-base: 180ms; --dur-mid: 240ms; --dur-slow: 320ms;

  --container: 1200px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Montserrat", system-ui, sans-serif;
  background:
    radial-gradient(120% 90% at 50% -10%, #faf8ff 0%, var(--bg) 55%) fixed;
  color: var(--ink);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(168,117,240,.25); color: var(--ink); }

:where(button, a, input, select, [tabindex]):focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px rgba(168,117,240,.55);
  border-radius: inherit;
}

/* ---------- Sticky glass header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(255,255,255,.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 16px; letter-spacing: -.01em; color: var(--ink); }
.logo-i { color: var(--ink); }
.logo-inc { color: var(--primary-dark); margin-left: 3px; }
.brand .divider { color: var(--muted); margin: 0 10px; font-weight: 400; }
.tool-name { font-weight: 500; color: var(--ink-mid); }
.badge-internal {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--primary-dark); background: rgba(168,117,240,.12);
  padding: 6px 12px; border-radius: var(--r-pill);
}

/* ---------- Layout ---------- */
.wrap { max-width: var(--container); margin: 0 auto; padding: clamp(40px,7vw,84px) clamp(16px,4vw,24px) 100px; }

.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--primary-dark); margin: 0 0 14px;
}
.hero { text-align: center; margin-bottom: var(--s12); }
.hero h1 {
  font-size: clamp(34px, 6vw, 60px); font-weight: 700; letter-spacing: var(--tracking-display);
  line-height: var(--lh-tight); margin: 0 0 18px;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-mid) 130%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero .sub { color: var(--ink-mid); max-width: 60ch; margin: 0 auto 36px; font-size: clamp(15px,1.6vw,18px); }

/* ---------- Search ---------- */
.search-row {
  display: flex; gap: 10px; max-width: 760px; margin: 0 auto; flex-wrap: wrap;
  padding: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
}
#seed {
  flex: 1 1 320px; min-width: 220px; height: 52px; padding: 0 18px;
  font-size: 15px; font-family: inherit; color: var(--ink);
  border: 1px solid transparent; border-radius: var(--r-md); background: var(--surface-alt);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
#seed::placeholder { color: var(--muted); }
#seed:hover { background: #fff; border-color: var(--border); }
#seed:focus { outline: none; background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(168,117,240,.16); }
#country {
  height: 52px; padding: 0 14px; font-size: 14px; font-family: inherit; color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-alt); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}
#country:hover { border-color: var(--border-strong); }
#go-btn {
  height: 52px; padding: 0 30px; font-size: 15px; font-weight: 600; font-family: inherit;
  border: none; border-radius: var(--r-md); cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: var(--shadow-btn);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), filter var(--dur-fast) var(--ease-out);
}
#go-btn:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 8px 22px rgba(124,79,192,.4); }
#go-btn:active { transform: scale(.97); transition-duration: 80ms; }
#go-btn:disabled { opacity: .6; cursor: wait; transform: none; }

.source-toggles { margin-top: 18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.source-toggles label {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none;
  font-size: 13px; font-weight: 500; color: var(--ink-mid);
  padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.source-toggles label:hover { border-color: var(--border-strong); }
.source-toggles input { accent-color: var(--primary); margin: 0; }

/* ---------- Status / skeleton ---------- */
.status { text-align: center; padding: 30px 0; color: var(--ink-mid); font-size: 15px; }
.skeleton-wrap { max-width: var(--container); margin: 8px auto 0; display: grid; gap: 12px; }
.sk-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 8px; }
.skeleton {
  background: linear-gradient(90deg, #efeaf7 25%, #f7f4fc 37%, #efeaf7 63%);
  background-size: 400% 100%; border-radius: var(--r-sm);
  animation: shimmer 1.4s ease infinite;
}
.sk-card { height: 92px; border-radius: var(--r-md); }
.sk-row { height: 46px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- Summary cards ---------- */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: var(--s8); }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.stat-num { font-size: 34px; font-weight: 700; letter-spacing: var(--tracking-h2); color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; }
.stat-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 10px; }
.stat-card.accent .stat-num { color: var(--primary-dark); }

/* ---------- Results bar ---------- */
.results-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.result-count { font-size: 15px; color: var(--ink-mid); font-weight: 500; }
.result-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#filter {
  height: 42px; padding: 0 16px; border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: inherit; font-size: 14px; background: var(--surface); color: var(--ink); min-width: 200px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
#filter:hover { border-color: var(--border-strong); }
#filter:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(168,117,240,.16); }
.ghost {
  height: 42px; padding: 0 18px; font-family: inherit; font-size: 13px; font-weight: 600;
  background: var(--surface); color: var(--primary-dark); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.ghost:hover { border-color: var(--primary); background: var(--surface-alt); }
.ghost:active { transform: scale(.97); }
#enrich-btn { opacity: .72; }

/* ---------- Clusters ---------- */
.cluster {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  margin-bottom: 16px; overflow: hidden; box-shadow: var(--shadow-sm);
  animation: rise var(--dur-slow) var(--ease-out) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.cluster-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 22px; cursor: pointer;
  border-bottom: 1px solid var(--border); background: var(--surface);
  transition: background var(--dur-fast) var(--ease-out);
}
.cluster-head:hover { background: var(--surface-alt); }
.cluster.collapsed .cluster-head { border-bottom-color: transparent; }
.intent-chip {
  display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 8px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 800; color: #fff; letter-spacing: 0;
}
.cluster-head h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.cluster-head .cnt {
  font-size: 12px; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--surface-alt); padding: 3px 10px; border-radius: var(--r-pill); border: 1px solid var(--border);
}
.cluster-head .chevron { margin-left: 6px; color: var(--muted); transition: transform var(--dur-base) var(--ease-out); font-size: 12px; }

/* View toggle (List ⇄ Wheel) */
.view-toggle {
  margin-left: auto; display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--r-pill);
}
.vt-btn {
  border: none; background: transparent; font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--muted); padding: 5px 13px; border-radius: var(--r-pill); cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.vt-btn:hover { color: var(--ink-mid); }
.vt-btn.active { background: var(--surface); color: var(--primary-dark); box-shadow: var(--shadow-sm); }

/* Wheel */
.wheel-wrap { padding: 14px; display: flex; justify-content: center; overflow: auto; }
.wheel-svg { width: 100%; max-width: 760px; height: auto; }
.wheel-label { font-family: "Montserrat", sans-serif; font-size: 11px; font-weight: 500; fill: var(--ink-mid); }
.wheel-hub-text { font-family: "Montserrat", sans-serif; font-size: 13px; font-weight: 700; fill: #fff; letter-spacing: -.01em; }
.wheel-note { text-align: center; font-size: 12px; color: var(--muted); padding: 0 16px 14px; }
.wheel-note strong { color: var(--primary-dark); }
.cluster.collapsed .chevron { transform: rotate(-90deg); }
.cluster.collapsed .cluster-body { display: none; }

.kw-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  border-bottom: 1px solid #f3eefb; font-size: 14px;
  transition: background var(--dur-fast) var(--ease-out);
}
.kw-row:last-child { border-bottom: none; }
.kw-row:hover { background: var(--surface-alt); }
.signal-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; position: relative;
}
.signal-dot.s3 { background: var(--signal-strong); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.signal-dot.s2 { background: var(--signal-mid); box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.signal-dot.s1 { background: var(--signal-weak); }
.kw-text { flex: 1; color: var(--ink); }
.kw-sources { display: flex; gap: 5px; }
.src-badge {
  font-size: 9px; font-weight: 800; padding: 3px 8px; border-radius: var(--r-pill);
  text-transform: uppercase; letter-spacing: .5px;
}
.src-google { background: #e8f0fe; color: #1a56db; }
.src-youtube { background: #fde8e8; color: #c5221f; }
.src-bing { background: #e6f4ea; color: #137333; }
.kw-vol { width: 56px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---------- Legend & footer ---------- */
.legend { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin: 24px 0 0; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .signal-dot { display: inline-block; }
.foot { text-align: center; margin-top: 40px; color: var(--muted); font-size: 13px; }
.foot strong { color: var(--ink-mid); }

[hidden] { display: none !important; }

@media (max-width: 720px) {
  .summary, .sk-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .search-row { flex-direction: column; }
  #go-btn, #country { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
