/* MakerSketch docs: the app's look on the web. Colours are the app's own (themes.css, generated
   from ThemePalette.swift); grounds, cards and buttons follow Home (HomeModel.swift, MakerHome.swift):
   Blue = faint square grid, soft shadows; Clean = plain, hairlines. Sketchbook is Ben's Sketchbook
   design system (sketchbook/sketchbook.css, only loaded in that scheme) with the docs' rules for
   it in sketchbook-docs.css. */

:root {
  color-scheme: light;
  --measure: 44rem;
  --radius: 16px;
  --radius-s: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --font-round: ui-rounded, -apple-system, "SF Pro Rounded", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --hairline: color-mix(in srgb, var(--secondary) 30%, transparent);
  --edge: color-mix(in srgb, var(--secondary) 50%, transparent);
  --card-shadow: none;
  --card-border: 1px solid var(--edge);
  --ground: none;
  --ground-size: auto;
}
@media (prefers-color-scheme: dark) { :root:not([data-mode="light"]) { color-scheme: dark; } }
:root[data-mode="dark"] { color-scheme: dark; }

/* Blue: a faint 24 px square grid and soft shadows. */
:root[data-scheme="classic"] {
  --ground: linear-gradient(to right, color-mix(in srgb, var(--secondary) 12%, transparent) .5px, transparent .5px),
            linear-gradient(to bottom, color-mix(in srgb, var(--secondary) 12%, transparent) .5px, transparent .5px);
  --ground-size: 24px 24px;
  --card-shadow: 0 3px 8px color-mix(in srgb, var(--shadow) 14%, transparent);
}
/* Clean: plain, hairlines only. */
:root[data-scheme="clean"] { --card-border: 1px solid var(--hairline); }
/* The Sketchbook wobble filters live in the page in every scheme; they take no room. */
.filters { position: absolute; width: 0; height: 0; overflow: hidden; }

* { box-sizing: border-box; }
html { scroll-padding-top: 5rem; }
body {
  margin: 0; color: var(--primary); font: 17px/1.65 var(--font);
  background-color: var(--canvas); background-image: var(--ground); background-size: var(--ground-size);
  background-attachment: fixed; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: .15em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Header: the app's top bar, a panel island with the scheme picker. */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.25rem; background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--primary); text-decoration: none; font: 700 1.05rem/1 var(--font-round); }
/* The app icon, in the appearance the page is in. */
.brand .mark { width: 30px; height: 30px; border-radius: 7px; box-shadow: 0 0 0 1px var(--hairline); }
.brand .mark.dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) .brand .mark.light { display: none; }
  :root:not([data-mode="light"]) .brand .mark.dark { display: block; }
}
:root[data-mode="dark"] .brand .mark.light { display: none; }
:root[data-mode="dark"] .brand .mark.dark { display: block; }
.brand small { font: 500 .95rem var(--font); color: var(--secondary); }
.menu { display: none; }
/* Appearance: one button naming the reader's look, opening a menu of schemes and modes. */
.look { position: relative; margin-left: auto; }
.look > summary {
  list-style: none; display: inline-flex; align-items: center; min-height: 36px; padding: .35rem .85rem;
  border-radius: 999px; background: var(--panel); border: 1px solid var(--hairline); color: var(--primary);
  font: 600 .82rem var(--font); white-space: nowrap; cursor: pointer;
}
.look > summary::-webkit-details-marker { display: none; }
.look > summary > span { display: inline-flex; align-items: center; gap: .45rem; }
.look .look-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 15rem; display: grid; gap: .9rem;
  padding: .9rem 1rem; background: var(--panel); border: var(--card-border); border-radius: var(--radius);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--shadow) 18%, transparent);
}
.look-menu fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 2px; }
.look-menu legend { padding: 0; margin-bottom: .3rem; font: 700 .72rem var(--font); letter-spacing: .07em; text-transform: uppercase; color: var(--secondary); }
.look-menu label { display: flex; align-items: center; gap: .6rem; min-height: 36px; cursor: pointer; font-weight: 600; }
.look-menu input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* Three columns: sections, the page, On this page. */
.wrap { display: grid; grid-template-columns: 15rem minmax(0, 1fr) 13rem; gap: 2.5rem; max-width: 84rem; margin: 0 auto; padding: 0 1.25rem; }
.side, .toc { position: sticky; top: 4.5rem; align-self: start; max-height: calc(100vh - 5.5rem); overflow: auto; padding: 1.75rem 0; font-size: .92rem; }
.side h2, .toc h2 {
  margin: 1.4rem 0 .4rem; padding: 0 .6rem; border: 0; font: 700 .72rem/1.2 var(--font);
  letter-spacing: .07em; text-transform: uppercase; color: var(--secondary);
}
.side h2:first-child, .toc h2:first-child { margin-top: 0; }
.side a { display: block; padding: .32rem .6rem; border-radius: var(--radius-s); color: var(--primary); text-decoration: none; }
.side a:hover { background: color-mix(in srgb, var(--inset) 70%, transparent); }
.side a[aria-current] { background: var(--panel); border: var(--card-border); box-shadow: var(--card-shadow); font-weight: 650; padding: calc(.32rem - 1px) calc(.6rem - 1px); }
.toc ul { list-style: none; margin: 0; padding: 0 0 0 .6rem; border-left: 1px solid var(--hairline); }
.toc li { margin: 0; }
.toc a { display: block; padding: .22rem .6rem; color: var(--secondary); text-decoration: none; line-height: 1.35; }
.toc a:hover, .toc a.here { color: var(--primary); }
.toc a.here { font-weight: 600; }
.toc .toc-3 a { padding-left: 1.4rem; font-size: .87rem; }

