/* pixfx site: one stylesheet for the landing page and the docs.
   Colours come from the effects' own ramps: night ground, wax text, flame and ember, the candle's blue root. */

:root {
  --night: #13101b;
  --ground: #1e1a24;
  --soot: #2f2a38;
  --wax: #f0dcc0;
  --ash: #b8a48e;
  --flame: #ffc23d;
  --ember: #f2561d;
  --root: #7fb4ff;
  --display: "Pixelify Sans", ui-monospace, monospace;
  --body: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --measure: 72ch;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--night); color: var(--wax); }

body {
  margin: 0;
  font: 400 1rem/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--flame); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: #ffe26b; }

:focus-visible { outline: 2px solid var(--flame); outline-offset: 2px; }

h1, h2 { font-family: var(--display); font-weight: 500; line-height: 1.15; letter-spacing: 0.01em; }
h3, h4 { font-family: var(--body); font-weight: 600; line-height: 1.3; }
h1 { font-size: 2.44rem; margin: 0 0 1rem; }
h2 { font-size: 1.95rem; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1.25rem; margin: 2rem 0 0.5rem; }
h4 { font-size: 1rem; margin: 1.5rem 0 0.25rem; }
p, ul, ol { margin: 0 0 1rem; }
li { margin: 0.25rem 0; }

code, pre, kbd { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code { color: var(--root); background: var(--ground); padding: 0.1em 0.35em; border-radius: 2px; }

pre {
  position: relative;
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  background: var(--ground);
  border-left: 3px solid var(--ember);
  line-height: 1.5;
  tab-size: 2;
}
pre code { color: var(--wax); }

.copy {
  position: absolute; top: 0.4rem; right: 0.4rem;
  font: 500 0.75rem var(--body); color: var(--ash);
  background: var(--night); border: 1px solid var(--soot); padding: 0.15rem 0.5rem; cursor: pointer;
}
.copy:hover { color: var(--wax); }

table { border-collapse: collapse; width: 100%; margin: 0 0 1.25rem; font-size: 0.95rem; }
th, td { text-align: left; vertical-align: top; padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--soot); }
th { font-weight: 600; color: var(--ash); }
.table-wrap { overflow-x: auto; }

.muted { color: var(--ash); }

.button {
  display: inline-block; padding: 0.65rem 1.1rem;
  font: 600 1rem var(--body); text-decoration: none;
  color: var(--night); background: var(--flame); border: 2px solid var(--flame);
}
.button:hover { color: var(--night); background: #ffe26b; border-color: #ffe26b; }
.button.quiet { color: var(--wax); background: transparent; border-color: var(--soot); }
.button.quiet:hover { border-color: var(--wax); }

.swatches { display: inline-flex; vertical-align: middle; }
.swatches span { width: 14px; height: 14px; display: inline-block; }

/* ---------- site header ---------- */

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--soot);
}
.topbar .brand { font: 500 1.4rem var(--display); color: var(--wax); text-decoration: none; }
.topbar nav { display: flex; gap: 1.25rem; margin-left: auto; }
.topbar nav a { color: var(--ash); text-decoration: none; }
.topbar nav a:hover, .topbar nav a[aria-current] { color: var(--wax); }
.landing .topbar { position: absolute; inset: 0 0 auto; z-index: 2; border-bottom: 0; padding-left: var(--edge); padding-right: var(--edge); }
/* the left edge of the centred sections, so full-bleed parts line up with them */
.landing { --edge: max(clamp(1rem, 4vw, 2.5rem), calc((100vw - 76rem) / 2 + clamp(1rem, 4vw, 2.5rem))); }

/* ---------- landing ---------- */

.hero { position: relative; min-height: min(78vh, 640px); overflow: hidden; }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; cursor: crosshair; }
.intro-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem;
  max-width: 76rem; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 0;
}
.intro-strip .pitch { flex: 1 1 28rem; max-width: 40rem; }
.intro-strip .lede { font-size: 1.15rem; line-height: 1.5; margin: 0; }
.intro-strip .proof { margin: 0.6rem 0 0; color: var(--ash); font-size: 0.95rem; line-height: 1.5; font-variant-numeric: tabular-nums; }
.intro-strip .proof b { color: var(--flame); font-weight: 600; }
.intro-strip .actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.section { padding: 4rem clamp(1rem, 4vw, 2.5rem); max-width: 76rem; margin: 0 auto; }
.section > h2 { margin-top: 0; }
.section > .intro { max-width: 60ch; color: var(--ash); font-size: 1.1rem; }



