/* The site's look. Every class is `doc-`; dj-spellbook's `spell-` classes are its own.
   Element rules that could reach a rendered example sit in an @scope that stops at
   .doc-example-frame, so an example shows the package's real output. */

:root {
  --doc-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --doc-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --doc-radius: 8px;
  --doc-gutter: 16px;

  --doc-page: #f0e6d2;
  --doc-card: #fff8e7;
  --doc-border: #8b4a1c;
  --doc-rule: #d8c5a6;
  --doc-text: #2b2118;
  --doc-muted: #5e4b39;
  --doc-link: #8a3a0c;
  --doc-bar: #7b3a10;
  --doc-bar-text: #fff3df;
  --doc-tab: #ecd7b8;
  --doc-tab-text: #6a2c08;
  --doc-box: #f5e8d1;
  --doc-box-edge: #c4ad8a;
  --doc-current: #e6cca9;
  --doc-inline-bg: #eedcc0;
  --doc-inline-text: #3a2312;
  --doc-code-bg: #2b2623;
  --doc-code-text: #f1e9dc;
  --doc-code-edge: #9a531f;
  --doc-code-comment: #9ccf8f;
  --doc-frame: #ffffff;
  --doc-shadow: 0 1px 3px rgb(60 35 10 / 0.18);
  color-scheme: light;
}

/* Dark before any script runs, when the reader's system asks for it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --doc-page: #1b1510;
    --doc-card: #271f18;
    --doc-border: #9a6236;
    --doc-rule: #4a3a2b;
    --doc-text: #ece2d2;
    --doc-muted: #c2b19b;
    --doc-link: #f2b57c;
    --doc-bar: #3b1f0d;
    --doc-bar-text: #f6e6cf;
    --doc-tab: #573519;
    --doc-tab-text: #fbe5c6;
    --doc-box: #33281e;
    --doc-box-edge: #6b5139;
    --doc-current: #4b3420;
    --doc-inline-bg: #3d3024;
    --doc-inline-text: #f5e3c8;
    --doc-code-bg: #120e0b;
    --doc-code-text: #eee4d4;
    --doc-code-edge: #b36a33;
    --doc-code-comment: #92cd86;
    --doc-frame: #201913;
    --doc-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --doc-page: #1b1510;
  --doc-card: #271f18;
  --doc-border: #9a6236;
  --doc-rule: #4a3a2b;
  --doc-text: #ece2d2;
  --doc-muted: #c2b19b;
  --doc-link: #f2b57c;
  --doc-bar: #3b1f0d;
  --doc-bar-text: #f6e6cf;
  --doc-tab: #573519;
  --doc-tab-text: #fbe5c6;
  --doc-box: #33281e;
  --doc-box-edge: #6b5139;
  --doc-current: #4b3420;
  --doc-inline-bg: #3d3024;
  --doc-inline-text: #f5e3c8;
  --doc-code-bg: #120e0b;
  --doc-code-text: #eee4d4;
  --doc-code-edge: #b36a33;
  --doc-code-comment: #92cd86;
  --doc-frame: #201913;
  --doc-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

/* Q1 A: in the dark theme the examples get dark --spell-* values, inside the frame only.
   The package stylesheet is never edited. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .doc-example-frame {
    --spell-border: #5d4936;
    --spell-surface: #30261d;
    --spell-info: #6aa8e4;
    --spell-warning: #e2a446;
    --spell-success: #5cbf88;
    --spell-danger: #f07b72;
  }
}
:root[data-theme="dark"] .doc-example-frame {
  --spell-border: #5d4936;
  --spell-surface: #30261d;
  --spell-info: #6aa8e4;
  --spell-warning: #e2a446;
  --spell-success: #5cbf88;
  --spell-danger: #f07b72;
}

/* Base */
@scope (body) to (.doc-example-frame) {
  :scope, *, *::before, *::after { box-sizing: border-box; }
  [hidden] { display: none !important; }
  :focus-visible { outline: 2px solid var(--doc-link); outline-offset: 2px; }
}
/* A jump lands below the sticky bar, and glides unless the reader asked for less motion. */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--doc-page);
  color: var(--doc-text);
  font: 1.0625rem/1.6 var(--doc-serif);
  overflow-wrap: break-word;
}
.doc-home, body > .doc-page, .doc-layout { flex: 1 0 auto; }
.doc-hidden-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.doc-skip {
  position: absolute; left: var(--doc-gutter); top: -3rem; z-index: 50;
  padding: 0.5rem 0.75rem; border-radius: var(--doc-radius);
  background: var(--doc-card); color: var(--doc-link);
}
.doc-skip:focus { top: 0.5rem; }

