/* ==========================================================================
   TanagerSpec — refined presentation polish for Material for MkDocs
   CSS-only. Light/dark aware. No markup changes required.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design tokens
   -------------------------------------------------------------------------- */

:root {
  /* Layout */
  --ts-site-width: 72rem;
  --ts-content-width: 44rem;

  /* Shape */
  --ts-radius-sm: 0.25rem;
  --ts-radius-md: 0.45rem;
  --ts-radius-lg: 0.6rem;

  /* Borders + shadows */
  --ts-border-color: var(--md-default-fg-color--lightest);
  --ts-shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.045),
    0 4px 12px rgba(0, 0, 0, 0.035);

  /* Typography */
  --md-text-font-features: "cv05", "ss01", "calt", "kern";

  /* Hero gradient — light-mode: faint indigo wash behind logo+h1 on index.md.
     Uses primary-fg at near-zero opacity, auto-adapts to any Material primary. */
  --ts-hero-gradient: linear-gradient(
    160deg,
    color-mix(in srgb, var(--md-primary-fg-color) 6%, transparent) 0%,
    transparent 60%
  );

  /* Inline-code tint: accent at ~9 % opacity reads as a faint indigo pill. */
  --ts-inline-code-bg: color-mix(
    in srgb,
    var(--md-primary-fg-color) 9%,
    var(--md-code-bg-color)
  );
}

[data-md-color-scheme="slate"] {
  --ts-shadow-soft: none;
}

/* --------------------------------------------------------------------------
   color-mix() fallback for Safari <16.2, Chrome <111, Firefox <113
   -------------------------------------------------------------------------- */

@supports not (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --ts-hero-gradient: linear-gradient(
      160deg,
      rgba(63, 81, 181, 0.06) 0%,
      transparent 60%
    );
    --ts-inline-code-bg: #eef0fb;
  }

  [data-md-color-scheme="slate"] {
    --ts-hero-gradient: linear-gradient(
      160deg,
      rgba(93, 108, 192, 0.1) 0%,
      transparent 60%
    );
    --ts-inline-code-bg: #2a2e4a;
  }
}

/* Better anchor positioning under sticky headers. */
html {
  scroll-padding-top: 4.8rem;
}

/* --------------------------------------------------------------------------
   Layout & reading measure
   -------------------------------------------------------------------------- */

.md-grid {
  max-width: var(--ts-site-width);
}

.md-content__inner {
  padding-bottom: 3rem;
}

/* Limit prose width, but let code, tables, tabs, diagrams, and images breathe. */
.md-typeset > :where(
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  p,
  ul,
  ol,
  dl,
  blockquote
) {
  max-width: var(--ts-content-width);
}

/* Keep metadata-like first paragraphs from feeling cramped. */
.md-typeset > p:first-of-type {
  margin-top: 0.2rem;
}

/* --------------------------------------------------------------------------
   Typography & rhythm
   -------------------------------------------------------------------------- */

.md-typeset {
  font-feature-settings: var(--md-text-font-features);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  line-height: 1.68;
}

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

.md-typeset h1 {
  margin-bottom: 1.1rem;
  letter-spacing: -0.025em;
}

.md-typeset h2 {
  margin-top: 2.4em;
  padding-top: 0.15em;
}

.md-typeset h3 {
  margin-top: 1.8em;
}

/* Make linked headings easier to land on from the table of contents. */
.md-typeset :target {
  scroll-margin-top: 5rem;
}

/* --------------------------------------------------------------------------
   Links & focus states — enhanced focus ring with glow
   -------------------------------------------------------------------------- */

.md-typeset a {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  transition: color 125ms ease, text-decoration-color 125ms ease;
}

.md-typeset a:hover {
  text-decoration-thickness: 1.5px;
}

/* Keyboard accessibility: outline + soft glow so the ring reads on any background. */
.md-typeset a:focus-visible,
.md-nav__link:focus-visible,
.md-tabs__link:focus-visible,
.md-clipboard:focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 0.18rem;
  border-radius: var(--ts-radius-sm);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-accent-fg-color) 22%, transparent);
}

