/* Study guide on /examples/:slug pages (rendered by lib/study-guide-html.js).
   Loaded only by examples that have a guide. Uses the tokens from styles.css. */

.study-guide {
  max-width: 1400px;
  margin: 48px auto 0;
  padding: 0 40px;
  color: var(--ink-2, #1a1d23);
}
@media (max-width: 900px) {
  .study-guide { padding: 0 20px; }
}

.sg-head {
  border-top: 1px solid var(--ink, #0a0c10);
  padding-top: 20px;
  max-width: 920px;
}
.sg-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 14px;
  line-height: 1.5;
}
.sg-toc a {
  color: var(--ink, #0a0c10);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--rule-strong, #0a0c1026);
}
.sg-toc a:hover { color: var(--signal, #1f3a8a); text-decoration-color: currentColor; }
.sg-tools { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.sg-section {
  max-width: 920px;
  margin-top: 44px;
  scroll-margin-top: 24px;
}
.sg-section h2 {
  font-family: var(--f-serif, Georgia, serif);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink, #0a0c10);
  margin: 0 0 14px;
}
.sg-section p,
.sg-section li {
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-3, #3a3f48);
}
.sg-section p { margin: 0 0 12px; max-width: 74ch; }
.sg-section p.sg-lede { font-size: 17px; color: var(--ink-2, #1a1d23); }
.sg-section a { color: var(--ink, #0a0c10); text-decoration: underline; text-underline-offset: 2px; }
.sg-section a:hover { color: var(--signal, #1f3a8a); }
.sg-section code {
  font-family: var(--f-mono, ui-monospace, Menlo, monospace);
  font-size: 0.86em;
  background: var(--paper-2, #f4f5f7);
  padding: 1px 5px;
}
.sg-note {
  font-size: 14px !important;
  color: var(--ink-4, #6b7280) !important;
  border-left: 2px solid var(--rule-strong, #0a0c1026);
  padding-left: 12px;
  margin-top: 12px !important;
}

/* Walk-through keyed to the flowchart's steps */
.sg-steps { margin: 0; padding: 0; list-style: none; counter-reset: sg-step; max-width: 78ch; }
.sg-steps li {
  counter-increment: sg-step;
  position: relative;
  padding: 12px 0 12px 44px;
  border-top: 1px solid var(--rule, #0a0c1014);
}
.sg-steps li:last-child { border-bottom: 1px solid var(--rule, #0a0c1014); }
.sg-steps li::before {
  content: counter(sg-step);
  position: absolute; left: 0; top: 13px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--ink, #0a0c10);
  font-family: var(--f-mono, ui-monospace, Menlo, monospace);
  font-size: 12px;
  color: var(--ink, #0a0c10);
}
.sg-step-node {
  display: block;
  font-weight: 600;
  color: var(--ink, #0a0c10);
  margin-bottom: 2px;
}
.sg-step-kind {
  font-family: var(--f-mono, ui-monospace, Menlo, monospace);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3, #3a3f48);
  background: var(--paper-2, #f4f5f7);
  border: 1px solid var(--rule-strong, #0a0c1026);
  padding: 1px 6px;
  margin-right: 6px;
  vertical-align: 1px;
}
.sg-step-text { display: block; }

/* Tables: trace tables, stage tables, symbol key */
.sg-table-wrap { overflow-x: auto; margin: 6px 0 4px; }
.sg-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14.5px;
  line-height: 1.5;
}
.sg-table caption {
  caption-side: top;
  text-align: left;
  font-size: 14px;
  color: var(--ink-4, #6b7280);
  padding-bottom: 8px;
}
.sg-table th,
.sg-table td {
  border: 1px solid var(--rule-strong, #0a0c1026);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  color: var(--ink-2, #1a1d23);
}
.sg-table th {
  background: var(--paper-2, #f4f5f7);
  font-family: var(--f-mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3, #3a3f48);
  white-space: nowrap;
}
.sg-trace td { font-family: var(--f-mono, ui-monospace, Menlo, monospace); font-size: 13px; }
.sg-trace tbody tr:last-child td { background: var(--signal-wash, #dce3f3); }

/* Code blocks */
.sg-code {
  margin: 0 0 16px;
  border: 1px solid var(--ink, #0a0c10);
  background: var(--paper, #fff);
  max-width: 820px;
}
.sg-code figcaption {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--rule-strong, #0a0c1026);
  background: var(--paper-2, #f4f5f7);
  font-family: var(--f-mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3, #3a3f48);
}
.sg-code pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--f-mono, ui-monospace, Menlo, monospace);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink, #0a0c10);
  tab-size: 4;
}
.sg-code pre code { background: none; padding: 0; font-size: inherit; }
.sg-io { border-color: var(--rule-strong, #0a0c1026); }
.sg-copy {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  background: none;
  border: 1px solid var(--rule-strong, #0a0c1026);
  padding: 2px 8px;
  color: var(--ink-3, #3a3f48);
  cursor: pointer;
}
.sg-copy:hover { border-color: var(--ink, #0a0c10); color: var(--ink, #0a0c10); }

/* Mistakes, confusions, facts */
.sg-points { margin: 0; padding: 0; list-style: none; max-width: 78ch; }
.sg-points li {
  padding: 12px 0 12px 16px;
  border-left: 2px solid var(--ink, #0a0c10);
  margin-bottom: 12px;
}
.sg-points li strong { color: var(--ink, #0a0c10); }

/* Memory aid */
.sg-memory {
  border: 1px solid var(--ink, #0a0c10);
  box-shadow: 4px 4px 0 var(--ink, #0a0c10);
  padding: 18px 22px;
  max-width: 720px;
  background: var(--paper, #fff);
}
.sg-memory p { margin: 0 0 8px; }
.sg-memory p:last-child { margin-bottom: 0; }
.sg-memory ul { margin: 8px 0 0; padding-left: 20px; }
.sg-memory-phrase {
  font-family: var(--f-serif, Georgia, serif);
  font-size: 22px !important;
  line-height: 1.3 !important;
  color: var(--ink, #0a0c10) !important;
}

/* Worked questions */
.sg-qa {
  border: 1px solid var(--rule-strong, #0a0c1026);
  margin-bottom: 10px;
  max-width: 820px;
  background: var(--paper, #fff);
}
.sg-qa[open] { border-color: var(--ink, #0a0c10); }
.sg-qa summary {
  cursor: pointer;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink, #0a0c10);
}
.sg-qa summary:hover { background: var(--paper-2, #f4f5f7); }
.sg-qa-n {
  font-family: var(--f-mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-4, #6b7280);
  margin-right: 6px;
}
.sg-qa-a { padding: 4px 16px 12px; border-top: 1px solid var(--rule, #0a0c1014); }
.sg-qa-a p:first-child { margin-top: 10px; }
.sg-qa-a .sg-code { margin-top: 8px; }
.sg-qa-a ol, .sg-qa-a ul { margin: 0 0 12px; padding-left: 22px; }

.sg-remix, .sg-sources { margin: 0; padding-left: 20px; max-width: 78ch; }
.sg-remix li, .sg-sources li { margin-bottom: 8px; }

/* The static figure is for paper: on screen the interactive canvas shows the diagram. */
.sg-print-figure { display: none; }

@media print {
  .page-backdrop,
  .site-header,
  .footer-nav,
  .site-footer,
  .example-detail-stage,
  .example-detail-header-actions,
  .example-related-section,
  .example-detail-cta,
  .sg-toc,
  .sg-tools,
  .sg-copy,
  #authControls { display: none !important; }

  html, body { background: #fff !important; }
  .example-detail-shell { max-width: none; padding: 0; }
  .example-detail-header h1 { font-size: 30px; }
  .study-guide { margin-top: 16px; padding: 0; max-width: none; }
  .sg-head { border-top: 0; padding-top: 0; }
  .sg-section, .sg-code, .sg-qa, .sg-memory { max-width: none; }
  .sg-section { margin-top: 26px; }
  .sg-section h2 { font-size: 20px; break-after: avoid; }
  .sg-section p, .sg-section li { font-size: 12pt; color: #000; }
  .sg-table { font-size: 10.5pt; }
  .sg-table-wrap, .sg-code pre { overflow: visible; }
  .sg-code pre { white-space: pre-wrap; word-break: break-word; font-size: 10pt; }
  .sg-code, .sg-qa, .sg-memory, .sg-steps li, .sg-points li, .sg-table tr { break-inside: avoid; }
  .sg-memory { box-shadow: none; }

  .sg-print-figure {
    display: block;
    margin: 0 0 18px;
    text-align: center;
    break-inside: avoid;
  }
  .sg-print-figure svg { max-width: 100%; max-height: 8.6in; height: auto; }
  .sg-print-figure figcaption { font-size: 10pt; color: #333; margin-top: 6px; }

  /* Worked answers print even when their <details> is closed. study-guide.js
     also opens them on beforeprint for browsers without ::details-content. */
  .sg-qa { border-color: #999; }
  .sg-qa::details-content { content-visibility: visible; display: block; height: auto; }
  .sg-qa summary { list-style: none; font-weight: 600; }
  .sg-qa summary::-webkit-details-marker { display: none; }

  .sg-section a { text-decoration: none; color: #000; }
  .example-use-section { display: none; }
}