/* Top bar: the site name in a lighter tab, the theme toggle at the far end. */
.doc-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem var(--doc-gutter);
  background: var(--doc-bar);
  color: var(--doc-bar-text);
  box-shadow: 0 2px 0 rgb(0 0 0 / 0.15);
}
.doc-brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.35rem 1rem 0.35rem 0.5rem;
  border-radius: var(--doc-radius);
  background: var(--doc-tab);
  color: var(--doc-tab-text);
  font: 700 1.3rem/1.2 var(--doc-serif);
  text-decoration: none;
}
.doc-brand img { display: block; border-radius: 6px; }
.doc-theme, .doc-menu {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; padding: 0;
  border: 1px solid rgb(255 255 255 / 0.25); border-radius: var(--doc-radius);
  background: transparent; color: var(--doc-bar-text);
  cursor: pointer;
}
.doc-theme { margin-left: auto; }
.doc-theme[aria-pressed="true"] { background: rgb(255 255 255 / 0.12); }
.doc-menu { display: none; }

/* Packages: each package's icon, then one button per registry. In the bar from
   tablet width up; on a phone the same links sit in the footer. */
.doc-packages { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem; }
.doc-packages-bar { display: none; margin-left: auto; }
.doc-package {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.2rem 0.25rem 0.2rem 0.4rem;
  border: 1px solid rgb(255 255 255 / 0.25); border-radius: var(--doc-radius);
  font: 0.8rem/1.2 var(--doc-mono);
}
.doc-package img { display: block; border-radius: 5px; }
.doc-package-name { display: none; }
.doc-package a {
  padding: 0.35rem 0.55rem; border-radius: 5px;
  background: rgb(255 255 255 / 0.12); color: inherit; text-decoration: none;
}
.doc-package a:hover { background: var(--doc-tab); color: var(--doc-tab-text); }
.doc-packages-foot { margin-bottom: 0.9rem; }
.doc-packages-foot .doc-package-name { display: inline; }
@media (min-width: 48rem) {
  .doc-packages-bar { display: flex; }
  .doc-packages-bar + .doc-theme { margin-left: 0; }
  .doc-packages-foot { display: none; }
}
@media (min-width: 64rem) { .doc-package-name { display: inline; margin-right: 0.15rem; } }

/* Cards: cream with a thin brown edge. */
.doc-page, .doc-sidebar, .doc-home-sections section, .doc-home > .doc-prose {
  background: var(--doc-card);
  border: 1px solid var(--doc-border);
  border-radius: var(--doc-radius);
  box-shadow: var(--doc-shadow);
}

/* Doc layout: sidebar and the page on desktop; the sidebar becomes a drawer on a phone. */
.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  width: 100%;
  max-width: 76rem;
  margin: 0 auto;
  padding: 1.25rem var(--doc-gutter) 2rem;
}
.doc-sidebar { padding: 0.75rem; font-family: var(--doc-mono); font-size: 0.9rem; }
/* A section label is small capitals over a rule; its pages hang off a guide line. */
.doc-sidebar h2 {
  margin: 1.25rem 0.5rem 0.4rem; padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--doc-rule);
  color: var(--doc-muted);
  font: 700 0.72rem/1.3 var(--doc-mono);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.doc-sidebar h2:first-child { margin-top: 0.25rem; }
.doc-sidebar ul {
  margin: 0 0 0 0.5rem; padding: 0 0 0 0.25rem; list-style: none;
  border-left: 1px solid var(--doc-box-edge);
}
.doc-sidebar a {
  display: block; padding: 0.4rem 0.5rem; border-radius: 6px;
  color: var(--doc-text); text-decoration: none;
}
.doc-sidebar a:hover { background: var(--doc-box); }
.doc-sidebar a[aria-current="page"] { background: var(--doc-current); font-weight: 700; }
.doc-backdrop { display: none; }

@media (min-width: 48rem) {
  .doc-layout { grid-template-columns: 17rem minmax(0, 1fr); align-items: start; }
  .doc-sidebar { position: sticky; top: 4.5rem; max-height: calc(100vh - 5.5rem); overflow-y: auto; }
}
@media (max-width: 47.99rem) {
  .js .doc-menu { display: inline-flex; }
  .js .doc-sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
    width: min(18rem, 85vw);
    border-radius: 0 var(--doc-radius) var(--doc-radius) 0;
    overflow-y: auto;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .js.doc-drawer-open .doc-sidebar {
    transform: none; visibility: visible;
    transition: transform 0.2s ease;
  }
  .js.doc-drawer-open .doc-backdrop {
    display: block; position: fixed; inset: 0; z-index: 30;
    background: rgb(20 10 0 / 0.45);
  }
  .js.doc-drawer-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .js .doc-sidebar, .js.doc-drawer-open .doc-sidebar { transition: none; }
}

