/* CTS blueprint layer: the exposed drawing grid and the footer nameplate.
   Optional. A page opts in by markup alone, and nothing here changes a page that does not use it:
     1. <div class="bp-rule" aria-hidden="true"></div> placed between two sections of <main> draws the section rule,
        its two brass register marks and the section index ("02 / 05"). The count is worked out here; no numbers in the HTML.
          bp-rule--open  where the next section starts flush with a panel and a line would cut through it:
                         the marks and rails only. It still counts as a section.
          bp-rule--mark  the rule and marks alone: no index, no rails, not counted (Insights mastheads).
     2. The footer: the site index (.cts-footer__grid) over the engraved nameplate (.nameplate).
   Load after cts-site.css. Every colour is a token from cts-tokens.css; this file defines no colour of its own.
   Nothing here moves: there is no animation and no transition, so there is nothing to switch off for reduced motion.
   Claude Code (Fable 5.2), 2026-11-24. */

/* ============ Local names for the tokens this layer reads ============ */
.bp-rule,
.cts-footer {
  --bp-line: var(--cts-color-line);
  --bp-line-strong: var(--cts-color-line-strong);
  --bp-brass: var(--cts-brass-hairline, var(--cts-color-accent-line)); /* polish-tokens' decorative brass; the older token until that file is merged */
  --bp-ink: var(--cts-color-text-tertiary);
  --bp-wrap: var(--cts-layout-wrap);
  --bp-mark: 9px;  /* a register mark is 9 x 9: odd, so its 1px strokes cross on a whole pixel */
  --bp-half: 4px;
  --bp-out: 0px;   /* how far a rule runs past the text column on each side; widened on desktop below */
  /* Painted layers, shared by the rules and the footer. A register mark is two 1px strokes at each end of the box. */
  --bp-marks:
    linear-gradient(var(--bp-brass), var(--bp-brass)) left var(--bp-half) top / 1px var(--bp-mark) no-repeat,
    linear-gradient(var(--bp-brass), var(--bp-brass)) left top var(--bp-half) / var(--bp-mark) 1px no-repeat,
    linear-gradient(var(--bp-brass), var(--bp-brass)) right var(--bp-half) top / 1px var(--bp-mark) no-repeat,
    linear-gradient(var(--bp-brass), var(--bp-brass)) right top var(--bp-half) / var(--bp-mark) 1px no-repeat;
  --bp-hair: linear-gradient(var(--bp-line), var(--bp-line)) center top var(--bp-half) / calc(100% - 2 * var(--bp-half)) 1px no-repeat;
  --bp-rails:
    linear-gradient(var(--bp-line), var(--bp-line)) left var(--bp-half) top var(--bp-half) / 1px 100% no-repeat,
    linear-gradient(var(--bp-line), var(--bp-line)) right var(--bp-half) top var(--bp-half) / 1px 100% no-repeat;
}

/* ============ Section rule ============
   A zero-height element that sits exactly on the boundary between two sections. It takes no room, so no page gets
   taller and nothing shifts. Its two drawn parts are placed against <main>:
     ::before  the hairline with a register mark at each end (and, on the first rule, the two rails)
     ::after   the index, hanging below the line inside the top padding of the section that follows
   Neither sets "top", so each starts at the rule's own place in the page. */
main { counter-reset: bp-sheet; }
main:has(> .bp-rule) { position: relative; }

.bp-rule {
  --bp-layers: var(--bp-marks), var(--bp-hair);
  /* The page margin on each side of the text column (.cts-wrap), as a share of <main>. */
  --bp-side: calc((100% - min(var(--bp-wrap), 100% - 2 * var(--cts-layout-gutter))) / 2);
  height: 0;
  counter-increment: bp-sheet;
}
.bp-rule--open { --bp-layers: var(--bp-marks); }
/* The Insights archive pages use a wider column (insights.css: 82rem). The rule follows it. */
:is(.insights-landing, .insights-category) .bp-rule { --bp-wrap: 82rem; }
/* A section that is switched off (the founding offer, launch-only blocks) takes its rule with it,
   and the count closes up: a hidden rule does not increment the counter. */
.bp-rule:has(+ [hidden]) { display: none; }

.bp-rule::before {
  content: "";
  position: absolute;
  z-index: 1;
  right: calc(var(--bp-side) - var(--bp-out) - var(--bp-half));
  left: calc(var(--bp-side) - var(--bp-out) - var(--bp-half));
  height: var(--bp-mark);
  margin-top: calc(-1 * var(--bp-half));
  background: var(--bp-layers);
  pointer-events: none;
}

