/**
 * BMAD Method Documentation - Custom Styles for Starlight
 * Dark theme matching bmadcode.com Ghost blog
 *
 * Design tokens from Ghost theme:
 * Background: #0a0a0a | Surface: #1a1a1a | Border: #262626
 * Accent: #3b82f6 | Gold: #d4a853 | Text: #fafafa/#a1a1a1/#666666
 */

/* Google Fonts - match Ghost blog typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================
   COLOR PALETTE - Light Mode
   ============================================ */
:root {
  --ai-banner-height: 2.75rem;
  --sl-nav-height: 6.25rem; /* Base nav height (~3.5rem) + banner height (2.75rem) */

  /* Full-width content - override Starlight's default 45rem/67.5rem */
  --sl-content-width: 65rem;

  /* Primary accent colors - blue to match Ghost blog */
  --sl-color-accent-low: #dbeafe;
  --sl-color-accent: #2563eb;
  --sl-color-accent-high: #1d4ed8;

  /* Text colors */
  --sl-color-white: #1e293b;
  --sl-color-gray-1: #334155;
  --sl-color-gray-2: #475569;
  --sl-color-gray-3: #64748b;
  --sl-color-gray-4: #94a3b8;
  --sl-color-gray-5: #cbd5e1;
  --sl-color-gray-6: #e2e8f0;
  --sl-color-black: #f8fafc;

  /* Font settings */
  --sl-font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  --sl-font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --sl-text-base: 1rem;
  --sl-line-height: 1.7;

  /* Code highlighting */
  --sl-color-bg-inline-code: rgba(59, 130, 246, 0.08);
}

/* ============================================
   COLOR PALETTE - Dark Mode (Primary Focus)
   ============================================ */
