/* The Glea User Guide: the page as a Mac window, like the home page. A
   toolbar, a sidebar like System Settings', the article in one column, and
   the app's own table of contents (dashes) in the right margin. Every page
   in help/ shares this file; tools/build-help.py writes their sidebar,
   pager and search index. */
:root {
  --bg: #ffffff;
  --surface: #f5f5f6;
  --sidebar: #f7f7f8;
  --line: rgba(0, 0, 0, 0.08);
  --ink: rgba(0, 0, 0, 0.86);
  --muted: rgba(0, 0, 0, 0.6);
  --faint: rgba(0, 0, 0, 0.38);
  --accent: #5459f2;
  --accent-ink: #fff;
  --seg: rgba(0, 0, 0, 0.05);
  --seg-on: rgba(0, 0, 0, 0.07);
  --bar: rgba(255, 255, 255, 0.82);
  --wash: rgba(84, 89, 242, 0.1);
  --frame: 0 0 0 1px var(--line), 0 30px 70px -40px rgba(20, 20, 40, 0.28);
  --pop: 0 0 0 1px var(--line), 0 24px 60px -12px rgba(20, 20, 40, 0.3);
  /* Callouts, in their type's color (as the app draws them). */
  --tip: #1f9d55; --tip-wash: rgba(31, 157, 85, 0.08);
  --note: #5459f2; --note-wash: rgba(84, 89, 242, 0.07);
  --warn: #c27803; --warn-wash: rgba(214, 140, 0, 0.09);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, "Helvetica Neue", sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", Inter, system-ui, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1f;
    --surface: #252528;
    --sidebar: #202023;
    --line: rgba(255, 255, 255, 0.09);
    --ink: rgba(255, 255, 255, 0.88);
    --muted: rgba(255, 255, 255, 0.62);
    --faint: rgba(255, 255, 255, 0.38);
    --accent: #8c94ff;
    --accent-ink: #14142a;
    --seg: rgba(255, 255, 255, 0.06);
    --seg-on: rgba(255, 255, 255, 0.12);
    --bar: rgba(28, 28, 31, 0.8);
    --wash: rgba(140, 148, 255, 0.18);
    --frame: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 8px 16px -4px rgba(0, 0, 0, 0.12), 0 16px 32px -12px rgba(0, 0, 0, 0.16);
    --pop: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 24px 60px -12px rgba(0, 0, 0, 0.6);
    --tip: #4fcf86; --tip-wash: rgba(79, 207, 134, 0.1);
    --note: #8c94ff; --note-wash: rgba(140, 148, 255, 0.12);
    --warn: #f0b443; --warn-wash: rgba(240, 180, 67, 0.1);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1c1f; --surface: #252528; --sidebar: #202023; --line: rgba(255, 255, 255, 0.09);
  --ink: rgba(255, 255, 255, 0.88); --muted: rgba(255, 255, 255, 0.62); --faint: rgba(255, 255, 255, 0.38);
  --accent: #8c94ff; --accent-ink: #14142a; --seg: rgba(255, 255, 255, 0.06); --seg-on: rgba(255, 255, 255, 0.12);
  --bar: rgba(28, 28, 31, 0.8); --wash: rgba(140, 148, 255, 0.18);
  --tip: #4fcf86; --tip-wash: rgba(79, 207, 134, 0.1); --note: #8c94ff; --note-wash: rgba(140, 148, 255, 0.12);
  --warn: #f0b443; --warn-wash: rgba(240, 180, 67, 0.1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-padding-top: 76px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code { font: 400 0.88em/1 var(--mono); background: var(--seg); padding: 0.15em 0.35em; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Toolbar ----------------------------------------------------------------- */
.toolbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--bar); backdrop-filter: saturate(1.6) blur(20px); -webkit-backdrop-filter: saturate(1.6) blur(20px);
  border-bottom: 1px solid var(--line);
}
.toolbar .bar { display: grid; grid-template-columns: 1fr minmax(0, 22rem) 1fr; align-items: center; gap: 16px; height: 56px; padding-inline: 20px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font: 600 16px/1 var(--display); letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; border-radius: 6px; }
.brand .beta {
  font: 500 9px/1 "JetBrains Mono", var(--mono); font-style: normal;
  color: var(--accent); background: var(--wash); padding: 3px 5px 2.5px; border-radius: 4px;
  margin-left: -1px; position: relative; top: 1.75px;
}
.brand .guide { color: var(--muted); font-weight: 500; padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--line); }
.find {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px 0 10px;
  border: 0; border-radius: 8px; background: var(--seg); color: var(--faint); cursor: text;
  font: 400 14px/1 var(--font); text-align: left;
}
.find:hover { background: var(--seg-on); }
.find svg { width: 15px; height: 15px; flex: none; }
.find span { flex: 1; }
.find kbd { font-size: 11px; height: 18px; min-width: 18px; }
.toolbar .end { justify-self: end; display: flex; align-items: center; gap: 8px; }
.button {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px;
  border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font: 500 13px/1 var(--font); white-space: nowrap; transition: filter 120ms ease, scale 120ms ease;
}
.button:hover { text-decoration: none; filter: brightness(1.07); }
.button:active { scale: 0.97; }
.menu-button { display: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; }
.menu-button:hover { background: var(--seg); }
.menu-button svg { width: 18px; height: 18px; }

