:root,
[data-md-color-scheme="default"] {
  --md-primary-fg-color: #7a1111;
  --md-primary-fg-color--light: #9b1c1c;
  --md-primary-fg-color--dark: #4a0909;
  --md-accent-fg-color: #c62828;
  --md-typeset-a-color: #a3191b;

  --cc-page-bg: #e6e6e6;
  --cc-content-bg: #ffffff;
  --cc-border: #a2a9b1;
  --cc-box-bg: #f8f9fa;
  --cc-box-head: #e9e2e2;
  --cc-heading-line: #a2a9b1;
  --cc-curse-red: #ff5555;
  --cc-pixel-font: "Tiny5", ui-monospace, monospace;
}

[data-md-color-scheme="slate"] {
  --md-primary-fg-color: #5a0c0c;
  --md-accent-fg-color: #ff6b6b;
  --md-typeset-a-color: #ff8a80;
  --md-default-bg-color: #141414;
  --md-default-fg-color--light: #b5b5b5;

  --cc-page-bg: #0d0d0d;
  --cc-content-bg: #1a1a1a;
  --cc-border: #3c3c3c;
  --cc-box-bg: #222222;
  --cc-box-head: #2f1a1a;
  --cc-heading-line: #444444;
}

body {
  --md-text-font-family:
    -apple-system, "Segoe UI", Arial, Helvetica, sans-serif;
  background: var(--cc-page-bg);
}

/* Square corners everywhere, like a block game should be */
.md-typeset *,
.md-search__form,
.md-search__output,
.md-typeset .admonition,
.md-typeset details,
.md-typeset pre > code,
.md-typeset code {
  border-radius: 0 !important;
}

/* Pixel art stays sharp when scaled up */
.mc-item,
.mc-icon,
.md-header__button.md-logo img,
.brew-stand,
.brew-stand span,
.infobox-image img {
  image-rendering: pixelated;
}

/* ---------- Header and footer: red nether bricks ---------- */

.md-header {
  background:
    linear-gradient(rgba(40, 0, 0, 0.45), rgba(40, 0, 0, 0.45)),
    url("../assets/textures/gui/header.png") 0 0 / 32px 32px;
  image-rendering: pixelated;
  border-bottom: 3px solid #2a0505;
  box-shadow: none;
}

.md-header__title,
.md-header__topic {
  font-family: var(--cc-pixel-font);
  font-weight: 400;
  font-size: 1.2rem;
  text-shadow: 2px 2px 0 #2a0000;
}

.md-header__button.md-logo img {
  height: 1.8rem;
  width: 1.8rem;
}

.md-search__form {
  background: rgba(0, 0, 0, 0.35);
}

.md-footer,
.md-footer-meta {
  background: #1c0606;
}

.md-footer-meta {
  border-top: 3px solid #3a0a0a;
}

/* ---------- Page layout: content in a bordered box, nav on the left ---------- */

.md-main__inner {
  margin-top: 1rem;
}

.md-content {
  background: var(--cc-content-bg);
  border: 1px solid var(--cc-border);
  margin-bottom: 1.5rem;
}

.md-sidebar--primary .md-nav__title {
  font-family: var(--cc-pixel-font);
}

