:root {
  --md-default-fg-color: #1f2328;
  --md-default-fg-color--light: #59636e;
  --md-default-fg-color--lighter: #7a8590;
  --md-default-bg-color: #ffffff;

  --md-primary-fg-color: #ffffff;
  --md-primary-bg-color: #1f2328;

  --md-accent-fg-color: #4f46e5;

  --md-typeset-a-color: #2563eb;
  --md-code-bg-color: #f6f8fa;
  --md-code-fg-color: #1f2328;
}

[data-md-color-scheme="slate"] {
  --md-default-fg-color: #e6edf3;
  --md-default-fg-color--light: #b8c0c8;
  --md-default-bg-color: #1a1f2b;

  --md-code-bg-color: #202635;
  --md-code-fg-color: #e6edf3;

  --md-typeset-a-color: #7aa2ff;
}

/* overall content width */
.md-grid {
  max-width: min(92vw,1800px);
}

/* make article area feel less cramped */
.md-content__inner {
  margin-top: 1rem;
}

/* calmer headings */
.md-typeset h1 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.md-typeset h2,
.md-typeset h3 {
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* section spacing */
.md-typeset h2 {
  margin-top: 2.25rem;
}

/* cleaner paragraph rhythm */
.md-typeset p,
.md-typeset li {
  line-height: 1.75;
}

/* nicer code blocks */
.md-typeset pre > code {
  border-radius: 12px;
  font-size: 0.92rem;
}

.md-typeset code {
  border-radius: 6px;
  padding: 0.15em 0.4em;
}

/* table of contents less shouty */
.md-nav--secondary .md-nav__title {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.md-nav--secondary .md-nav__link {
  font-size: 0.82rem;
}

/* softer blocks */
.md-typeset .admonition,
.md-typeset details {
  border-radius: 12px;
}

/* tables cleaner */
.md-typeset table:not([class]) {
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.95rem;
}

/* Mermaid spacing */
.mermaid {
  margin: 1.5rem 0 2rem 0;
}

/* horizontal rule spacing */
.md-typeset hr {
  margin: 2rem 0;
  opacity: 0.18;
}

/* =========================
   Grid cards
   ========================= */

.md-typeset .grid.cards {
  margin-top: 0.75rem;
}

.md-typeset .grid.cards > ul {
  display: grid;

  /* Wider cards -> fewer 2-line titles on smaller laptops */
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));

  gap: 1rem;
  margin: 1.25rem 0 2rem 0;
  padding: 0;
}

.md-typeset .grid.cards > ul > li {
  list-style: none;
  margin: 0;
  padding: 1.1rem 1.15rem;
  border: 1px solid rgba(127, 127, 127, 0.18);
  border-radius: 16px;
  background: rgba(127, 127, 127, 0.03);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease;
}

/* hover effect on the card shell */
.md-typeset .grid.cards > ul > li:hover {
  transform: translateY(-3px);
  border-color: rgba(79, 70, 229, 0.35);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
  background: rgba(79, 70, 229, 0.035);
}

/* dark mode card shell */
[data-md-color-scheme="slate"] .md-typeset .grid.cards > ul > li {
  background: rgba(255, 255, 255, 0.015);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
}

[data-md-color-scheme="slate"] .md-typeset .grid.cards > ul > li:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  background: rgba(122, 162, 255, 0.035);
}

/* default card content structure:
   title link in first paragraph, body text in following paragraph(s) */