/* Layout ------------------------------------------------------------------- */
.layout { display: grid; grid-template-columns: 16.5rem minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar {
  position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow-y: auto;
  background: var(--sidebar); border-right: 1px solid var(--line); padding: 18px 12px 40px; scrollbar-width: thin;
}
.content { display: grid; grid-template-columns: minmax(0, 44rem) 12rem; justify-content: center; gap: 56px; padding: 48px 32px 0; }
/* The footer runs across the column beside the sidebar, which stays beside
   it (it spans both rows). */
.sidebar { grid-row: 1 / span 2; }
.layout > .site-footer { grid-column: 2; }

/* Sidebar, grouped like System Settings. */
.sidebar h2 { font: 600 11px/1 var(--font); color: var(--faint); margin: 20px 10px 6px; letter-spacing: 0.01em; }
.sidebar h2:first-child { margin-top: 4px; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: 7px; color: var(--ink); font: 400 14px/1.3 var(--font); }
.sidebar a:hover { text-decoration: none; background: var(--seg); }
.sidebar a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.sidebar a[aria-current="page"] .ico { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35); }
.ico { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--c, #8e8e93); color: #fff; }
.ico svg { width: 14px; height: 14px; }

/* Article ------------------------------------------------------------------ */
article { position: relative; isolation: isolate; min-width: 0; padding-bottom: 24px; }
.crumb { font: 500 13px/1 var(--font); color: var(--faint); margin: 0 0 14px; }
article h1 { font: 600 clamp(32px, 4vw, 42px)/1.1 var(--display); letter-spacing: -0.03em; margin: 0 0 14px; text-wrap: balance; }
.lede { font-size: 19px; line-height: 1.5; color: var(--muted); margin: 0 0 32px; text-wrap: pretty; }
article h2 { font: 600 24px/1.25 var(--display); letter-spacing: -0.02em; margin: 52px 0 12px; text-wrap: balance; }
article h3 { font: 600 17px/1.35 var(--display); margin: 30px 0 8px; }
article h2 .anchor, article h3 .anchor { color: var(--faint); margin-left: 6px; opacity: 0; font-weight: 400; transition: opacity 120ms; }
article h2:hover .anchor, article h3:hover .anchor, .anchor:focus { opacity: 1; text-decoration: none; }
article p, article li { color: var(--muted); }
article p { margin: 0 0 14px; }
article ul, article ol { margin: 0 0 16px; padding-left: 22px; }
article li { margin-bottom: 6px; }
article li::marker { color: var(--faint); }
article b, article strong { color: var(--ink); font-weight: 600; }
/* A menu path, a button or a setting, as it reads in the app. */
.ui { color: var(--ink); font-weight: 500; }
kbd {
  display: inline-grid; place-items: center; min-width: 21px; height: 21px; padding: 0 5px;
  border-radius: 5px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line), 0 1px 0 var(--line);
  font: 500 12.5px/1 var(--display); color: var(--ink); vertical-align: 1px; white-space: nowrap;
}

/* Numbered steps, like a how-to in Apple's guides. */
ol.steps { list-style: none; padding: 0; counter-reset: step; margin: 0 0 20px; }
ol.steps > li { position: relative; padding-left: 36px; margin-bottom: 12px; counter-increment: step; }
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 1px;
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--wash); color: var(--accent); font: 600 12px/1 var(--font);
}

