/* Theme customisations: green/slate palette, wide layout with minimal
   gutters, and card-style right sidebar blocks. Light is the default
   scheme; dark matches the slate/green dashboard design. */

/* ---------- palette: light ---------- */

[data-md-color-scheme="default"] {
  --md-primary-fg-color: #ffffff;          /* header background */
  --md-primary-fg-color--light: #f8fafc;
  --md-primary-fg-color--dark: #e2e8f0;
  --md-primary-bg-color: #1f2937;          /* text/icons on header */
  --md-primary-bg-color--light: #475569;
  --md-accent-fg-color: #16a34a;
  --md-accent-fg-color--transparent: rgba(22, 163, 74, 0.1);
  --md-typeset-a-color: #15803d;           /* links */
  --al-card-bg: #f8fafc;
  --al-card-border: #e2e8f0;
  --al-muted: #64748b;
}

/* ---------- palette: dark ---------- */

[data-md-color-scheme="slate"] {
  --md-default-bg-color: #0d1117;
  --md-primary-fg-color: #0d1117;          /* header background */
  --md-primary-fg-color--light: #151b23;
  --md-primary-fg-color--dark: #0b0e13;
  --md-primary-bg-color: #e6edf3;          /* text/icons on header */
  --md-primary-bg-color--light: #8b949e;
  --md-accent-fg-color: #22c55e;
  --md-accent-fg-color--transparent: rgba(34, 197, 94, 0.1);
  --md-typeset-a-color: #4ade80;           /* links */
  --md-code-bg-color: #161b22;
  --md-footer-bg-color: #0b0e13;
  --md-footer-bg-color--dark: #0b0e13;
  --al-card-bg: #151b23;
  --al-card-border: #262e3a;
  --al-muted: #8b949e;
}

/* ---------- header ---------- */

/* White (light) / slate (dark) header needs a border to separate it
   from the page instead of relying on colour contrast */
.md-header {
  border-bottom: 1px solid var(--al-card-border);
  box-shadow: none;
}

/* ---------- layout: use the full viewport width ---------- */

.md-grid {
  max-width: 100%;
}

/* Tighter outer gutters on the sidebars */
@media screen and (min-width: 76.25em) {
  .md-sidebar--primary {
    padding-left: 0.2rem;
  }
  .md-sidebar--secondary {
    padding-right: 0.2rem;
  }
}

/* ---------- article header (overrides/main.html + hooks/hero.py) ---------- */

/* Breadcrumbs above the category badge and title */
.page-breadcrumbs {
  font-size: 0.64rem;
  color: var(--al-muted);
  margin-bottom: 0.5rem;
}
.page-breadcrumbs a {
  color: var(--al-muted);
}
.page-breadcrumbs a:hover {
  color: var(--md-accent-fg-color);
}
.page-breadcrumbs__sep {
  margin: 0 0.15rem;
  opacity: 0.6;
}

/* Category badge between breadcrumbs and the H1 */
.page-category {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--md-typeset-a-color);
  background: var(--md-accent-fg-color--transparent);
  border-radius: 2rem;
  padding: 0.15rem 0.6rem;
  margin-bottom: 0.4rem;
}

/* Author/date meta row between the summary lede and the hero image */
.md-typeset .page-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  color: var(--al-muted);
  margin: 0.2rem 0 0.8rem;
}
.md-typeset .page-meta img.page-meta__avatar {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
}
.md-typeset .page-meta a.page-meta__author {
  font-weight: 600;
}

/* Tag chips at the bottom of the article (overrides/main.html) */
.md-content .page-tags {
  margin-top: 1.2rem;
}

/* ---------- home page timeline cards (overrides/blog.html) ---------- */

.timeline-card {
  position: relative;             /* anchor for the stretched title link */
  display: flex;
  gap: 0.8rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--al-card-border);
}
.timeline-card:hover .timeline-card__title a {
  color: var(--md-accent-fg-color);
}

/* Square thumbnail, cropped from the wide hero image */
.timeline-card__thumb {
  width: 6.4rem;
  height: 6.4rem;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 0.4rem;
  border: 1px solid var(--al-card-border);
}
@media screen and (max-width: 30em) {
  .timeline-card__thumb {
    width: 4.4rem;
    height: 4.4rem;
  }
}

/* Placeholder tile for pages without a hero image: the page's initial
   on the card background, same footprint as a real thumbnail */
.timeline-card__thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--al-muted);
  background: var(--al-card-bg);
  opacity: 0.85;
}

.timeline-card__body {
  min-width: 0;
}
.timeline-card__body .timeline-card__title {
  margin: 0.15rem 0 0.1rem;
  font-size: 1rem;
}
/* Stretch the title link over the whole card: one tap target, one
   article link per card instead of several */
.timeline-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}
/* Keep the category badge clickable above the stretched link */
.timeline-card__category {
  position: relative;
  z-index: 1;
}
.timeline-card__meta {
  font-size: 0.68rem;
  color: var(--al-muted);
  margin-bottom: 0.3rem;
}
.timeline-card__body .timeline-card__excerpt {
  margin: 0 0 0.3rem;
}
.timeline-card__more {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--md-typeset-a-color);
}

/* ---------- summary lede (frontmatter summary:, hooks/hero.py) ---------- */

.md-typeset .page-summary {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--al-muted);
  margin: 0.2rem 0 0.8rem;
}

/* ---------- hero images (frontmatter image:, hooks/hero.py) ---------- */

.md-typeset img.page-hero {
  width: 100%;
  max-height: 320px;        /* cap vertical space so the lede stays above the fold */
  object-fit: cover;        /* crop rather than distort when height-capped */
  object-position: center;
  border-radius: 0.6rem;
  border: 1px solid var(--al-card-border);
  margin: 0.2rem 0 0.6rem;
}

@media screen and (max-width: 44rem) {
  .md-typeset img.page-hero { max-height: 240px; }
}

/* ---------- tighten top-of-page whitespace ---------- */

/* Material reserves 1.5rem above the main columns and 1.25em below every
   H1. On article pages that stacks into a tall empty band above the
   content and a wide gap between the title and its summary lede, pushing
   the article down the screen. Pull both in. */
.md-main__inner {
  margin-top: 0.4rem;
}

.md-typeset h1:has(+ .page-summary),
.md-typeset h1:has(+ .page-meta) {
  margin-bottom: 0.4rem;
}

/* ---------- left nav ---------- */

.md-nav__link--active {
  color: var(--md-typeset-a-color);
  font-weight: 600;
}


/* ---------- right sidebar: card-style blocks ---------- */

@media screen and (min-width: 60em) {
  /* Pages without headings render an empty TOC nav; hide its card */
  .md-sidebar--secondary .md-nav--secondary:not(:has(.md-nav__list li)) {
    display: none;
  }

  .md-sidebar--secondary .md-nav--secondary,
  .md-sidebar--secondary .tags-sidebar {
    background: var(--al-card-bg);
    border: 1px solid var(--al-card-border);
    border-radius: 0.6rem;
    padding: 0.7rem 0.8rem;
    margin: 0 0.4rem 0.9rem 0;
  }

  /* Card headers: small uppercase labels, like the dashboard design */
  .md-sidebar--secondary .md-nav--secondary > .md-nav__title,
  .md-sidebar--secondary .tags-sidebar > .md-nav__title {
    background: transparent;
    box-shadow: none;
    text-transform: uppercase;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    color: var(--al-muted);
    padding: 0 0 0.5em;
  }
}