.md-typeset .grid.cards > ul > li > p:first-child {
  margin: 0 0 0.75rem 0;
  font-size: 1.08rem;
  font-weight: 750;
  line-height: 1.35;

  /* Improved: baseline alignment + predictable wrapping */
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.md-typeset .grid.cards > ul > li > p:first-child a {
  color: var(--md-default-fg-color);
  text-decoration: none;

  /* Take remaining width so long titles wrap cleanly */
  flex: 1 1 auto;
  min-width: 0;
}

.md-typeset .grid.cards > ul > li > p:first-child a:hover,
.md-typeset .grid.cards > ul > li > p:first-child a:focus {
  text-decoration: none;
}

.md-typeset .grid.cards > ul > li > p:not(:first-child) {
  margin: 0.35rem 0 0 0;
  color: var(--md-default-fg-color--light);
  line-height: 1.6;
}

/* support for cards that use a single link block */
.md-typeset .grid.cards > ul > li > a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.md-typeset .grid.cards > ul > li > a:hover,
.md-typeset .grid.cards > ul > li > a:focus {
  color: inherit;
  text-decoration: none;
}

.md-typeset .grid.cards > ul > li > a strong {
  display: block;
  margin-bottom: 0.55rem;
  font-size: 1.08rem;
  font-weight: 750;
  line-height: 1.35;
  color: var(--md-default-fg-color);
}

/* icon alignment (general) */
.md-typeset .grid.cards .twemoji,
.md-typeset .grid.cards svg {
  vertical-align: -0.18em;
  margin-right: 0.35rem;
}

/* icon sizing/alignment specifically in title row */
.md-typeset .grid.cards > ul > li > p:first-child .twemoji,
.md-typeset .grid.cards > ul > li > p:first-child svg {
  flex: 0 0 auto;
  margin-right: 0; /* gap handles spacing */
  height: 1.1em;
  width: 1.1em;
}

/* Optional: nicer word breaking for long titles */
.md-typeset .grid.cards > ul > li > p:first-child a strong {
  hyphens: auto;
  overflow-wrap: anywhere;
}

/* =========================
   Left nav: collapsible drawer on large screens
   ========================= */

/* Always show the hamburger toggle button */
.md-header__button.md-icon[for="__drawer"] {
  display: inline-flex !important;
}

@media screen and (min-width: 76.25em) {
  /* Push sidebar off-screen and slide it in on demand */
  .md-sidebar--primary {
    position: fixed !important;
    left: 0;
    top: var(--md-header-height, 2.4rem);
    bottom: 0;
    /* Material sets height: 0 on large screens – override so top/bottom
       constraint sets the real height instead */
    height: auto !important;
    width: var(--md-sidebar-width, 12.1rem);
    z-index: 6; /* must be above .md-overlay (z-index: 5) so the sidebar isn't hidden behind the backdrop */
    transform: translateX(-100%);
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    background: var(--md-default-bg-color);
    box-shadow: none;
  }

  /* Slide sidebar in when the drawer checkbox is checked */
  #__drawer:checked ~ .md-container .md-sidebar--primary {
    transform: translateX(0);
    box-shadow: 0.2rem 0 0.8rem rgba(0, 0, 0, 0.12);
  }

  /* Overlay base styles for large screens.
     Material only sets position/size on the overlay inside its mobile
     media query (max-width: 76.234375em), so we must replicate them here
     to get a proper full-screen backdrop on desktop. */
  .md-overlay {
    background-color: rgba(0, 0, 0, 0.54);
    height: 0;
    opacity: 0;
    pointer-events: none;
    position: fixed;
    top: 0;
    /* delay width/height collapse until after opacity fade-out */
    transition: width 0ms 0.25s, height 0ms 0.25s, opacity 0.25s;
    width: 0;
    z-index: 5;
  }

  /* Show full-screen overlay so clicking outside closes the drawer */
  #__drawer:checked ~ .md-overlay {
    height: 100%;
    width: 100%;
    opacity: 1;
    pointer-events: auto;
    /* width/height expand immediately, opacity fades in */
    transition: width 0ms, height 0ms, opacity 0.25s;
  }
}

/* mobile comfort */
@media screen and (max-width: 768px) {
  .md-typeset .grid.cards > ul {
    grid-template-columns: 1fr;
  }

  .md-typeset .grid.cards > ul > li {
    padding: 1rem 1rem;
  }
}
