// --------------- Typography ---------------

$body-font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
$mono-font-family: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", ui-monospace, monospace;
$heading-font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

// Apply
body {
  font-family: $body-font-family;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.site-title {
  font-family: $heading-font-family;
}

code,
pre,
.highlight {
  font-family: $mono-font-family;
}

// --------------- Type scale ---------------

.main-content {
  h1 {
    font-size: 1.875rem !important;   // 30px
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-top: 0;
  }
  h2 {
    font-size: 1.5rem !important;     // 24px
    font-weight: 600;
    letter-spacing: -0.01em;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-color, #{$zinc-200});
  }
  h3 {
    font-size: 1.25rem !important;    // 20px
    font-weight: 600;
  }

  font-size: 15px;
  line-height: 1.7;
}

// Tighter sidebar text
.nav-list .nav-list-item {
  font-size: 14px;
  line-height: 1.4;
}

// --------------- Code blocks ---------------

// Inline code
code {
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.87em;
  background-color: $zinc-100;
  color: $indigo-600;
}

// Code blocks
div.highlighter-rouge,
figure.highlight {
  border-radius: 8px;
  border: 1px solid $zinc-800;
  overflow: hidden;
  position: relative;

  pre {
    padding: 1rem 1.25rem;
    margin: 0;
    overflow-x: auto;
    line-height: 1.6;
    background-color: $warm-850;
    color: $zinc-300;

    code {
      background: transparent;
      color: inherit;
      padding: 0;
      font-size: 13px;
    }
  }
}

// Shell prompt styling
.language-bash .highlight pre::before,
.language-shell .highlight pre::before {
  content: "$ ";
  color: $zinc-600;
  user-select: none;
}

// Copy button enhancement
.copy-code-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  color: $zinc-500;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;

  &:hover {
    background: rgba(255,255,255,0.12);
    color: $zinc-300;
  }
}

div.highlighter-rouge:hover .copy-code-button {
  opacity: 1;
}

// --------------- Syntax theme (tuned for indigo accent) ---------------

