/* =============================================================
   Augmented Advisors — Book Theme
   Context Engineering: From Vibe Coder to Software Engineer

   Design tokens sourced from AA website (tailwind.config.ts)
   Color accessibility: ADR-013 dual-color pattern
   ============================================================= */

/* ---- CSS Variable Overrides (mdBook Light Theme) ---- */

:root {
  /* AA brand colors */
  --deep-navy: #1A2B4A;
  --vibrant-teal: #00A6A6;
  --vibrant-teal-text: #15605F;
  --slate-grey: #566876;
  --slate-charcoal: #2B2F32;
  --mist-gray: #F5F7F8;
  --warm-coral: #FF6B6B;

  /* mdBook color overrides */
  --bg: #ffffff;
  --fg: var(--slate-grey);
  --sidebar-bg: var(--mist-gray);
  --sidebar-fg: var(--deep-navy);
  --sidebar-non-existant: #515151;
  --sidebar-active: var(--vibrant-teal-text);
  --sidebar-spacer: rgba(0, 0, 0, 0.08);
  --scrollbar: rgba(0, 0, 0, 0.15);
  --icons: var(--slate-grey);
  --icons-hover: var(--vibrant-teal);
  --links: var(--vibrant-teal-text);
  --inline-code-color: var(--deep-navy);
  --theme-popup-bg: #ffffff;
  --theme-popup-border: #e0e0e0;
  --theme-hover: #f0f0f0;
  --quote-bg: var(--mist-gray);
  --quote-border: var(--vibrant-teal);
  --table-border-color: #e0e0e0;
  --table-header-bg: var(--mist-gray);
  --table-alternate-bg: #fafafa;
  --searchbar-border-color: #e0e0e0;
  --searchbar-bg: #ffffff;
  --searchbar-fg: var(--deep-navy);
  --searchbar-shadow-color: rgba(0, 0, 0, 0.08);
  --searchresults-header-fg: var(--deep-navy);
  --searchresults-border-color: #e0e0e0;
  --searchresults-li-bg: var(--mist-gray);
  --search-mark-bg: rgba(0, 166, 166, 0.2);
}

/* Force light theme — disable dark themes */
.coal, .navy, .ayu, .rust {
  --bg: #ffffff;
  --fg: var(--slate-grey);
  --sidebar-bg: var(--mist-gray);
  --sidebar-fg: var(--deep-navy);
  --sidebar-active: var(--vibrant-teal-text);
  --links: var(--vibrant-teal-text);
}

/* ---- Typography ---- */

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.content main {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--slate-grey);
  max-width: 720px;
  margin: 0 auto;
}

/* Headings */
.content main h1 {
  color: var(--deep-navy);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.2;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.content main h2 {
  color: var(--deep-navy);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.3;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--vibrant-teal);
}

.content main h3 {
  color: var(--deep-navy);
  font-weight: 600;
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.content main h4, .content main h5, .content main h6 {
  color: var(--deep-navy);
  font-weight: 600;
}

/* Paragraphs */
.content main p {
  margin-bottom: 1.2rem;
}

/* ---- Links ---- */

.content main a {
  color: var(--vibrant-teal-text);
  text-decoration: underline;
  text-decoration-color: rgba(21, 96, 95, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s;
}

.content main a:hover {
  text-decoration-color: var(--vibrant-teal-text);
}

/* ---- Code Blocks ---- */

.content main code {
  font-family: 'Source Code Pro', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.88em;
  background: var(--mist-gray);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  color: var(--deep-navy);
}

.content main pre {
  background: #1e1e2e !important;
  border-radius: 8px;
  padding: 1.2rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.content main pre code {
  background: transparent;
  color: #cdd6f4;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.6;
}

/* Code block horizontal scroll on mobile */
.content main pre {
  -webkit-overflow-scrolling: touch;
}

/* ---- Blockquotes ---- */

.content main blockquote {
  border-left: 4px solid var(--vibrant-teal);
  background: var(--mist-gray);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
  color: var(--slate-charcoal);
  font-style: italic;
}

.content main blockquote p:last-child {
  margin-bottom: 0;
}

/* ---- Tables ---- */

.content main table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95em;
}

.content main th {
  background: var(--deep-navy);
  color: #ffffff;
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
}

.content main td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--table-border-color);
}

