/* Cedar spec — small visual tweaks on top of mdBook's default theme. */

/* mdBook shrinks <pre><code> blocks below body text by default, which
   makes both EBNF productions and code samples (Python, TypeScript,
   Java in bindings.md) hard to read. Bump them up across the board.
   The dedicated `pre.ebnf code` rule below overrides this for EBNF. */
pre code {
  font-size: 1.4rem;
  line-height: 1.5;
}

/* Spec tables — left-align by default, slightly tighter cell padding. */
.content table th,
.content table td {
  text-align: left;
  padding: 0.4rem 0.7rem;
}

/* Blockquotes (used for spec notes / advisories) — make them stand out
   without dominating. */
.content blockquote {
  border-left: 4px solid #0d8a8a;
  background: rgba(13, 138, 138, 0.06);
  padding: 0.6rem 1rem;
}

/* Make in-text production-name `code spans` slightly more emphatic. */
.content p code,
.content li code,
.content td code {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
}

/* ---------- EBNF block rendering (mdbook-ebnf-xref output) ---------- */

pre.ebnf {
  background: var(--quote-bg, #f6f7f6);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  font-size: 1.4rem;
}

pre.ebnf code {
  font-family: var(--mono-font, "Source Code Pro", Consolas, monospace);
  font-size: 1.4rem;
  line-height: 1.55;
  background: transparent;
  padding: 0;
}

/* LHS (definition) — anchor target. Slightly heavier weight. */
.ebnf-def {
  color: #0d6f6f;
  font-weight: 600;
  text-decoration: none;
}
.ebnf-def:hover {
  text-decoration: underline;
}

/* "See also" annotation appended to the LHS of EmbeddedXxxField
   productions, linking to the standalone XxxField production. */
.ebnf-see-also {
  font-size: 0.7em;
  font-weight: 400;
  color: #5a8a8a;
  text-decoration: none;
  margin-left: 0.5em;
  padding: 0.05em 0.4em;
  border: 1px solid rgba(13, 111, 111, 0.25);
  border-radius: 3px;
  vertical-align: 0.15em;
  white-space: nowrap;
}
.ebnf-see-also:hover {
  background: rgba(13, 111, 111, 0.08);
  color: #0d6f6f;
}
.navy .ebnf-see-also,
.coal .ebnf-see-also,
.ayu .ebnf-see-also {
  color: #6dd3d3;
  border-color: rgba(109, 211, 211, 0.3);
}

/* RHS reference — clickable link to the definition. */
.ebnf-ref {
  color: #0d6f6f;
  text-decoration: none;
  border-bottom: 1px dotted rgba(13, 111, 111, 0.5);
}
.ebnf-ref:hover {
  border-bottom-style: solid;
}

/* Identifiers we couldn't resolve — render plain so dangling refs are
   visible during authoring. */
.ebnf-ident {
  color: #b03030;
}

/* Operators (::= and :::) — subdued. */
.ebnf-op {
  color: #888;
}

/* Metasymbols ( | * + ? ) — accent. */
.ebnf-meta {
  color: #b66a00;
  font-weight: 600;
}

/* Punctuation ( ( ) [ ] { } < > , ; : = ) — keep neutral. */
.ebnf-punct {
  color: #555;
}

/* Constructor forms / wire-grammar primitives (lower_snake_case). */
.ebnf-ctor {
  color: #2a4d8f;
}

/* String literals. */
.ebnf-string {
  color: #4a7a2a;
}

/* Inline EBNF comments ( //... ). */
.ebnf-comment {
  color: #888;
  font-style: italic;
}

/* Dark theme adjustments. */
.navy pre.ebnf,
.coal pre.ebnf,
.ayu pre.ebnf {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}
.navy .ebnf-def, .coal .ebnf-def, .ayu .ebnf-def,
.navy .ebnf-ref, .coal .ebnf-ref, .ayu .ebnf-ref {
  color: #6dd3d3;
}
.navy .ebnf-ref, .coal .ebnf-ref, .ayu .ebnf-ref {
  border-bottom-color: rgba(109, 211, 211, 0.5);
}
.navy .ebnf-ctor, .coal .ebnf-ctor, .ayu .ebnf-ctor {
  color: #8aa9d9;
}
.navy .ebnf-string, .coal .ebnf-string, .ayu .ebnf-string {
  color: #a8c97a;
}
.navy .ebnf-meta, .coal .ebnf-meta, .ayu .ebnf-meta {
  color: #d8a157;
}
.navy .ebnf-ident, .coal .ebnf-ident, .ayu .ebnf-ident {
  color: #e07b7b;
}

/* ---------- Validation algorithm subroutine signatures ---------- */
/* Each subroutine in spec/validation.md has an h5 heading with an
   id of the form `fn-validate-...`. Box those headings so each
   signature stands out as a navigable landmark. */

.content h5[id^="fn-validate-"] {
  background: rgba(13, 138, 138, 0.08);
  border-left: 4px solid #0d8a8a;
  border-radius: 3px;
  padding: 0.5rem 0.8rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.content h5[id^="fn-validate-"] code {
  background: transparent;
  padding: 0;
  font-size: 1.05em;
}

.content h5[id^="fn-validate-"] a.header {
  color: #0d6f6f;
  text-decoration: none;
}

/* In-text links to the boxed subroutines — give them a subtle marker
   so the reader can spot them at a glance. */
.content a[href^="#fn-validate-"] code {
  background: rgba(13, 138, 138, 0.08);
  border-bottom: 1px dotted rgba(13, 138, 138, 0.5);
}

/* Dark-theme adjustments. */
.navy .content h5[id^="fn-validate-"],
.coal .content h5[id^="fn-validate-"],
.ayu .content h5[id^="fn-validate-"] {
  background: rgba(109, 211, 211, 0.08);
  border-left-color: #6dd3d3;
}
.navy .content h5[id^="fn-validate-"] a.header,
.coal .content h5[id^="fn-validate-"] a.header,
.ayu .content h5[id^="fn-validate-"] a.header {
  color: #6dd3d3;
}
.navy .content a[href^="#fn-validate-"] code,
.coal .content a[href^="#fn-validate-"] code,
.ayu .content a[href^="#fn-validate-"] code {
  background: rgba(109, 211, 211, 0.10);
  border-bottom-color: rgba(109, 211, 211, 0.5);
}

/* ---------- Prose code-span colouring (mdbook-prose-highlight) ---------- */

/* When a property-access chain or subroutine signature renders as
   adjacent <code> elements, each piece gets the default code-span
   padding, leaving a visible gap. Tighten the padding for these
   classes so the parts read as one continuous identifier. */
.content code.ph-prod,
.content code.ph-var,
.content code.ph-prop,
.content code.ph-string,
.content code.ph-keyword,
.content code.ph-fn,
.content code.ph-punct {
  padding: 0.05rem 0.15rem;
}

/* Compound expressions (set-builder, membership predicates) render
   as a single <span class="ph-expr"> wrapper with monospace styling
   and the standard code-span tinted background, then nested inner
   <span class="ph-..."> tokens contributing colour. We use <span>
   rather than <code> to avoid pulldown-cmark warnings about
   phrasing-content nesting. */
.content span.ph-expr {
  font-family: var(--mono-font, "Source Code Pro", Consolas, monospace);
  background: rgba(0, 0, 0, 0.05);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.content span.ph-expr span.ph-prod {
  color: #0d6f6f;
  font-style: italic;
}
.content span.ph-expr span.ph-var {
  color: #a06800;
}
.content span.ph-expr span.ph-prop {
  color: #4a6080;
}
.content span.ph-expr span.ph-string {
  color: #4a7a2a;
}
.content span.ph-expr span.ph-keyword {
  color: #5a3e9a;
  font-weight: 600;
}
.content span.ph-expr span.ph-punct {
  color: #888;
}

/* Dark-theme variants for compound-expression inner tokens. */
.navy .content span.ph-expr,
.coal .content span.ph-expr,
.ayu .content span.ph-expr {
  background: rgba(255, 255, 255, 0.06);
}
.navy .content span.ph-expr span.ph-prod,
.coal .content span.ph-expr span.ph-prod,
.ayu .content span.ph-expr span.ph-prod {
  color: #6dd3d3;
}
.navy .content span.ph-expr span.ph-var,
.coal .content span.ph-expr span.ph-var,
.ayu .content span.ph-expr span.ph-var {
  color: #d8a157;
}
.navy .content span.ph-expr span.ph-prop,
.coal .content span.ph-expr span.ph-prop,
.ayu .content span.ph-expr span.ph-prop {
  color: #8aa9d9;
}
.navy .content span.ph-expr span.ph-string,
.coal .content span.ph-expr span.ph-string,
.ayu .content span.ph-expr span.ph-string {
  color: #a8c97a;
}
.navy .content span.ph-expr span.ph-keyword,
.coal .content span.ph-expr span.ph-keyword,
.ayu .content span.ph-expr span.ph-keyword {
  color: #b39ddb;
}
.navy .content span.ph-expr span.ph-punct,
.coal .content span.ph-expr span.ph-punct,
.ayu .content span.ph-expr span.ph-punct {
  color: #aaa;
}

/* Subroutine signatures in headings: the function name keeps the
   heading's teal accent; punctuation (parens, commas, colons)
   reads as quiet structural glue. */
.content code.ph-fn {
  color: #0d6f6f;
  background: transparent;
  font-weight: 600;
}
.content code.ph-punct {
  color: #888;
  background: transparent;
  padding: 0;
}
.navy .content code.ph-fn,
.coal .content code.ph-fn,
.ayu .content code.ph-fn {
  color: #6dd3d3;
}
.navy .content code.ph-punct,
.coal .content code.ph-punct,
.ayu .content code.ph-punct {
  color: #aaa;
}

/* Production names — UpperCamelCase identifiers from the abstract grammar.
   Subtle teal italic; readers can spot grammar references at a glance. */
.content code.ph-prod {
  color: #0d6f6f;
  font-style: italic;
  background: rgba(13, 138, 138, 0.06);
}

/* Algorithm keywords (Run, Verify, Warn, Let, MUST, SHOULD, MAY, etc.).
   Bold accent in a contrasting hue so they pop against the code-span
   background of variables and property accesses. */
.content code.ph-keyword {
  color: #5a3e9a;
  font-weight: 600;
  background: rgba(90, 62, 154, 0.06);
}

/* Local algorithm variables (T, F, E, fields, keys, req, eff_min, …).
   Soft amber accent so they read as named bindings within the algorithm
   text without competing visually with productions or properties. */
.content code.ph-var {
  color: #a06800;
  background: rgba(160, 104, 0, 0.06);
}

/* Property-access chains (T.embedded_artifacts, M.versioning_metadata.status).
   Slate-blue tint slightly darker than ph-var so a chain reads as a
   structural path rather than a bare variable. */
.content code.ph-prop {
  color: #4a6080;
  background: rgba(74, 96, 128, 0.06);
}

/* String literals ("required", "draft", "year", …). Soft green so
   literal values stand out against the surrounding identifier soup. */
.content code.ph-string {
  color: #4a7a2a;
  background: rgba(74, 122, 42, 0.06);
}

/* Dark-theme adjustments. */
.navy .content code.ph-prod,
.coal .content code.ph-prod,
.ayu .content code.ph-prod {
  color: #6dd3d3;
  background: rgba(109, 211, 211, 0.08);
}
.navy .content code.ph-keyword,
.coal .content code.ph-keyword,
.ayu .content code.ph-keyword {
  color: #b39ddb;
  background: rgba(179, 157, 219, 0.10);
}

/* ---------- On-failure / On-warning boxes ---------- */
/* Each Verify step in spec/validation.md has an inline annotation
   describing the error a conforming binding MUST report. The
   prose-highlight preprocessor rewrites those annotations into a
   structured key-value box: a left accent bar, a label header, and
   a definition list aligning category/path/production/message. */

.content .on-failure,
.content .on-warning {
  margin: 0.4rem 0 0.8rem 0;
  padding: 0.35rem 0.7rem 0.5rem 0.9rem;
  border-radius: 3px;
}

.content .on-failure {
  background: rgba(192, 57, 43, 0.04);
  border-left: 3px solid rgba(192, 57, 43, 0.55);
}
.content .on-warning {
  background: rgba(214, 137, 16, 0.04);
  border-left: 3px solid rgba(214, 137, 16, 0.55);
}

.content .on-failure-label,
.content .on-warning-label {
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.content .on-failure-label {
  color: #a0392b;
}
.content .on-warning-label {
  color: #a76e10;
}

.content .on-failure-fields,
.content .on-warning-fields {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 0.75rem;
  margin: 0;
}

.content .on-failure-fields dt,
.content .on-warning-fields dt {
  font-size: 0.85em;
  color: #777;
  font-weight: 500;
  margin: 0;
  padding: 0;
}
.content .on-failure-fields dd,
.content .on-warning-fields dd {
  margin: 0;
  padding: 0;
  font-size: 0.9em;
}

/* Inline note next to a path, e.g. "(the second occurrence)". */
.content .of-path-note {
  font-size: 0.85em;
  color: #888;
  font-style: italic;
}
.navy .content .of-path-note,
.coal .content .of-path-note,
.ayu .content .of-path-note {
  color: #aaa;
}

/* Dark-theme adjustments. */
.navy .content .on-failure,
.coal .content .on-failure,
.ayu .content .on-failure {
  background: rgba(255, 100, 90, 0.06);
  border-left-color: rgba(255, 130, 120, 0.6);
}
.navy .content .on-warning,
.coal .content .on-warning,
.ayu .content .on-warning {
  background: rgba(255, 180, 80, 0.05);
  border-left-color: rgba(255, 180, 80, 0.6);
}
.navy .content .on-failure-label,
.coal .content .on-failure-label,
.ayu .content .on-failure-label {
  color: #ff9a8a;
}
.navy .content .on-warning-label,
.coal .content .on-warning-label,
.ayu .content .on-warning-label {
  color: #f1b878;
}
.navy .content .on-failure-fields dt,
.coal .content .on-failure-fields dt,
.ayu .content .on-failure-fields dt,
.navy .content .on-warning-fields dt,
.coal .content .on-warning-fields dt,
.ayu .content .on-warning-fields dt {
  color: #aaa;
}
.navy .content code.ph-var,
.coal .content code.ph-var,
.ayu .content code.ph-var {
  color: #d8a157;
  background: rgba(216, 161, 87, 0.10);
}
.navy .content code.ph-prop,
.coal .content code.ph-prop,
.ayu .content code.ph-prop {
  color: #8aa9d9;
  background: rgba(138, 169, 217, 0.10);
}
.navy .content code.ph-string,
.coal .content code.ph-string,
.ayu .content code.ph-string {
  color: #a8c97a;
  background: rgba(168, 201, 122, 0.10);
}
