/* ==========================================================================
 AI Agent View , "Structured Data Terminal" Design System
   mattkundodigitalmarketing.com/ai/
   ========================================================================== */

:root {
  --ai-bg: #0d1117;
  --ai-bg-card: #161b22;
  --ai-bg-code: #1c2128;
  --ai-text: #c9d1d9;
  --ai-text-bright: #e6edf3;
  --ai-text-muted: #7d8590;
  --ai-accent: #BFA07A;
  --ai-green: #3fb950;
  --ai-blue: #58a6ff;
  --ai-purple: #bc8cff;
  --ai-orange: #d29922;
  --ai-red: #f85149;
  --ai-border: #30363d;
  --ai-border-bright: #484f58;
  --ai-font: 'Space Mono', 'Courier New', 'Consolas', monospace;
  --ai-font-sans: 'Inter', -apple-system, sans-serif;
  --ai-radius: 6px;
  --ai-max-width: 900px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.ai-view {
  background: var(--ai-bg);
  color: var(--ai-text);
  font-family: var(--ai-font);
  line-height: 1.7;
  min-height: 100vh;
}

/* Subtle scanline overlay */
body.ai-view::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ==========================================================================
   Header
   ========================================================================== */

.ai-header {
  border-bottom: 1px solid var(--ai-border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--ai-bg);
  z-index: 100;
}

.ai-header__logo {
  font-family: var(--ai-font);
  font-size: 0.9rem;
  color: var(--ai-text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-header__logo:hover {
  color: var(--ai-text);
}

.ai-header__logo-mark {
  color: var(--ai-accent);
  font-weight: 700;
}

.ai-header__mode {
  font-size: 0.75rem;
  color: var(--ai-green);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-header__mode::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--ai-green);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.ai-header__nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.ai-header__link {
  color: var(--ai-text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.2s;
}

.ai-header__link:hover {
  color: var(--ai-blue);
}

/* ==========================================================================
   AI Toggle (shared between human and AI views)
   ========================================================================== */

.ai-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--ai-border, #30363d);
  border-radius: 4px;
  text-decoration: none;
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  transition: all 0.2s ease;
  white-space: nowrap;
}

/* In human view context */
.header .ai-toggle {
  color: #8A8785;
  border-color: #d5d3d0;
  background: transparent;
}

.header .ai-toggle:hover {
  color: #1A1A1A;
  border-color: #BFA07A;
  background: rgba(191, 160, 122, 0.08);
}

/* In AI view context */
.ai-header .ai-toggle {
  color: var(--ai-accent);
  border-color: var(--ai-accent);
  background: rgba(191, 160, 122, 0.08);
}

.ai-header .ai-toggle:hover {
  background: rgba(191, 160, 122, 0.15);
}

.ai-toggle__icon {
  font-size: 0.85rem;
  line-height: 1;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.ai-main {
  max-width: var(--ai-max-width);
  margin: 0 auto;
  padding: 2rem;
}

/* ==========================================================================
   Section Blocks
   ========================================================================== */

.ai-section {
  margin-bottom: 2rem;
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius);
  overflow: hidden;
}

.ai-section__header {
  background: var(--ai-bg-card);
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--ai-border);
  font-size: 0.75rem;
  color: var(--ai-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-section__header-icon {
  color: var(--ai-accent);
}

.ai-section__body {
  padding: 1rem;
  background: var(--ai-bg);
}

/* ==========================================================================
   Document Identity
   ========================================================================== */

.ai-identity {
  margin-bottom: 2rem;
}

.ai-identity__title {
  font-family: var(--ai-font);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ai-text-bright);
  line-height: 1.3;
  margin-bottom: 1.2rem;
}

.ai-identity__title::before {
  content: '# ';
  color: var(--ai-accent);
}

.ai-meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1.5rem;
  font-size: 0.85rem;
}

.ai-meta-grid dt {
  color: var(--ai-green);
  white-space: nowrap;
}

.ai-meta-grid dt::after {
  content: ':';
}

.ai-meta-grid dd {
  color: var(--ai-text);
}

/* ==========================================================================
   JSON / Code Blocks
   ========================================================================== */

.ai-code-block {
  background: var(--ai-bg-code);
  border-radius: var(--ai-radius);
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.6;
}

.ai-code-block pre {
  padding: 1rem;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* JSON Syntax Highlighting */
.json-key { color: var(--ai-blue); }
.json-string { color: var(--ai-green); }
.json-number { color: var(--ai-orange); }
.json-boolean { color: var(--ai-purple); }
.json-null { color: var(--ai-text-muted); }
.json-bracket { color: var(--ai-text-muted); }

/* ==========================================================================
   Content Section
   ========================================================================== */

.ai-content {
  font-family: var(--ai-font-sans);
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--ai-text);
}

.ai-content h2 {
  font-family: var(--ai-font);
  font-size: 1.1rem;
  color: var(--ai-text-bright);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--ai-border);
}

.ai-content h2::before {
  content: '## ';
  color: var(--ai-accent);
}

.ai-content h3 {
  font-family: var(--ai-font);
  font-size: 0.95rem;
  color: var(--ai-text-bright);
  margin: 1.2rem 0 0.5rem;
}

.ai-content h3::before {
  content: '### ';
  color: var(--ai-accent);
}

.ai-content p {
  margin-bottom: 1rem;
}

.ai-content a {
  color: var(--ai-blue);
  text-decoration: underline;
  text-decoration-color: rgba(88, 166, 255, 0.3);
  text-underline-offset: 2px;
}

.ai-content a:hover {
  text-decoration-color: var(--ai-blue);
}

.ai-content ul, .ai-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.ai-content li {
  margin-bottom: 0.3rem;
}

.ai-content img {
  display: none; /* Hide decorative images in AI view */
}

.ai-content blockquote {
  border-left: 3px solid var(--ai-accent);
  padding-left: 1rem;
  color: var(--ai-text-muted);
  font-style: italic;
}

/* ==========================================================================
   Entity Graph
   ========================================================================== */

.ai-entity-graph {
  font-size: 0.85rem;
}

.ai-entity-node {
  padding: 0.2rem 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.ai-entity-node--pillar {
  color: var(--ai-accent);
  font-weight: 700;
}

.ai-entity-node--spoke {
  padding-left: 1.5rem;
}

.ai-entity-node--spoke::before {
  content: '\251C\2500\2500 ';
  color: var(--ai-border-bright);
}

.ai-entity-node--spoke:last-child::before {
  content: '\2514\2500\2500 ';
}

.ai-entity-link {
  color: var(--ai-blue);
  text-decoration: none;
  font-size: 0.8rem;
}

.ai-entity-link:hover {
  text-decoration: underline;
}

.ai-entity-label {
  color: var(--ai-text-muted);
  font-size: 0.75rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.ai-footer {
  border-top: 1px solid var(--ai-border);
  padding: 1.5rem 2rem;
  margin-top: 3rem;
  font-size: 0.75rem;
  color: var(--ai-text-muted);
}

.ai-footer__inner {
  max-width: var(--ai-max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.ai-footer__links {
  display: flex;
  gap: 1.5rem;
}

.ai-footer__link {
  color: var(--ai-text-muted);
  text-decoration: none;
}

.ai-footer__link:hover {
  color: var(--ai-blue);
}

/* ==========================================================================
   AI Index / Landing Page
   ========================================================================== */

.ai-landing__hero {
  margin-bottom: 3rem;
  padding: 2rem 0;
  border-bottom: 1px solid var(--ai-border);
}

.ai-landing__title {
  font-size: 1.6rem;
  color: var(--ai-text-bright);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.ai-landing__subtitle {
  color: var(--ai-text-muted);
  font-size: 0.9rem;
}

.ai-landing__endpoints {
  margin-bottom: 2rem;
}

.ai-endpoint {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--ai-border);
}

.ai-endpoint:last-child {
  border-bottom: none;
}

.ai-endpoint__method {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.ai-endpoint__method--get {
  color: var(--ai-green);
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.ai-endpoint__method--post {
  color: var(--ai-blue);
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.3);
}

.ai-endpoint__path {
  color: var(--ai-text-bright);
  font-size: 0.85rem;
}

.ai-endpoint__desc {
  color: var(--ai-text-muted);
  font-size: 0.8rem;
  margin-left: auto;
}

/* ==========================================================================
   Page List (for index pages)
   ========================================================================== */

.ai-page-list {
  list-style: none;
}

.ai-page-list__item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--ai-border);
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.ai-page-list__item:last-child {
  border-bottom: none;
}

.ai-page-list__link {
  color: var(--ai-blue);
  text-decoration: none;
  font-size: 0.85rem;
}

.ai-page-list__link:hover {
  text-decoration: underline;
}

.ai-page-list__meta {
  color: var(--ai-text-muted);
  font-size: 0.75rem;
  margin-left: auto;
  white-space: nowrap;
}

.ai-page-list__type {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--ai-bg-card);
  border: 1px solid var(--ai-border);
  color: var(--ai-text-muted);
  flex-shrink: 0;
}

.ai-page-list__type--pillar {
  color: var(--ai-accent);
  border-color: var(--ai-accent);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .ai-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .ai-header__nav {
    display: none;
  }

  .ai-main {
    padding: 1rem;
  }

  .ai-meta-grid {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .ai-meta-grid dt {
    margin-top: 0.3rem;
  }

  .ai-footer__inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .ai-endpoint {
    flex-wrap: wrap;
  }

  .ai-endpoint__desc {
    margin-left: 0;
    width: 100%;
  }
}
