/* bricky's docs: LEGO® colors, one text column on every page, and cards built like bricks. */

@import url("https://fonts.googleapis.com/css2?family=Rubik:wght@500;600;700&display=swap");

/*
 * The four classic colors take the RGB values of bricky's catalog, so the docs match the images.
 * The LEGO Group publishes no RGB values; BrickLink's Red, Yellow, Blue and Green are its Bright Red,
 * Bright Yellow, Bright Blue and Dark Green.
 */
:root {
  --bricky-red: #d82424;
  --bricky-yellow: #ffda19;
  --bricky-blue: #196bcf;
  --bricky-green: #009d48;
  --bricky-panel: #ffffff;
  --bricky-line: #d0d7de;
  --bricky-line-strong: #8c959f;
  --bricky-stud: rgb(216 36 36 / 7%);
  --bricky-terminal: #16181d;
  --bricky-terminal-ink: #e6edf3;

  /* A plate seen from the side: the band is one plate tall, and studs sit on it at the stud pitch. */
  --bricky-band: 12px;
  --bricky-stud-height: 7px;
  --bricky-stud-pitch: 32px;
  --bricky-studs: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 7'%3E%3Crect x='6.5' width='19' height='10' rx='2'/%3E%3C/svg%3E");
  --bricky-brick-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12'%3E%3Crect x='2' width='4' height='4' rx='0.8'/%3E%3Crect x='10' width='4' height='4' rx='0.8'/%3E%3Crect y='3' width='16' height='9' rx='1'/%3E%3C/svg%3E");
}

[data-md-color-primary="custom"] {
  --md-primary-fg-color: var(--bricky-red);
  --md-primary-fg-color--light: #e25050;
  --md-primary-fg-color--dark: #b01c1c;
  --md-primary-bg-color: #ffffff;
  --md-primary-bg-color--light: rgb(255 255 255 / 70%);
  --md-typeset-a-color: var(--bricky-red);
}

[data-md-color-accent="custom"] {
  --md-accent-fg-color: var(--bricky-blue);
  --md-accent-fg-color--transparent: rgb(25 107 207 / 10%);
  --md-accent-bg-color: #ffffff;
  --md-accent-bg-color--light: rgb(255 255 255 / 70%);
}

/* The dark scheme lightens the red and the blue of text and links, which would lack contrast on slate. */
[data-md-color-scheme="slate"] {
  --bricky-line: #3d444d;
  --bricky-line-strong: #6e7681;
  --bricky-stud: rgb(255 255 255 / 5%);
  --md-typeset-a-color: #ff6b5e;
}

[data-md-color-scheme="slate"][data-md-color-accent="custom"] {
  --md-accent-fg-color: #6ea8ff;
  --md-accent-fg-color--transparent: rgb(110 168 255 / 12%);
}

/*
 * Every page keeps the space of both sidebars, even a page that hides them,
 * so the text column has the same width and position on every page.
 */
@media screen and (min-width: 60em) {
  .md-sidebar--secondary[hidden] {
    display: block;
    visibility: hidden;
  }

  .md-content > .md-content__inner {
    margin-right: 1.2rem;
  }
}

@media screen and (min-width: 76.25em) {
  .md-sidebar--primary[hidden] {
    display: block;
    visibility: hidden;
  }

  .md-content > .md-content__inner {
    margin-left: 1.2rem;
  }
}

/* A stripe of the four colors tops the header; a plain line separates the header from the page. */
.md-header::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--bricky-red) 0 25%,
    var(--bricky-yellow) 25% 50%,
    var(--bricky-blue) 50% 75%,
    var(--bricky-green) 75% 100%
  );
}

.md-header,
.md-header--shadow {
  box-shadow: 0 1px 0 var(--bricky-line);
}

/* The tab of the current section sits on the line, underlined in red. */
.md-tabs__item--active {
  border-bottom: 2px solid var(--md-typeset-a-color);
}

/* Headings */
.md-typeset h1,
.md-typeset h2,
.md-typeset h3 {
  font-family: Rubik, var(--md-text-font-family), sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.md-typeset h1 {
  font-weight: 700;
}

/*
 * A section's sidebar opens with the section's name, after a brick, linked to its overview page.
 * The theme hides that name when tabs show; a single page, such as Get started, needs no name.
 */
@media screen and (min-width: 76.25em) {
  .md-nav--lifted > .md-nav__list > .md-nav__item--active.md-nav__item--nested > .md-nav__link {
    display: flex;
    margin-bottom: 0.4rem;
  }

  .md-nav--lifted > .md-nav__list > .md-nav__item--active.md-nav__item--nested > .md-nav__link > a {
    gap: 0.5rem;
    align-items: center;
    font-family: Rubik, var(--md-text-font-family), sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--md-default-fg-color);
  }

  .md-nav--lifted > .md-nav__list > .md-nav__item--active.md-nav__item--nested > .md-nav__link > a::before {
    content: "";
    flex: none;
    width: 0.8rem;
    height: 0.6rem;
    background: var(--bricky-red);
    mask: var(--bricky-brick-icon) center / contain no-repeat;
  }

  .md-nav--lifted
    > .md-nav__list
    > .md-nav__item--active.md-nav__item--nested
    > .md-nav__link
    > a.md-nav__link--active {
    color: var(--md-typeset-a-color);
  }
}