@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .md-typeset a:focus-visible,
  .md-nav__link:focus-visible,
  .md-tabs__link:focus-visible,
  .md-clipboard:focus-visible {
    box-shadow: 0 0 0 4px rgba(66, 135, 255, 0.25);
  }
}

/* --------------------------------------------------------------------------
   Code: fences, inline code, annotations
   -------------------------------------------------------------------------- */

.md-typeset code {
  border-radius: var(--ts-radius-sm);
  font-feature-settings: "liga" 0, "calt" 0;
}

/* Inline code: indigo-tinted pill so method names pop vs neutral gray. */
.md-typeset :not(pre) > code {
  padding: 0.1em 0.32em;
  white-space: break-spaces;
  background-color: var(--md-code-bg-color); /* fallback */
  background-color: var(--ts-inline-code-bg);
  color: var(--md-primary-fg-color--dark);
}

/* Dark mode: keep tinted background but let Material's code color lead. */
[data-md-color-scheme="slate"] .md-typeset :not(pre) > code {
  color: var(--md-code-fg-color);
  background-color: color-mix(
    in srgb,
    var(--md-primary-fg-color) 14%,
    var(--md-code-bg-color)
  );
}

/* Code inside links: inherit link color, not the pill tint. */
.md-typeset a > code {
  color: inherit;
  background-color: var(--md-accent-fg-color--transparent);
}

.md-typeset pre {
  border-radius: var(--ts-radius-md);
}

.md-typeset pre > code {
  border-radius: var(--ts-radius-md);
  line-height: 1.55;
}

/* Code blocks as discrete cards. */
.md-typeset .highlight {
  border: 1px solid var(--ts-border-color);
  border-radius: var(--ts-radius-md);
  box-shadow: var(--ts-shadow-soft);
  overflow: hidden;
}

.md-typeset .highlight > pre {
  margin: 0;
}

/* Copy button readability. */
.md-clipboard {
  transition: color 125ms ease, opacity 125ms ease;
}

[data-md-color-scheme="slate"] .md-clipboard {
  color: var(--md-default-fg-color--light);
}

.md-clipboard:hover {
  color: var(--md-accent-fg-color);
}

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

.md-typeset table:not([class]) {
  overflow: hidden;
  border: 1px solid var(--ts-border-color);
  border-radius: var(--ts-radius-md);
  font-size: 0.78rem;
  box-shadow: var(--ts-shadow-soft);
}

.md-typeset table:not([class]) th {
  font-weight: 650;
  background-color: var(--md-default-fg-color--lightest);
}

.md-typeset table:not([class]) td,
.md-typeset table:not([class]) th {
  border: none;
  vertical-align: top;
}

/* Softer zebra striping. */
.md-typeset table:not([class]) tbody tr:nth-child(even) {
  background-color: var(--md-default-fg-color--lightest);
}

/* Improve scanability in dense API/reference tables. */
.md-typeset table:not([class]) td code,
.md-typeset table:not([class]) th code {
  white-space: nowrap;
}

/* Compact bullet lists inside course/overview tables. */
.md-typeset table:not([class]) ul {
  margin: 0;
  padding-left: 1.1em;
}

.md-typeset table:not([class]) li {
  margin: 0.1em 0;
}

.md-typeset table:not([class]) li:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Admonitions / collapsible details — hover card lift
   -------------------------------------------------------------------------- */

.md-typeset .admonition,
.md-typeset details {
  border-radius: var(--ts-radius-md);
  border-left-width: 0.22rem;
  box-shadow: var(--ts-shadow-soft);
  transition: box-shadow 125ms ease, transform 125ms ease;
}

.md-typeset .admonition:hover,
.md-typeset details:hover {
  transform: translateY(-1px);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.06),
    0 6px 18px rgba(0, 0, 0, 0.055);
}

[data-md-color-scheme="slate"] .md-typeset .admonition:hover,
[data-md-color-scheme="slate"] .md-typeset details:hover {
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.25),
    0 8px 20px rgba(0, 0, 0, 0.2);
}

.md-typeset .admonition-title,
.md-typeset summary {
  font-weight: 650;
}

.md-typeset details[open] {
  padding-bottom: 0.2rem;
}

