/* Alchemy Cast user manual. Built into web/manual/ by build-manual.mjs. */
:root {
  --ink: #0f0c1f; --night: #17122e; --panel: #1d1838; --panel-2: #251f47;
  --text: #ece9f7; --muted: #aaa4c4; --line: #352d5c;
  --gold: #f6b93b; --gold-2: #ffd36e; --blue: #7db4ff;
  --top: 56px; --side: 280px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 12px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--text); font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
a { color: var(--gold-2); text-decoration: none; }
a:hover { color: #fff3c8; }
img { max-width: 100%; height: auto; display: block; }

/* Top bar */
header.top {
  position: sticky; top: 0; z-index: 30; height: var(--top);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: rgba(15,12,31,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; color: var(--text); }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand span { background: linear-gradient(180deg, var(--gold-2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.crumb { color: var(--muted); font-weight: 600; padding-left: 14px; border-left: 1px solid var(--line); }
.open { margin-left: auto; background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #241a00; font-weight: 700; border-radius: 999px; padding: .45em 1.1em; white-space: nowrap; }
.open:hover { color: #241a00; filter: brightness(1.05); }
.toc-btn { display: none; align-items: center; gap: 6px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; height: 40px; font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; }

/* Sidebar table of contents */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
.toc {
  position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto;
  border-right: 1px solid var(--line); background: var(--night); padding: 20px 14px 40px;
}
.toc-title { margin: 0 10px 10px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.toc ol, .toc ul { list-style: none; margin: 0; padding: 0; }
.toc li > a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: .95rem; line-height: 1.35; }
.toc li > a:hover { background: var(--panel-2); color: #fff; }
.toc li.here > a { background: var(--panel-2); color: var(--gold-2); font-weight: 700; }
.toc ul { margin: 4px 0 8px 12px; border-left: 1px solid var(--line); }
.toc ul a { color: var(--muted); font-size: .88rem; padding: 5px 10px; }
.toc ul a.on { color: var(--gold-2); }
.scrim { display: none; }

/* Page */
.page { padding: 32px 48px 64px; max-width: 900px; }
article h1 { font-size: clamp(1.9rem, 5vw, 2.5rem); line-height: 1.15; margin: 0 0 .6em; letter-spacing: -.01em; }
article h2 { font-size: 1.5rem; margin: 2em 0 .5em; padding-top: 1em; border-top: 1px solid var(--line); line-height: 1.25; }
article h3 { font-size: 1.15rem; margin: 1.6em 0 .4em; }
article h2, article h3 { position: relative; }
.anchor { position: absolute; left: -1em; color: var(--line); opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
article p, article li { color: #d9d5ea; }
article strong { color: var(--text); }
article ul, article ol { padding-left: 1.3em; }
article li { margin: .3em 0; }
article code { background: var(--panel-2); border-radius: 5px; padding: .1em .35em; font-size: .9em; }
kbd { background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 .4em; font: .85em/1.6 ui-monospace, monospace; }
blockquote { margin: 1.2em 0; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 10px; }
blockquote p { margin: .3em 0; }
table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .95rem; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--gold-2); }
figure { margin: 1.4em 0; }
figure button.shot { all: unset; display: block; cursor: zoom-in; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
figure button.shot:focus-visible { outline: 3px solid var(--gold); }
figcaption { color: var(--muted); font-size: .88rem; margin-top: 6px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; padding: 0 !important; list-style: none; }
.cards li { margin: 0; }
.cards a { display: block; height: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; color: var(--text); }
.cards a:hover { border-color: var(--gold); }
.cards a strong { display: block; color: var(--gold-2); margin-bottom: 2px; }
.cards a span { color: var(--muted); font-size: .92rem; }

/* Videos load from YouTube only when tapped. */
.video { margin: 1.4em 0; }
.video button { all: unset; cursor: pointer; position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.video img { width: 100%; height: 100%; object-fit: cover; opacity: .85; }
.video .play { position: absolute; inset: 0; margin: auto; width: 68px; height: 48px; border-radius: 12px; background: #e33; }
.video .play::after { content: ""; position: absolute; left: 27px; top: 14px; border-style: solid; border-width: 10px 0 10px 18px; border-color: transparent transparent transparent #fff; }
.video .vt { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px; background: linear-gradient(transparent, rgba(0,0,0,.8)); font-weight: 600; }
.video iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 12px; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 56px; }
.pager a { flex: 1 1 0; max-width: 48%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; color: var(--text); font-weight: 600; }
.pager a:hover { border-color: var(--gold); }
.pager .next { text-align: right; margin-left: auto; }
.pager small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }
.edit { color: var(--muted); font-size: .9rem; margin-top: 28px; }

dialog.viewer { padding: 0; border: 0; background: transparent; max-width: 96vw; max-height: 92vh; }
dialog.viewer::backdrop { background: rgba(5,4,12,.9); }
dialog.viewer img { max-width: 96vw; max-height: 86vh; width: auto; border-radius: 10px; }
dialog.viewer p { color: var(--text); text-align: center; margin: 10px 0 0; }
dialog.viewer button { position: fixed; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 1.4rem; cursor: pointer; }

/* Phones and small tablets: the contents slide in from the left. */
@media (max-width: 900px) {
  .layout { display: block; }
  .toc-btn { display: inline-flex; }
  .crumb { display: none; }
  .toc {
    position: fixed; z-index: 40; top: 0; left: 0; bottom: 0; height: auto; width: min(86vw, 320px);
    transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.6);
    padding-top: 18px; padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
  body.toc-open .toc { transform: none; }
  body.toc-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(5,4,12,.6); }
  body.toc-open { overflow: hidden; }
  .toc li > a { padding: 10px 12px; font-size: 1rem; }
  .toc ul a { padding: 8px 12px; font-size: .93rem; }
  .page { padding: 22px 18px 48px; }
  .anchor { display: none; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .brand span { display: none; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { .toc { transition: none; } }
