/* ==========================================================================
   base.css — tokens, reset, and shared UI primitives
   Owns design tokens, typography, buttons, chips, cards, and reusable visuals.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Colors */
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --text: #1f2a2e;
  --muted: #5f6b73;
  --border: #d7d2c8;
  --border-strong: #b9b3a8;
  --rule: rgba(31, 42, 46, 0.08);

  /* Accent (Indigo) */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --accent-glow: rgba(79, 70, 229, 0.18);

  --role-bg: rgba(79, 70, 229, 0.10);
  --role-border: rgba(79, 70, 229, 0.24);
  --role-border-strong: rgba(79, 70, 229, 0.42);
  --role-text: #4338ca;
  --tag-bg: rgba(147, 51, 234, 0.10);
  --tag-border: rgba(147, 51, 234, 0.24);
  --tag-border-strong: rgba(147, 51, 234, 0.42);
  --tag-text: #7e22ce;

  --danger: #b42318;
  --danger-bg: #fde7e3;

  /* Typography */
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 24px;
  --line-loose: 1.6;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Layout */
  --container: 1100px;
  --header-h: 64px;
  --footer-h: 72px;

  /* Radius — use one family across the product */
  --radius-sm: 12px;
  --radius-md: 12px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-1: 0 6px 18px rgba(18, 24, 28, 0.08);
  --shadow-2: 0 10px 26px rgba(18, 24, 28, 0.14);

  /* Motion */
  --dur: 150ms;
  --ease: ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  padding: 0;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
}

button,
a,
input,
select,
textarea {
  transition:
    border-color var(--dur) var(--ease),
    background-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform 120ms ease;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* Layout helpers */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.muted {
  color: var(--muted);
}

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

/* Typography + brand */
.brand {
  font-size: var(--text-xl);
  color: var(--accent);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.brandLink {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.brandStack {
  display: inline-flex;
  flex-direction: column;
  min-width: 0;
}

.brandWordmarkRow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brandMark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.18), rgba(79, 70, 229, 0.08));
  border: 1px solid rgba(79, 70, 229, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transform: rotate(-5deg);
}

.brandMarkCore {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-hover));
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.brandBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(79, 70, 229, 0.18);
  background: rgba(79, 70, 229, 0.08);
  color: var(--accent-hover);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field-hint {
  font-size: var(--text-sm);
}

.field-label {
  font-size: var(--text-sm);
  color: var(--muted);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Inputs */
.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input {
  height: 48px;
  font-size: var(--text-lg);
  border-radius: var(--radius-lg);
}

.search-block {
  margin-bottom: var(--space-4);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 42px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
}

.btn-sm {
  min-height: 34px;
  padding: 8px 12px;
  font-size: var(--text-sm);
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent-hover);
}

.is-disabled,
.btn:disabled,
.input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 30px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--text-sm);
  cursor: pointer;
}

.chip:hover {
  border-color: var(--accent);
}

.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* Semantic chip styling: roles = blue, tags = purple */
.chip[data-type="role"] {
  border-color: var(--role-border);
}

.chip[data-type="role"]:hover {
  border-color: var(--role-border-strong);
}

.chip[data-type="role"].is-active {
  background: var(--role-bg);
  border-color: var(--accent);
  color: var(--role-text);
}

.chip[data-type="tag"] {
  border-color: var(--tag-border);
}

.chip[data-type="tag"]:hover {
  border-color: var(--tag-border-strong);
}

.chip[data-type="tag"].is-active {
  background: var(--tag-bg);
  border-color: rgba(147, 51, 234, 0.52);
  color: var(--tag-text);
}

.chip-sm {
  min-height: 28px;
  padding: 4px 10px;
}

/* Cards and lists */
.question-list {
  display: grid;
  gap: var(--space-4);
}

.question-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.question-card:hover {
  border-color: rgba(79, 70, 229, 0.45);
  box-shadow: var(--shadow-2);
}

.question-body {
  min-width: 0;
  display: grid;
  gap: var(--space-3);
}

.question-main {
  min-width: 0;
}

.question-text {
  font-size: var(--text-lg);
  line-height: var(--line-loose);
}

.question-meta {
  display: grid;
  gap: var(--space-2);
}

.question-metaDivider {
  height: 1px;
  background: var(--rule);
  margin: 2px 0;
}

.tag-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.meta-group {
  min-width: 0;
}

.meta-icon {
  flex: 0 0 auto;
  width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.78;
  margin-top: 4px;
}

.meta-chipWrap {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.card-actions {
  display: flex;
  align-items: flex-start;
}

/* Sections */
.filter-block {
  margin-top: var(--space-4);
  display: grid;
  gap: var(--space-2);
}

.results-section {
  margin-top: var(--space-6);
}

.empty-state {
  padding: var(--space-6);
  text-align: center;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
  background: var(--surface-2);
}

.empty-title {
  font-size: var(--text-lg);
  font-weight: 700;
}

.empty-text {
  color: var(--muted);
  margin-top: var(--space-2);
}

/* Footer helpers */
.footer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.selected-count {
  font-size: var(--text-sm);
}

/* Responsive */
@media (max-width: 720px) {
  .brandMark {
    width: 30px;
    height: 30px;
  }

  .brandBadge {
    display: none;
  }

  .question-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .card-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .footer-actions {
    flex-direction: column;
    width: 100%;
    align-items: stretch;
  }
}