/* A group inside a section, such as the Python API, reads as a small label above its pages. */
.md-nav__item--section .md-nav__item--section > .md-nav__link {
  margin-top: 0.8rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--md-default-fg-color--light);
}

/* Images in prose sit on a white panel, which keeps them calm in dark mode. */
.md-typeset p > img,
.md-typeset .tabbed-block img {
  background: var(--bricky-panel);
  border: 1px solid var(--bricky-line);
  border-radius: 0.4rem;
}

/* Reports read like a terminal, in both color schemes. */
.md-typeset .language-text.highlight pre > code {
  background: var(--bricky-terminal);
  color: var(--bricky-terminal-ink);
}

.md-typeset .language-text.highlight .md-clipboard {
  color: rgb(230 237 243 / 45%);
}

/* Diagrams sit centered in the column and use the page's colors: plain boxes, gray lines and the text color. */
.md-typeset .mermaid {
  display: flex;
  justify-content: center;
}

:root > * {
  --md-mermaid-font-family: var(--md-text-font-family), sans-serif;
  --md-mermaid-node-bg-color: var(--md-default-bg-color);
  --md-mermaid-node-fg-color: var(--bricky-line-strong);
  --md-mermaid-edge-color: var(--bricky-line-strong);
  --md-mermaid-label-bg-color: var(--md-default-bg-color);
  --md-mermaid-label-fg-color: var(--md-default-fg-color);
}

/* The home page's hero: the name, the pitch and the Colosseum, on a baseplate of studs. */
.bricky-hero {
  margin: 0 0 2rem;
  padding: 2rem 2rem 2.2rem;
  border: 1px solid var(--bricky-line);
  border-radius: 0.4rem;
  background:
    radial-gradient(circle, var(--bricky-stud) 6px, transparent 6.5px) 0 0 / 24px 24px,
    var(--md-code-bg-color);
}

.md-typeset .bricky-hero h1 {
  margin: 0 0 0.25rem;
  font-size: 3rem;
  line-height: 1;
  color: var(--bricky-red);
}

[data-md-color-scheme="slate"] .md-typeset .bricky-hero h1 {
  color: #ff6b5e;
}

.md-typeset .bricky-tagline {
  margin-top: 0.5rem;
  font-family: Rubik, var(--md-text-font-family), sans-serif;
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--md-default-fg-color);
}

.md-typeset .bricky-hero .md-button {
  margin: 0.2rem 0.5rem 0 0;
}

/* A secondary button is outlined in the text color, so it reads as a button and not as a disabled one. */
.md-typeset .md-button:not(.md-button--primary) {
  color: var(--md-default-fg-color);
  background: var(--md-default-bg-color);
  box-shadow: inset 0 0 0 1px var(--bricky-line-strong);
}

.md-typeset .md-button:not(.md-button--primary):is(:hover, :focus) {
  box-shadow: inset 0 0 0 1px var(--md-default-fg-color);
}

.md-typeset .bricky-hero-image {
  display: block;
  width: 100%;
  margin-top: 1.6rem;
}

@media screen and (max-width: 44.9375em) {
  .bricky-hero {
    padding: 1.4rem 1rem 1.6rem;
  }

  .md-typeset .bricky-hero h1 {
    font-size: 2.4rem;
  }

  .md-typeset .bricky-tagline {
    font-size: 1.05rem;
  }
}

/*
 * Cards are bricks: a plate of color along the top, with studs on it, and a visible edge.
 * The colors cycle red, blue, yellow and green; on hover a card lifts and its edge darkens.
 */
.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) {
  gap: calc(var(--bricky-stud-height) + 1rem) 0.8rem;
  margin-top: calc(var(--bricky-stud-height) + 1.2rem);
}

.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) > ul > li {
  --bricky-brick: var(--bricky-red);

  position: relative;
  border: 1px solid var(--bricky-line);
  border-top: var(--bricky-band) solid transparent;
  border-radius: 0.2rem;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) > ul > li:nth-child(4n + 2) {
  --bricky-brick: var(--bricky-blue);
}

