/* Structure page: the shared grid, with the record viewer in the main column (columns 1-7)
   and the reading notes beside it as margin notes (columns 8-12). */
:root { --json-num: #26706a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) { --json-num: var(--s3); } }
:root[data-theme=dark] { --json-num: var(--s3); }

main.structure-page {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  align-content: start;
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
main.structure-page > .wrap { grid-column: var(--main-span); min-width: 0; max-width: none; margin-inline: 0; padding-inline: 0; }
main.structure-page > .structure-intro { grid-column: 1 / -1; grid-row: 1; }
main.structure-page > #explore { grid-row: 2; }
main.structure-page > .structure-notes { grid-column: var(--side-span); grid-row: 2; align-self: start; }

/* Page head */
.structure-intro { padding-top: 72px; }
.structure-intro h1 { margin: 0 0 24px; font-size: 44px; line-height: 1.1; letter-spacing: -0.015em; }
.structure-intro p { max-width: none; margin: 0 0 1em; color: var(--ink-2); }
.structure-intro p:last-child { margin-bottom: 0; }
.structure-intro code, .structure-caption code, .structure-source code { overflow-wrap: anywhere; }

/* The record viewer */
#explore, main.structure-page > .structure-notes { margin-top: 48px; }
.structure-caption { margin: 0 0 10px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.structure-caption strong { color: var(--ink); }
.structure-jumps { margin: 0 0 18px; font-size: 14.5px; color: var(--muted); }
#explore { container-type: inline-size; }
.structure-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 0; }
.structure-controls[hidden] { display: none; }
.structure-controls label { flex: 1 1 260px; font-size: 14px; font-weight: 500; line-height: 1.35; color: var(--ink); }
.structure-controls input { display: block; width: 100%; margin-top: 6px; }
.structure-controls button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: 500 14px/1.2 var(--f-body);
  cursor: pointer;
}
@container (max-width: 640px) {
  .structure-controls label { flex-basis: 100%; }
  .structure-controls button { flex: 1 1 0; }
}
.structure-controls button:hover { background: var(--paper-2); border-color: var(--ink); }
#structure-status { min-height: 1.5em; margin: 12px 0 10px; font: 13.5px/1.5 var(--f-body); font-variant-numeric: tabular-nums lining-nums; color: var(--muted); }

.json-document { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); background: transparent; }
.json-document-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  font: 500 12.5px/1.5 var(--f-mono);
  color: var(--ink);
}
.json-document-bar a { font-family: var(--f-body); font-size: 14px; }
.json-document-label { color: var(--muted); font-weight: 400; }
.structure-tree { padding: 14px 0 16px; font: 13.5px/1.75 var(--f-mono); font-variant-numeric: tabular-nums; }
.json-node { min-width: 0; scroll-margin-top: 24px; }
.json-line { margin-left: 16px; padding: 2px 4px; min-height: 30px; border-radius: var(--radius); overflow-wrap: anywhere; }
.json-children { margin-left: 21px; padding-left: 10px; border-left: 1px solid var(--rule); }
.json-branch > summary.field-help { display: list-item; cursor: pointer; text-decoration: none; }
.json-branch > summary::marker { color: var(--muted); font-size: 0.78em; }
.json-branch > summary:hover::marker { color: var(--accent); }
.json-branch > summary:hover, .json-scalar > .json-line:hover { background: var(--paper-2); }
.json-key { color: var(--ink); }
.json-key-help { font: inherit; text-underline-offset: 3px; }
.json-branch > summary .json-key { text-decoration: underline dotted var(--rule-2); text-underline-offset: 3px; }
.json-value { color: var(--accent); white-space: pre-wrap; }
[data-type=boolean] > .json-line > .json-value, [data-type=integer] > .json-line > .json-value, [data-type=number] > .json-line > .json-value { color: var(--json-num); }
.json-punctuation, .json-preview { color: var(--muted); }
.json-hint, .json-context-note { margin-left: 14px; color: var(--muted); font: 12.5px var(--f-body); }
.json-context-note { margin-left: 12px; font-weight: 500; }
.json-branch[open] > summary .json-preview, .json-branch[open] > summary .json-hint { display: none; }
.json-field-link { margin-left: 12px; padding: 2px 5px; color: var(--muted); font: 13.5px var(--f-body); text-decoration: none; opacity: 0; }
.json-line:hover > .json-field-link, .json-line:focus-within > .json-field-link, .json-field-link:focus-visible { opacity: 1; }
.json-node:target > .json-line { outline: 1px solid var(--accent); outline-offset: 0; background: var(--accent-soft); }
.field-tooltip { max-height: calc(100dvh - 24px); overflow-y: auto; }
/* On phones the tooltip is at most the column's width, so it never crosses the 16px gutter. */
@media (max-width: 600px) { .field-tooltip { max-width: calc(100vw - 2 * var(--gutter) - 8px); } }
.structure-source { margin: 12px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }

/* Reading notes: margin notes beside the viewer. */
.structure-notes { display: block; margin: 0; padding-top: 12px; border-top: 1px solid var(--rule); }
.structure-notes > div + div { margin-top: 16px; }
/* The heading sits on the same rule, at the same size, as the caption over the record. */
.structure-notes h2 { margin: 0 0 10px; font: 600 15px/1.55 var(--f-body); letter-spacing: 0; color: var(--ink); }
/* Each note opens with an italic first sentence that names its point. */
.structure-notes em { font-style: italic; color: var(--ink); }
.structure-notes p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.structure-notes code { overflow-wrap: anywhere; }

/* The notes scroll with the page, beside the top of the record, so there is one scroll. From
   960px to 1099px they are set a step smaller to suit the narrower side column. */
@media (min-width: 960px) and (max-width: 1099px) {
  .structure-notes > div + div { margin-top: 14px; }
  .structure-notes h2 { font-size: 14px; }
  .structure-notes p { font-size: 13.5px; line-height: 1.5; }
}


@media (max-width: 959px) {
  /* One column of one width, as on the homepage. */
  main.structure-page { display: block; max-width: calc(720px + 2 * var(--gutter)); margin-left: 0; }
  main.structure-page > .structure-notes { margin-top: 40px; }
}
@media (max-width: 600px) {
  .structure-intro { padding-top: 44px; }
  .structure-intro h1 { font-size: 34px; margin-bottom: 18px; }
  #explore { margin-top: 36px; }
}
@media (max-width: 640px) {
  .structure-tree { padding: 10px 0 14px; font-size: 12.25px; }
  .json-line { margin-left: 13px; min-height: 30px; padding-block: 3px; }
  .json-children { margin-left: 13px; padding-left: 5px; }
  .json-field-link { opacity: 1; padding: 5px; margin-left: 6px; }
  .json-hint { display: none; }
  .json-array-item:not([open]) > summary .json-hint { display: inline; margin-left: 8px; }
}
@media (max-width: 420px) {
  .structure-intro h1 { font-size: 30px; }
}
@media print {
  .structure-controls, .json-field-link, .field-tooltip { display: none; }
  main.structure-page { display: block; }
}
