/* The kit's dither (loaded after kit.css).
   The --dz-* textures are drawn by dither.js with the dither-ui engine and set on <html>.
   The colours, type and shape are the design tokens at the top of kit.css; this file only
   adds texture, in six roles:
     rule    a dithered line that frames a region: under the top bar, under a panel's title,
             between the sidebar's blocks
     marker  the state of a control: the open page, the open sub-page, the picked segment, a
             ticked box
     ground  the kit's own button fill, a screen that thickens toward the lower edge, on the
             buttons that act
     plate   a decorative block with no text on it: empty states, a loading bar
     fill    data drawn as dither: the area under a line, a bar, a meter
     art     the kit's poster beside a page's heading, the animated scenes, the class crests,
             and the character's seeded avatar
   Texture frames things; it is never repeated down a table. Badges, chips, fields, table heads
   and rows stay flat, so forty rows read as one surface. */

/* The mark beside the title: the `brand` scene (dither.js adds it), 80 by 16 cells. The name it
   draws stays in the brand (.sd-name) for search engines and screen readers, out of sight (.dz-vh). */
canvas.dz-scene.dz-brand { width: 160px; height: 32px; display: block; }
.dz-vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:root svg image.dz-area { image-rendering: pixelated; pointer-events: none; }
:root svg .dz-area { pointer-events: none; }
:root svg .dz-dot { shape-rendering: crispEdges; }

/* ---- Art ---- */
/* The art stands to the left of a page's heading: the page places the canvas as the first child
   of the heading's block, straight before its heading (the page's h1, or an h2 inside a page), and
   dither.js paints the kit's poster on it. */
canvas.dz-art { position: absolute; left: 0; top: 0; width: 72px; height: 56px; image-rendering: pixelated; pointer-events: none; }
:has(> canvas.dz-art) { position: relative; }
canvas.dz-art + :is(h1, h2), canvas.dz-art + :is(h1, h2) + p.lead { margin-left: 86px; }
canvas.dz-art + :is(h1, h2) { padding-top: 2px; }
@media (max-width: 700px) {
  canvas.dz-art { display: none; }
  canvas.dz-art + :is(h1, h2), canvas.dz-art + :is(h1, h2) + p.lead { margin-left: 0; }
}
/* Scenes (dither.js animates them): inline wherever the page puts one, 72×56px unless the page
   sizes it. As the first child of a heading's block, straight before its heading, a scene stands
   where the poster would. .lg is the larger one (256×128px): its whole block moves right of it. */
canvas.dz-scene { display: inline-block; flex: none; width: 72px; height: 56px; vertical-align: middle; image-rendering: pixelated; pointer-events: none; }
canvas.dz-scene.lg { width: 256px; height: 128px; }
canvas.dz-scene:has(+ :is(h1, h2)) { position: absolute; left: 0; top: 0; }
:has(> canvas.dz-scene + :is(h1, h2)) { position: relative; }
canvas.dz-scene + :is(h1, h2), canvas.dz-scene + :is(h1, h2) + p.lead { margin-left: 86px; }
canvas.dz-scene + :is(h1, h2) { padding-top: 2px; }
:has(> canvas.dz-scene.lg + :is(h1, h2)) { padding-left: 272px; min-height: 128px; }
canvas.dz-scene.lg + :is(h1, h2), canvas.dz-scene.lg + :is(h1, h2) + p.lead { margin-left: 0; }
@media (max-width: 700px) {
  canvas.dz-scene:has(+ :is(h1, h2)) { display: none; }
  canvas.dz-scene + :is(h1, h2), canvas.dz-scene + :is(h1, h2) + p.lead { margin-left: 0; }
  canvas.dz-scene.lg:has(+ :is(h1, h2)) { display: block; position: static; margin: 0 0 var(--s4); }
  :has(> canvas.dz-scene.lg + :is(h1, h2)) { padding-left: 0; min-height: 0; }
}
/* The class crests (the page places the canvas, dither.js paints it): 48px, .sm 22px. */
canvas.dz-crest { display: inline-block; flex: none; width: 48px; height: 48px; vertical-align: middle; image-rendering: pixelated; pointer-events: none; }
canvas.dz-crest.sm { width: 22px; height: 22px; margin-right: 6px; vertical-align: -5px; }
/* The character's avatar, the same height as the picker beside it. */
#dzAvatar, canvas.dz-avatar { box-sizing: content-box; flex: none; width: 24px; height: 24px; border: 1px solid var(--line-2); background: var(--inset); image-rendering: pixelated; }
#dzAvatar[hidden], canvas.dz-avatar[hidden] { display: none; }
/* The wipe's veil lies over the page area only while a page opens. */
#dzWipe { grid-area: view; z-index: 4; background: var(--bg); pointer-events: none; }
#dzWipe[hidden] { display: none; }