@media screen and (min-width: 76.25em) {
  .md-sidebar--primary .md-sidebar__scrollwrap {
    background: var(--cc-box-bg);
    border: 1px solid var(--cc-border);
    margin-top: 0.1rem;
  }

  .md-sidebar--primary
    .md-nav--primary
    > .md-nav__list
    > .md-nav__item--section
    > .md-nav__link {
    font-family: var(--cc-pixel-font);
    font-size: 0.8rem;
    color: var(--md-primary-fg-color--light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  [data-md-color-scheme="slate"]
    .md-sidebar--primary
    .md-nav--primary
    > .md-nav__list
    > .md-nav__item--section
    > .md-nav__link {
    color: #ff8a80;
  }
}

.md-nav__link--active {
  font-weight: 700;
}

/* ---------- Text ---------- */

.md-typeset {
  font-size: 0.8rem;
  line-height: 1.6;
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3 {
  font-family: var(--cc-pixel-font);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--md-default-fg-color);
}

.md-typeset h1 {
  font-size: 1.9em;
  margin-bottom: 0.8em;
  padding-bottom: 0.15em;
  border-bottom: 1px solid var(--cc-heading-line);
}

.md-typeset h2 {
  font-size: 1.45em;
  padding-bottom: 0.1em;
  border-bottom: 1px solid var(--cc-heading-line);
  clear: none;
}

.md-typeset h3 {
  font-size: 1.15em;
}

.mc-item {
  width: 1.4em;
  height: 1.4em;
  vertical-align: -0.35em;
}

.mc-icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.12em;
  margin-right: 0.2em;
}

/* ---------- Tables: classic "wikitable" ---------- */

.md-typeset table:not([class]),
.md-typeset .wikitable {
  display: table;
  border: 1px solid var(--cc-border);
  border-collapse: collapse;
  background: var(--cc-box-bg);
  font-size: 0.75rem;
  box-shadow: none;
}

.md-typeset table:not([class]) th,
.md-typeset .wikitable th {
  background: var(--cc-box-head);
  border: 1px solid var(--cc-border);
  font-weight: 700;
  padding: 0.4em 0.7em;
}

.md-typeset table:not([class]) td,
.md-typeset .wikitable td {
  border: 1px solid var(--cc-border);
  padding: 0.4em 0.7em;
  vertical-align: middle;
}

.md-typeset__scrollwrap {
  margin: 1em 0;
}

/* A first column with only icons (and an empty header) stays narrow */
.md-typeset table:has(th:first-child:empty) th:first-child,
.md-typeset table:has(th:first-child:empty) td:first-child {
  min-width: 2.4em;
  width: 1%;
  text-align: center;
}

.md-typeset table:has(th:first-child:empty) td:first-child > * {
  max-width: none;
}

/* ---------- Infobox (right side of a page) ---------- */

.infobox {
  float: right;
  clear: right;
  width: 17rem;
  margin: 0 0 1rem 1.2rem;
  border: 1px solid var(--cc-border);
  background: var(--cc-box-bg);
  font-size: 0.72rem;
}

.infobox-title {
  font-family: var(--cc-pixel-font);
  font-size: 1.05rem;
  text-align: center;
  color: #fff;
  padding: 0.35rem 0.5rem;
  background: #7a1111;
  text-shadow: 2px 2px 0 #2a0000;
}

.infobox-image {
  text-align: center;
  padding: 0.8rem 0 0.4rem;
}

.infobox-image img {
  width: 64px;
  height: 64px;
}

.infobox .mc-tooltip {
  margin: 0.3rem 0.6rem 0.6rem;
}

.md-typeset .infobox table.infobox-table {
  display: table;
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: inherit;
  border: none;
  background: none;
}

.md-typeset .infobox-table th,
.md-typeset .infobox-table td {
  border: none;
  border-top: 1px solid var(--cc-border);
  padding: 0.35rem 0.6rem;
  text-align: left;
  vertical-align: top;
  background: none;
}

.md-typeset .infobox-table th {
  width: 40%;
  font-weight: 700;
}

.infobox code {
  font-size: 0.9em;
  word-break: break-all;
}

@media (max-width: 44.9375em) {
  .infobox {
    float: none;
    width: auto;
    margin: 0 0 1rem;
  }
}

/* Section headings stay below the infobox's left edge without overlapping it */
.md-typeset h2 {
  overflow: hidden;
}

/* ---------- In-game item tooltip ---------- */

.mc-tooltip {
  font-family: var(--cc-pixel-font);
  font-size: 0.85rem;
  line-height: 1.35;
  color: #fff;
  background: rgba(16, 0, 16, 0.94);
  border: 2px solid #100010;
  outline: 2px solid #2d0a5e;
  outline-offset: -4px;
  padding: 0.5rem 0.7rem;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}

.mc-tooltip .curse {
  color: var(--cc-curse-red);
}

.mc-tooltip .desc {
  color: #aaa;
}

/* ---------- Admonitions: plain boxes ---------- */

.md-typeset .admonition,
.md-typeset details {
  border-width: 1px;
  border-left-width: 4px;
  box-shadow: none;
  font-size: 0.75rem;
}

/* ---------- Home page ---------- */

.welcome {
  overflow: hidden; /* stays beside the infobox instead of running under it */
  border: 1px solid var(--cc-border);
  background: var(--cc-box-bg);
  padding: 0.8rem 1rem;
  margin-bottom: 1.2rem;
}

.welcome p {
  margin: 0.2em 0;
}

.welcome strong:first-child {
  font-family: var(--cc-pixel-font);
  font-size: 1.2rem;
  font-weight: 400;
}

/* ---------- Brewing stand ---------- */

.brew {
  margin: 1rem 0 1.5rem;
}

.brew-stand {
  position: relative;
  width: min(100%, 440px);
  aspect-ratio: 176 / 82;
  background: url("../assets/textures/gui/brewing_stand.png") 0 0 / 100% 100%;
}

.brew-stand > span {
  position: absolute;
  display: block;
}

.brew-slot img {
  width: 100%;
  height: 100%;
  display: block;
}

.brew-bubbles {
  background: url("../assets/textures/gui/bubbles.png") 0 0 / 100% 100%;
  animation: brew-bubbles 1.2s steps(6) infinite;
}

.brew-arrow {
  background: url("../assets/textures/gui/brew_progress.png") 0 0 / 100% 100%;
  animation: brew-arrow 5s steps(28, end) infinite;
}

.brew-fuel {
  background: url("../assets/textures/gui/fuel_length.png") 0 0 / 100% 100%;
}

.brew-output {
  animation: brew-show 5s step-end infinite;
}

.brew-input,
.brew-ingredient {
  animation: brew-hide 5s step-end infinite;
}

@keyframes brew-arrow {
  0% {
    clip-path: inset(0 0 100% 0);
  }
  75%,
  100% {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes brew-bubbles {
  from {
    clip-path: inset(100% 0 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes brew-show {
  0% {
    opacity: 0;
  }
  76% {
    opacity: 1;
  }
}

@keyframes brew-hide {
  0% {
    opacity: 1;
  }
  76% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brew-arrow,
  .brew-bubbles {
    animation: none;
  }
  .brew-input {
    animation: none;
    opacity: 0;
  }
  .brew-ingredient {
    animation: none;
  }
  .brew-output {
    animation: none;
    opacity: 1;
  }
}

/* Hover tooltips on the slots */
.brew-slot:hover {
  background: rgba(255, 255, 255, 0.5);
}

.brew-slot[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 110%;
  top: -40%;
  z-index: 2;
  white-space: nowrap;
  font-family: var(--cc-pixel-font);
  font-size: 0.75rem;
  color: #fff;
  background: rgba(16, 0, 16, 0.94);
  border: 2px solid #2d0a5e;
  padding: 0.15rem 0.45rem;
  pointer-events: none;
}

/* Recipe line under the stand */
/* The upgrades table scrolls sideways on small screens instead of squashing */
.brew-upgrades-wrap {
  overflow-x: auto;
  margin-top: 0.8rem;
}

.md-typeset .brew-upgrades {
  margin: 0;
}

.md-typeset .brew-upgrades td {
  white-space: nowrap;
}

.brew-recipe {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
}

.brew-recipe .op {
  opacity: 0.6;
  font-weight: 700;
}

/* All recipes side by side on the brewing page */
.brew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.5rem 1.5rem;
}

.brew-grid h3 {
  margin-top: 0.6rem;
}