/* Callouts. */
.callout { border-radius: 10px; padding: 12px 16px 12px 44px; margin: 20px 0; position: relative; background: var(--note-wash); }
.callout p:last-child { margin-bottom: 0; }
.callout::before {
  content: ""; position: absolute; left: 16px; top: 15px; width: 16px; height: 16px;
  background: var(--note); -webkit-mask: var(--glyph) center / contain no-repeat; mask: var(--glyph) center / contain no-repeat;
  --glyph: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="7" fill="none" stroke="black" stroke-width="1.6"/><rect x="7.2" y="7" width="1.6" height="5" rx=".8"/><circle cx="8" cy="4.6" r="1"/></svg>');
}
.callout .t { display: block; font-weight: 600; color: var(--note); margin-bottom: 2px; }
.callout.tip { background: var(--tip-wash); }
.callout.tip::before { background: var(--tip); --glyph: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M8 1.5a4.5 4.5 0 0 0-2.6 8.2c.4.3.6.7.6 1.1V12h4v-1.2c0-.4.2-.8.6-1.1A4.5 4.5 0 0 0 8 1.5Z" fill="none" stroke="black" stroke-width="1.5"/><rect x="6" y="13.2" width="4" height="1.5" rx=".75"/></svg>'); }
.callout.tip .t { color: var(--tip); }
.callout.warning { background: var(--warn-wash); }
.callout.warning::before { background: var(--warn); --glyph: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M8 1.8 15 14H1L8 1.8Z" fill="none" stroke="black" stroke-width="1.5" stroke-linejoin="round"/><rect x="7.25" y="6" width="1.5" height="4.2" rx=".75"/><circle cx="8" cy="11.9" r=".9"/></svg>'); }
.callout.warning .t { color: var(--warn); }

/* Code and Markdown samples. */
pre {
  margin: 0 0 18px; padding: 14px 16px; border-radius: 10px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font: 400 13px/1.7 var(--mono); color: var(--ink); overflow-x: auto; scrollbar-width: thin;
}
pre code { background: none; padding: 0; font: inherit; }

/* Tables: a grouped list, like System Settings. */
.table { margin: 0 0 20px; background: var(--surface); border-radius: 12px; padding: 0 16px; overflow-x: auto; }
.table table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font: 600 12px/1 var(--font); color: var(--faint); padding: 14px 12px 8px 0; }
.table td { padding: 10px 12px 10px 0; border-top: 1px solid var(--line); color: var(--muted); vertical-align: top; }
.table td:first-child { color: var(--ink); white-space: nowrap; }
.table td:first-child code { white-space: nowrap; }

figure { margin: 24px 0 28px; }
figure img, figure video { display: block; width: 100%; height: auto; border-radius: 1.55% / 2.45%; box-shadow: var(--frame); background: var(--bg); }
figcaption { font-size: 13px; color: var(--faint); margin-top: 10px; text-align: center; }

/* The guide's front page: its chapters as cards. */
.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 12px; margin: 8px 0 24px; }
.chapters a { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 14px 16px; border-radius: 12px; background: var(--surface); color: inherit; transition: background 120ms; }
.chapters a:hover { text-decoration: none; background: var(--seg-on); }
.chapters .ico { grid-row: span 2; width: 30px; height: 30px; border-radius: 8px; }
.chapters .ico svg { width: 18px; height: 18px; }
.chapters b { font: 600 15px/1.3 var(--display); color: var(--ink); }
.chapters span:last-child { font-size: 13.5px; line-height: 1.45; color: var(--muted); }

/* Previous and next. */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 56px 0 0; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 10px; color: var(--ink); font-weight: 500; }
.pager a:hover { text-decoration: none; background: var(--surface); }
.pager a small { font: 400 12.5px/1 var(--font); color: var(--faint); }
.pager .next { text-align: right; grid-column: 2; }
.feedback { font-size: 13.5px; color: var(--faint); margin: 28px 0 0; }

.site-footer { margin-top: 64px; }

/* The table of contents, as the app draws it, with the home page's motion
   (.gl-toc in assets/glea/glea.css): one dash per heading, the current one
   brighter and longer; hovering fades the dashes out and springs the titles
   in from the left. The springs and timings are the app's. */
.toc {
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.42, 0, 0.58, 1);
  --spring-dash: linear(0, .0469, .158, .2983, .4441, .5807, .6999, .7981, .8752, .9327, .9734, 1.0004, 1.0167, 1.0252, 1.0281, 1.0274, 1.0247, 1.0209, 1.0167, 1.0128, 1.0093, 1.0064, 1.004, 1.0023, 1);
  --spring-label: linear(0, .0525, .1725, .3189, .4659, .5993, .7123, .8031, .8727, .9238, .9597, .9837, .9986, 1.0071, 1.0112, 1.0124, 1.0119, 1.0105, 1.0087, 1.0068, 1.0052, 1.0037, 1.0026, 1.0017, 1);
  position: sticky; top: 104px; align-self: start; max-height: calc(100vh - 140px); overflow: visible;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