.controls { display: grid; grid-template-columns: auto 1fr auto; gap: 0.4rem 0.75rem; align-items: center; font-size: 0.9rem; }
.controls label { color: var(--ash); }
.controls output { font-family: var(--mono); font-size: 0.85rem; min-width: 3ch; text-align: right; }
.controls select, .controls button {
  grid-column: 2 / 4; font: inherit; color: var(--wax); background: var(--night);
  border: 1px solid var(--soot); padding: 0.3rem 0.5rem;
}
.controls button { cursor: pointer; }
.controls button:hover { border-color: var(--wax); }
input[type="range"] { accent-color: var(--flame); width: 100%; }

/* ---------- effects: the gallery of stills, and one effect's page ---------- */

.page { padding: 2.5rem clamp(1rem, 4vw, 2.5rem) 4rem; max-width: 76rem; margin: 0 auto; }
.page > .lead { max-width: 60ch; color: var(--ash); font-size: 1.1rem; }
.cards { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1.25rem; }
.cards li { margin: 0; }
.card { display: flex; flex-direction: column; gap: 0.2rem; text-decoration: none; color: var(--wax); background: var(--ground); padding: 0 0 0.9rem; border: 1px solid transparent; }
.card canvas { width: 100%; height: auto; aspect-ratio: 4 / 3; image-rendering: pixelated; display: block; margin-bottom: 0.6rem; }
.card-name { font-weight: 600; padding: 0 1rem; }
.card .card-id { background: none; padding: 0 1rem; font-size: 0.8rem; color: var(--ash); }
.card:hover, .card:focus-visible { border-color: var(--flame); color: var(--wax); }
.card:hover .card-name { color: var(--flame); }

.crumbs { margin: 0 0 0.5rem; font-size: 0.95rem; }
.effect-page .page > .lead { max-width: 70ch; }
.effect-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(18rem, 2fr); gap: 2rem; align-items: start; margin-top: 1.5rem; }
.effect-stage { margin: 0; }
.effect-mode { display: flex; gap: 0.25rem; margin-bottom: 0.6rem; font-size: 0.9rem; }
.effect-mode label {
  position: relative; color: var(--ash); background: var(--night); border: 1px solid var(--soot);
  padding: 0.3rem 0.75rem; cursor: pointer;
}
.effect-mode input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.effect-mode label:hover { color: var(--wax); border-color: var(--wax); }
.effect-mode label:has(:checked) { color: var(--wax); border-color: var(--flame); }
.effect-mode label:has(:focus-visible) { outline: 2px solid var(--flame); outline-offset: 2px; }
.effect-caption { margin: 0.6rem 0 0; color: var(--ash); font-size: 0.95rem; }
.effect-stage canvas { width: 100%; height: auto; image-rendering: pixelated; display: block; background: var(--ground); border: 1px solid var(--soot); }
.effect-side { display: flex; flex-direction: column; gap: 1.25rem; }
.effect-side pre { margin: 0; font-size: 0.85rem; border-left-color: var(--soot); }
.effect-side table { margin: 0; }
.effect-code [role="tablist"] { margin-bottom: 0.5rem; }
.effect-code [role="tab"] { font-size: 0.85rem; }
.effect-code-docs { margin: 0.4rem 0 0; font-size: 0.85rem; }
.page .pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--soot); }
.page .pager a { text-decoration: none; }

.tabs [role="tablist"] { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--soot); margin-bottom: 1.25rem; }
.tabs [role="tab"] {
  font: 500 0.95rem var(--body); color: var(--ash); background: none; border: 0;
  border-bottom: 3px solid transparent; padding: 0.6rem 0.9rem; cursor: pointer;
}
.tabs [role="tab"]:hover { color: var(--wax); }
.tabs [role="tab"][aria-selected="true"] { color: var(--wax); border-bottom-color: var(--flame); }
.tabs [role="tabpanel"] { max-width: var(--measure); }

