/* Charts and screenshots keep their own (light) background; round them so they sit well in dark mode. */
.md-typeset figure img {
  border-radius: 0;
}

/* Screenshots, GIFs and charts fill the text column; the width on the page is only the fallback.
   Recipes (width 350), block icons (width 100) and .own-size screenshots keep the size the page gives them. */
.md-typeset figure:has(img:not([width="350"]):not([width="100"]):not(.own-size)),
.md-typeset figure > a:has(> img:not([width="350"]):not([width="100"]):not(.own-size)) {
  width: 100%;
}
.md-typeset figure img:not([width="350"]):not([width="100"]):not(.own-size) {
  width: 100%;
  height: auto;
}

/* Home page: download buttons centred, one row per mod. */
.md-typeset .download-buttons {
  text-align: center;
}
.md-typeset .download-buttons .md-button {
  margin: 0.2rem;
}

/* Language switch left of the light/dark toggle: Material puts it to the right, so the toggle
   and everything after it (search, repo link) move behind the switch. */
.md-header__inner > [data-md-component="palette"],
.md-header__inner > [data-md-component="palette"] ~ :not(.md-header__option) {
  order: 1;
}

/* Default events table: item icons, effect charts, direction arrows */
.md-typeset img.item-icon {
  vertical-align: middle;
}
.md-typeset td:has(> img.item-icon) {
  white-space: nowrap;
}
.md-typeset img.effect-chart {
  vertical-align: middle;
}
.md-typeset .news-up {
  color: #1f9d55;
}
.md-typeset .news-down {
  color: #e03e3e;
}
/* Default events table: every news picture 112 px, 4 px from the cell border;
   a row is then as tall as a row with three markets */
.md-typeset td:has(img.news-pic) {
  width: 112px;
  padding: 4px;
}
.md-typeset td img.news-pic {
  display: block;
  width: 112px;
  height: 112px;
}
/* Default events table: the JSON button under the ID opens the event's file in the row below */
.md-typeset details.json-toggle {
  display: inline-block;
  margin: 0.5em 0 0;
  padding: 0;
  border: 0;
  border-radius: 0.2rem;
  box-shadow: none;
  background: none;
  font-size: inherit;
}
.md-typeset details.json-toggle > summary {
  margin: 0;
  padding: 0.15em 1.8em 0.15em 0.7em;
  border-radius: 0.2rem;
  background-color: var(--md-code-bg-color);
  color: var(--md-accent-fg-color);
  font-weight: 400;
}
.md-typeset details.json-toggle > summary::before {
  display: none;
}
.md-typeset details.json-toggle > summary::after {
  top: 0.15em;
  right: 0.3em;
  width: 1.2em;
  height: 1.2em;
}
.md-typeset tr.event-json {
  display: none;
}
.md-typeset tr:has(details.json-toggle[open]) + tr.event-json {
  display: table-row;
}
.md-typeset tr.event-json > td {
  max-width: 0; /* the JSON never widens the table */
  padding: 0 0.8em 0.8em;
  border-top: 0;
}
.md-typeset tr.event-json .highlight,
.md-typeset tr.event-json pre {
  margin: 0;
}
.md-typeset tr.event-json code {
  overflow-x: auto; /* long lines scroll inside the viewer */
}
/* Left menu (wide screens): a tree. The tab title is largest, section titles a bit smaller,
   and the pages of a section sit indented below its title. */
