@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&display=swap');
@import "tailwindcss";

@theme {
  --color-background: #0a0a0f;
  --color-foreground: #f0f0f5;
  --color-card: #13131a;
  --color-card-foreground: #f0f0f5;
  --color-muted: #1c1c26;
  --color-muted-foreground: #9898a8;
  --color-border: rgba(139, 92, 246, 0.12);
  --color-input: rgba(139, 92, 246, 0.12);
  --color-ring: #8b5cf6;
  --color-primary: #8b5cf6;
  --color-primary-foreground: #fafafa;
  --color-secondary: #1c1c26;
  --color-secondary-foreground: #f0f0f5;
  --color-accent: #1e1e30;
  --color-accent-foreground: #f0f0f5;
  --color-destructive: #f87171;
  --color-destructive-foreground: #fafafa;

  /* Semantic finding colors */
  --color-confirmed: #34d399;
  --color-disputed: #f87171;
  --color-unverified: #fbbf24;
  --color-unique: #c084fc;

  /* Severity palette */
  --color-severity-high: #f87171;

  /* v3 additions */
  --color-impact: #60a5fa;
  --color-insight: #71717a;
  --color-text-dim: #666674;

  /* Chart / dynamic-data palette — turquoise tones for bars, sparklines,
     and activity graphs that don't carry finding semantics. Kept separate
     from --color-primary (purple) which remains the UI chrome accent. */
  --color-chart: #75dddd;
  --color-chart-accent: #09bc8a;
  --color-chart-deep: #508991;

  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-inter: 'Inter', system-ui, sans-serif;

  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
}

/* ───── Serif utility — no-op in default theme, serif in editorial ───── */
.font-serif-editorial {
  font-family: inherit;
}

body {
  background-color: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* ───── Editorial theme — cream/ink palette + serif typography ───── */
[data-theme="editorial"] {
  /* Background / surface */
  --color-background: #F4F1EA;
  --color-foreground: #0E0E0C;
  --color-card: #EAE5D9;
  --color-card-foreground: #0E0E0C;
  --color-muted: #EAE5D9;
  --color-muted-foreground: #524E41;
  --color-border: #C8C1AB;
  --color-input: #C8C1AB;

  /* Primary / accent */
  --color-ring: #A4161A;
  --color-primary: #A4161A;
  --color-primary-foreground: #F4F1EA;
  --color-secondary: #EAE5D9;
  --color-secondary-foreground: #0E0E0C;
  --color-accent: #C4BB9E;
  --color-accent-foreground: #0E0E0C;

  /* Destructive unchanged — still red */
  --color-destructive: #A4161A;
  --color-destructive-foreground: #F4F1EA;

  /* Semantic finding colors */
  --color-confirmed: #2D6A4F;
  --color-disputed: #A4161A;
  --color-unverified: #7A5F00;
  --color-unique: #1D3557;

  /* Severity */
  --color-severity-high: #B83235;  /* warmer crimson, AA on card, distinguishable from --color-disputed #A4161A */

  /* v3 additions */
  --color-impact: #1D3557;
  --color-insight: #6B6657;
  --color-text-dim: #6B6657;

  /* Chart palette — olive/warm tones for editorial */
  --color-chart: #1E4D52;
  --color-chart-accent: #2D6A4F;
  --color-chart-deep: #1D3557;

  /* Typography */
  --font-sans: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
}

[data-theme="editorial"] body {
  font-family: var(--font-sans);
}

[data-theme="editorial"] .font-serif-editorial {
  font-family: 'Spectral', 'GT Sectra', Georgia, serif;
}

/* ───── Editorial tooltip overrides ───── */
[data-theme="editorial"] [data-tooltip]::after {
  background: rgba(14, 14, 12, 0.95);
  border-color: var(--color-border);
  color: var(--color-card);
}
[data-theme="editorial"] [data-tooltip]::before {
  border-top-color: rgba(14, 14, 12, 0.95);
}

/* ───── Editorial vignette suppression ───── */
html:has([data-theme="editorial"])::after,
[data-theme="editorial"]::after {
  display: none;
}

/* ───── Editorial scrollbar override ───── */
[data-theme="editorial"] ::-webkit-scrollbar-thumb {
  background: rgba(82, 78, 65, 0.3);
}
[data-theme="editorial"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(82, 78, 65, 0.5);
}

/* ───── Editorial inline-code override ───── */
[data-theme="editorial"] .task-md code.md-inline-code,
[data-theme="editorial"] .finding-md code.md-inline-code {
  background: rgba(214, 208, 191, 0.5);
  border-color: var(--color-border);
}

/* ───── Editorial CRT logo glow suppression ───── */
[data-theme="editorial"] .crt-logo:hover::after,
[data-theme="editorial"] .crt-logo--glitch::after {
  display: none;
}
[data-theme="editorial"] .crt-logo:hover .crt-logo-img {
  filter: brightness(0.95) contrast(1.05);
}

/* Subtle vignette — no scanlines (they wash out avatar glows) */
html::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: radial-gradient(ellipse 90% 85% at 50% 50%, transparent 65%, rgba(0, 0, 0, 0.2) 100%);
}

/* ───── CRT / TV hover effect ───── */
@keyframes crt-flicker {
  0%   { opacity: 1; }
  8%   { opacity: 0.6; }
  9%   { opacity: 1; }
  22%  { opacity: 1; }
  23%  { opacity: 0.4; }
  24%  { opacity: 1; }
  60%  { opacity: 1; }
  61%  { opacity: 0.7; }
  62%  { opacity: 0.3; }
  63%  { opacity: 1; }
  85%  { opacity: 1; }
  86%  { opacity: 0.5; }
  87%  { opacity: 1; }
}