:root[data-theme='dark'] {
  /* Full-width content - override Starlight's default */
  --sl-content-width: 65rem;

  /* Primary accent colors - blue to match Ghost blog */
  --sl-color-accent-low: rgba(59, 130, 246, 0.12);
  --sl-color-accent: #3b82f6;
  --sl-color-accent-high: #60a5fa;

  /* Background colors - match Ghost blog */
  --sl-color-bg: #0a0a0a;
  --sl-color-bg-nav: #0a0a0a;
  --sl-color-bg-sidebar: #0a0a0a;
  --sl-color-hairline-light: rgba(255, 255, 255, 0.06);
  --sl-color-hairline: #262626;

  /* Text colors - match Ghost blog */
  --sl-color-white: #fafafa;
  --sl-color-gray-1: #e2e8f0;
  --sl-color-gray-2: #a1a1a1;
  --sl-color-gray-3: #94a3b8;
  --sl-color-gray-4: #666666;
  --sl-color-gray-5: #475569;
  --sl-color-gray-6: #262626;
  --sl-color-black: #0a0a0a;

  /* Code highlighting */
  --sl-color-bg-inline-code: rgba(59, 130, 246, 0.15);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

/* Space Grotesk for all headings - match Ghost blog */
.sl-markdown-content h1,
.sl-markdown-content h2,
.sl-markdown-content h3,
.sl-markdown-content h4,
.sl-markdown-content h5,
.sl-markdown-content h6,
.site-title,
starlight-toc h2 {
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  letter-spacing: -0.02em;
}

.sl-markdown-content h1 {
  margin-bottom: 1.5rem;
}

.sl-markdown-content h2 {
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.sl-markdown-content h3 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.sl-markdown-content p {
  margin-bottom: 1.25rem;
}

/* ============================================
   SIDEBAR & NAVIGATION
   Clean styling inspired by React Native docs
   ============================================ */

/* Base transition for all sidebar links */
.sidebar-content a {
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
  border-radius: 4px;
}

/* Top-level sidebar items (Diataxis categories) */
.sidebar-content > ul > li > details > summary,
.sidebar-content > ul > li > a {
  font-weight: 700;
  font-size: 0.9375rem;
  padding: 0.5rem 0.75rem;
}

/* Nested sidebar items */
.sidebar-content ul ul a {
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  padding-left: 1.5rem;
  border-left: 3px solid transparent;
}

/* Deep nested items */
.sidebar-content ul ul ul a {
  font-weight: 400;
  font-size: 0.8125rem;
  padding-left: 2.25rem;
}

/* Active state - thin left accent bar */
.sidebar-content a[aria-current='page'] {
  background-color: rgba(59, 130, 246, 0.08);
  color: var(--sl-color-accent);
  border-left-color: var(--sl-color-accent);
  font-weight: 600;
}

:root[data-theme='dark'] .sidebar-content a[aria-current='page'] {
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--sl-color-accent-high);
  border-left-color: var(--sl-color-accent);
}

/* Hover states */
.sidebar-content a:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

:root[data-theme='dark'] .sidebar-content a:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Section spacing */
.sidebar-content > ul > li {
  margin-top: 0.75rem;
}

.sidebar-content > ul > li:first-child {
  margin-top: 0;
}

/* Lighter chevrons/carets */
.sidebar-content summary::marker,
.sidebar-content details > summary::after {
  opacity: 0.4;
}

.sidebar-content summary:hover::marker,
.sidebar-content details > summary:hover::after {
  opacity: 0.6;
}

/* ============================================
   LAYOUT - Full width content
   ============================================ */
.content-panel {
  width: 100%;
  margin: 0 auto;
}

/* Full-width workflow diagram iframe */
.sl-markdown-content > iframe:first-child {
  width: 100vw !important;
  margin-left: calc(50% - 50vw);
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
}

/* Main content area */
main {
  min-width: 0;
}

.sl-markdown-content {
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Hide breadcrumbs if desired */
/* Uncomment to hide:
nav[aria-label="Breadcrumb"] {
  display: none;
}
*/

/* ============================================
   NAVBAR
   ============================================ */
header.header {
  padding: 0 !important; /* Remove all padding for full-width banner */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  height: var(--sl-nav-height) !important;
  display: flex;
  flex-direction: column;
}

header.header .header.sl-flex {
  padding: 0 1.5rem;
  height: calc(var(--sl-nav-height) - var(--ai-banner-height));
  width: 100%;
}

:root[data-theme='dark'] header.header {
  box-shadow: none;
  border-bottom: 1px solid #262626;
}

.site-title {
  font-weight: 700;
  margin-left: 0;
  padding-left: 0;
}

/* Logo sizing - constrain to reasonable size */
.site-title img {
  height: 2.5rem;
  width: auto;
}

/* Social links styling */
.social-icons a {
  padding: 0.5rem;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
  border-radius: 6px;
}

.social-icons a:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

:root[data-theme='dark'] .social-icons a:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* ============================================
   CARDS
   ============================================ */
.card {
  border-radius: 12px;
  border: 2px solid var(--sl-color-gray-5);
  background-color: var(--sl-color-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--sl-color-accent);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
}

:root[data-theme='dark'] .card {
  background: #1a1a1a;
  border-color: #262626;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

:root[data-theme='dark'] .card:hover {
  border-color: #3b82f6;
  box-shadow:
    0 8px 32px rgba(59, 130, 246, 0.15),
    0 0 0 1px rgba(59, 130, 246, 0.1);
}

/* Starlight card grid */
.sl-link-card {
  border-radius: 12px;
  border: 2px solid var(--sl-color-gray-5);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.sl-link-card:hover {
  transform: translateY(-3px);
  border-color: var(--sl-color-accent);
}

:root[data-theme='dark'] .sl-link-card {
  border-color: #262626;
}

:root[data-theme='dark'] .sl-link-card:hover {
  border-color: #3b82f6;
}

/* ============================================
   BUTTONS
   ============================================ */
.sl-flex a[href],
button {
  transition:
    background-color 0.2s ease,
    transform 0.1s ease;
}

.sl-flex a[href]:hover,
button:hover {
  transform: translateY(-1px);
}

/* ============================================
   MISC ENHANCEMENTS
   ============================================ */

/* Prevent horizontal scrollbar from full-viewport-width breakout elements (e.g. iframe) */
html {
  overflow-x: clip;
}

/* Smooth scrolling */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Disable hover animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .card:hover,
  .sl-link-card:hover {
    transform: none;
  }
}

/* Better link underlines */
.sl-markdown-content a:not(.sl-link-card) {
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Table styling */
table {
  display: table;
  width: 100%;
}

:root[data-theme='dark'] table {
  border-color: #262626;
}

:root[data-theme='dark'] table th {
  background-color: rgba(59, 130, 246, 0.05);
}

:root[data-theme='dark'] table tr:nth-child(2n) {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Blockquotes */
blockquote {
  border-left-color: var(--sl-color-accent);
  background-color: rgba(59, 130, 246, 0.05);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
}

/* ============================================
   ADMONITIONS (Starlight Asides)
   Rounded, no left border bar
   ============================================ */
.starlight-aside {
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  border: none;
  border-left: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Tip aside */
.starlight-aside--tip {
  background-color: rgba(16, 185, 129, 0.08);
}

.starlight-aside--tip .starlight-aside__title {
  color: #047857;
}

:root[data-theme='dark'] .starlight-aside--tip {
  background-color: rgba(16, 185, 129, 0.12);
}

:root[data-theme='dark'] .starlight-aside--tip .starlight-aside__title {
  color: #34d399;
}

/* Note aside */
.starlight-aside--note {
  background-color: rgba(59, 130, 246, 0.08);
}

.starlight-aside--note .starlight-aside__title {
  color: #2563eb;
}

:root[data-theme='dark'] .starlight-aside--note {
  background-color: rgba(59, 130, 246, 0.12);
}

:root[data-theme='dark'] .starlight-aside--note .starlight-aside__title {
  color: #3b82f6;
}

/* Caution aside */
.starlight-aside--caution {
  background-color: rgba(245, 158, 11, 0.1);
}

.starlight-aside--caution .starlight-aside__title {
  color: #a14908;
}

:root[data-theme='dark'] .starlight-aside--caution {
  background-color: rgba(245, 158, 11, 0.15);
}

:root[data-theme='dark'] .starlight-aside--caution .starlight-aside__title {
  color: #fbbf24;
}

/* Danger aside */
.starlight-aside--danger {
  background-color: rgba(239, 68, 68, 0.1);
}

.starlight-aside--danger .starlight-aside__title {
  color: #be1c1c;
}

:root[data-theme='dark'] .starlight-aside--danger {
  background-color: rgba(239, 68, 68, 0.15);
}

:root[data-theme='dark'] .starlight-aside--danger .starlight-aside__title {
  color: #f87171;
}

/* Aside icon styling */
.starlight-aside__icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ============================================
   FOOTER - No custom styling needed
   The only <footer> in Starlight is the content footer
   (meta/pagination), which should stay transparent.
   ============================================ */

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 72rem) {
  .content-panel {
    max-width: 100%;
  }
}

/* Responsive padding on navbar row only - banner stays full-width */
@media (min-width: 50rem) {
  header.header .header.sl-flex {
    padding-left: 1rem;
    padding-right: 2.5rem;
  }
}

@media (min-width: 72rem) {
  header.header .header.sl-flex {
    padding-left: 1rem;
    padding-right: 3rem;
  }
}

/* ============================================
   ROADMAP STYLES
   ============================================ */
.roadmap-container {
  --color-planned: #3b82f6;
  --color-in-progress: #10b981;
  --color-exploring: #f59e0b;
  --color-bg-card: rgba(255, 255, 255, 0.03);
  --color-border: rgba(255, 255, 255, 0.1);
}

.dark .roadmap-container {
  --color-bg-card: rgba(255, 255, 255, 0.03);
  --color-border: rgba(255, 255, 255, 0.1);
}

.light .roadmap-container {
  --color-bg-card: rgba(0, 0, 0, 0.02);
  --color-border: rgba(0, 0, 0, 0.1);
}

.roadmap-legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin: 2rem 0;
  padding: 1rem 1.5rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.planned { background: var(--color-planned); }
.legend-dot.in-progress { background: var(--color-in-progress); }
.legend-dot.exploring { background: var(--color-exploring); }

.roadmap-timeline {
  position: relative;
  max-width: 1000px;
  margin: 3rem auto;
  padding: 0 1rem;
}

.roadmap-timeline::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--color-in-progress), var(--color-planned), var(--color-exploring));
  transform: translateX(-50%);
  border-radius: 3px;
}

.roadmap-item {
  position: relative;
  margin-bottom: 3rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 2rem;
  align-items: start;
}

.roadmap-item:nth-child(odd) .roadmap-card {
  grid-column: 1;
}

.roadmap-item:nth-child(even) .roadmap-card {
  grid-column: 3;
}

.roadmap-marker {
  grid-column: 2;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 4px solid var(--starlight-canvas-bg);
  background: var(--color-in-progress);
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 4px var(--color-border);
}

.roadmap-item.in-progress .roadmap-marker { background: var(--color-in-progress); }
.roadmap-item.planned .roadmap-marker { background: var(--color-planned); }
.roadmap-item.exploring .roadmap-marker { background: var(--color-exploring); }

.roadmap-item:nth-child(odd) .roadmap-content {
  grid-column: 1;
  text-align: right;
}

.roadmap-item:nth-child(even) .roadmap-content {
  grid-column: 3;
  text-align: left;
}

.roadmap-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.roadmap-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  border-color: var(--color-in-progress);
}

.roadmap-card.planned:hover { border-color: var(--color-planned); }
.roadmap-card.exploring:hover { border-color: var(--color-exploring); }

.roadmap-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.roadmap-item:nth-child(odd) .roadmap-header {
  flex-direction: row-reverse;
}

.roadmap-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.roadmap-badge.in-progress {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.roadmap-badge.planned {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.roadmap-badge.exploring {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.roadmap-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.roadmap-description {
  color: var(--slate-color-500);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.roadmap-features {
  list-style: none;
  padding: 0;
  margin: 0;
}

.roadmap-features li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
  font-size: 0.9rem;
  color: var(--slate-color-400);
}

.roadmap-features li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--color-in-progress);
}

.roadmap-item.planned .roadmap-features li::before { color: var(--color-planned); }
.roadmap-item.exploring .roadmap-features li::before { color: var(--color-exploring); }

.roadmap-section-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 3rem 0 2rem;
  padding: 1rem;
  background: linear-gradient(135deg, var(--color-in-progress), var(--color-planned));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.roadmap-future {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
  gap: 1.5rem;
  margin-top: 3rem;
  padding: 2rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
}

.roadmap-future-card {
  padding: 1.5rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(212, 168, 83, 0.05));
  border: 1px solid var(--color-border);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: 140px;
}

.roadmap-future-card h4 {
  margin: 0 0 0.5rem 0;
}

.roadmap-future-card p {
  margin: 0;
}

.roadmap-future-card:hover {
  transform: scale(1.02);
}

.roadmap-future-card h4 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  color: var(--color-planned);
}

.roadmap-future-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--slate-color-400);
}

.roadmap-emoji {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  display: block;
}

@media (max-width: 768px) {
  .roadmap-timeline::before {
    left: 20px;
  }

  .roadmap-item {
    grid-template-columns: auto 1fr;
    gap: 1rem;
  }

  .roadmap-item:nth-child(odd) .roadmap-card,
  .roadmap-item:nth-child(even) .roadmap-card {
    grid-column: 2;
  }

  .roadmap-item:nth-child(odd) .roadmap-content,
  .roadmap-item:nth-child(even) .roadmap-content {
    grid-column: 2;
    text-align: left;
  }

  .roadmap-marker {
    grid-column: 1;
    grid-row: 1;
  }

  .roadmap-item:nth-child(odd) .roadmap-header {
    flex-direction: row;
  }
}