/* Nested admonitions must not compound-lift. */
.md-typeset .admonition .admonition,
.md-typeset details details {
  box-shadow: none;
}

.md-typeset .admonition .admonition:hover,
.md-typeset details details:hover {
  transform: none;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   Images, figures & media — hover zoom on standalone images
   -------------------------------------------------------------------------- */

.md-typeset img,
.md-typeset svg,
.md-typeset video {
  max-width: 100%;
  height: auto;
}

/* Hero/overview pattern: <p align="center"><img> */
.md-typeset p[align="center"] img {
  border-radius: var(--ts-radius-lg);
}

/* Standalone images: deliberate block presentation. */
.md-typeset > p > img:only-child {
  display: block;
  margin: 1.5rem auto;
  border-radius: var(--ts-radius-lg);
}

/* Captions */
.md-typeset figcaption {
  max-width: var(--ts-content-width);
  margin: 0.6rem auto 1.2rem;
  color: var(--md-default-fg-color--light);
  font-size: 0.72rem;
  line-height: 1.45;
}

/* --------------------------------------------------------------------------
   Navigation polish — active left-border indicator
   -------------------------------------------------------------------------- */

.md-tabs__link--active,
.md-nav__link--active {
  font-weight: 650;
}

.md-nav__link {
  transition: color 125ms ease;
}

/* Primary sidebar: accent left-border on active item. */
.md-nav--primary .md-nav__item > .md-nav__link--active {
  position: relative;
  padding-left: calc(0.8rem + 3px);
}

.md-nav--primary .md-nav__item > .md-nav__link--active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 1.1em;
  width: 3px;
  border-radius: 2px;
  background: var(--md-primary-fg-color);
}

/* TOC sidebar: 2px accent left-border. */
.md-nav--secondary .md-nav__link--active {
  border-left: 2px solid var(--md-accent-fg-color);
  padding-left: calc(0.6rem + 2px);
  transition: color 125ms ease, border-color 125ms ease;
}

/* --------------------------------------------------------------------------
   Search / header small refinements
   -------------------------------------------------------------------------- */

.md-search__form {
  border-radius: var(--ts-radius-md);
}

/* Hide the default header logo; show site name text only. */
.md-header__button.md-logo {
  display: none;
}


/* --------------------------------------------------------------------------
   Custom scrollbar — slim indigo/slate, only visible on interaction
   -------------------------------------------------------------------------- */

/* Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--md-default-fg-color--lighter) transparent;
}

/* WebKit: Chrome, Edge, Safari */
html::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

html::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb {
  background-color: var(--md-default-fg-color--lighter);
  border-radius: 3px;
  transition: background-color 150ms ease;
}

html::-webkit-scrollbar-thumb:hover {
  background-color: var(--md-primary-fg-color--light);
}

/* --------------------------------------------------------------------------
   Hero landing section — centered gradient card on index.md (.ts-hero)
   Logo + h1 + tagline + CTA buttons + badges, all centered.
   -------------------------------------------------------------------------- */

.md-typeset .ts-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  background: var(--ts-hero-gradient);
  border-radius: var(--ts-radius-lg);
  padding: 2.6rem 1.4rem 2rem;
  margin: 0 -0.8rem 2.2rem;
}

.md-typeset .ts-hero__logo {
  width: min(460px, 78%);
  height: auto;
  margin: 0 auto 0.4rem;
  border-radius: var(--ts-radius-lg);
}

/* Hero h1: large, centered, no left accent rule. */
.md-typeset .ts-hero h1 {
  margin: 0;
  padding-left: 0;
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.md-typeset .ts-hero h1::before {
  display: none;
}

.md-typeset .ts-hero__tagline {
  max-width: 40rem;
  margin: 0.2rem auto 0.8rem;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--md-default-fg-color--light);
}

/* CTA button row: wrap on small screens, even gaps. */
.md-typeset .ts-hero .md-button {
  margin: 0.3rem 0.35rem 0;
}

/* Badge strip: compact, centered, vertically aligned. */
.md-typeset .ts-hero__badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.3rem 0.5rem;
  margin: 1.4rem auto 0;
}