.highlight {
  .k, .kd, .kn, .kp, .kr, .kt   { color: #c678dd; }  // keywords — purple
  .s, .s1, .s2, .sb, .sc, .sd,
  .sh, .sx                        { color: #98c379; }  // strings — green
  .nf, .nx                        { color: #e39479; }  // functions — terracotta
  .nc, .nn                        { color: #e5c07b; }  // classes/namespaces — gold
  .c, .c1, .cm, .cs               { color: #5c6370; font-style: italic; } // comments
  .mi, .mf, .mh, .mo, .il        { color: #d19a66; }  // numbers — orange
  .o, .ow                         { color: #d19a66; }  // operators — warm orange
  .nb                             { color: #e5c07b; }  // builtins
  .na                             { color: #d19a66; }  // attributes
  .p                              { color: #abb2bf; }  // punctuation
  .se                             { color: #d19a66; }  // string escape
  .err                            { color: #e06c75; }  // error — red
}

// --------------- Homepage ---------------

// Hero
.hero-section {
  background: $zinc-950;
  border-radius: 12px;
  padding: 3rem 2.5rem;
  margin-bottom: 2rem;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  border: 1px solid $zinc-800;

  // Subtle radial glow
  &::before {
    content: "";
    position: absolute;
    top: -60%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(217, 119, 87, 0.08) 0%, transparent 70%);
    pointer-events: none;
  }
}

.hero-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  position: relative;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: $zinc-400;
  text-decoration: none;
  transition: all 0.2s ease;

  &:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.18);
    color: $zinc-200;
    text-decoration: none;
  }
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;

  &--green { background: $green-500; }
  &--amber { background: $amber-500; }
}

.hero-title {
  font-family: $heading-font-family;
  font-size: 2.5rem !important;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ffffff !important;
  margin-bottom: 0.75rem;
  line-height: 1.1;
  position: relative;
}

.hero-tagline {
  font-size: 1.25rem;
  color: $zinc-300;
  margin-bottom: 0.5rem;
  line-height: 1.4;
  max-width: 540px;
  position: relative;
}

.hero-description {
  font-size: 0.95rem;
  color: $zinc-500;
  line-height: 1.6;
  max-width: 540px;
  margin-bottom: 1.5rem;
  position: relative;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
}

.btn-hero {
  display: inline-flex;
  align-items: center;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;

  &--primary {
    background: linear-gradient(135deg, $indigo-500, $indigo-600);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2), 0 0 0 1px rgba(217, 119, 87, 0.3);
    &:hover {
      background: linear-gradient(135deg, $indigo-400, $indigo-500);
      box-shadow: 0 2px 8px rgba(217, 119, 87, 0.3), 0 0 0 1px rgba(217, 119, 87, 0.4);
      color: #ffffff;
      text-decoration: none;
      transform: translateY(-1px);
    }
  }

  &--outline {
    background: transparent;
    border: 1px solid $zinc-700;
    color: $zinc-400;
    &:hover {
      background: rgba(255,255,255,0.04);
      border-color: $zinc-600;
      color: $zinc-200;
      text-decoration: none;
    }
  }
}

// Quick install
.quick-install {
  margin-bottom: 2.5rem;

  &__title {
    font-size: 1.25rem !important;
    margin-bottom: 1rem;
  }
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.install-step {
  &__label {
    font-size: 13px;
    font-weight: 600;
    color: $zinc-500;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
  &__code {
    pre {
      margin: 0;
      padding: 0.75rem 1rem;
      background: $warm-850;
      border-radius: 8px;
      border: 1px solid $zinc-800;
      overflow-x: auto;

      code {
        color: $zinc-300;
        font-family: $mono-font-family;
        font-size: 13px;
        background: transparent;
        padding: 0;
      }
    }
  }
}

// Demo
.demo-section {
  margin-bottom: 2.5rem;

  .demo-embed {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid $zinc-800;

    img {
      width: 100%;
      height: auto;
      display: block;
    }
  }
}

// Feature grid
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 2.5rem;
}

.feature-card {
  padding: 1.25rem;
  border: 1px solid $zinc-200;
  border-radius: 10px;
  background: #ffffff;
  transition: all 0.2s ease;
  position: relative;

  // Top accent line
  &::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12px;
    right: 12px;
    height: 2px;
    background: transparent;
    border-radius: 0 0 2px 2px;
    transition: background 0.2s ease;
  }

  &:hover {
    border-color: rgba(217, 119, 87, 0.3);
    box-shadow: 0 4px 12px rgba(217, 119, 87, 0.06);

    &::before {
      background: $indigo-500;
    }
  }
}

.feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;

  &--cyan   { background: $indigo-100; color: $indigo-600; }
  &--green  { background: #d1fae5;     color: #065f46; }
  &--amber  { background: #fef3c7;     color: #92400e; }
  &--purple { background: #ede9fe;     color: #5b21b6; }
}

.feature-title {
  font-size: 16px !important;
  font-weight: 600;
  margin-bottom: 6px;
  color: $zinc-950;
}

.feature-desc {
  font-size: 14px;
  line-height: 1.55;
  color: $zinc-500;
  margin: 0;
}

// Tip callout
.tip-callout {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  background: $indigo-100;
  color: $indigo-600;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 2rem;
  border: 1px solid rgba(217, 119, 87, 0.15);

  a {
    color: $indigo-600;
    font-weight: 600;
    text-decoration: underline;
  }
}

// --------------- Sidebar layout ---------------
// Fix: Just the Docs grows the sidebar with viewport and right-aligns nav content,
// leaving dead space on the left. Override to use fixed width, flush left.

@media (min-width: 66.5rem) {
  .side-bar {
    width: 16.5rem !important;
    align-items: stretch !important;
  }

  .side-bar + .main {
    margin-left: 16.5rem !important;
    max-width: none !important;
  }
}

// Active page — subtle warm background pill (Claude docs style)
.nav-list-item.active > .nav-list-link {
  font-weight: 600 !important;
  color: $warm-050 !important;
  background-color: rgba(222, 220, 209, 0.08) !important;
  background-image: none !important;
  border-radius: 6px;
  border-left: none !important;
}

// Top-level section headers (Getting Started, Guides, etc.)
.site-nav > .nav-list > .nav-list-item > .nav-list-link {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: $warm-400;
  margin-top: 1rem;
  padding: 6px 12px;

  &:hover {
    color: $warm-200;
    background: transparent;
  }
}

// First section header — no top margin
.site-nav > .nav-list > .nav-list-item:first-child > .nav-list-link {
  margin-top: 0;
}

// All nav links — clean, minimal
.nav-list .nav-list-item .nav-list-link {
  font-size: 14px;
  padding: 5px 12px;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
  color: $warm-400;
  border-left: none;

  &:hover {
    background: rgba(222, 220, 209, 0.06);
    color: $warm-200;
  }
}

// Child nav links — slightly indented, smaller
.nav-list .nav-list .nav-list-link {
  font-size: 13px;
  padding-left: 24px;
  color: $warm-500;

  &:hover {
    color: $warm-300;
  }
}

// Site title in sidebar
.site-title {
  font-family: $heading-font-family;
  font-weight: 700;
  font-size: 18px !important;
  color: $warm-050;
  letter-spacing: -0.02em;
}

// Sidebar background — clean, no gradient
.side-bar {
  border-right: 1px solid rgba(222, 220, 209, 0.08);
}

// Nav expander arrows — muted
.nav-list-expander {
  color: $warm-600;
}

// --------------- Tables ---------------

// Dark-by-default. Site is always dark (color_scheme: agent-dashboard-dark)
// — do not gate on prefers-color-scheme; the parent light scheme leaks
// through tbody td background otherwise.
.main-content table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 14px;
  margin: 1.5rem 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  overflow: hidden;

  thead th {
    background-color: $warm-850;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: $warm-400;
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    text-align: left;
  }

  tbody td {
    background-color: transparent;
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: $warm-300;
    vertical-align: top;
  }

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

  tbody tr:hover td {
    background-color: rgba(217, 119, 87, 0.04);
  }

  // Keycap pill — used for keys, flags, short file names inside cells.
  // Uses $warm-700 (~Material 12dp elevation) so it reads as a tactile
  // chip against both page bg ($warm-900) and the muted thead strip.
  code {
    font-family: $mono-font-family;
    font-size: 12px;
    padding: 2px 7px;
    border-radius: 4px;
    background: $warm-700;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: $warm-100;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25);
    white-space: nowrap;
  }
}

// --------------- Dark mode overrides ---------------

@media (prefers-color-scheme: dark) {
  .hero-section {
    border-color: $zinc-800;
  }

  .feature-card {
    background: $zinc-900;
    border-color: $zinc-800;

    &:hover {
      border-color: rgba(217, 119, 87, 0.3);
      box-shadow: 0 4px 12px rgba(217, 119, 87, 0.08);
    }
  }

  .feature-title {
    color: $zinc-050;
  }

  .feature-icon {
    &--cyan   { background: rgba(217, 119, 87, 0.15); color: $indigo-400; }
    &--green  { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
    &--amber  { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
    &--purple { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; }
  }

  .tip-callout {
    background: rgba(217, 119, 87, 0.08);
    border-color: rgba(217, 119, 87, 0.15);
    color: $indigo-300;

    a { color: $indigo-300; }
  }

  .install-step__label {
    color: $zinc-500;
  }

  code {
    background-color: $zinc-900;
    color: $indigo-400;
  }

  .site-title {
    color: $warm-050;
  }

  .nav-list-item.active > .nav-list-link {
    color: $warm-050;
    background-color: rgba(222, 220, 209, 0.1);
  }

  .demo-section .demo-embed {
    border-color: $zinc-800;
  }

  .main-content h2 {
    border-bottom-color: $zinc-800;
  }
}

// --------------- Blog ---------------

.blog-post,
.blog-index {
  max-width: 65ch;
  margin: 0 auto;

  p, ul, ol, blockquote, pre, table, figure {
    margin-bottom: 1.25em;
  }
}

.blog-post__body {
  font-size: 17px;
  line-height: 1.7;
}

.blog-post__header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(222, 220, 209, 0.08);
}

.blog-post .blog-post__title {
  font-size: 2.5rem !important;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 0.75rem 0;
}

.blog-post__deck {
  font-size: 1.125rem;
  font-weight: 400;
  color: $warm-400;
  line-height: 1.5;
  margin: 0;

  time {
    color: $warm-500;
    font-variant-numeric: tabular-nums;
    margin-right: 0.25em;
  }
}

.blog-post__body,
.blog-index {
  h2 {
    font-size: 1.625rem !important;
    font-weight: 600;
    letter-spacing: -0.015em;
    margin-top: 2.5rem;
    padding-bottom: 0.4rem;
  }

  h3 {
    font-size: 1.25rem !important;
    margin-top: 1.75rem;
  }

  a:not(.btn-hero):not(.hero-badge):not(.post-list__link) {
    color: $terra-400;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(227, 148, 121, 0.4);

    &:hover {
      text-decoration-color: $terra-400;
    }
  }

  code {
    background-color: rgba(255, 255, 255, 0.06);
    color: $warm-200;
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.85em;
  }

  a code {
    color: inherit;
  }

  hr {
    border: none;
    height: 1px;
    background: rgba(222, 220, 209, 0.06);
    margin: 2.5rem auto;
    width: 60%;
  }
}

.blog-index .blog-index__header {
  margin-bottom: 2rem;

  h1 {
    font-size: 2.25rem !important;
    font-weight: 700;
    letter-spacing: -0.025em;
  }
}

.blog-index__deck {
  font-size: 1.125rem;
  color: $warm-400;
  line-height: 1.5;
  margin: 0.5rem 0 0;
}

.post-list {
  list-style: none !important;
  padding: 0 !important;
  margin: 2rem 0 0 !important;
  border-top: 1px solid rgba(222, 220, 209, 0.08);
}

.post-list__item {
  border-bottom: 1px solid rgba(222, 220, 209, 0.08);
  margin: 0;

  &::before {
    content: none !important;
  }
}

.post-list__link {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.5rem 1.5rem;
  padding: 1.25rem 0;
  text-decoration: none !important;
  color: inherit !important;
  transition: background 0.15s ease;

  &:hover {
    background: rgba(255, 255, 255, 0.02);

    .post-list__title {
      color: $terra-400;
    }
  }
}

.post-list__date {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.8125rem;
  color: $warm-500;
  font-variant-numeric: tabular-nums;
  padding-top: 0.15rem;
}

.post-list__title {
  grid-column: 2;
  grid-row: 1;
  font-size: 1.125rem;
  font-weight: 600;
  color: $warm-100;
  transition: color 0.15s ease;
}

.post-list__deck {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.9375rem;
  color: $warm-400;
  line-height: 1.5;
}

@media (max-width: 40rem) {
  .post-list__link {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .post-list__date,
  .post-list__title,
  .post-list__deck {
    grid-column: 1;
    grid-row: auto;
  }
}