@keyframes crt-scanlines-move {
  from { background-position: 0 0; }
  to   { background-position: 0 8px; }
}

@keyframes crt-rgb-bleed {
  0%   { text-shadow: 2px 0 0 rgba(255,0,80,0.5), -2px 0 0 rgba(0,200,255,0.5); }
  25%  { text-shadow: -2px 0 0 rgba(255,0,80,0.5), 2px 0 0 rgba(0,200,255,0.5); }
  50%  { text-shadow: 1px 0 0 rgba(255,0,80,0.3), -1px 0 0 rgba(0,200,255,0.3); }
  75%  { text-shadow: -1px 0 0 rgba(255,0,80,0.5), 1px 0 0 rgba(0,200,255,0.5); }
  100% { text-shadow: 2px 0 0 rgba(255,0,80,0.5), -2px 0 0 rgba(0,200,255,0.5); }
}

.crt-logo {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

/* Scanlines layer */
.crt-logo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.25) 3px,
    rgba(0, 0, 0, 0.25) 4px
  );
  pointer-events: none;
  border-radius: 12px;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 2;
}

/* Phosphor glow layer */
.crt-logo::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 16px;
  background: radial-gradient(ellipse at center, rgba(139,92,246,0.15) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 1;
}

.crt-logo:hover::before,
.crt-logo--glitch::before {
  opacity: 1;
  animation: crt-scanlines-move 0.1s linear infinite;
}

.crt-logo:hover::after,
.crt-logo--glitch::after {
  opacity: 1;
}

.crt-logo:hover .crt-logo-img,
.crt-logo--glitch .crt-logo-img {
  animation: crt-flicker 0.6s step-end infinite;
  filter: brightness(1.25) saturate(1.1) drop-shadow(0 0 32px rgba(139,92,246,0.7));
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.25); }

/* ───── Tooltip system (CSS-only, data-tooltip="text") ───── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  padding: 8px 12px;
  background: rgba(14, 14, 20, 0.98);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--color-foreground);
  white-space: pre-line;
  width: max-content;
  max-width: 220px;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease 50ms;
  z-index: 1000;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7);
}
[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: rgba(14, 14, 20, 0.98);
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease 50ms;
  z-index: 1000;
}
[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
  opacity: 1;
}
[data-tooltip]:focus-within::after,
[data-tooltip]:focus-within::before {
  opacity: 1;
}
[data-tooltip-pos="bottom"]::after {
  bottom: auto;
  top: 100%;
  transform: translateX(-50%) translateY(6px);
}
[data-tooltip-pos="bottom"]::before {
  bottom: auto;
  top: 100%;
  border-top-color: transparent;
  border-bottom-color: rgba(14, 14, 20, 0.98);
}
[data-tooltip-pos="left"]::after {
  left: auto;
  right: 0;
  transform: translateY(-6px);
}
[data-tooltip-pos="left"]::before {
  left: auto;
  right: 12px;
  transform: none;
}
[data-tooltip-pos="right"]::after {
  left: 0;
  right: auto;
  transform: translateY(-6px);
}
[data-tooltip-pos="right"]::before {
  left: 12px;
  right: auto;
  transform: none;
}

/* ───── Task markdown renderer (.task-md) ───── */
.task-md {
  white-space: pre-wrap;
  word-break: break-word;
}

.task-md h1.md-h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-foreground);
  margin-top: 0.75rem;
  margin-bottom: 0.375rem;
  line-height: 1.4;
}

.task-md h2.md-h2 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-foreground);
  margin-top: 0.625rem;
  margin-bottom: 0.3rem;
  line-height: 1.4;
}

.task-md h3.md-h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-foreground);
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.task-md ul.md-list {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0.375rem 0;
}

.task-md ul.md-list li {
  margin: 0.2rem 0;
  line-height: 1.5;
}

.task-md code.md-inline-code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  color: var(--color-foreground);
}

.task-md pre.md-code-block {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(139, 92, 246, 0.12);
  border-radius: 5px;
  padding: 0.6rem 0.75rem;
  margin: 0.5rem 0;
  overflow-x: auto;
  white-space: pre;
  color: var(--color-foreground);
  line-height: 1.5;
}

.task-md pre.md-code-block code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* ── finding-md: compact markdown scope for agent findings and signal evidence ── */

.finding-md h1.md-h1 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-foreground);
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.finding-md h2.md-h2 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-foreground);
  margin-top: 0.4rem;
  margin-bottom: 0.2rem;
  line-height: 1.4;
}

.finding-md h3.md-h3 {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-foreground);
  margin-top: 0.3rem;
  margin-bottom: 0.15rem;
  line-height: 1.4;
}

.finding-md ul.md-list {
  list-style: disc;
  padding-left: 1rem;
  margin: 0.25rem 0;
}

.finding-md ul.md-list li {
  margin: 0.1rem 0;
  line-height: 1.5;
}

.finding-md code.md-inline-code {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 3px;
  padding: 0.1em 0.3em;
  color: var(--color-foreground);
}

.finding-md pre.md-code-block {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(139, 92, 246, 0.12);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  margin: 0.35rem 0;
  overflow-x: auto;
  white-space: pre;
  color: var(--color-foreground);
  line-height: 1.5;
}

.finding-md pre.md-code-block code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}