.md-typeset .ts-hero__badges img {
  height: 1.3rem;
  width: auto;
}

@media screen and (max-width: 44.9375em) {
  .md-typeset .ts-hero {
    padding: 1.8rem 1rem 1.4rem;
  }

  .md-typeset .ts-hero h1 {
    font-size: 2rem;
  }

  .md-typeset .ts-hero__tagline {
    font-size: 0.95rem;
  }
}

/* --------------------------------------------------------------------------
   Call-to-action buttons (.md-button)
   -------------------------------------------------------------------------- */

.md-typeset .md-button {
  border-radius: var(--ts-radius-md);
  font-weight: 600;
  transition: background-color 125ms ease, color 125ms ease,
    border-color 125ms ease, box-shadow 125ms ease, transform 125ms ease;
}

.md-typeset .md-button:hover {
  transform: translateY(-1px);
}

.md-typeset .md-button--primary {
  background-color: var(--md-primary-fg-color);
  border-color: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
  box-shadow: var(--ts-shadow-soft);
}

.md-typeset .md-button--primary:hover,
.md-typeset .md-button--primary:focus {
  background-color: var(--md-accent-fg-color);
  border-color: var(--md-accent-fg-color);
  color: #fff;
}

/* --------------------------------------------------------------------------
   Grid cards — polish on top of Material defaults
   -------------------------------------------------------------------------- */

.md-typeset .grid.cards > ul > li,
.md-typeset .grid.cards > :where(ol, ul) > li,
.md-typeset .grid > .card {
  border: 1px solid var(--ts-border-color);
  border-radius: var(--ts-radius-md);
  box-shadow: var(--ts-shadow-soft);
  background-color: var(--md-default-bg-color);
  padding: 1rem 1.1rem;
  transition: box-shadow 125ms ease, transform 125ms ease, border-color 125ms ease;
}

/* Subtle elevated surface in dark mode so cards separate from the page. */
[data-md-color-scheme="slate"] .md-typeset .grid.cards > ul > li,
[data-md-color-scheme="slate"] .md-typeset .grid.cards > :where(ol, ul) > li,
[data-md-color-scheme="slate"] .md-typeset .grid > .card {
  background-color: var(--md-code-bg-color);
}

.md-typeset .grid.cards > ul > li:hover,
.md-typeset .grid.cards > :where(ol, ul) > li:hover,
.md-typeset .grid > .card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--md-primary-fg-color) 35%, var(--ts-border-color));
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.06),
    0 10px 24px rgba(0, 0, 0, 0.06);
}

[data-md-color-scheme="slate"] .md-typeset .grid.cards > ul > li:hover,
[data-md-color-scheme="slate"] .md-typeset .grid.cards > :where(ol, ul) > li:hover {
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.3),
    0 10px 24px rgba(0, 0, 0, 0.25);
}

@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .md-typeset .grid.cards > ul > li:hover,
  .md-typeset .grid.cards > :where(ol, ul) > li:hover {
    border-color: var(--md-primary-fg-color--light);
  }
}

/* Card lead icon: brand-tinted, sized up. */
.md-typeset .grid.cards .twemoji.lg,
.md-typeset .grid.cards :where(.lg).twemoji {
  color: var(--md-primary-fg-color);
}

.md-typeset .grid.cards svg {
  fill: currentColor;
}