/* The page */
.doc-page { min-width: 0; padding: 1.25rem var(--doc-gutter) 1.5rem; }
body > .doc-page { width: calc(100% - 2 * var(--doc-gutter)); max-width: 60rem; margin: 1.25rem auto 2rem; }
.doc-title {
  display: inline-block; max-width: 100%;
  margin: 0 0 1rem; padding: 0.35rem 1rem;
  background: var(--doc-box);
  border: 2px solid var(--doc-box-edge);
  border-radius: 4px;
  box-shadow: inset 0 0 6px rgb(120 80 30 / 0.18);
  font: 700 clamp(1.6rem, 5vw, 2.2rem)/1.2 var(--doc-serif);
}
@media (min-width: 48rem) { .doc-page { padding: 1.75rem 2.25rem 2rem; } }

/* On this page */
.doc-contents {
  width: fit-content; min-width: min(100%, 18rem); max-width: 100%;
  margin: 0 0 1.5rem; padding: 0.6rem;
  border: 1px solid var(--doc-box-edge);
  background: var(--doc-box);
  border-radius: 6px;
  font-family: var(--doc-mono); font-size: 0.85rem;
}
.doc-contents-label {
  margin: 0 0.5rem 0.4rem; padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--doc-box-edge);
  color: var(--doc-muted);
  font: 700 0.95rem/1.3 var(--doc-serif);
}
.doc-contents ul { margin: 0; padding: 0; list-style: none; }
.doc-contents a {
  display: block; padding: 0.3rem 0.5rem; border-radius: 4px;
  color: var(--doc-text); text-decoration: none;
}
.doc-contents a::before { content: "#"; margin-right: 0.5rem; color: var(--doc-border); }
.doc-contents a:hover { background: var(--doc-current); }
.doc-contents .doc-contents-h3 { margin-left: 1rem; border-left: 1px solid var(--doc-box-edge); }
.doc-contents .doc-contents-h3 a { margin-left: 0.35rem; color: var(--doc-muted); }

/* Prose: element rules stop at a rendered example. Class rules outside the scope
   (.doc-example-source, .doc-note) outrank these, which carry only element weight. */
