/* Palette from the Brotor icon (public/assets/icon.svg). */
:root {
  --ink: #101011;
  --night: #161922;
  --slate: #262a37;
  --steel: #535b74;
  --grey: #8d8f97;
  --sand: #e0b094;
  --text: #dcdde2;
  --muted: #9a9ca6;
  --max: 64rem;
}

/* Brotor's UI title face (Chakra Petch SemiBold, OFL; brotor src/Brotor.Game/Ui/UiFonts.cs). */
@font-face {
  font-family: "Chakra Petch";
  src: url("/assets/fonts/ChakraPetch-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

* { box-sizing: border-box; }

h1, h2, h3, h4, h5 { font-family: "Chakra Petch", system-ui, sans-serif; font-weight: 600; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--sand); }
a:hover { color: #f0cbb4; }

.top {
  position: sticky;
  top: 0;
  z-index: 100;   /* above the slide arrows (1) and the stage tooltips (10) */
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem max(1.25rem, calc((100% - var(--max)) / 2));
  background: rgb(16 16 17 / 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--slate);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.top nav { display: flex; gap: 1.25rem; }
.top nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; white-space: nowrap; }
.top nav a:hover { color: var(--text); }

/* On phones the menu folds into a burger; open, it drops below the header as a column. */
.menu-toggle {
  display: none;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.menu-toggle svg { display: block; width: 1.5rem; height: 1.5rem; }
.menu-toggle .menu-close, .top.open .menu-toggle .menu-open { display: none; }
.top.open .menu-toggle .menu-close { display: block; }
@media (max-width: 640px) {
  .menu-toggle { display: grid; margin-right: -0.5rem; }
  .top nav { display: none; flex-basis: 100%; flex-direction: column; gap: 0; padding-bottom: 0.25rem; }
  .top.open nav { display: flex; }
  .top nav a { padding: 0.6rem 0; font-size: 1rem; border-top: 1px solid var(--slate); }
}

.hero {
  text-align: center;
  padding: 4rem 1.25rem 3rem;
  position: relative;
}
/* The hero's background, assets/hero.webp: the user's screenshot at its own resolution with the dimming and the arch
   fade baked in and dithered (tools/bake-hero.sh; a CSS mask over it banded), lossless (JPEG made blocks of the
   dither), 112rem wide, from the header down. Its edges are exactly the page's ink, so it runs on under What's New's
   top padding with no edge, and narrower screens show its middle. It sits behind the page (z-index -1, no stacking
   context on .hero). */
.hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  z-index: -1;
  width: 112rem;
  aspect-ratio: 2560 / 928;
  transform: translateX(-50%);
  background: url("/assets/hero.webp") center / 100% 100% no-repeat;
  pointer-events: none;
}
.hero { overflow-x: clip; }

.hero-icon { filter: drop-shadow(0 12px 32px rgb(0 0 0 / 0.6)); }
.hero-icons { display: flex; justify-content: center; align-items: center; gap: 2rem; }
.hero-divider { align-self: flex-start; margin-top: 12px; width: 2px; height: 96px; border-radius: 1px; background: var(--grey); }
.hero-game { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.hero-game .tag { margin-left: 0; }

/* The BETA and PRE-ALPHA tags: an (i) icon and a tooltip under the tag (under both icons on narrow screens). */
.hero-icons { position: relative; }
.tag.stage { position: relative; display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.35em 0.5em; background: none; font: inherit; font-size: 0.72rem; line-height: 1; }
.stage:hover, .stage:focus-visible { color: var(--text); border-color: var(--grey); }
.stage-label { text-box: trim-both cap alphabetic; }
.stage .info { width: 0.95em; height: 0.95em; }
.stage-tip {
  position: absolute; z-index: 10; top: calc(100% + 0.5rem); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(18rem, calc(100vw - 2.5rem)); padding: 0.6rem 0.75rem;
  background: rgb(0 0 0 / 0.8); backdrop-filter: blur(6px); border: none; border-radius: 4px;
  color: var(--text); font-size: 0.85rem; line-height: 1.45; text-align: left; letter-spacing: normal;
  visibility: hidden; opacity: 0; transition: opacity 0.12s, visibility 0.12s; pointer-events: none;
}
.stage:hover .stage-tip, .stage:focus .stage-tip { visibility: visible; opacity: 1; }
@media (max-width: 560px) { .tag.stage { position: static; } }

h1 {
  margin: 1rem 0 0.5rem;
  font-size: clamp(2.5rem, 7vw, 4rem);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.hero h1, .brand { text-transform: uppercase; }
.brand { font-family: "Chakra Petch", system-ui, sans-serif; font-weight: 600; letter-spacing: 0.26em; }
/* The spacing trails the last letter too: pull it back so the title stays centred. */
.hero h1 { letter-spacing: 0.26em; margin-right: -0.26em; }

.lede {
  max-width: 36rem;
  margin: 0 auto;
  font-size: 1.1rem;
  color: var(--muted);
}

.actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 2rem 0 1rem;
  flex-wrap: wrap;
}

.button {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border: 1px solid var(--steel);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.button:hover { border-color: var(--grey); color: #fff; }
.button.primary { background: var(--sand); border-color: var(--sand); color: var(--ink); }
.button.primary:hover { background: #f0cbb4; color: var(--ink); }

.status { color: var(--muted); font-size: 0.9rem; }

.band {
  padding: 4rem max(1.25rem, calc((100% - var(--max)) / 2));
}
.band.alt { background: var(--night); border-block: 1px solid var(--slate); }

h2 { font-size: 1.8rem; font-weight: 600; margin: 0 0 1rem; }
h3 { font-size: 1.05rem; margin: 0 0 0.4rem; color: var(--sand); }


.fine { color: var(--muted); font-size: 0.9rem; }

footer {
  padding: 2.5rem max(1.25rem, calc((100% - var(--max)) / 2));
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--slate);
}

.meta { color: var(--muted); font-size: 0.9rem; }

/* Page titles look like the home page's section titles (What's New, FAQ): h2 size, centred. */
.page-title { font-size: 1.8rem; letter-spacing: normal; text-align: center; margin: 0 0 2rem; }
/* Under a page title, section headings step down so the title leads. */
.band:has(.page-title) h2 { font-size: 1.35rem; }

/* What's New: rows of slides, one slide wide, snapping. */
.highlight { margin: 0 0 3rem; }
.highlight h3 { font-size: 1.3rem; color: var(--text); margin-bottom: 0.4rem; }
.highlight-text { margin: 0 0 1rem; color: var(--muted); font-size: 0.92rem; }
.slides {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.slides::-webkit-scrollbar { display: none; }
.slide { margin: 0; scroll-snap-align: start; }
.slide > img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--slate);
  border-radius: 8px;
}
.slide figcaption { margin-top: 0.6rem; color: var(--muted); }
.slider { position: relative; }
.slide-nav button {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 2.6rem;
  height: 2.6rem;
  margin-top: -1.3rem;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--steel);
  border-radius: 50%;
  background: rgb(0 0 0 / 0.55);
  color: var(--text);
  cursor: pointer;
}
.slide-nav svg { display: block; width: 1.4rem; height: 1.4rem; }
.slide-nav button[data-step="-1"] { left: 0.75rem; }
.slide-nav button[data-step="1"] { right: 0.75rem; }
.slide-nav button:hover { border-color: var(--grey); background: rgb(0 0 0 / 0.75); }
.slide-empty {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border: 1px dashed var(--steel);
  border-radius: 8px;
  color: var(--muted);
}

/* Before/after slider: the before image is clipped to the left of --pos. */
.compare-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--slate);
  border-radius: 8px;
  background: var(--night);
  user-select: none;
}
.compare-frame img { display: block; width: 100%; height: auto; }
.compare-before {
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: cover;
  clip-path: inset(0 calc(100% - var(--pos)) 0 0);
}
.compare-frame::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: var(--sand);
  pointer-events: none;
}
.compare-frame { cursor: ew-resize; touch-action: pan-y; }
.compare-frame:has(input:focus-visible) { outline: 2px solid var(--grey); outline-offset: 2px; }
/* Only for the keyboard: compare.js drags the split with the pointer. */
.compare-frame input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
/* Each label sits on its image's side of the split and is cut off with it. */
.compare-labels { position: absolute; inset: 0; pointer-events: none; }
.compare-labels.before { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.compare-labels.after { clip-path: inset(0 0 0 var(--pos)); }
.compare-label {
  position: absolute;
  top: 0.75rem;
  padding: 0.25rem 0.7rem;
  border-radius: 4px;
  background: rgb(10 10 11 / 0.9);
  font-family: "Chakra Petch", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1rem;
}
.compare-label.left { left: 0.75rem; }
.compare-label.right { right: 0.75rem; }

details {
  border-bottom: 1px solid var(--slate);
  padding: 0.9rem 0;
}
summary { cursor: pointer; font-weight: 500; }
details p { color: var(--muted); margin: 0.6rem 0 0; }

.change-groups {
  columns: 2 22rem;
  column-gap: 2.5rem;
  margin-bottom: 3.5rem;
}
.change-group { break-inside: avoid; margin-bottom: 1.75rem; }
.change-group.flow { break-inside: auto; }
.change-group h3 { margin-bottom: 0.2rem; }
.count { color: var(--muted); font-size: 1rem; font-weight: 400; margin-left: 0.3rem; }
.changes { list-style: none; padding: 0; margin: 0; }
.changes li { padding: 0.45rem 0; border-bottom: 1px solid var(--slate); }

.tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.4rem;
  border: 1px solid var(--steel);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  vertical-align: 0.1em;
}
.tag.option { border-color: var(--sand); color: var(--sand); }