/* Card title line reads as a heading even though it's bold text. */
.md-typeset .grid.cards > ul > li > p:first-child strong {
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

/* The "read more" link sits at the card foot. */
.md-typeset .grid.cards > ul > li > hr + p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Layout helpers (replace inline styles in content)
   -------------------------------------------------------------------------- */

.md-typeset .ts-rounded {
  border-radius: var(--ts-radius-lg);
}

.md-typeset .ts-center {
  text-align: center;
}

.md-typeset .ts-course-logo {
  border-radius: var(--ts-radius-lg);
  border: 1px solid var(--ts-border-color);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  margin: 1rem auto;
}

[data-md-color-scheme="slate"] .md-typeset .ts-course-logo {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

/* --------------------------------------------------------------------------
   Heading accent decoration — left-edge indigo rule on h1 / h2
   -------------------------------------------------------------------------- */

.md-typeset h1,
.md-typeset h2 {
  position: relative;
  padding-left: 0.85rem;
}

.md-typeset h1::before,
.md-typeset h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.12em;
  bottom: 0.12em;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(
    to bottom,
    var(--md-primary-fg-color),
    var(--md-accent-fg-color) 70%,
    transparent
  );
  opacity: 0.75;
}

.md-typeset h1::before {
  width: 4px;
  opacity: 0.9;
}

/* Don't apply accent decoration inside search results or nav. */
.md-search-result .md-typeset h1,
.md-search-result .md-typeset h2,
.md-nav .md-typeset h1,
.md-nav .md-typeset h2 {
  padding-left: 0;
}

.md-search-result .md-typeset h1::before,
.md-search-result .md-typeset h2::before,
.md-nav .md-typeset h1::before,
.md-nav .md-typeset h2::before {
  display: none;
}

/* --------------------------------------------------------------------------
   Content tabs — pill underline with accent color indicator
   -------------------------------------------------------------------------- */

/* Accent color indicator line (Material's JS drives position via CSS vars). */
.js .md-typeset .tabbed-labels::before {
  background: var(--md-accent-fg-color);
  height: 2px;
  border-radius: 2px 2px 0 0;
}

/* Inactive labels: smooth transitions. */
.md-typeset .tabbed-labels > label {
  transition: color 200ms ease, background-color 200ms ease;
  border-radius: var(--ts-radius-sm) var(--ts-radius-sm) 0 0;
  padding-left: 1.1rem;
  padding-right: 1.1rem;
}

/* Hover: faint accent tint. */
.md-typeset .tabbed-labels > label:hover {
  background-color: var(--md-accent-fg-color--transparent);
  color: var(--md-accent-fg-color);
}

/* Active tab: primary color + bold (covers up to 5 tabs). */
@media screen {
  .md-typeset .tabbed-set > input:nth-child(1):checked ~ .tabbed-labels > label:nth-child(1),
  .md-typeset .tabbed-set > input:nth-child(2):checked ~ .tabbed-labels > label:nth-child(2),
  .md-typeset .tabbed-set > input:nth-child(3):checked ~ .tabbed-labels > label:nth-child(3),
  .md-typeset .tabbed-set > input:nth-child(4):checked ~ .tabbed-labels > label:nth-child(4),
  .md-typeset .tabbed-set > input:nth-child(5):checked ~ .tabbed-labels > label:nth-child(5) {
    color: var(--md-primary-fg-color);
    font-weight: 700;
  }
}

/* Tab content area: bordered, rounded bottom. */
.md-typeset .tabbed-content {
  border: 1px solid var(--ts-border-color);
  border-top: none;
  border-radius: 0 0 var(--ts-radius-md) var(--ts-radius-md);
}

/* --------------------------------------------------------------------------
   Footer polish
   -------------------------------------------------------------------------- */

.md-footer {
  border-top: 1px solid var(--md-default-fg-color--lightest);
}

.md-footer-meta {
  opacity: 0.85;
}

.md-footer__title {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.md-footer__direction {
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.6rem;
}

/* --------------------------------------------------------------------------
   Mobile refinements
   -------------------------------------------------------------------------- */

@media screen and (max-width: 44.9375em) {
  .md-typeset {
    line-height: 1.62;
  }

  .md-typeset h1 {
    font-size: 1.72em;
  }

  .md-typeset h2 {
    margin-top: 2em;
  }

  .md-typeset table:not([class]) {
    font-size: 0.72rem;
  }
}

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

@media print {
  .md-typeset {
    font-size: 11pt;
    line-height: 1.45;
  }

  .md-typeset a {
    text-decoration: none;
  }

  .md-typeset .highlight,
  .md-typeset .admonition,
  .md-typeset details,
  .md-typeset table:not([class]) {
    box-shadow: none;
  }

  .md-typeset h1,
  .md-typeset h2 {
    padding-left: 0;
  }

  .md-typeset h1::before,
  .md-typeset h2::before {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Motion preferences
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