.steps { counter-reset: step; list-style: none; padding: 0; max-width: var(--measure); }
.steps > li { counter-increment: step; position: relative; padding-left: 2.75rem; margin-bottom: 1.5rem; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  font: 500 1.4rem/1 var(--display); color: var(--flame);
}

.footer { border-top: 1px solid var(--soot); padding: 2rem clamp(1rem, 4vw, 2.5rem); color: var(--ash); font-size: 0.9rem; }
.footer p { max-width: var(--measure); }

/* ---------- docs ---------- */

.docs-shell {
  display: grid; grid-template-columns: 15rem minmax(0, 1fr) 13rem; gap: 2.5rem;
  max-width: 82rem; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem);
}
.sidebar { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding: 2rem 0; font-size: 0.95rem; }
.sidebar h4 { margin: 1.25rem 0 0.35rem; color: var(--ash); font-size: 0.85rem; font-weight: 500; }
.sidebar h4:first-child { margin-top: 0; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar a { display: block; padding: 0.2rem 0 0.2rem 0.75rem; color: var(--wax); text-decoration: none; border-left: 2px solid var(--soot); }
.sidebar a:hover { border-left-color: var(--ash); }
.sidebar a[aria-current="page"] { color: var(--flame); border-left-color: var(--flame); }

.doc { padding: 2rem 0 4rem; max-width: var(--measure); }
.doc h2 { scroll-margin-top: 1rem; }
.doc h3 { scroll-margin-top: 1rem; }
.doc .pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--soot); }
.doc .pager a { text-decoration: none; }
.doc .pager small { display: block; color: var(--ash); }
.doc .note { border-left: 3px solid var(--root); padding: 0.5rem 1rem; background: var(--ground); margin: 0 0 1.25rem; }
.doc .note > :last-child { margin-bottom: 0; }

.toc { position: sticky; top: 0; align-self: start; padding: 2rem 0; font-size: 0.85rem; }
.toc h4 { margin: 0 0 0.5rem; color: var(--ash); font-weight: 500; }
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc a { display: block; padding: 0.15rem 0; color: var(--ash); text-decoration: none; }
.toc a:hover { color: var(--wax); }

.menu-toggle { display: none; }

/* ---------- narrow screens ---------- */