@scope (.doc-prose) to (.doc-example-frame) {
  :scope > :first-child { margin-top: 0; }
  :is(p, ul, ol, table, blockquote, figure) { margin: 0 0 1rem; }
  :is(ul, ol) { padding-left: 1.5rem; }
  li { margin: 0.2rem 0; }
  a:not(.doc-heading-link) { color: var(--doc-link); text-underline-offset: 2px; }
  h2 {
    display: inline-block; max-width: 100%;
    margin: 1.75rem 0 0.9rem; padding: 0.25rem 0.85rem;
    background: var(--doc-box);
    border: 2px solid var(--doc-box-edge);
    border-radius: 4px;
    font: 700 1.4rem/1.25 var(--doc-serif);
  }
  h3 { margin: 1.5rem 0 0.6rem; font: 700 1.15rem/1.3 var(--doc-serif); }
  h4 { margin: 1.25rem 0 0.5rem; font: 700 1rem/1.3 var(--doc-serif); }
  blockquote { padding: 0.25rem 1rem; border-left: 3px solid var(--doc-rule); color: var(--doc-muted); }
  hr { margin: 2rem 0; border: 0; border-top: 1px solid var(--doc-rule); }
  code {
    padding: 0.1em 0.35em; border-radius: 4px;
    background: var(--doc-inline-bg); color: var(--doc-inline-text);
    font: 0.88em/1.4 var(--doc-mono);
  }
  table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
  :is(th, td) { padding: 0.45rem 0.7rem; border: 1px solid var(--doc-rule); text-align: left; vertical-align: top; }
  th { background: var(--doc-box); }

  /* Code listings: dark, a brown left edge, a copy button. */
  pre {
    margin: 0 0 1rem; padding: 0.9rem 1rem 0.9rem 1.1rem;
    overflow-x: auto;
    background: var(--doc-code-bg); color: var(--doc-code-text);
    border-left: 4px solid var(--doc-code-edge);
    border-radius: 6px;
    box-shadow: var(--doc-shadow);
    font: 0.88rem/1.55 var(--doc-mono);
    tab-size: 4;
  }
  pre code { padding: 0; background: none; color: inherit; font: inherit; }
  .doc-code > pre { padding-right: 4.75rem; }
  .doc-note > :last-child { margin-bottom: 0; }

  /* A phone stacks each table row, its column heads as labels, and wraps listings:
     nothing scrolls sideways at 390px. */
  @media (max-width: 47.99rem) {
    :is(table, tbody, tr, td) { display: block; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    tr { margin-bottom: 0.75rem; border: 1px solid var(--doc-rule); border-radius: 6px; }
    td { border: 0; border-top: 1px solid var(--doc-rule); }
    td:first-child { border-top: 0; background: var(--doc-box); }
    td::before { content: attr(data-label); display: block; color: var(--doc-muted); font-size: 0.8rem; }
    pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  }
}
.doc-heading-link { color: inherit; text-decoration: none; }
.doc-heading-link:hover::after { content: " #"; color: var(--doc-muted); }
.doc-code-comment { color: var(--doc-code-comment); }
.doc-code { position: relative; }
.doc-copy {
  position: absolute; top: 0.45rem; right: 0.45rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgb(255 255 255 / 0.3); border-radius: 4px;
  background: var(--doc-code-bg); color: var(--doc-code-text);
  box-shadow: -0.5rem 0 0.5rem var(--doc-code-bg);
  font: 0.75rem/1.4 var(--doc-mono);
  cursor: pointer;
}
.doc-copy:hover { border-color: rgb(255 255 255 / 0.6); }

/* The site's note block */
.doc-note {
  margin: 0 0 1rem; padding: 0.75rem 1rem;
  border: 1px solid var(--doc-rule); border-left: 4px solid var(--doc-border);
  border-radius: 6px;
  background: var(--doc-box);
}

/* An example: its source listing, then the real output in a frame, or its refusal. */
.doc-example { margin: 0 0 1.5rem; }
.doc-example-source { margin-bottom: 0; border-radius: 6px 6px 0 0; }
.doc-example-frame {
  display: flow-root;
  padding: 0 1rem;
  border: 1px solid var(--doc-rule); border-top: 0;
  border-radius: 0 0 6px 6px;
  background: var(--doc-frame);
}
/* Rendered with no listing: the page's own words, so no frame around them. */
.doc-example-bare { margin: 0 0 1.5rem; padding: 0; border: 0; background: none; }
.doc-example-bare a { color: var(--doc-link); }
.doc-example-refusal {
  border-radius: 0 0 6px 6px; border-left-color: #b4432c;
  white-space: pre-wrap;
  box-shadow: none;
}

/* Previous and next */
.doc-pager {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  margin-top: 2rem; padding-top: 1.25rem;
  border-top: 1px solid var(--doc-rule);
}
.doc-pager a {
  flex: 1 1 12rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--doc-box-edge); border-radius: 6px;
  background: var(--doc-box);
  color: var(--doc-link); text-decoration: none;
}
.doc-pager a:hover { border-color: var(--doc-border); }
.doc-pager a[rel="prev"]::before { content: "\2190\00a0"; }
.doc-pager a[rel="next"] { text-align: right; }
.doc-pager a[rel="next"]::after { content: "\00a0\2192"; }

/* Home: monospace prose in a card, then the sections as cards. */
.doc-home {
  width: 100%; max-width: 60rem;
  margin: 0 auto; padding: 1.25rem var(--doc-gutter) 2rem;
}
.doc-home > .doc-prose { padding: 1.25rem var(--doc-gutter); font: 0.95rem/1.75 var(--doc-mono); }
.doc-home-sections {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  margin-top: 1.25rem;
}
.doc-home-sections section { padding: 1rem 1.25rem; }
.doc-home-sections h2 { margin: 0 0 0.5rem; font: 700 1.2rem/1.3 var(--doc-serif); }
.doc-home-sections ul { margin: 0; padding-left: 1.2rem; font-family: var(--doc-mono); font-size: 0.9rem; }
.doc-home-sections a { color: var(--doc-link); }
@media (min-width: 48rem) { .doc-home > .doc-prose { padding: 1.75rem 2.25rem; } }

/* Footer: Storm, once. */
.doc-footer {
  margin-top: 1.5rem; padding: 1.5rem var(--doc-gutter) 1.75rem;
  background: var(--doc-bar); color: var(--doc-bar-text);
  font-size: 0.9rem;
  text-align: center;
}
.doc-footer p { max-width: 60rem; margin: 0 auto; opacity: 0.85; }
.doc-footer .doc-footer-storm { margin-bottom: 0.4rem; font-size: 1rem; opacity: 1; }
.doc-footer a { color: inherit; text-underline-offset: 0.2em; }
.doc-footer .doc-footer-built { margin-top: 1rem; font: 0.8rem/1.3 var(--doc-mono); }
.doc-footer-built svg { vertical-align: -0.15em; }