.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) > ul > li:nth-child(4n + 3) {
  --bricky-brick: var(--bricky-yellow);
}

.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) > ul > li:nth-child(4n + 4) {
  --bricky-brick: var(--bricky-green);
}

/*
 * The studs and the band are layers over the card's outer edge, one pixel past each side border.
 * A colored top border would meet the gray side borders at a slant and leave them showing.
 */
.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) > ul > li::before,
.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) > ul > li::after {
  content: "";
  position: absolute;
  right: -1px;
  left: -1px;
  background: var(--bricky-brick);
}

.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) > ul > li::before {
  top: calc(-1 * (var(--bricky-band) + var(--bricky-stud-height)));
  height: var(--bricky-stud-height);
  mask: var(--bricky-studs) 0 0 / var(--bricky-stud-pitch) var(--bricky-stud-height) round no-repeat;
}

.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) > ul > li::after {
  top: calc(-1 * var(--bricky-band));
  height: var(--bricky-band);
  border-radius: 0.2rem 0.2rem 0 0;
}

.md-typeset .grid.cards:is(.bricky-cards, .bricky-links) > ul > li:is(:hover, :focus-within) {
  border-color: var(--bricky-line-strong);
  border-top-color: transparent;
  box-shadow: 0 10px 24px rgb(0 0 0 / 12%);
  transform: translateY(-3px);
}

/* The title links the whole card. */
.md-typeset .grid.cards.bricky-cards > ul > li > p:nth-child(2),
.md-typeset .grid.cards.bricky-links > ul > li > p:first-child {
  font-family: Rubik, var(--md-text-font-family), sans-serif;
  font-size: 1.05em;
}

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

.md-typeset .grid.cards.bricky-cards > ul > li > p:nth-child(2) a::after,
.md-typeset .grid.cards.bricky-links > ul > li > p:first-child a::after {
  content: "";
  position: absolute;
  inset: 0;
}

/*
 * A card with an image is a row: the image's 4:3 frame on the left sets the card's height, and the text, kept
 * short enough to fit, centers on the right. Text that runs taller stretches the frame, so the image's panel
 * still reaches the card's bottom. The rows stack in one column, so any number of cards lines up; on a phone
 * the image goes on top.
 */
.md-typeset .grid.cards.bricky-cards {
  grid-template-columns: minmax(0, 1fr);
}

.md-typeset .grid.cards.bricky-cards > ul > li {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  grid-template-rows: 1fr auto auto auto 1fr;
  padding: 0;
}

/* The gallery gives each model half its card. */
.md-typeset .grid.cards.bricky-gallery > ul > li {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.md-typeset .grid.cards.bricky-cards > ul > li > p {
  grid-column: 2;
  margin: 0 1rem;
}

.md-typeset .grid.cards.bricky-cards > ul > li > p:first-child {
  display: flex;
  grid-row: 1 / -1;
  grid-column: 1;
  align-self: stretch;
  align-items: center;
  justify-content: center;
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bricky-panel);
  border-right: 1px solid var(--bricky-line);
}

.md-typeset .grid.cards.bricky-cards > ul > li > p:first-child img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  border: 0;
  border-radius: 0;
}

.md-typeset .grid.cards.bricky-cards > ul > li > p:nth-child(2) {
  grid-row: 2;
  margin-top: 1rem;
}

.md-typeset .grid.cards.bricky-cards > ul > li > p:nth-child(3) {
  grid-row: 3;
  margin-top: 0.4rem;
}

.md-typeset .grid.cards.bricky-cards > ul > li > p:last-child {
  margin-bottom: 1rem;
}

/* Links after the text, such as a gallery card's "Open in 3D", stay clickable above the card's link. */
.md-typeset .grid.cards.bricky-cards > ul > li > p:nth-child(4) {
  position: relative;
  z-index: 1;
  grid-row: 4;
  margin-top: 0.6rem;
  font-size: 0.9em;
}

@media screen and (max-width: 44.9375em) {
  .md-typeset .grid.cards.bricky-cards > ul > li {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
  }

  .md-typeset .grid.cards.bricky-cards > ul > li > p,
  .md-typeset .grid.cards.bricky-cards > ul > li > p:first-child {
    grid-row: auto;
    grid-column: 1;
  }

  .md-typeset .grid.cards.bricky-cards > ul > li > p:first-child {
    border-right: 0;
    border-bottom: 1px solid var(--bricky-line);
  }
}

/* Text cards that lead to other pages, two by two; on a phone, one per row. */
.md-typeset .grid.cards.bricky-links {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media screen and (max-width: 44.9375em) {
  .md-typeset .grid.cards.bricky-links {
    grid-template-columns: minmax(0, 1fr);
  }
}
