/* Context Blend Community — spectrum-on-black channel CI, ported from
   docs/context-blend-community-prototype.html. Shipped as an external file
   (not inlined) so the global CSP's script-src/style-src 'self' covers it
   without weakening the policy — see public/_headers. */

/* ============ Design tokens ============ */
:root {
  --bg: var(--cb-bg, #06070d);
  --bg2: #0d1222;
  --surface: #121829;
  --surface-2: #182139;
  --ink: var(--cb-ink, #f7f8ff);
  --muted: #aab3c8;
  --line: rgba(255, 255, 255, 0.14);
  --cyan: var(--cb-cyan, #20c7ff);
  --blue: var(--cb-blue, #2078ff);
  --violet: var(--cb-violet, #7c4dff);
  --magenta: var(--cb-magenta, #ff2fd6);
  --orange: var(--cb-orange, #ff7a1a);
  --spectrum: var(--cb-spectrum, linear-gradient(90deg, #20c7ff, #2078ff, #7c4dff, #ff2fd6, #ff7a1a));
  --danger: #ff7a1a;
  --focus-ring: #29b6ff;
  --shadow-glow: 0 0 0 1px rgba(41, 182, 255, 0.08), 0 18px 60px -20px rgba(139, 92, 246, 0.35);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-display: var(--cb-font-display, "Space Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif);
  --font-body: var(--cb-font-body, system-ui, -apple-system, "Segoe UI", sans-serif);
}

[data-theme="light"] {
  --bg: #f4f6fc;
  --bg2: #eaeef8;
  --surface: #ffffff;
  --surface-2: #f2f4fa;
  --ink: #0b0f1a;
  --muted: #5a6478;
  --line: #dbe1ef;
  /* Deepened variants of the spectrum for AA text/icon contrast on light surfaces.
     The --spectrum gradient itself keeps the original vivid brand stops. */
  --cyan: #0089c9;
  --blue: #2e57d1;
  --violet: #7439d9;
  --magenta: #c21f74;
  --orange: #cc5c00;
  --shadow-glow: 0 1px 0 rgba(11, 15, 26, 0.03), 0 18px 44px -24px rgba(41, 92, 214, 0.25);
}

/* Match the browser canvas to the ACTIVE theme so any transparent area
   paints the themed color, never the opposite system preference. */
:root[data-theme="dark"] {
  color-scheme: dark;
}
:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* Paint the root canvas explicitly so the whole page is themed regardless of
   system preference — sections without their own surface color sit on --bg. */
html {
  background-color: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  /* Explicit background-color (the shorthand would reset it to transparent) plus a
     layered gradient image; keeps every band painted --bg even where the fixed
     gradient does not reach. */
  background-color: var(--bg);
  background-image: radial-gradient(1100px 560px at 50% -10%, var(--bg2), var(--bg) 60%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

.icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: inherit;
}

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

.skip-link {
  position: absolute;
  top: -48px;
  left: 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus-visible {
  top: 12px;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

/* ============ Header ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-decoration: none;
  font-size: 1.02rem;
}
.brand-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--cyan) 38%, transparent);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 0 22px rgba(32, 199, 255, 0.18);
  object-fit: cover;
}
.brand-mark .cb-wordmark {
  flex: none;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============ Buttons ============ */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.btn:hover {
  border-color: var(--cyan);
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  border: none;
  background: var(--spectrum);
  color: #06070c;
  font-weight: 700;
}
.btn-primary:hover {
  filter: brightness(1.06);
}
.btn-ghost {
  background: transparent;
}
.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  justify-content: center;
  border-radius: 999px;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn[disabled]:hover {
  border-color: var(--line);
}

/* ============ Hero ============ */
.hero {
  position: relative;
  overflow: hidden;
  padding: 64px 0 56px;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--bg);
  background-image: var(--cb-asset-banner);
  background-repeat: no-repeat;
  background-size: 100% auto;
  background-position: center 35%;
  opacity: 0.74;
  filter: saturate(1.18) contrast(1.08);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(8, 11, 20, 0.72) 0%, rgba(8, 11, 20, 0.42) 28%, rgba(8, 11, 20, 0.14) 52%, rgba(8, 11, 20, 0) 70%),
    linear-gradient(90deg, rgba(8, 11, 20, 0) 82%, rgba(8, 11, 20, 0.42) 100%),
    linear-gradient(0deg, rgba(8, 11, 20, 0.52) 0%, rgba(8, 11, 20, 0) 42%),
    linear-gradient(180deg, rgba(8, 11, 20, 0.45) 0%, rgba(8, 11, 20, 0) 22%);
}
.hero-glow {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 420px;
  background: radial-gradient(60% 60% at 30% 20%, rgba(32, 199, 255, 0.30), transparent 70%),
    radial-gradient(50% 50% at 75% 30%, rgba(255, 47, 214, 0.20), transparent 70%),
    radial-gradient(45% 45% at 55% 60%, rgba(255, 122, 26, 0.16), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
[data-theme="light"] .hero-glow {
  opacity: 0.55;
}
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 860px;
}
.hero-copy {
  max-width: 760px;
}
.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 999px;
  margin: 0 0 22px;
}
.hero-tag .icon {
  color: var(--orange);
}
.hero-title {
  margin: 0 0 18px;
}
.hero-title .cb-wordmark {
  filter: drop-shadow(0 1px 18px rgba(8, 11, 20, 0.78)) drop-shadow(0 1px 4px rgba(8, 11, 20, 0.68));
}
.hero-sub {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0 0 8px;
  max-width: 52ch;
  text-shadow: 0 1px 14px rgba(8, 11, 20, 0.65), 0 1px 3px rgba(8, 11, 20, 0.5);
}
.hero-invite {
  font-size: 1.24rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 22px;
  text-shadow: 0 1px 14px rgba(8, 11, 20, 0.65), 0 1px 3px rgba(8, 11, 20, 0.5);
}
.cb-topics {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  display: inline-flex;
  gap: 0.4em;
  align-items: baseline;
  margin: 0 0 30px;
  text-shadow: 0 1px 14px rgba(8, 11, 20, 0.65), 0 1px 3px rgba(8, 11, 20, 0.5);
}
.cb-topics .ai {
  color: var(--orange);
}
.cb-topics .tech {
  color: var(--violet);
}
.cb-topics .eng {
  color: var(--cyan);
}
.cb-topics .sep,
.cb-topics .amp {
  color: var(--muted);
  font-weight: 400;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}
.hero-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 1px solid transparent;
}
.hero-secondary:hover {
  color: var(--ink);
  border-color: var(--line);
}
.hero-secondary .icon {
  color: var(--cyan);
}

/* ============ Sections ============ */
.section {
  padding: 44px 0;
  border-top: 1px solid var(--line);
}
.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0 0 6px;
}
.section-desc {
  color: var(--muted);
  margin: 0;
  max-width: 60ch;
}
.feed-header {
  align-items: flex-start;
  margin-bottom: 12px;
}
.compose-toggle {
  width: 100%;
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--cyan) 24%, var(--line));
  background: color-mix(in srgb, var(--cyan) 5%, var(--surface));
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin: 14px 0 18px;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
}
.compose-toggle:hover,
.compose-toggle[aria-expanded="true"] {
  border-color: var(--cyan);
}
.compose-plus,
.compose-chevron {
  flex: none;
  display: inline-grid;
  place-items: center;
  color: var(--cyan);
  font-family: var(--font-display);
  font-weight: 800;
}
.compose-plus {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cyan) 15%, var(--bg2));
}
.compose-copy {
  flex: 1;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compose-copy strong {
  color: var(--ink);
}
.compose-chevron {
  transition: transform 0.15s ease;
}
.compose-toggle[aria-expanded="true"] .compose-chevron {
  transform: rotate(180deg);
}
.compose-region {
  margin: 0 0 22px;
}

/* ============ Propose form ============ */
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow-glow);
}
.field {
  margin-bottom: 22px;
}
.field-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.field-label {
  font-weight: 700;
  font-size: 0.94rem;
}
.field-optional {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.82rem;
}
.field-counter {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.field-counter.is-warn {
  color: var(--orange);
  font-weight: 700;
}
.field-input,
.field-textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.field-input::placeholder,
.field-textarea::placeholder {
  color: var(--muted);
}
.field-input:focus-visible,
.field-textarea:focus-visible {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(41, 182, 255, 0.18);
}
.field-textarea {
  resize: vertical;
  min-height: 96px;
}
.field-help {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.field-error {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--orange);
  font-weight: 600;
  display: none;
}
.field.has-error .field-input,
.field.has-error .field-textarea {
  border-color: var(--orange);
}
.field.has-error .field-error {
  display: block;
}

.category-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.category-option {
  position: relative;
}
.category-option.cat-ideas { --chip-color: var(--cyan); }
.category-option.cat-questions { --chip-color: var(--blue); }
.category-option.cat-context { --chip-color: var(--violet); }
.category-option.cat-insights { --chip-color: var(--magenta); }
.category-option.cat-future { --chip-color: var(--orange); }
.category-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.category-chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--chip-color);
  flex: none;
}
.category-option input:checked + .category-chip {
  border-color: var(--chip-color);
  background: color-mix(in srgb, var(--chip-color) 16%, var(--bg2));
  color: var(--chip-color);
}
.category-option input:focus-visible + .category-chip {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Honeypot — kept in the tab order removed, hidden from sighted users and AT alike */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.turnstile-box {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  padding: 14px 16px;
  color: var(--muted);
  font-size: 0.88rem;
}
.turnstile-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(41, 182, 255, 0.16);
  color: var(--cyan);
  flex: none;
}
.icon-check-small {
  width: 14px;
  height: 14px;
}

.form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.rate-limit-msg {
  display: none;
  font-size: 0.85rem;
  color: var(--orange);
  font-weight: 600;
  max-width: 40ch;
}
.rate-limit-msg.is-visible {
  display: block;
}
.form-status {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--cyan);
  display: none;
}
.form-status.is-visible {
  display: block;
}
.form-status.is-error {
  color: var(--orange);
}

/* ============ Browse ============ */
.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}
.topic-count {
  color: var(--muted);
  font-size: 0.9rem;
}
.sort-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: var(--surface);
  gap: 2px;
}
.sort-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.sort-btn[aria-pressed="true"] {
  background: var(--spectrum);
  color: #06070c;
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.topic-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.topic-card:hover {
  border-color: color-mix(in srgb, var(--chip-color, var(--cyan)) 55%, var(--line));
}
.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip-color) 16%, transparent);
  color: var(--chip-color);
}
.topic-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--chip-color);
}
.topic-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.06rem;
  line-height: 1.3;
  margin: 0;
}
.topic-detail {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: auto;
}
.topic-meta .yours {
  color: var(--cyan);
  font-weight: 700;
}
.topic-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}
.vote-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.vote-btn .icon {
  color: var(--muted);
  transition: color 0.12s ease, transform 0.12s ease;
}
.vote-btn:hover {
  border-color: var(--cyan);
}
.vote-btn[aria-pressed="true"] {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 16%, var(--bg2));
  color: var(--cyan);
}
.vote-btn[aria-pressed="true"] .icon {
  color: var(--cyan);
  transform: translateY(-1px);
}
.vote-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}
.vote-count {
  font-variant-numeric: tabular-nums;
}

.empty-state {
  display: none;
  text-align: center;
  padding: 56px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--muted);
}
.empty-state.is-visible {
  display: block;
}
.empty-icon {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  color: var(--cyan);
}
.empty-cta {
  margin-top: 12px;
}
.empty-state h3 {
  color: var(--ink);
  font-family: var(--font-display);
  margin: 12px 0 8px;
}

/* ============ Footer ============ */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 34px 0 48px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-reassurance {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0;
}
.footer-links {
  display: flex;
  align-items: center;
  gap: 18px;
}
.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.footer-links a:hover {
  color: var(--ink);
}

/* ============ Responsive ============ */
@media (max-width: 620px) {
  .header-inner {
    padding: 12px 0;
  }
  .btn-label-full {
    display: none;
  }
  .hero {
    padding: 44px 0 40px;
  }
  .form-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions,
  .form-actions .btn {
    width: 100%;
  }
  .form-actions .btn {
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .topics-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
