/*
 * python.org's colours, read off python.org rather than approximated.
 *
 * The site makes a distinction worth keeping: its chrome is a dark, desaturated
 * blue (#2b5b84), while links in the prose are the brighter logo blue (#3776ab).
 * Using one colour for both loses the contrast the original relies on — the
 * chrome recedes so the text can carry the page.
 *
 * Everything below is colour and nothing else, so the theme's own spacing and
 * type rhythm are left intact.
 */

:root {
  --py-header: #2b5b84; /* .main-header */
  --py-header-light: #2d618c; /* .python-navigation */
  --py-header-dark: #1e2933; /* .top-bar */
  --py-link: #3776ab; /* prose links, and the logo's blue */
  --py-yellow: #ffd343; /* the donate button, and headings on the blue */
  --py-text: #444; /* python.org's body colour, softer than the theme's */
}

[data-md-color-primary="custom"] {
  --md-primary-fg-color: var(--py-header);
  --md-primary-fg-color--light: var(--py-header-light);
  --md-primary-fg-color--dark: var(--py-header-dark);
  --md-primary-bg-color: #ffffff;
  --md-primary-bg-color--light: rgba(255, 255, 255, 0.7);
}

[data-md-color-accent="custom"] {
  --md-accent-fg-color: var(--py-link);
  --md-accent-fg-color--transparent: rgba(55, 118, 171, 0.1);
  --md-accent-bg-color: #ffffff;
  --md-accent-bg-color--light: rgba(255, 255, 255, 0.7);
}

[data-md-color-scheme="default"] {
  --md-typeset-a-color: var(--py-link);
  --md-typeset-color: var(--py-text);
}

/* On the dark scheme the blue loses too much contrast against the background,
   so the accent becomes the yellow — the pairing the logo already makes, and
   the one python.org itself uses for headings over its blue. */
[data-md-color-scheme="slate"] {
  --md-typeset-a-color: var(--py-yellow);
}

[data-md-color-scheme="slate"][data-md-color-accent="custom"] {
  --md-accent-fg-color: var(--py-yellow);
  --md-accent-fg-color--transparent: rgba(255, 211, 67, 0.1);
  --md-accent-bg-color: #1e1e2e;
}

.md-typeset .md-button--primary {
  background-color: var(--py-link);
  border-color: var(--py-link);
  color: #ffffff;
}

.md-typeset .md-button--primary:hover {
  background-color: var(--py-header);
  border-color: var(--py-header);
}

/*
 * The home page hero. Home hides both sidebars (its `hide:` front matter), so
 * without a bound the article would run the full grid width and every prose
 * line below the hero would grow too long to read; the :has() rule caps the
 * column on that one page and recentres it. Everything else is scoped under
 * .home-hero and cannot leak onto other pages.
 */
.md-main:has(.home-hero) .md-content {
  margin-inline: auto;
  max-width: 46rem;
}

.home-hero {
  margin: 1.2rem auto 2.8rem;
  text-align: center;
}

.md-typeset .home-hero h1 {
  color: var(--md-default-fg-color);
  font-size: 2.6em;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: 0.5em;
}

.home-hero > p {
  font-size: 0.9rem;
  margin-inline: auto;
  max-width: 32rem;
}

.home-hero .highlight {
  margin-inline: auto;
  max-width: 34rem;
  text-align: left;
}

/* The code sample keeps LTR order inside the RTL edition's centred hero. */
[dir="rtl"] .home-hero .highlight {
  direction: ltr;
}

.md-typeset .home-hero .md-button {
  margin: 0.4rem 0.25rem 0;
}

/*
 * The facts a reader needs before deciding whether to keep reading: maturity,
 * Python requirement, what it interoperates with. Sits directly under the
 * buttons, quieter than the pitch and louder than the footnote below it.
 */
.home-hero .home-facts {
  color: var(--md-default-fg-color--light);
  font-size: 0.75rem;
  margin-top: 1.2rem;
  max-width: 32rem;
}

.home-hero .home-hero-note {
  color: var(--md-default-fg-color--light);
  font-size: 0.7rem;
  margin-top: 1.4rem;
  max-width: 32rem;
}

@media screen and (max-width: 44.984375em) {
  .md-typeset .home-hero h1 {
    font-size: 2em;
  }
}

/*
 * A translation icon alone is too easy to read as an action rather than a
 * language menu. Keep the current language visible in a compact, familiar
 * select-shaped control.
 */
.md-header__button.md-language-switcher {
  align-items: center;
  border: 0.05rem solid var(--md-primary-bg-color--light);
  border-radius: 0.2rem;
  display: flex;
  gap: 0.3rem;
  max-width: 9rem;
  padding-inline: 0.45rem;
  width: auto;
}

.md-language-switcher > svg {
  flex: 0 0 auto;
}

.md-language-switcher::after {
  border-bottom: 0.08rem solid currentcolor;
  border-right: 0.08rem solid currentcolor;
  content: "";
  flex: 0 0 auto;
  height: 0.3rem;
  margin-top: -0.15rem;
  transform: rotate(45deg);
  width: 0.3rem;
}

.md-language-switcher__label {
  font-size: 0.65rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-select__link[aria-current="page"] {
  font-weight: 700;
}

@media screen and (max-width: 44.984375em) {
  .md-header__button.md-language-switcher {
    max-width: 5.5rem;
    padding-inline: 0.35rem;
  }
}

@media screen and (max-width: 59.984375em) {
  .md-language-select .md-select__inner {
    left: auto;
    right: 0;
    transform: translate3d(0, 0.3rem, 0);
  }

  .md-language-select:focus-within .md-select__inner,
  .md-language-select:hover .md-select__inner {
    transform: translate3d(0, 0, 0);
  }

  [dir="rtl"] .md-language-select .md-select__inner {
    left: 0;
    right: auto;
  }
}