.content main tr:nth-child(even) td {
  background: var(--mist-gray);
}

/* ---- Images / SVG Diagrams ---- */

.content main img {
  max-width: 100%;
  height: auto;
  margin: 1.5rem auto;
  display: block;
  border-radius: 6px;
}

/* SVG diagrams — constrain width and center */
.content main img[src$=".svg"] {
  max-width: min(100%, 680px);
  background: #ffffff;
  padding: 0.5rem;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
}

/* ---- Sidebar ---- */

.sidebar {
  background: var(--mist-gray);
  font-family: 'Inter', sans-serif;
}

.sidebar .sidebar-scrollbox {
  padding-top: 1rem;
}

/* Book title in sidebar */
.sidebar .sidebar-scrollbox .chapter li.part-title {
  color: var(--deep-navy);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1.2rem;
  padding: 0.3rem 0;
}

.sidebar .sidebar-scrollbox a {
  color: var(--slate-grey);
  font-size: 0.9rem;
  padding: 0.35rem 1.2rem;
}

.sidebar .sidebar-scrollbox a:hover {
  color: var(--vibrant-teal-text);
}

.sidebar .sidebar-scrollbox .active a {
  color: var(--vibrant-teal-text);
  font-weight: 600;
}

/* ---- Navigation (prev/next) ---- */

.nav-chapters {
  color: var(--vibrant-teal-text);
  font-size: 1.5rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.nav-chapters:hover {
  color: var(--vibrant-teal);
  opacity: 1;
}

/* ---- Top Menu Bar ---- */

.menu-bar {
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.menu-bar .icon-button {
  color: var(--slate-grey);
}

.menu-bar .icon-button:hover {
  color: var(--vibrant-teal);
}

/* Hide theme toggle — we force light theme */
#theme-list {
  display: none !important;
}

.menu-bar .right-buttons #theme-toggle {
  display: none;
}

/* ---- AA Branding: Top Bar ---- */

/* Add subtle AA branding above menu bar */
.menu-bar::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--vibrant-teal), var(--deep-navy));
}

/* ---- AA Branding: Chapter Footer CTA ---- */

.content main::after {
  content: "";
  display: block;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid #e0e0e0;
}

/* ---- Horizontal Rules ---- */

.content main hr {
  border: none;
  border-top: 2px solid var(--mist-gray);
  margin: 2.5rem 0;
}

/* ---- Lists ---- */

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

.content main li {
  margin-bottom: 0.4rem;
  line-height: 1.65;
}

/* ---- Strong / Bold ---- */

.content main strong {
  color: var(--deep-navy);
  font-weight: 600;
}

/* ---- Emphasis ---- */

.content main em {
  color: var(--slate-charcoal);
}

/* ---- Search ---- */

#searchbar {
  font-family: 'Inter', sans-serif;
  border-radius: 6px;
}

.searchresults a {
  color: var(--vibrant-teal-text);
}

/* ---- Mobile Responsive ---- */

@media (max-width: 768px) {
  .content main {
    font-size: 1rem;
    padding: 0 0.5rem;
  }

  .content main h1 {
    font-size: 1.6rem;
  }

  .content main h2 {
    font-size: 1.3rem;
  }

  .content main pre {
    font-size: 0.8em;
    padding: 0.8rem;
    border-radius: 6px;
  }

  .content main table {
    font-size: 0.85em;
  }

  .content main th, .content main td {
    padding: 0.5rem 0.6rem;
  }

  .content main img[src$=".svg"] {
    padding: 0.25rem;
  }
}

@media (max-width: 480px) {
  .content main {
    font-size: 0.95rem;
  }

  .content main h1 {
    font-size: 1.4rem;
  }

  .content main h2 {
    font-size: 1.15rem;
  }

  /* Allow tables to scroll horizontally */
  .content main table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---- Print Styles ---- */

@media print {
  .sidebar, .menu-bar, .nav-chapters, .mobile-nav-chapters {
    display: none !important;
  }

  .content main {
    max-width: 100%;
  }

  .content main a {
    color: var(--deep-navy);
    text-decoration: none;
  }

  .content main a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: var(--slate-grey);
  }
}
