/* ============================================================
   AI Engineering Handbook — custom styles
   ============================================================ */

/* ── Typography (Material overrides) ─────────────────────── */
:root {
  --aie-font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --aie-indigo: #4f46e5;
  --aie-indigo-dark: #4338ca;
  --aie-indigo-light: #eef2ff;
}

.md-typeset {
  font-size: 0.94rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.md-typeset p,
.md-typeset li {
  line-height: 1.65;
}

/* Homepage: site title already in header — hero is the visual headline */
.md-typeset:has(.hero) > h1:first-of-type {
  display: none;
}

/* ── Homepage hero ───────────────────────────────────────── */
.hero {
  margin: 0.25rem 0 1.75rem;
  padding: 2rem 1.75rem;
  border-radius: 12px;
  border: 1px solid rgba(79, 70, 229, 0.25);
  background: linear-gradient(135deg, var(--aie-indigo-light) 0%, var(--md-code-bg-color) 55%);
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.08);
}

[data-md-color-scheme="slate"] .hero {
  border-color: rgba(129, 140, 248, 0.35);
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.15) 0%, var(--md-code-bg-color) 60%);
}

.hero__tagline {
  font-family: var(--aie-font-sans);
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 0 0 0.75rem;
  color: var(--md-default-fg-color);
}

.hero__sub {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--md-default-fg-color--light);
  margin: 0 0 1.5rem;
  max-width: 40rem;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.hero__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.6em 1.25em;
  border-radius: 8px;
  font-family: var(--aie-font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.hero__btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.hero__btn--primary {
  background: var(--aie-indigo);
  border: 2px solid var(--aie-indigo);
  color: #ffffff !important;
}

.hero__btn--primary:hover {
  background: var(--aie-indigo-dark);
  border-color: var(--aie-indigo-dark);
  color: #ffffff !important;
}

.hero__btn--secondary {
  background: #ffffff;
  border: 2px solid var(--aie-indigo);
  color: var(--aie-indigo) !important;
}

.hero__btn--secondary:hover {
  background: var(--aie-indigo-light);
  color: var(--aie-indigo-dark) !important;
}

[data-md-color-scheme="slate"] .hero__btn--secondary {
  background: var(--md-default-bg-color);
}

.hero__btn--github {
  background: #24292f;
  border: 2px solid #24292f;
  color: #ffffff !important;
}

.hero__btn--github:hover {
  background: #1c2128;
  border-color: #1c2128;
  color: #ffffff !important;
}

[data-md-color-scheme="slate"] .hero__btn--github {
  background: #f0f6fc;
  border-color: #f0f6fc;
  color: #24292f !important;
}

[data-md-color-scheme="slate"] .hero__btn--github:hover {
  background: #dce4ec;
  color: #24292f !important;
}

/* Material sets .md-typeset a { color: link } — must override for buttons */
.md-typeset a.hero__btn,
.md-typeset a.hero__btn:hover,
.md-typeset a.hero__btn:focus,
.md-typeset a.hero__btn strong {
  text-decoration: none !important;
}

.md-typeset a.hero__btn--primary,
.md-typeset a.hero__btn--primary:hover,
.md-typeset a.hero__btn--primary:focus {
  color: #ffffff !important;
}

.md-typeset a.hero__btn--secondary,
.md-typeset a.hero__btn--secondary:hover,
.md-typeset a.hero__btn--secondary:focus {
  color: var(--aie-indigo) !important;
}

[data-md-color-scheme="slate"] .md-typeset a.hero__btn--secondary:hover {
  color: var(--aie-indigo-dark) !important;
}

.md-typeset a.hero__btn--github,
.md-typeset a.hero__btn--github:hover {
  color: #ffffff !important;
}

[data-md-color-scheme="slate"] .md-typeset a.hero__btn--github,
[data-md-color-scheme="slate"] .md-typeset a.hero__btn--github:hover {
  color: #24292f !important;
}

/* ── Mobile & tables ─────────────────────────────────────── */
@media screen and (max-width: 768px) {
  .hero {
    padding: 1.25rem 1rem;
  }

  .hero__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero__btn {
    width: 100%;
    justify-content: center;
  }

  .persona-grid {
    grid-template-columns: 1fr;
  }

  .md-typeset table:not([class]) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .md-sidebar--primary {
    max-width: 100%;
  }

  /* Code blocks are small (0.82em of a 0.94rem base) — bump on mobile for legibility */
  .md-typeset pre code {
    font-size: 0.88em;
  }
}

/* ── Typography & reading width ─────────────────────────── */
.md-content {
  max-width: 860px;
}

.md-typeset h1 {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.md-typeset h2 {
  font-weight: 600;
  border-bottom: 2px solid var(--md-primary-fg-color--light);
  padding-bottom: 0.2em;
  margin-top: 2em;
}

/* ── Navigation tabs ─────────────────────────────────────── */
.md-tabs__link {
  font-weight: 500;
}

/* ── Lesson metadata badges ─────────────────────────────── */
.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.78rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2em 0.65em;
  border-radius: 99px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--module {
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
}

.badge--difficulty-beginner {
  background: #d1fae5;
  color: #065f46;
}

.badge--difficulty-intermediate {
  background: #fef3c7;
  color: #92400e;
}

.badge--difficulty-advanced {
  background: #fee2e2;
  color: #991b1b;
}

[data-md-color-scheme="slate"] .badge--difficulty-beginner {
  background: #064e3b;
  color: #a7f3d0;
}

[data-md-color-scheme="slate"] .badge--difficulty-intermediate {
  background: #78350f;
  color: #fde68a;
}

[data-md-color-scheme="slate"] .badge--difficulty-advanced {
  background: #7f1d1d;
  color: #fca5a5;
}

/* ── Callout / tip boxes ─────────────────────────────────── */
.callout {
  border-left: 4px solid var(--md-primary-fg-color);
  background: var(--md-code-bg-color);
  padding: 0.8rem 1rem;
  border-radius: 0 6px 6px 0;
  margin: 1rem 0;
}

.callout-title {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--md-primary-fg-color);
  margin-bottom: 0.3rem;
}

.callout--depth {
  border-left-color: #7c3aed;
}

.callout--depth .callout-title {
  color: #7c3aed;
}

[data-md-color-scheme="slate"] .callout--depth .callout-title {
  color: #c4b5fd;
}

/* ── Persona cards on homepage ──────────────────────────── */
.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.persona-card {
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  background: var(--md-code-bg-color);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.persona-card:hover {
  border-color: var(--md-primary-fg-color);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

[data-md-color-scheme="slate"] .persona-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.persona-card__title {
  font-family: var(--aie-font-sans);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
  color: var(--aie-indigo);
}

.persona-card__desc {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--md-default-fg-color--light);
  margin-bottom: 0.75rem;
}

.persona-card__cta {
  display: inline-block;
  font-family: var(--aie-font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--aie-indigo) !important;
  text-decoration: none !important;
  margin-right: 0.75rem;
  margin-top: 0.35rem;
}

.persona-card__cta:hover {
  color: var(--aie-indigo-dark) !important;
  text-decoration: underline !important;
}

.md-typeset a.persona-card__cta,
.md-typeset a.persona-card__cta:hover,
.md-typeset a.persona-card__cta strong {
  color: var(--aie-indigo) !important;
}

.md-typeset a.persona-card__cta:hover,
.md-typeset a.persona-card__cta:hover strong {
  color: var(--aie-indigo-dark) !important;
}

/* ── Quick-nav pills (homepage, topic map) ──────────────── */
.quick-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}

.quick-nav__item {
  display: inline-flex;
  align-items: center;
  padding: 0.45em 1em;
  border-radius: 8px;
  border: 1.5px solid rgba(79, 70, 229, 0.35);
  font-family: var(--aie-font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--aie-indigo) !important;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s;
}

.quick-nav__item:hover {
  background: var(--aie-indigo-light);
  border-color: var(--aie-indigo);
  color: var(--aie-indigo-dark) !important;
}

.md-typeset a.quick-nav__item,
.md-typeset a.quick-nav__item:hover {
  color: var(--aie-indigo) !important;
  text-decoration: none !important;
}

.md-typeset a.quick-nav__item:hover {
  color: var(--aie-indigo-dark) !important;
}

[data-md-color-scheme="slate"] .quick-nav__item:hover {
  background: rgba(79, 70, 229, 0.2);
}

/* ── Module stat pills on homepage ──────────────────────── */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4em 1em;
  border-radius: 99px;
  border: 1.5px solid rgba(79, 70, 229, 0.3);
  background: #ffffff;
  font-family: var(--aie-font-sans);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--md-default-fg-color);
}