@media (max-width: 1100px) {
  .docs-shell { grid-template-columns: 14rem minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 900px) {
  .effect-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { position: static; max-height: none; padding: 1rem 0 0; display: none; }
  .sidebar.open { display: block; }
  .menu-toggle {
    display: inline-block; margin-left: auto; font: 500 0.95rem var(--body);
    color: var(--wax); background: none; border: 1px solid var(--soot); padding: 0.3rem 0.7rem;
  }
  .docs-page .topbar nav { display: none; }
  .hero { min-height: 62vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ---------- fx layer (assets/fx.js) ---------- */

.fx-overlay, .fx-screen { position: fixed; left: 0; top: 0; pointer-events: none; image-rendering: pixelated; }
.fx-overlay { z-index: 900; }
/* the burn between pages: its edge and smoke over the leaving page, its light added on top */
.fx-screen { z-index: 1000; }
.fx-light { mix-blend-mode: plus-lighter; }
/* the page being left, kept on top of the new one (scrolled as it was) while the burn takes it away */
.page-leaving { position: fixed; inset: 0; z-index: 800; overflow: hidden; background: var(--night); mask-repeat: no-repeat; }

.fx-switch {
  font: 500 0.85rem var(--body); color: var(--ash); background: none;
  border: 1px solid var(--soot); padding: 0.2rem 0.6rem; cursor: pointer;
}
.fx-switch:hover { color: var(--wax); border-color: var(--wax); }
.fx-switch[aria-pressed="true"] { color: var(--flame); }

/* a click waiting on the network for its page (nav.js) */
html[aria-busy="true"], html[aria-busy="true"] * { cursor: progress; }
/* with fx off the browser changes pages itself: the new page fades in, with no blank frame between */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

/* the duel's tooltips: what a skill or a buff under the pointer is */
/* The duel's tooltip, in the duel's own pixels (--px is one of them): a stepped bronze frame like the bars', a header
   band in the tier's or buff's colour, flat fills and dotted rules. */
.duel-tip {
  --px: 3px; --tone: #c8c8c8; --deep: #2a1c0e; --bronze: #b8893c;
  position: fixed; z-index: 30; min-width: 200px; max-width: 290px; margin: calc(var(--px) * 2);
  background: #120d18; color: #c8c0d4; text-align: center; pointer-events: none;
  font: 500 0.85rem/1.4 var(--display); letter-spacing: 0.02em;
  /* a bronze ring with its corners cut, then a dark outline stepped round them */
  box-shadow:
    calc(var(--px) * -1) 0 0 0 var(--bronze), var(--px) 0 0 0 var(--bronze),
    0 calc(var(--px) * -1) 0 0 var(--bronze), 0 var(--px) 0 0 var(--bronze),
    calc(var(--px) * -2) 0 0 0 var(--deep), calc(var(--px) * 2) 0 0 0 var(--deep),
    0 calc(var(--px) * -2) 0 0 var(--deep), 0 calc(var(--px) * 2) 0 0 var(--deep),
    calc(var(--px) * -1) calc(var(--px) * -1) 0 0 var(--deep), var(--px) calc(var(--px) * -1) 0 0 var(--deep),
    calc(var(--px) * -1) var(--px) 0 0 var(--deep), var(--px) var(--px) 0 0 var(--deep),
    inset 0 var(--px) 0 0 #f0cf7a40;
}
.duel-tip[data-tone="common"] { --tone: #f0cf7a; }
.duel-tip[data-tone="rare"] { --tone: #6fb3ff; }
.duel-tip[data-tone="epic"] { --tone: #c88bff; }
.duel-tip[data-tone="legendary"] { --tone: #ff9a1a; }
.duel-tip[data-tone="ultimate"] { --tone: #3fd1c6; }
.duel-tip[data-tone="good"] { --tone: #6fd77a; --bronze: #3fae5a; }
.duel-tip[data-tone="bad"] { --tone: #ee5a4c; --bronze: #c8322a; }
.duel-tip .tip-head {
  position: relative; padding: calc(var(--px) * 2) calc(var(--px) * 9); color: var(--tone);
  background: color-mix(in srgb, var(--tone) 18%, #120d18);
  border-bottom: var(--px) solid color-mix(in srgb, var(--tone) 55%, #120d18);
}
/* the header's end pieces: a pixel diamond either side */
.duel-tip .tip-head::before, .duel-tip .tip-head::after {
  --p: var(--px); --n: calc(var(--px) * -1); --p2: calc(var(--px) * 2); --n2: calc(var(--px) * -2);
  content: ""; position: absolute; top: calc(50% - var(--px) / 2); width: var(--px); height: var(--px); background: var(--tone);
  box-shadow:
    var(--p) 0 var(--tone), var(--n) 0 var(--tone), 0 var(--p) var(--tone), 0 var(--n) var(--tone),
    var(--p2) 0 var(--tone), var(--n2) 0 var(--tone), 0 var(--p2) var(--tone), 0 var(--n2) var(--tone),
    var(--p) var(--p) var(--tone), var(--n) var(--p) var(--tone), var(--p) var(--n) var(--tone), var(--n) var(--n) var(--tone);
}
.duel-tip .tip-head::before { left: calc(var(--px) * 4); }
.duel-tip .tip-head::after { right: calc(var(--px) * 4); }
.duel-tip h3 { margin: 0; font: inherit; font-size: 1.05rem; line-height: 1.2; color: inherit; text-shadow: 0 2px 0 #000; }
.duel-tip .tip-type { margin: 0; font-size: 0.75rem; color: color-mix(in srgb, var(--tone) 70%, #c8c0d4); }
.duel-tip .tip-body { padding: calc(var(--px) * 2) calc(var(--px) * 4) calc(var(--px) * 3); }
.duel-tip p { margin: 0; }
.duel-tip hr {
  height: var(--px); width: 60%; margin: calc(var(--px) * 2) auto; border: 0;
  background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--tone) 60%, #120d18) 0 var(--px), transparent var(--px) calc(var(--px) * 2));
}
.duel-tip .tip-prop { color: #7f7890; }
.duel-tip .tip-prop span { color: #fff; }
.duel-tip .tip-text { color: #c8c0d4; }
.duel-tip .tip-mod { color: #8a8cff; }
