@font-face {
    font-family: "Noto Math Symbols";
    src: url("/assets/fonts/NotoSansMath-Regular.woff2") format("woff2");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    unicode-range:
        U+2100-214F,
        U+2190-22FF,
        U+27C0-27EF,
        U+2980-2AFF;
}

/* Unspoken instructions in video narration documents. */
.production-note {
    color: #666;
    font-style: italic;
}

.production-note img.production-thumbnail {
    display: inline-block;
    width: 160px;
    max-width: 100%;
    height: auto;
    margin: 0 0.75rem 0.35rem 0;
    vertical-align: middle;
    border: 1px solid #ccd3da;
    border-radius: 4px;
}

/* Title block */
h1 {
    font-size: 2.2rem;
    text-align: center;
    margin-bottom: 0.3rem;
    letter-spacing: 0.5px;
}

.version {
    font-size: 0.6em;
    font-weight: 400;
    color: #567;
    margin-left: 0.2rem;
}

.subtitle {
    text-align: center;
    font-size: 1.1rem;
    color: #555;
    margin-top: 0.2rem;
    margin-bottom: 2rem;
    letter-spacing: 0.3px;
    font-family: 'Proxima Nova', sans-serif;
    font-style: italic;
}

body {
    font-family: "Noto Math Symbols", Verdana, Arial, sans-serif;
    line-height: 1.6;
    margin: 2rem auto;
    max-width: 900px;
    color: #222;
    background: #f7f7f7;   /* paper‑white */
    padding-inline: 1rem;
}

.part {
    page-break-before: always;   /* Forces a new page in print/PDF */
    margin-top: 8rem;            /* Pushes content down on screen */
    text-align: center;
}

.part h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.part p {
    max-width: 40rem;
    margin: 0 auto;
    font-size: 1.3rem;
    line-height: 1.6;
}

h1, h2, h3, h4, h5 {
    margin-top: 1.6rem;
    color: #358;
    font-family: 'Proxima Nova', sans-serif;
}

h1 { font-size: 2rem; text-align: center; }
h2 { font-size: 1.5rem; border-bottom: 1px solid #ddd; padding-bottom: 0.3rem; }
h3 { font-size: 1.25rem; margin-top: 1.2rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }

.labelled-statement {
    margin-block: 1em;
}

.statement {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 0.35em;
    align-items: baseline;
}

.statement-label {
    font-weight: 600;
}

.statement-content {
    min-width: 0;
}

.statement-content > :first-child {
    margin-block-start: 0;
}

.statement-content > :last-child {
    margin-block-end: 0;
}

.proof-body {
    margin-block-start: 0.5em;
}

.proof-label {
    font-weight: 600;
}

.proof-content {
    margin-inline-start: 2rem;
}

.proof-content > .proof-cases,
.proof-content > .proof-derivation {
    margin-inline-start: 0;
}

.proof-cases {
    margin-inline-start: 2rem;
}

.proof-branch + .proof-branch {
    margin-block-start: 0.75em;
}

.proof-keyword {
    font-weight: 600;
}

.proof-derivation {
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr) minmax(12rem, auto);
    column-gap: 1.5rem;
    margin-inline-start: 2rem;
}

.indented-block,
.proof-detail {
    margin-inline-start: 2rem;
}

.procedure {
    margin-block: 1em;
}

.procedure-body {
    margin-inline-start: 2rem;
}

.proof-detail {
    grid-column: 1 / -1;
}

.proof-row {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: baseline;
}

.proof-expression:first-child {
    grid-column: 1 / 3;
}

.proof-relation {
    grid-column: 1;
    text-align: right;
}

.proof-expression {
    grid-column: 2;
}

.proof-expression:last-child {
    grid-column-end: -1;
}

.proof-reason {
    grid-column: 3;
    color: #555;
}

@media (max-width: 700px) {
    .proof-content,
    .proof-cases,
    .proof-derivation,
    .indented-block,
    .proof-detail,
    .procedure-body {
        margin-inline-start: 1rem;
    }

    .proof-content > .proof-cases,
    .proof-content > .proof-derivation {
        margin-inline-start: 0;
    }

    .proof-derivation {
        grid-template-columns: 1.25rem minmax(0, 1fr);
        column-gap: 0.5rem;
    }

    .proof-reason {
        grid-column: 2;
        margin-inline-start: 1rem;
    }
}

.api-signature {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
}