/* The index: this section's number, then how many there are. */
.bp-rule::after {
  content: counter(bp-sheet, decimal-leading-zero) var(--bp-of, "");
  content: counter(bp-sheet, decimal-leading-zero) var(--bp-of, "") / ""; /* decoration: screen readers skip it */
  position: absolute;
  z-index: 1;
  right: var(--bp-side);
  margin-top: var(--cts-space-3);
  color: var(--bp-ink);
  font-family: var(--cts-font-family-mono);
  font-size: var(--cts-font-size-eyebrow);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: pre;
  pointer-events: none;
}
.bp-rule--mark { counter-increment: none; }
.bp-rule--open::after,
.bp-rule--mark::after { content: none; }

/* How many sections the page has: count the rules that are followed by a section that is showing.
   Each line overrides the one before it, so the last one that matches wins. Browsers without :has() or
   "of <selector>" show the section number alone ("02"). */
main:has(> :nth-child(2 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 02"; }
main:has(> :nth-child(3 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 03"; }
main:has(> :nth-child(4 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 04"; }
main:has(> :nth-child(5 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 05"; }
main:has(> :nth-child(6 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 06"; }
main:has(> :nth-child(7 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 07"; }
main:has(> :nth-child(8 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 08"; }
main:has(> :nth-child(9 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 09"; }
main:has(> :nth-child(10 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 10"; }
main:has(> :nth-child(11 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 11"; }
main:has(> :nth-child(12 of .bp-rule:not(.bp-rule--mark) + :not([hidden]))) { --bp-of: " / 12"; }

/* On a phone an open rule draws nothing: its marks would sit on the corners of the panel below it. */
@media (max-width: 899px) {
  .bp-rule--open::before { content: none; }
}

/* ---- Desktop: the rule reaches into the gutter and the two rails run down the page ----
   One level deep: rails and section rules only. Nothing inside a section is boxed.
   On a phone the gutter is 20px, so there are no rails there: a rail would crowd the text. */
@media (min-width: 900px) {
  .bp-rule {
    --bp-out: calc(var(--cts-layout-gutter) / 2);
    --bp-out: round(down, calc(var(--cts-layout-gutter) / 2), 1px);
  }
  /* The rails belong to the first rule: its box runs from the rule down to the end of <main>.
     They start under the hero, so no line is drawn across a hero scene. */
  @supports selector(:has(*)) and selector(:nth-child(1 of a)) {
    .bp-rule:nth-child(1 of .bp-rule:not(.bp-rule--mark))::before {
      height: var(--bp-rail-h, 0px);
      background: var(--bp-layers), var(--bp-rails);
    }
  }
}

/* ============ Footer: site index over the nameplate ============ */
/* Register marks where the rails meet the footer's top line. */
.cts-footer::after {
  content: "";
  position: absolute;
  top: calc(-1 * var(--bp-half));
  left: 50%;
  width: calc(min(var(--bp-wrap), 100% - 2 * var(--cts-layout-gutter)) + 2 * var(--bp-out) + var(--bp-mark));
  height: var(--bp-mark);
  translate: -50% 0;
  background: var(--bp-marks);
  pointer-events: none;
}

/* Site index: the three link lists. The company name now lives on the nameplate below. */
.cts-footer__grid { padding-block: var(--cts-space-8) var(--cts-space-7); }
@media (min-width: 900px) {
  .cts-footer { --bp-out: calc(var(--cts-layout-gutter) / 2); --bp-out: round(down, calc(var(--cts-layout-gutter) / 2), 1px); }
  .cts-footer__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
  .footer__pages { gap: 0; }
  /* One hairline between neighbouring lists: the same one-level grid as the page above. */
  .footer__pages > div + div,
  .cts-footer__contact { padding-left: var(--cts-space-6); box-shadow: inset 1px 0 0 var(--bp-line); }
}

/* The nameplate: a maker's plate. Name and line on the left, then three stamped fields. */
.nameplate { padding-bottom: var(--cts-space-7); }
.nameplate__plate {
  position: relative;
  display: grid;
  border: 1px solid var(--bp-line-strong);
  border-radius: var(--cts-radius-xs);
  background: var(--cts-gradient-surface);
  box-shadow: var(--cts-shadow-sheen), var(--cts-shadow-1);
}
/* The engraved border: a second, finer line set in from the edge. */
.nameplate__plate::before {
  content: "";
  position: absolute;
  inset: var(--cts-space-1);
  border: 1px solid var(--bp-line);
  border-radius: 3px;
  pointer-events: none;
}
.nameplate__maker,
.nameplate__cell { padding: var(--cts-space-5); }
/* Letters cut into the plate: dark on the upper edge of each stroke, a line of light on the lower. */
.nameplate__maker .footer__wordmark,
.nameplate__cell dd { text-shadow: 0 -1px 0 var(--cts-color-black), 0 1px 0 var(--bp-line); }
.nameplate__maker p:not(.footer__wordmark) { max-width: none; }

.nameplate__data { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nameplate__cell { display: grid; align-content: start; gap: var(--cts-space-2); min-width: 0; }
.nameplate__cell--area { grid-column: 1 / -1; }
/* A groove between fields: a dark line with a line of light beside it. */
.nameplate__data,
.nameplate__cell:not(.nameplate__cell--area) { border-top: 1px solid var(--cts-color-black); box-shadow: inset 0 1px 0 var(--bp-line); }
.nameplate__cell:last-child { border-left: 1px solid var(--cts-color-black); box-shadow: inset 0 1px 0 var(--bp-line), inset 1px 0 0 var(--bp-line); }
.nameplate__cell dt {
  color: var(--bp-ink);
  font-family: var(--cts-font-family-mono);
  font-size: var(--cts-font-size-eyebrow);
  letter-spacing: var(--cts-letter-spacing-eyebrow);
  line-height: 1.5;
  text-transform: uppercase;
}
.nameplate__cell dd span { display: block; }
.nameplate__cell dd {
  margin: 0;
  color: var(--cts-color-text);
  font-size: var(--cts-font-size-small);
  font-variant-numeric: tabular-nums;
  line-height: var(--cts-line-height-snug);
  text-wrap: balance;
}
/* The revision is the one stamped value: mono, a size down, on the same 21px line as its neighbours (13px x 1.62). */
.nameplate__cell .nameplate__rev { font-family: var(--cts-font-family-mono); font-size: var(--cts-font-size-caption); letter-spacing: 0.06em; line-height: 1.62; white-space: nowrap; }
.nameplate__legal { margin-top: var(--cts-space-5); color: var(--bp-ink); font-size: var(--cts-font-size-caption); }

/* Small phones: tighter padding, so "Veteran-owned" and the revision each stay on one line in their half. */
@media (max-width: 479px) {
  .nameplate__maker,
  .nameplate__cell { padding: var(--cts-space-5) var(--cts-space-4); }
}
/* From 900px the three fields sit in one row under the name. */
@media (min-width: 900px) {
  .nameplate__data { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) minmax(0, 1fr); }
  .nameplate__cell--area { grid-column: auto; }
  .nameplate__data .nameplate__cell { border-top: 0; box-shadow: none; }
  .nameplate__data .nameplate__cell + .nameplate__cell { border-left: 1px solid var(--cts-color-black); box-shadow: inset 1px 0 0 var(--bp-line); }
}
/* From 1120px the plate is one row: the name, then the fields. */
@media (min-width: 1120px) {
  .nameplate__plate { grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr); }
  .nameplate__maker { align-self: center; }
  .nameplate__data { border-top: 0; box-shadow: none; }
  .nameplate__data .nameplate__cell:first-child { border-left: 1px solid var(--cts-color-black); box-shadow: inset 1px 0 0 var(--bp-line); }
}

/* ============ Forced colours and print ============ */
@media (forced-colors: active) {
  /* The system paints its own colours; gradients used as lines would vanish, so draw real borders. */
  .bp-rule::before, .bp-rule:nth-child(n)::before { bottom: auto; height: 0; margin-top: 0; background: none; border-top: 1px solid GrayText; }
  .cts-footer::after { display: none; }
  .nameplate__plate, .nameplate__plate::before { border-color: ButtonText; }
  .nameplate__maker .footer__wordmark, .nameplate__cell dd { text-shadow: none; }
}
@media print {
  .bp-rule, .cts-footer::after { display: none; }
  .nameplate__plate { border-color: currentColor; background: none; box-shadow: none; }
  .nameplate__plate::before { display: none; }
  .nameplate__maker .footer__wordmark, .nameplate__cell dd { text-shadow: none; }
}