@media screen and (min-width: 76.25em) {
  .md-nav--lifted > .md-nav__list > .md-nav__item--active > .md-nav__link {
    font-size: 0.85rem;
  }
  .md-nav__item--section .md-nav__item--section > .md-nav__link {
    font-size: 0.78rem;
  }
  [dir=ltr] .md-nav__item--section .md-nav__item--section > .md-nav {
    margin-left: 0.2rem;
  }
}
/* Depth: pictures float a little above the page (not diagrams or block icons) */
:root {
  --fx-shadow: 0 1px 3px rgb(0 0 0 / 0.12), 0 8px 24px rgb(0 0 0 / 0.16);
  --fx-shadow-high: 0 2px 6px rgb(0 0 0 / 0.14), 0 16px 40px rgb(0 0 0 / 0.22);
}
[data-md-color-scheme="slate"] {
  --fx-shadow: 0 1px 3px rgb(0 0 0 / 0.4), 0 10px 28px rgb(0 0 0 / 0.45);
  --fx-shadow-high: 0 2px 6px rgb(0 0 0 / 0.45), 0 18px 44px rgb(0 0 0 / 0.6);
}
.md-typeset figure img:not([src$=".svg"]):not([width="100"]) {
  box-shadow: var(--fx-shadow);
}

/* Home page effects, switched on by assets/javascripts/home-fx.js */
.home-fx .md-typeset figure > a:has(> img.hero) {
  display: block;
  overflow: hidden;
  box-shadow: var(--fx-shadow-high);
}
.home-fx .md-typeset img.hero {
  box-shadow: none;
  transform: translateY(var(--hero-shift, 0px)) scale(1.12);
  will-change: transform;
}
.home-fx .md-typeset .grid.cards > ul > li {
  position: relative;
  transform: perspective(800px) translateY(var(--lift, 0px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.15s ease-out, box-shadow 0.25s, border 0.25s,
              opacity 0.7s ease var(--delay, 0s), translate 0.7s ease var(--delay, 0s);
}
.home-fx .md-typeset .grid.cards > ul > li:hover {
  --lift: -6px;
  box-shadow: var(--fx-shadow-high);
}
.home-fx .md-typeset .grid.cards > ul > li::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), rgb(255 255 255 / 0.14), transparent 60%);
}
.home-fx .md-typeset .grid.cards > ul > li:hover::after {
  opacity: 1;
}
.home-fx .reveal {
  opacity: 0;
  translate: 0 24px;
  transition: opacity 0.7s ease var(--delay, 0s), translate 0.7s ease var(--delay, 0s);
}
.home-fx figure.reveal {
  transform: perspective(900px) rotateX(14deg);
  transform-origin: 50% 100%;
  transition: opacity 0.8s ease, translate 0.8s ease, transform 0.8s ease;
}
.home-fx .reveal.is-visible {
  opacity: 1;
  translate: none;
}
.home-fx figure.reveal.is-visible {
  transform: none;
}
@media print {
  .home-fx .reveal {
    opacity: 1;
    translate: none;
    transform: none;
  }
}

/* Mod look, taken from the mods' own screens: dark slate panels (Bank Terminal), candle green
   and red, the green "Create" button, gold group headings; square bevelled Minecraft panels
   and buttons; chart-paper grid, pixel candles in the top bar. */
:root,
[data-md-color-scheme="default"] {
  --mc-slate: #343b47;
  --mc-green: #2d8a4e;
  --mc-green-bright: #32cc6f;
  --mc-red: #e74c3c;
  --mc-gold: #ffd966;
  --md-primary-fg-color: #343b47;
  --md-primary-fg-color--light: #4a5363;
  --md-primary-fg-color--dark: #262b34;
  --md-primary-bg-color: #fff;
  --md-primary-bg-color--light: #ffffffb3;
  --md-accent-fg-color: #a86f00;
  --md-accent-fg-color--transparent: #a86f001a;
  --md-accent-bg-color: #fff;
  --md-accent-bg-color--light: #ffffffb3;
  --md-typeset-a-color: #237a4a;
  --mc-panel: #f4f4f4;
  --mc-edge: #8b8b8b;
  --mc-bevel: inset 2px 2px 0 #fff, inset -2px -2px 0 #c6c6c6;
}
[data-md-color-scheme="slate"] {
  --md-hue: 218;
  --md-accent-fg-color: #ffd966;
  --md-accent-fg-color--transparent: #ffd9661a;
  --md-accent-bg-color: #1e2229;
  --md-typeset-a-color: #32cc6f;
  --mc-panel: #2a3039;
  --mc-edge: #14171c;
  --mc-bevel: inset 2px 2px 0 rgb(255 255 255 / 0.07), inset -2px -2px 0 rgb(0 0 0 / 0.35);
}