a {
    color: #245f8f;
}

a:visited {
    color: #6b4f9a;
}

ol, ul { margin-left: 1.2rem; }

table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

th, td {
    border: 1px solid #ccc;
    padding: 0.5rem;
    vertical-align: top;
}

th {
    background: #eaeaea;   /* subtle contrast with #f7f7f7 */
    text-align: left;
    font-weight: 600;
}

.table-scroll {
    margin: 1rem 0;
    overflow-x: auto;
}

.table-scroll table {
    margin: 0 auto;
    min-width: max-content;
    width: max-content;
    max-width: none;
}

table.benchmark-table {
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

table.benchmark-table th {
    text-align: center;
    white-space: nowrap;
}

table.benchmark-table td {
    text-align: right;
    white-space: nowrap;
}

table.benchmark-table tbody tr:nth-child(even) {
    background: #f3f6f8;
}

table.std td:first-child,
table.std th:first-child {
    white-space: nowrap;
}

table.noborder {
    border-collapse: collapse;
    width: auto;
}

.code-examples {
    table-layout: fixed;
}

.code-examples th,
.code-examples td {
    padding: 0.35rem;
}

.code-examples pre {
    margin: 0;
    padding: 0.3rem 0.4rem;
    overflow-x: visible;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.84rem;
}

.code-examples pre code {
    white-space: inherit;
}

table.query-example {
    table-layout: fixed;
}

table.query-example th:first-child {
    width: 10rem;
}

.noborder th, .noborder td {
    border: none;
    padding-left: 5px;
    padding-right: 5px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-align: centre;
}


.small { font-size: 0.95rem; color: #444; }
.article { margin-top: 2rem; }
.std { width: 100%; }
sub { font-size: 0.8em; }

.indent {
    display: inline-block;
    margin-left: 2rem;
}

.verbatim {
    display: inline-block;
    max-width: 100%;
    white-space: pre-wrap;
}

.formula {
    margin-left: 2rem;
}

div.predicate {
    margin: 1rem 0;
    padding: 0.5rem;
    background: #e0f0ff;
    font-style: italic;
}

table.std2 {
    border-collapse: collapse;
    background: #fff;
}

table.std2,
.std2 th,
.std2 td {
    border: 1px solid #555;
}

.std2 th,
.std2 td {
    padding: 0.6rem;
    text-align: center;
}

table.effects-state-table {
    width: 25rem;
    max-width: 100%;
    table-layout: fixed;
}

table.assignment-field-table {
    width: 36rem;
    max-width: 100%;
    table-layout: fixed;
}

.assignment-field-table col.field {
    width: 8rem;
}

.assignment-field-table th,
.assignment-field-table td {
    text-align: left;
}

.effects-state-table col.state,
.effects-state-table col.property {
    width: 10rem;
}

.effects-state-table col.value {
    width: 5rem;
}

.effects-state-table th,
.effects-state-table td {
    white-space: nowrap;
}

li + li { margin-top: 0.4rem; }
li > ol, li > ul { margin-top: 0.3em; }
li > p { margin-top: 0.5em; }

.predicate-gloss-list {
    margin: 1rem 0;
}

.predicate-gloss {
    display: grid;
    grid-template-columns: max-content max-content minmax(0, 1fr);
    gap: 0.5rem;
    align-items: baseline;
    margin: 0.25rem 0;
}

.predicate-gloss-expression {
    white-space: nowrap;
}

.predicate-gloss-text {
    font-style: italic;
}

@media (max-width: 520px) {
    .predicate-gloss {
        grid-template-columns: max-content minmax(0, 1fr);
    }

    .predicate-gloss-text {
        grid-column: 2;
    }
}

code {
    font-family:
        "Cascadia Mono",
        "Consolas",
        "Menlo",
        "DejaVu Sans Mono",
        monospace;
    color: steelblue;
    font-size: 0.92em;
    line-height: 1em;
    /*background: #f6f8fa;*/
    padding: 0.1rem 0.15rem;
    border-radius: 3px;
    position: relative;
    top: -0.05em;
}

code {
    font-family:
        "Cascadia Mono",
        "Consolas",
        "Menlo",
        "DejaVu Sans Mono",
        "Noto Sans Mono",
        "Noto Sans Math",
        "Noto Sans Symbols 2",
        "Noto Sans Symbols",
        monospace;
    font-size: 1.07em;
}

pre,
pre[class*="language-"] {
    font-family:
        "Cascadia Mono",
        "Consolas",
        "Menlo",
        "DejaVu Sans Mono",
        monospace;
    font-size: 0.95rem;
    background: #f0f2f4;
    border: 1px solid #d8dee6;
    padding: 0.8rem 1rem;
    border-radius: 4px;
    overflow-x: auto;
    line-height: 1.4;
    margin: 1rem 0;
}

pre code,
pre code[class*="language-"] {
    background: none;
    padding: 0;
}

td pre,
th pre,
td pre[class*="language-"],
th pre[class*="language-"] {
    background: transparent !important;
    border: none !important;
    border-radius: 0;
    margin: 0;
    padding: 0.25rem 0;
}

td pre code,
th pre code,
td pre code[class*="language-"],
th pre code[class*="language-"] {
    background: transparent !important;
}

td code,
th code,
td code[class*="language-"],
th code[class*="language-"],
td code[class*="language-"] *,
th code[class*="language-"] * {
    background: transparent !important;
}

img {
    max-width: 100%;
    height: auto;
}

mjx-container {
    font-weight: 400 !important;
}

mjx-container mjx-math {
    font-weight: 400 !important;
}

.substeps {
    margin-left: 1.5rem;
}

/* -----------------------------------------
Dark mode (document‑like, not UI‑like)
----------------------------------------- */
@media (prefers-color-scheme: dark) {
    .proof-reason {
        color: #bbb;
    }

    img.transparent-diagram {
        filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.9));
    }

    div.predicate {
        background: #203447;
    }

    table.std2 {
        background: #202428;
    }

    table.benchmark-table tbody tr:nth-child(even) {
        background: #242a30;
    }

    body {
        background: #1a1a1a;
        color: #e6e6e6;
    }

    h1, h2, h3, h4, h5 {
        color: #c8d4ff;   /* soft, muted blue for headings */
    }

    a {
        color: #8fd0ff;
    }

    a:visited {
        color: #d6b8ff;
    }

    th {
        background: #2a2a2a;
        border-color: #444;
    }

    td {
        border-color: #444;
    }

    code,
    pre,
    code[class*="language-"],
    pre[class*="language-"] {
        background: #1e1e1e;
        color: #e6e6e6;
    }

    pre,
    pre[class*="language-"] {
        border-color: #444;
    }

    code {
        color: #bde;
        background: none;
    }

    pre code,
    pre code[class*="language-"] {
        background: none;
        color: inherit;
    }

    h2 {
        border-bottom: 1px solid #444;
    }
}

