/* Question Wheel — design system
   Original visual design: deep indigo + warm coral, radial wheel visualization.
   Not a copy of any third-party product's assets, CSS, or exact styling — built fresh. */

:root {
  --ink-900: #14121f;
  --ink-700: #3a3650;
  --ink-500: #6b6684;
  --ink-300: #a8a3bd;
  --ink-100: #ede9f7;
  --surface: #ffffff;
  --surface-alt: #faf9fd;
  --border: #e6e2f2;

  --brand-600: #4b3df6;
  --brand-500: #6c5ffb;
  --brand-100: #ece9fe;

  --accent-500: #ff6b57;
  --accent-100: #ffe6e1;

  --success-600: #1a9e6b;
  --warn-600: #d97a1c;
  --danger-600: #e0413a;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(20, 18, 31, 0.06), 0 1px 1px rgba(20, 18, 31, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 18, 31, 0.10), 0 2px 6px rgba(20, 18, 31, 0.06);
  --shadow-lg: 0 20px 48px rgba(20, 18, 31, 0.16), 0 6px 16px rgba(20, 18, 31, 0.08);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* deterministic category palette — JS assigns these in order per search */
  --cat-1: #6c5ffb;
  --cat-2: #ff6b57;
  --cat-3: #1a9e6b;
  --cat-4: #d97a1c;
  --cat-5: #2f8fd6;
  --cat-6: #c0459b;
  --cat-7: #7a8c1f;
  --cat-8: #925fe0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-alt);
  color: var(--ink-900);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; }

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ---------- topbar ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--brand-600);
}

.brand-name {
  font-weight: 800;
  font-size: 18px;
  color: var(--ink-900);
  letter-spacing: -0.01em;
}

.account-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-700);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--brand-100);
  color: var(--brand-600);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}

.pill.is-low { background: var(--accent-100); color: var(--danger-600); }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-900);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  transition: box-shadow .15s ease, transform .1s ease, background .15s ease;
}
.btn:hover { box-shadow: var(--shadow-sm); background: var(--surface-alt); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--brand-600);
  color: #fff;
  border-color: var(--brand-600);
}
.btn-primary:hover { background: var(--brand-500); }

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

/* ---------- hero / search ---------- */

.search-hero {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 20px 32px;
  text-align: center;
}

.hero-title {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink-900);
}

.hero-sub {
  margin-top: 10px;
  color: var(--ink-500);
  font-size: 15.5px;
}

.search-form {
  margin-top: 28px;
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, border-color .15s ease;
}
.search-form:focus-within {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px var(--brand-100);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  background: transparent;
  color: var(--ink-900);
  min-width: 0;
}
.search-input::placeholder { color: var(--ink-300); }

.search-button {
  border: none;
  background: var(--brand-600);
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  padding: 12px 24px;
  border-radius: 999px;
  transition: background .15s ease;
  white-space: nowrap;
}
.search-button:hover { background: var(--brand-500); }
.search-button:disabled { opacity: .6; cursor: not-allowed; }

/* display set only via :not([hidden]) — see the .modal comment above for why; same cascade
   trap applies to every element JS shows/hides via the hidden attribute. */
.search-error {
  margin-top: 16px;
  color: var(--danger-600);
  background: var(--accent-100);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
}
.search-error:not([hidden]) { display: inline-block; }

/* ---------- loading ---------- */

.loading-state {
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--ink-500);
  font-size: 14.5px;
}
.loading-state:not([hidden]) { display: flex; }

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--brand-100);
  border-top-color: var(--brand-600);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- results ---------- */

.results-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 20px 80px;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.results-heading {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink-900);
}
.results-heading em { color: var(--brand-600); font-style: normal; }

.view-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.view-toggle-btn {
  border: none;
  background: transparent;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-500);
}
.view-toggle-btn.is-active {
  background: var(--ink-900);
  color: #fff;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 18px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-700);
  font-weight: 600;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------- wheel ---------- */

.wheel-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 8px;
}

.wheel-svg {
  width: 100%;
  height: auto;
  display: block;
}

.wheel-center-label {
  /* fill is intentionally NOT set here — app.js sets fill="#fff" directly on the element
     (white text on the dark hub circle), and an author CSS `fill` declaration on this class
     would win over that attribute regardless, silently making the label invisible. */
  font-family: var(--font-sans);
  font-weight: 800;
}

.wheel-center-circle {
  fill: var(--ink-900);
}