/* The open tab is underlined with a candle-green bar */
.md-tabs__item--active .md-tabs__link {
  box-shadow: inset 0 -3px 0 var(--mc-green-bright);
}

/* Cards: Minecraft panels with a bevelled edge */
.md-typeset .grid.cards > ul > li,
.md-typeset .grid > .card {
  border: 2px solid var(--mc-edge);
  border-radius: 0;
  background: var(--mc-panel);
  box-shadow: var(--mc-bevel);
}
.md-typeset .grid.cards > ul > li:hover,
.md-typeset .grid.cards > ul > li:focus-within,
.md-typeset .grid > .card:hover {
  border-color: var(--mc-edge);
  box-shadow: var(--mc-bevel), var(--fx-shadow);
}
.home-fx .md-typeset .grid.cards > ul > li:hover {
  box-shadow: var(--mc-bevel), var(--fx-shadow-high);
}

/* Buttons: Minecraft buttons, the primary one in the mods' green */
.md-typeset .md-button {
  border: 2px solid #000;
  border-radius: 0;
  background: #6f6f6f;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f;
  box-shadow: inset 2px 2px 0 rgb(255 255 255 / 0.35), inset -2px -3px 0 rgb(0 0 0 / 0.35);
}
.md-typeset .md-button--primary {
  background: var(--mc-green);
  border-color: #000;
  text-shadow: 2px 2px 0 #1b5230;
}
.md-typeset .md-button:hover,
.md-typeset .md-button:focus {
  background: #8a8a8a;
  border-color: #fff;
  color: #fff;
}
.md-typeset .md-button--primary:hover,
.md-typeset .md-button--primary:focus {
  background: #36a25c;
}

/* Notes and collapsibles: square, with a 2 px edge */
.md-typeset .admonition,
.md-typeset details {
  border-width: 2px;
  border-radius: 0;
}

/* Tables: header row in the dark slate of the mods' panels */
.md-typeset table:not([class]) {
  border-radius: 0;
}
.md-typeset table:not([class]) th {
  background: var(--mc-slate);
  color: #fff;
}

/* Pixel candles along the top bar (title and tabs), faint, behind the text */
.md-header {
  isolation: isolate;
}
.md-header .md-tabs {
  background-color: transparent; /* the header behind it has the same colour */
}
.md-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.3;
  background: url("../images/shared/header-candles.svg") right bottom / auto 100% no-repeat;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 45%);
  mask-image: linear-gradient(90deg, transparent, #000 45%);
}

/* Chart paper: a faint grid behind every page */
:root,
[data-md-color-scheme="default"] {
  --mc-grid: rgb(0 0 0 / 0.04);
}
[data-md-color-scheme="slate"] {
  --mc-grid: rgb(255 255 255 / 0.03);
}
.md-main {
  background-image:
    linear-gradient(var(--mc-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--mc-grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* Section headings: a small candle chart under the heading text (repeats without a jump) */
.md-typeset h2 {
  width: fit-content;
}
.md-typeset h2::after {
  content: "";
  display: block;
  height: 20px;
  margin-top: 0.3rem;
  opacity: 0.85;
  background: url("../images/shared/heading-candles.svg") left center / auto 100% repeat-x;
}

/* Crafting recipes side by side, two per row (one on phones) */
.md-typeset .recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
  align-items: start;
}
@media screen and (max-width: 44.9375em) {
  .md-typeset .recipe-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Every table spans the full text width; a table wider than the column still scrolls sideways */
.md-typeset__table {
  min-width: 100%;
}
.md-typeset table:not([class]) {
  display: table;
}