/* quoted sections */

blockquote {
    border-left: 5px solid #ccc;
    margin: 0.8em 0;        /* reduced vertical margin */
    padding: 0.6em 1em;     /* modest padding */
    text-align: justify;
}

blockquote.constitution {
    border-left: 3px solid #666;
    margin: 0.6em 0;
    padding: 0.4em 1em;
    background: none;
    font-style: normal;
}

blockquote p,
blockquote ol,
blockquote ul {
    line-height: 1.5;       /* apply line-height to text, not container */
    margin: 0.4em 0;        /* keeps internal spacing tight */
}

/* highlighted blocks and formal definitions */

.highlight,
.definition {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border: 1px solid var(--highlight-border, #aebfcb);
    border-radius: 4px;
    background: var(--highlight-background, #edf3f7);
    break-inside: avoid;
}

/* Semantic highlight variants. Blue is the default, neutral highlight. */
.highlight.positive {
    --highlight-border: #adcbb9;
    --highlight-background: #edf8f2;
}

.highlight.caution {
    --highlight-border: #d8cda3;
    --highlight-background: #fffbea;
}

.highlight.warning {
    --highlight-border: #ddc0aa;
    --highlight-background: #fff5eb;
}

.highlight.danger {
    --highlight-border: #d9b2b2;
    --highlight-background: #fff5f5;
}

.definition-label {
    display: block;
    margin-bottom: 0.2rem;
    color: #315d7d;
    font-family: 'Proxima Nova', sans-serif;
    font-weight: 700;
}

.highlight p,
.definition p {
    margin: 0;
}

@media (prefers-color-scheme: dark) {
    .highlight,
    .definition {
        --highlight-border: #587080;
        --highlight-background: #202c35;
    }

    .highlight.positive {
        --highlight-border: #527562;
        --highlight-background: #1d3027;
    }

    .highlight.caution {
        --highlight-border: #807553;
        --highlight-background: #332d1d;
    }

    .highlight.warning {
        --highlight-border: #87654f;
        --highlight-background: #38261c;
    }

    .highlight.danger {
        --highlight-border: #865858;
        --highlight-background: #382020;
    }

    .definition-label {
        color: #b9d9f1;
    }
}


/* ------------------------- relational tables ---------------------*/

.relation-title {
    color: #358;
    font-size: 0.8rem;
    font-family: 'Proxima Nova', sans-serif;
    font-weight: 600;
    margin-bottom: 0.1em;
}

table.relation {
    width: auto;
    display: inline-table;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.relation th {
    color: white;
    font-weight: 500;
    background-color: #2DA2BF;
}

.relation tr {
    background-color: #E8F0F4;
}

.relation tr:nth-child(even) {
    background-color: #D5E8F0;
}

table.relation,
.relation th,
.relation td {
    border: 1px solid white;
}

.relation th,
.relation td {
    padding: 2px 5px;
    text-align: center;
}

@media (prefers-color-scheme: dark) {
    .relation-title {
        color: #9edfff;
    }

    table.relation {
        background-color: #1e1e1e;
        color: #e6e6e6;
        border-color: #444;
    }

    .relation th {
        background-color: #3a6f80;
        color: white;
        border-color: #444;
    }

    .relation tr {
        background-color: #2a2a2a;
    }

    .relation tr:nth-child(even) {
        background-color: #333;
    }

    table.relation,
    .relation th,
    .relation td {
        border: 1px solid #444;
    }
}

.relation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.relation-block relation {
    display: block;
    font-family: monospace;
    white-space: pre;
    background: #f7f7f7;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid #ddd;
}

/* ------------------------- grammar snippets ---------------------*/

pre.grammar {
    background: #f8f4ff;
    border-left: 4px solid #6a2ca0;
    padding: 0.75rem 1rem;
    font-family: "Fira Code", monospace;
}

/* ------------------------- source browser ---------------------*/

.source-browser {
    box-sizing: border-box;
    width: min(94vw, 90rem);
    height: min(90vh, 60rem);
    padding: 0;
    border: 1px solid #aeb7c0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1rem 3rem rgb(0 0 0 / 30%);
}

.source-browser::backdrop {
    background: rgb(0 0 0 / 55%);
}

.source-browser-frame {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
}

.source-browser header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid #d8dde2;
}

.source-browser-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-browser-raw {
    margin-left: auto;
    white-space: nowrap;
}

.source-browser-close {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.source-browser-close:hover {
    background: #e8ebee;
}

.source-browser-body {
    display: grid;
    grid-template-columns: minmax(12rem, 18rem) minmax(0, 1fr);
    min-height: 0;
}

.source-browser.is-single-file .source-browser-body {
    grid-template-columns: minmax(0, 1fr);
}

.source-browser.is-single-file nav {
    display: none;
}

.source-browser nav {
    overflow: auto;
    padding: 0.6rem;
    border-right: 1px solid #d8dde2;
    background: #f4f6f8;
}

.source-browser ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.source-browser nav button {
    box-sizing: border-box;
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-family: monospace;
    text-align: left;
    cursor: pointer;
}

.source-browser nav button:hover,
.source-browser nav button.is-active {
    background: #dce8f1;
}

.source-browser main {
    min-width: 0;
    overflow: auto;
    padding: 0;
}

.source-browser-status {
    margin: 1rem;
}

.source-browser pre[class*="language-"] {
    min-height: 100%;
    margin: 0;
    border-radius: 0;
}

@media (max-width: 700px) {
    .source-browser-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }

    .source-browser nav {
        border-right: 0;
        border-bottom: 1px solid #d8dde2;
    }
}

@media (prefers-color-scheme: dark) {
    .source-browser {
        border-color: #444;
        background: #1e1e1e;
        color: #e6e6e6;
    }

    .source-browser header,
    .source-browser nav {
        border-color: #444;
    }

    .source-browser nav {
        background: #25292d;
    }

    .source-browser-close:hover,
    .source-browser nav button:hover,
    .source-browser nav button.is-active {
        background: #344554;
    }
}

@media (prefers-color-scheme: dark) {
    pre.grammar {
        background: #1e1e1e;
        border-color: #444;
        border-left-color: #6f7f9a;
        color: #e6e6e6;
    }
}