.hero-downloads { margin-top: 2rem; }
.hero-downloads .actions { margin: 0 0 0.5rem; }
.hero-downloads .meta { margin: 0.3rem 0; }
.hero-downloads .meta a { color: var(--muted); }
.button.download { display: inline-flex; align-items: center; gap: 0.55rem; min-width: 9rem; justify-content: center; }
.icon { width: 1.1em; height: 1.1em; flex: none; }

.release { margin-bottom: 2rem; }
.release h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.release h2 a { color: var(--text); text-decoration: none; }
.release ul { margin: 0; padding-left: 1.2rem; color: var(--text); }
.release li { margin: 0.2rem 0; }
.hero-downloads .requirements { font-size: 0.75rem; margin-top: 0.8rem; }
.hero-downloads .requirements a { color: var(--muted); }
.button.disabled, .button.disabled:hover { opacity: 0.4; cursor: not-allowed; }
.button.primary.disabled:hover { background: var(--sand); }
.button.download .version { font-size: 0.7em; opacity: 0.7; }
/* A split button: the platform's download, and a chevron opening its other builds (Windows: Portable). */
.split { display: inline-flex; position: relative; }
.split > .button.download { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-menu { display: flex; padding: 0; border: 0; }
.split-menu summary.button { display: flex; align-items: center; list-style: none; min-width: 0; padding: 0.7rem 0.65rem; border-radius: 0 6px 6px 0; border-left-color: rgba(16, 16, 17, 0.3); cursor: pointer; }
.split-menu summary::-webkit-details-marker { display: none; }
.split-menu summary .icon { transition: transform 0.15s; }
.split-menu[open] summary .icon { transform: rotate(180deg); }
.split-menu .menu { position: absolute; top: calc(100% + 0.35rem); right: 0; z-index: 10; padding: 0.3rem; background: var(--night); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.menu-item { display: flex; cursor: pointer; align-items: center; gap: 0.55rem; padding: 0.55rem 0.8rem; border-radius: 4px; color: var(--text); text-decoration: none; white-space: nowrap; }
.menu-item:hover { background: var(--slate); color: #fff; }
.menu-item .version { font-size: 0.7em; opacity: 0.7; }
.menu-item.disabled, .menu-item.disabled:hover { opacity: 0.4; background: none; cursor: default; }
/* On a phone: the split button across the top, the others two by two under it. */
@media (max-width: 640px) {
  .hero-downloads .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .hero-downloads .split { grid-column: 1 / -1; }
  .hero-downloads .split > .button.download { flex: 1; }
  .hero-downloads .button.download { min-width: 0; }
}

/* Section titles on the home page sit centred; back-to-back sections share one gap instead of two paddings. */
#new > h2, #faq > h2 { text-align: center; }
.highlight:last-child { margin-bottom: 0; }
.band:has(+ .band:not(.alt)) { padding-bottom: 2rem; }
.band + .band:not(.alt) { padding-top: 1rem; }

.mod { margin-bottom: 2.5rem; }
.mod h2 { font-size: 1.3rem; margin-bottom: 0.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0; }
.mod h2 .tag { margin-left: 0.5rem; vertical-align: 0; line-height: 1.6; }
.mod p { color: var(--muted); margin: 0 0 0.75rem; }
.submods { margin: 0 0 0 1.5rem; }
.submods dt { color: var(--text); font-weight: 600; padding: 0.2rem 0; }
.submods dd { margin: -0.3rem 0 0; padding-bottom: 0.45rem; color: var(--muted); }

/* Release notes: the Stable | Preview toggle, top right beside the title. */
.notes-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; margin-bottom: 2rem; }
.notes-head .page-title { margin: 0; grid-column: 2; }
.notes-head .channel-toggle { grid-column: 3; justify-self: end; }
@media (max-width: 640px) {
  .notes-head { grid-template-columns: 1fr; justify-items: center; }
  .notes-head .page-title, .notes-head .channel-toggle { grid-column: 1; justify-self: center; }
}
.channel-toggle { display: flex; align-items: center; gap: 0.6rem; color: var(--slate); font-family: "Chakra Petch", system-ui, sans-serif; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.channel-toggle button { background: none; border: 0; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--muted); cursor: pointer; }
.channel-toggle button:hover { color: var(--text); }
.channel-toggle button[aria-pressed="true"] { color: var(--sand); }
.notes[data-show="stable"] [data-channel="preview"]:not(button),
.notes[data-show="preview"] [data-channel="stable"]:not(button) { display: none; }
.mods-intro { margin: 0 0 1rem; }
.mods-note { margin: 0 0 2.5rem; color: var(--muted); font-size: 0.85rem; }

/* Long reference pages (the Rule hooks page): tables, code, a contents line. */
.doc .lead { font-size: 1.05rem; }
.doc h2 { font-size: 1.35rem; margin-top: 3rem; scroll-margin-top: 6rem; }
.doc h3 { margin-top: 2rem; color: var(--text); font-size: 1.15rem; scroll-margin-top: 6rem; }
.doc p, .doc li { color: var(--muted); }
.doc strong { color: var(--text); }
.doc code { font-family: ui-monospace, Menlo, monospace; font-size: 0.88em; color: var(--text); }
.doc pre { line-height: 1.45; margin: 0.75rem 0 1rem; padding: 0.8rem 1rem; background: var(--night); border: 1px solid var(--slate); border-radius: 6px; overflow-x: auto; }
.doc pre code { font-size: 0.85rem; line-height: inherit; }
.doc table { width: 100%; border-collapse: collapse; margin: 0.75rem 0 1rem; font-size: 0.92rem; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--slate); }
.doc th { color: var(--text); font-weight: 600; }
.doc td { color: var(--muted); }
.doc .table-wrap { overflow-x: auto; }
.toc { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; margin: 1.5rem 0 0; padding: 0.8rem 1rem; border: 1px solid var(--slate); border-radius: 6px; }
.toc a { text-decoration: none; }

.tag.requires { border-color: #b5655b; color: #e08a7f; }

.rules td { font-size: 0.9rem; }
.rules td:first-child { white-space: nowrap; }
.doc th[scope], .doc tbody th { white-space: nowrap; padding-right: 1.5rem; }

/* /stats/: the download counts, numbers right-aligned. */
.doc .stats .n { text-align: right; font-variant-numeric: tabular-nums; }
.doc .stats tfoot th, .doc .stats tfoot td { color: var(--text); font-weight: 600; border-bottom: none; }
