@import 'tailwindcss';
@plugin '@tailwindcss/typography';

/* Token values sourced from ../../design-system/tokens.json — keep in sync. */
@theme {
  --color-neutral-bg: #010408;
  --color-neutral-surface: #030b14;
  --color-neutral-text: #b0cceb;
  --color-neutral-muted: #4a6a8a;
  --color-neutral-border: #081828;
  --color-primary-50: #a0c8e8;
  --color-primary-500: #0c6a9e;
  --color-primary-900: #062840;
  --color-secondary-50: #a0d8d8;
  --color-secondary-400: #0e7a88;
  --color-secondary-900: #082830;
  --color-accent-500: #086878;
  --color-semantic-success: #10b981;
  --color-semantic-warning: #f59e0b;
  --color-semantic-error: #ef4444;
  --font-heading: Inter, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --animate-glow: glow 4s linear infinite;
  --animate-pulse-neon: pulse-neon 2s ease-in-out infinite;

  @keyframes glow {
    0%, 100% { opacity: 0.3; filter: brightness(100%); }
    50% { opacity: 1; filter: brightness(150%); }
  }

  @keyframes scanline {
    from { transform: translateY(-100%); }
    to { transform: translateY(400%); }
  }

  --animate-scanline: scanline 2s linear infinite;
}

/* --- Deep Ocean Plankton --- */

@keyframes plankton-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); opacity: 0; }
  8% { opacity: 0.8; }
  50% { opacity: 1; }
  92% { opacity: 0.8; }
  100% { transform: translate3d(var(--drift-x), var(--drift-y), 0) scale(var(--drift-scale)); opacity: 0; }
}

.plankton {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform, opacity;
  animation: plankton-drift var(--drift-duration) var(--drift-delay) infinite ease-in-out;
  opacity: 0;
}

/* --- Floating Organism --- */

@keyframes organism-drift {
  0%   { transform: translate3d(0, 0, 0); }
  15%  { transform: translate3d(30vw, 15vh, 0); }
  30%  { transform: translate3d(55vw, -5vh, 0); }
  45%  { transform: translate3d(40vw, 40vh, 0); }
  60%  { transform: translate3d(15vw, 55vh, 0); }
  75%  { transform: translate3d(50vw, 30vh, 0); }
  90%  { transform: translate3d(10vw, 10vh, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

.organism-float {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  opacity: 0.6;
  animation: organism-drift 240s ease-in-out infinite;
  will-change: transform;
}

/* Second organism — different path, hatches later, smaller & dimmer */
@keyframes organism-drift-2 {
  0%   { transform: translate3d(0, 0, 0); }
  12%  { transform: translate3d(-20vw, -25vh, 0); }
  28%  { transform: translate3d(-40vw, 10vh, 0); }
  42%  { transform: translate3d(-15vw, -35vh, 0); }
  58%  { transform: translate3d(10vw, -20vh, 0); }
  72%  { transform: translate3d(-30vw, -10vh, 0); }
  88%  { transform: translate3d(-5vw, -30vh, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

.organism-float-2 {
  opacity: 0.4;
  animation: organism-drift-2 280s ease-in-out infinite;
}

/* Third organism — another path, hatches even later, smallest */
@keyframes organism-drift-3 {
  0%   { transform: translate3d(0, 0, 0); }
  18%  { transform: translate3d(25vw, 20vh, 0); }
  35%  { transform: translate3d(-10vw, 35vh, 0); }
  50%  { transform: translate3d(35vw, 10vh, 0); }
  68%  { transform: translate3d(5vw, -15vh, 0); }
  82%  { transform: translate3d(20vw, 25vh, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

.organism-float-3 {
  opacity: 0.3;
  animation: organism-drift-3 320s ease-in-out infinite;
}

/* --- High-Fidelity Tactical Polish --- */

.neural-noise {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0%200%20200%20200'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter%20id='noiseFilter'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.65'%20numOctaves='3'%20stitchTiles='stitch'/%3E%3C/filter%3E%3Crect%20width='100%25'%20height='100%25'%20filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.text-glow-primary {
  text-shadow: 0 0 12px var(--color-primary-500), 0 0 30px rgba(14, 165, 233, 0.2);
}

.text-gradient-neon {
  background: linear-gradient(to bottom right, #e0f2fe 30%, var(--color-primary-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- High-Fidelity Global Overrides --- */

::selection {
  background: rgba(12, 106, 158, 0.3);
  color: #c8daf0;
  text-shadow: 0 0 8px rgba(12, 106, 158, 0.5);
}

/* Custom Neon Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #010408;
}

::-webkit-scrollbar-thumb {
  background: #081828;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #0c6a9e;
  box-shadow: 0 0 10px #0c6a9e;
}

/* Smooth internal scrolling */
* {
  scrollbar-width: thin;
  scrollbar-color: #081828 #010408;
}

/* Hide scrollbar but keep scrolling */
.no-scrollbar {
  scrollbar-width: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* --- Markdown Table Styling --- */

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.8rem;
  border: 1px solid var(--color-neutral-border);
  border-radius: 8px;
  overflow: hidden;
}

.prose thead {
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--color-neutral-border);
}

.prose th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-neutral-muted);
}

.prose td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.prose tr:last-child td {
  border-bottom: none;
}

.prose tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

/* Phase 7: conflict-row highlight pulse — fallback in case the Tailwind
   arbitrary data-attr variant compiler step skips the rule. */
[data-conflict-highlight='true'] {
  outline: 2px solid rgb(251 191 36 / 0.9);
  outline-offset: 2px;
  transition: outline-color 200ms ease-out;
  animation: harness-conflict-pulse 2s ease-out;
}
@keyframes harness-conflict-pulse {
  0% {
    outline-color: rgb(251 191 36 / 0);
  }
  20% {
    outline-color: rgb(251 191 36 / 1);
  }
  100% {
    outline-color: rgb(251 191 36 / 0);
  }
}

/* Respect users with vestibular sensitivities: skip the pulse animation
   but keep a static amber outline so the conflict indication remains visible. */
@media (prefers-reduced-motion: reduce) {
  [data-conflict-highlight='true'] {
    animation: none;
    outline: 2px solid rgb(251 191 36 / 0.9);
  }
}