.wheel-spoke {
  /* stroke color is NOT set here — app.js sets each spoke's stroke to its category color via
     the element's stroke attribute, and a CSS `stroke` declaration on this class would
     override every spoke to one flat color regardless (same cascade trap as the two fixes
     above: author CSS beats a presentation attribute). Only width is safe to set here since
     JS never sets stroke-width per element. */
  stroke-width: 1.5;
}

.wheel-node-group { cursor: default; }

.wheel-node-circle {
  stroke: #fff;
  stroke-width: 2;
  transition: r .12s ease;
}
.wheel-node-group:hover .wheel-node-circle { stroke-width: 3; }

.wheel-node-label {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  fill: var(--ink-900);
}

.wheel-node-volume {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 700;
  fill: #fff;
}

/* Volume badge for bubbles too small to fit the number inside the circle. Shown for every
   bubble that has a real (possibly small) volume value, so small-but-real numbers don't just
   disappear the way they used to once a bubble dropped below the "big enough" size threshold. */
.wheel-node-volume-badge {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  fill: var(--ink-500);
}

/* Muted "no data" marker for keywords DataForSEO returned no measurable volume for, so an
   empty-looking bubble reads as "checked, nothing found" rather than "forgot to render". */
.wheel-node-volume-badge.is-unknown {
  fill: var(--ink-300);
  font-weight: 600;
}

/* ---------- table ---------- */

.table-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-controls {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.table-filter {
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
}
.table-filter:focus { border-color: var(--brand-500); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-500);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table th:hover { color: var(--ink-900); }

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-900);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-alt); }

.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-700);
}
.cat-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cat-color, var(--ink-300));
}

.vol-cell { font-weight: 700; font-variant-numeric: tabular-nums; }
.vol-cell.is-unknown { color: var(--ink-300); font-weight: 500; }

.comp-tag {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.comp-low { background: #e4f7ee; color: var(--success-600); }
.comp-medium { background: #fdf1e0; color: var(--warn-600); }
.comp-high { background: #fde8e6; color: var(--danger-600); }
.comp-unknown { background: var(--ink-100); color: var(--ink-300); }

/* ---------- modals ---------- */

/* NOTE: the [hidden] attribute alone is NOT enough here — an author-stylesheet rule like
   `.modal { display: flex }` overrides the browser's built-in `[hidden] { display: none }`
   rule regardless of selector specificity, because same-origin author rules beat the
   user-agent stylesheet. Scoping the flex layout to :not([hidden]) keeps `hidden` authoritative,
   so JS can keep toggling `modal.hidden = true/false` without a full-viewport click-blocking
   overlay silently sitting over the page at all times.
*/
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 31, 0.45);
  z-index: 50;
  padding: 20px;
}
.modal:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  position: relative;
}

.modal-card-wide { max-width: 640px; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-500);
  padding: 4px;
}
.modal-close:hover { color: var(--ink-900); }

.modal-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 20px;
}

.modal-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink-500);
}
.modal-tab.is-active { background: var(--ink-900); color: #fff; }

.modal-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 18px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-700);
  margin-top: 10px;
}

.field-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.field-input:focus { border-color: var(--brand-500); }

.auth-error {
  color: var(--danger-600);
  font-size: 13px;
  margin-top: 10px;
}

.modal-submit {
  margin-top: 18px;
  border: none;
  background: var(--brand-600);
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  padding: 11px 0;
  border-radius: var(--radius-sm);
}
.modal-submit:hover { background: var(--brand-500); }
.modal-submit:disabled { opacity: .6; cursor: not-allowed; }

.plans-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.plan-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  text-align: left;
}
.plan-card.is-current { border-color: var(--brand-500); background: var(--brand-100); }

.plan-name { font-weight: 800; font-size: 15px; }
.plan-price { margin-top: 6px; font-size: 22px; font-weight: 800; color: var(--ink-900); }
.plan-price span { font-size: 12.5px; font-weight: 600; color: var(--ink-500); }
.plan-credits { margin-top: 6px; font-size: 12.5px; color: var(--ink-500); }

.plan-buy-row { display: flex; gap: 6px; margin-top: 14px; }
.plan-buy-row .btn { flex: 1; padding: 8px 0; font-size: 12.5px; }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .search-hero { padding: 40px 16px 24px; }
  .search-form { border-radius: var(--radius-lg); flex-wrap: wrap; padding: 10px; }
  .search-input { width: 100%; padding: 6px 4px; }
  .search-button { width: 100%; }
  .results-toolbar { flex-direction: column; align-items: flex-start; }
  .account-area { font-size: 12px; }
}