/* Each row clips its title, which starts well to the left of it. */
.toc a { position: relative; display: block; height: 24px; overflow: hidden; }
.toc a:hover { text-decoration: none; }
.toc a::before {
  content: ""; position: absolute; left: 0; top: 11px; width: 10px; height: 2px; border-radius: 1px;
  background: var(--ink); transform-origin: 0 50%; opacity: 0.35;
  transition: width 0.46s var(--spring-dash), opacity 0.2s var(--ease-in-out), transform 0.3s var(--ease-in-out);
}
.toc a.on::before { width: 18px; opacity: 1; }
.toc a.sub::before { width: 6px; left: 6px; }
.toc a.sub.on::before { width: 18px; }
.toc a span {
  position: absolute; left: 0; right: 0; top: 4.2px; height: 15.6px; font: 500 12px/15.6px var(--font); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; translate: -144px 0;
  transition: translate 0.61s var(--spring-label), opacity 0.2s var(--ease-in-out), color 0.15s ease;
}
.toc a.sub span { left: 10px; }
/* The hovered title is the bright one; with none hovered, the current one. */
.toc a.on span, .toc a:hover span, .toc a:focus-visible span { color: var(--ink); }
.toc:hover a.on:not(:hover) span { color: var(--muted); }
.toc:hover a::before, .toc:focus-within a::before {
  opacity: 0; transform: scaleX(0.5);
  transition: width 0.46s var(--spring-dash), opacity 0.1s var(--ease-in-out), transform 0.3s var(--ease-in-out);
}
.toc:hover a span, .toc:focus-within a span {
  opacity: 1; translate: 0 0;
  transition: translate 0.61s var(--spring-label), opacity 0.35s var(--ease-in-out) 0.04s, color 0.15s ease;
}
.toc .label { font: 600 11px/1 var(--font); color: var(--faint); margin: 0 0 10px; opacity: 0; transition: opacity 0.2s var(--ease-in-out); }
.toc:hover .label, .toc:focus-within .label { opacity: 1; transition: opacity 0.35s var(--ease-in-out) 0.04s; }

/* Search, like the omnibox: a floating field over the page. */
.search[hidden] { display: none; }
.search { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgba(0, 0, 0, 0.18); }
.search .panel {
  width: 100%; max-width: 38rem; border-radius: 14px; background: var(--bg); box-shadow: var(--pop); overflow: hidden;
  animation: omni 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes omni { from { opacity: 0; scale: 0.96; } }
.search .field { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px; border-bottom: 1px solid var(--line); }
.search .field svg { width: 18px; height: 18px; color: var(--faint); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--ink); font: 400 18px/1 var(--font); }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search ul { list-style: none; margin: 0; padding: 6px; max-height: min(60vh, 26rem); overflow-y: auto; scrollbar-width: thin; }
.search ul:empty { display: none; }
.search li a { display: grid; grid-template-columns: auto 1fr; gap: 1px 12px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.search li a:hover { text-decoration: none; }
.search li a .ico { grid-row: span 2; }
.search li a b { font-weight: 500; font-size: 14.5px; }
.search li a small { font-size: 12.5px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.search li a mark { background: none; color: inherit; font-weight: 600; }
.search li a.on { background: var(--accent); color: var(--accent-ink); }
.search li a.on small { color: var(--accent-ink); opacity: 0.8; }
.search .empty { padding: 18px; color: var(--faint); font-size: 14px; text-align: center; }

/* Narrower windows ---------------------------------------------------------- */
@media (max-width: 1180px) {
  .content { grid-template-columns: minmax(0, 44rem); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .toolbar .bar { grid-template-columns: auto 1fr auto; gap: 10px; padding-inline: 12px 16px; }
  .brand .guide { display: none; }
  .menu-button { display: grid; place-items: center; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout > .site-footer { grid-column: 1; }
  .sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0; z-index: 25; width: min(20rem, 86vw); height: auto; align-self: stretch;
    translate: -100% 0; transition: translate 280ms cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: var(--pop);
  }
  .nav-open .sidebar { translate: 0 0; }
  .content { padding: 32px 16px 0; }
  .find span, .find kbd { display: none; }
  .find { width: 32px; padding: 0; justify-content: center; justify-self: end; background: none; color: var(--ink); }
  .toolbar .end .button { display: none; }
}
@media (max-width: 560px) {
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .search .panel { animation: none; }
  .toc a::before, .toc a span, .sidebar { transition: none; }
}