/* The page. */
main { min-width: 0; max-width: var(--measure); padding: 2rem 0 5rem; }
.eyebrow { margin: 0 0 .35rem; font: 700 .78rem var(--font); letter-spacing: .07em; text-transform: uppercase; color: var(--accent); }
h1 { margin: 0 0 .4rem; font: 800 2.6rem/1.1 var(--font-round); letter-spacing: -.02em; }
.lede { margin: 0 0 1.75rem; font-size: 1.25rem; line-height: 1.45; color: var(--secondary); }
h2 { margin: 3rem 0 .9rem; font: 750 1.6rem/1.2 var(--font-round); letter-spacing: -.01em; }
h3 { margin: 2rem 0 .6rem; font: 700 1.15rem/1.3 var(--font); }
h2, h3 { position: relative; }
.anchor { position: absolute; left: -1.1em; color: var(--hairline); text-decoration: none; opacity: 0; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
p, li { max-width: var(--measure); }
ul li, ol li { margin: .4rem 0; }
strong { font-weight: 650; }

/* On-screen controls: `Done` in the Markdown, a key-cap pill here. */
code {
  font: 600 .86em var(--font); padding: .08em .5em; border-radius: 7px; white-space: nowrap;
  background: var(--panel); color: var(--primary); border: 1px solid var(--edge);
  box-shadow: 0 1.5px 0 var(--edge);
}

/* The app's SF Symbols, drawn by DocGen, tinted with the scheme's ink. */
.sf {
  display: inline-block; width: 1.05em; height: 1.05em; margin-right: .32em; vertical-align: -.17em;
  background: currentColor; -webkit-mask: var(--sf) center / contain no-repeat; mask: var(--sf) center / contain no-repeat;
}
h1 .sf { width: .9em; height: .9em; margin-right: .25em; vertical-align: -.08em; color: var(--accent); }
.side .sf { color: var(--secondary); }
code .sf { width: 1em; height: 1em; margin-right: .3em; vertical-align: -.15em; }

/* Numbered steps: the app's mint action dot with an ink edge. */
main ol { list-style: none; counter-reset: step; padding-left: 0; }
main ol > li { counter-increment: step; position: relative; padding-left: 2.75rem; margin: 1.1rem 0; }
main ol > li::before {
  content: counter(step); position: absolute; left: 0; top: .05rem; width: 1.9rem; height: 1.9rem;
  display: grid; place-items: center; border-radius: 50%; font: 700 .95rem/1 var(--font-round);
  background: var(--action); color: var(--onAction); border: 1.5px solid var(--onAction);
}
:root[data-scheme="clean"] main ol > li::before, :root[data-scheme="classic"] main ol > li::before { border-color: transparent; }

/* Screenshots in framed cards, enlarged on tap. */
figure, main > picture, main > p > picture { display: block; margin: 1.25rem 0 1.5rem; }
picture img, figure img {
  display: block; width: 100%; max-width: 40rem; height: auto; border-radius: 12px; cursor: zoom-in;
  background: var(--panel); padding: 6px; border: var(--card-border); box-shadow: var(--card-shadow);
}
figcaption { margin-top: .55rem; font-size: .9rem; color: var(--secondary); max-width: 40rem; }
dialog.zoom { padding: 0; border: 0; background: none; max-width: 96vw; max-height: 96vh; }
dialog.zoom::backdrop { background: color-mix(in srgb, #000 70%, transparent); }
dialog.zoom img { display: block; max-width: 96vw; max-height: 92vh; border-radius: 12px; cursor: zoom-out; }

/* Callouts: a card with a coloured edge and a label. */
.callout {
  margin: 1.5rem 0; padding: .9rem 1.1rem; border-radius: var(--radius-s); background: var(--panel);
  border: var(--card-border); border-left: 5px solid var(--success); box-shadow: var(--card-shadow);
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout.tip { border-left-color: var(--success); }
.callout.tip strong:first-child { color: var(--success); }
.callout.heads-up { border-left-color: var(--warning); }
.callout.heads-up strong:first-child { color: var(--warning); }

/* Tables: a card. */
table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 1.25rem 0; font-size: .95rem;
  background: var(--panel); border: var(--card-border); border-radius: var(--radius-s); overflow: hidden; box-shadow: var(--card-shadow); }
th, td { padding: .65rem .9rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--hairline); }
tr:last-child td { border-bottom: 0; }
th { background: var(--inset); font-weight: 650; font-size: .85rem; }
td:first-child { white-space: nowrap; }

/* If it won't work: one card of questions, each opening to its answer. */
.faqs {
  margin: 1rem 0; background: var(--panel); border: var(--card-border);
  border-radius: var(--radius); box-shadow: var(--card-shadow); overflow: hidden;
}
.faq + .faq { border-top: 1px solid var(--hairline); }
.faq summary {
  display: flex; align-items: center; gap: .75rem; padding: .85rem 1.25rem; cursor: pointer; list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; margin-left: auto; flex: none; width: .55rem; height: .55rem;
  border-right: 2px solid var(--secondary); border-bottom: 2px solid var(--secondary);
  transform: rotate(45deg) translateY(-2px); transition: transform .15s;
}
.faq[open] summary::after { transform: rotate(-135deg) translate(-2px, 0); }
.faq summary:hover { background: var(--inset); }
.faq summary h3 { margin: 0; font-size: 1.02rem; }
.faq summary h3 .anchor { display: none; }
.faq .answer { padding: 0 1.25rem 1rem; }
.faq .answer > :first-child { margin-top: 0; }
.faq .answer > :last-child { margin-bottom: 0; }
.faq figure { margin-bottom: .5rem; }
/* Messages: the app's words as the question, the fix inside. */
.faq.message summary { font-size: .97rem; line-height: 1.45; }
.faq.message summary strong { font-weight: 650; }

/* At a glance: the facts card. */
.facts { margin-top: 3rem; padding: 1.1rem 1.35rem; background: var(--panel); border: var(--card-border); border-radius: var(--radius); box-shadow: var(--card-shadow); }
.facts h2 { margin: 0 0 .75rem; font-size: 1.15rem; }
.facts dl { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: .5rem 1rem; margin: 0; font-size: .95rem; }
.facts dt { font-weight: 650; color: var(--secondary); }
.facts dd { margin: 0; }
.related ul { padding-left: 1.1rem; }
.updated { margin-top: 2.5rem; font-size: .88rem; color: var(--secondary); }

/* iPad portrait and narrower: no TOC; phones: the sidebar folds into a menu. */
@media (max-width: 1180px) {
  .wrap { grid-template-columns: 14rem minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 760px) {
  .wrap { display: block; padding: 0 1rem; }
  .menu { display: inline-flex; border: var(--card-border); background: var(--panel); color: var(--primary); border-radius: 999px; padding: .35rem .8rem; font: 600 .85rem var(--font); }
  .side { display: none; position: static; max-height: none; padding: .5rem 0 1rem; border-bottom: 1px solid var(--hairline); }
  .side.open { display: block; }
  .look .look-now { display: none; }
  /* A wide table scrolls sideways inside its card instead of widening the page. */
  main table { display: block; overflow-x: auto; }
  /* Long names (a tool's arguments, an id) break rather than widen the page. */
  main :is(p, li) { overflow-wrap: anywhere; }
  main :is(p, li) > code { white-space: normal; }
  .brand small { display: none; }
  h1 { font-size: 2.1rem; }
  main { padding-top: 1.25rem; }
  main ol > li { padding-left: 2.4rem; }
  .facts dl { grid-template-columns: 1fr; }
  td:first-child { white-space: normal; }
}