[data-md-color-scheme="slate"] .stat-pill {
  background: var(--md-default-bg-color);
}

.stat-pill__value {
  color: var(--aie-indigo);
  font-size: 1.05rem;
  font-weight: 700;
}

/* ── Phase table improvements ───────────────────────────── */
.md-typeset table:not([class]) th {
  background: var(--aie-indigo);
  color: #ffffff !important;
  font-weight: 600;
}

.md-typeset table:not([class]) th a {
  color: #ffffff !important;
}

/* ── Mermaid diagram centering ──────────────────────────── */
.mermaid {
  text-align: center;
  margin: 1.5rem 0;
}

/* ── "Back to top" button polish ───────────────────────── */
.md-top {
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ── Announcement banner ─────────────────────────────────── */
.md-banner {
  background: var(--aie-indigo);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 500;
}

.md-banner a {
  color: #ffffff !important;
  text-decoration: underline;
  font-weight: 600;
}

/* ── Code block improvements ───────────────────────────── */
.md-typeset pre {
  border-radius: 6px;
}

/* ── Lesson table inside module index ───────────────────── */
.lesson-table td:first-child {
  font-weight: 600;
  white-space: nowrap;
}

/* ── Math / formulas (MathJax + arithmatex) ─────────────── */
.arithmatex {
  overflow-x: auto;
}

.md-typeset .arithmatex mjx-container {
  margin: 0.6em 0;
}

.md-typeset mjx-container[display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.4em 0;
}

.md-typeset mjx-container[display="true"] > mjx-math {
  text-align: center;
}

/* Inline math — don't break line awkwardly */
.md-typeset mjx-container:not([display="true"]) {
  margin: 0 0.1em;
}

/* Code + math readability */
.md-typeset code {
  font-size: 0.85em;
}

.md-typeset pre code {
  font-size: 0.82em;
  line-height: 1.5;
}

.md-typeset table {
  display: table;
  width: 100%;
  font-size: 0.85rem;
}

.md-typeset blockquote {
  border-left: 4px solid var(--md-primary-fg-color--light);
  color: var(--md-default-fg-color--light);
}

/* ── Search highlight ───────────────────────────────────── */
.md-search-result mark {
  background: rgba(var(--md-primary-fg-color--rgb), 0.15);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}