/* ---- Rules ---- */
/* The top bar ends on the kit's live field (dither.js): it moves for a moment when you change page, then rests. */
#hdr { border-bottom: 0; padding-bottom: calc(var(--s3) + 8px); }
#hdr > #dzField { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 8px; image-rendering: pixelated; pointer-events: none; }
/* A panel's title and a popover's section titles sit on a rule. */
:root .panel > h2 { border-bottom: 0; padding-bottom: 5px; background: var(--dz-rule) repeat-x left bottom / var(--dz-rule-size); }
:root .pop h3 { padding-bottom: 5px; background: var(--dz-rule) repeat-x left bottom / var(--dz-rule-size); }
/* The sidebar's blocks are parted by a dotted rule, and each group's name runs out into one. */
:root .sd-brand, :root .sd-block { border-bottom-color: transparent; background: var(--dz-sep) repeat-x left bottom / var(--dz-sep-size); }
:root .sd-data { border-top-color: transparent; background: var(--dz-sep) repeat-x left top / var(--dz-sep-size); }
:root #side .nav-h { display: flex; align-items: center; gap: var(--s4); }
:root #side .nav-h::after { content: ''; flex: 1 1 0; height: 2px; background: var(--dz-sep) repeat-x left top / var(--dz-sep-size); }
/* Cards carry a dithered rule along the top edge. */
:root .stat-c, :root .card {
  background-image: var(--dz-frame); background-repeat: repeat-x; background-position: left top; background-size: var(--dz-frame-size); }
/* Notices carry a hatched stripe in their tone down the left side. */
:root .alert { border-left-width: 1px; padding-left: calc(var(--s5) + 10px); background-image: var(--dz-al-n); background-repeat: repeat-y; background-position: left top; background-size: var(--dz-al-n-size); }
:root .alert.bad { background-image: var(--dz-al-r); }
:root .alert.warn { background-image: var(--dz-al-w); }
:root .alert.info { background-image: var(--dz-al-b); }
/* Popovers, the dialog and the tooltip open under a short rule. */
:root :is(.pop, #uiTip, .modal > .card) { background-image: var(--dz-pop); background-repeat: repeat-x; background-position: left top; background-size: var(--dz-pop-size); border-top-color: transparent; }
:root #uiTip { padding-top: calc(var(--s3) + 3px); }

/* ---- Markers and grounds: the open page, the open sub-page, the picked segment, a ticked box, the buttons that act ---- */
:root .tab { position: relative; }
:root .tab.on { border-left-color: transparent; }
:root .tab.on::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--dz-vmark) left top / var(--dz-vmark-size); }
/* A box is ticked by filling it: a screened square of the accent inside a clear ring. */
:root input[type=checkbox] { appearance: none; -webkit-appearance: none; border: 1px solid var(--line-2); background: var(--inset); cursor: pointer; }
:root input[type=checkbox]:hover { border-color: var(--dim); }
:root input[type=checkbox]:checked { border-color: var(--accent); background: var(--accent) var(--dz-screen) left top / var(--dz-screen-size); box-shadow: inset 0 0 0 2px var(--inset); }
:root input[type=checkbox]:disabled { opacity: .5; cursor: default; }
:root .fsub.on { border-bottom-color: transparent; background: var(--dz-mark) repeat-x left bottom / var(--dz-mark-size); }
:root .btn { background: var(--accent-bg) var(--dz-btn) repeat-x left bottom / var(--dz-btn-size); }
:root .btn:hover { background-color: #172a44; }
:root .cta { background: var(--good-bg) var(--dz-cta) repeat-x left bottom / var(--dz-cta-size); }
:root .cta:hover, :root .cta.on { background-color: #17361f; }
:root .csubs button.on { background: var(--accent-bg) var(--dz-btn) repeat-x left bottom / var(--dz-btn-size); }

/* ---- Fills ---- */
/* Progress as dither: dither.js prints the kit's meter over the plain bar. */
:root .meter.dz { background: none; }
:root .meter.dz > i { visibility: hidden; }

/* ---- Dialog and scrollbars ---- */
/* A dialog dims the page through a screen, not a wash. */
:root .modal { background: #0006 var(--dz-veil) left top / var(--dz-veil-size); }
/* A screened thumb in a recessed track (browsers that can style them). */
@supports selector(::-webkit-scrollbar) {
  :root, :root body * { scrollbar-width: auto; scrollbar-color: auto; }
  :root ::-webkit-scrollbar { width: 10px; height: 10px; background: var(--inset); }
  :root ::-webkit-scrollbar-thumb { background: var(--line) var(--dz-thumb) left top / var(--dz-thumb-size); border: 1px solid var(--line-2); }
  :root ::-webkit-scrollbar-thumb:hover { background-image: var(--dz-thumb-on); }
  :root ::-webkit-scrollbar-corner { background: var(--inset); }
}

/* ---- Plates: empty states. Text never sits on them. ---- */
:root .empty::before { width: 128px; height: 28px; opacity: 1; border-radius: 0; background: var(--dz-poster) no-repeat center / var(--dz-poster-size); }
/* Something loading shows the kit's running bar: a band of ink stepping along a faint track. */
:root .empty.loading::before { width: 120px; height: 6px; background: var(--dz-run) repeat-x 0 0 / var(--dz-run-size); animation: dz-run 1.5s steps(30) infinite; }
@keyframes dz-run { to { background-position-x: 120px; } }
@media (prefers-reduced-motion: reduce) { :root .empty.loading::before { animation: none; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
