/* Page-specific styling for the real analysis with filters project.
 * Shared chrome comes from ../project-base.css.
 *
 * Two colours carry the page's one idea: sienna for the epsilon-and-delta
 * world, blue for the filter world. Every equation, cell and code block
 * belongs to one side or the other, or bridges them.
 */

.ra-shell {
  --ra-classic: #9a5b33;
  --ra-filter: #2d718f;
  --ra-code: #f3f4f2;
  --ra-mono: "Cascadia Mono", "JetBrains Mono", ui-monospace, "DejaVu Sans Mono",
    "Segoe UI Mono", Menlo, Consolas, monospace;
}

/* --------------------------------------------------------------- rhythm */

.project-section {
  padding-block: clamp(2.5rem, 5vw, 4.5rem);
}

.ra-shell .section-rail span:first-child {
  color: var(--ra-filter);
}

/* ---------------------------------------------------------- typography */

.project-section-body h2 {
  margin: 0;
  max-width: 24ch;
  font-size: clamp(1.65rem, 3.6vw, 2.5rem);
  font-weight: 500;
  line-height: 1.16;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.project-question h2 {
  max-width: 26ch;
}

.project-section-body h3 {
  margin: clamp(2.25rem, 4.5vw, 3.25rem) 0 0.85rem;
  font-size: clamp(1.05rem, 2.1vw, 1.28rem);
  font-weight: 500;
  letter-spacing: -0.015em;
}

.project-section-body > p {
  max-width: 62ch;
  margin: 1.15rem 0 0;
  font-size: 0.97rem;
  line-height: 1.72;
}

.project-section-body .lede {
  max-width: 58ch;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.68;
}

.project-section-body .project-section-intro {
  max-width: 62ch;
  color: var(--muted);
}

.ra-shell .project-section .project-eyebrow {
  color: var(--ra-filter);
}

/* ------------------------------------------------------ table of contents */

.project-toc {
  width: min(100%, calc(var(--content-width) + (2 * var(--gutter))));
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1.35rem;
  margin-inline: auto;
  padding: 1.1rem var(--gutter);
  border-bottom: 1px solid var(--line);
}

.project-toc-label {
  margin-right: 0.4rem;
  color: var(--faint);
  font-size: 0.59rem;
  font-weight: 650;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.project-toc a {
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 130ms ease, border-color 130ms ease;
}

.project-toc a:hover {
  color: var(--ra-filter);
  border-bottom-color: var(--ra-filter);
}

/* ---------------------------------------------------------------- hero */

.hero-claim {
  margin: 0.2rem 0 0;
  line-height: 1;
}

.hero-claim img {
  display: block;
  width: 100%;
  max-width: 28rem;
  height: auto;
}

.hero-claim-gloss {
  display: block;
  max-width: 30ch;
  margin-top: 1.2rem;
  color: rgba(248, 245, 237, 0.62);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.hero-proof {
  min-width: 0;
}

.hero-check {
  color: var(--project-mint);
}

.hero-code {
  margin: 0.7rem 0;
  padding: 0.95rem 1.05rem;
  border: 1px solid rgba(246, 244, 237, 0.14);
  background: rgba(8, 18, 20, 0.42);
  overflow-x: auto;
}

.hero-code code {
  font-family: var(--ra-mono);
  font-size: 0.715rem;
  line-height: 1.62;
  color: #e2e8e4;
  white-space: pre;
}

.hero-code .tok-kw { color: #8fc0dd; }
.hero-code .tok-tac,
.hero-code .tok-sym { color: var(--project-mint); }
.hero-code .tok-type { color: #e5b98a; }
.hero-code .tok-comment { color: #7d8f90; }

.hero-proof .hero-analysis-topline span:first-child {
  font-family: var(--ra-mono);
  letter-spacing: 0;
  text-transform: none;
}

/* ------------------------------------------------------------- equations */

.eq {
  margin: 1.2rem 0 0;
  padding: 0.95rem 1.1rem;
  border-left: 2px solid var(--line);
  background: var(--paper-deep);
  overflow-x: auto;
}

/* which side of the translation an equation belongs to */
.eq-classic {
  border-left-color: var(--ra-classic);
}

.eq-filter {
  border-left-color: var(--ra-filter);
}

.eq img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
}

.project-section-body > .eq-note {
  max-width: 62ch;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.65;
}

/* ------------------------------------------------------------- code blocks */

.code-figure {
  margin: clamp(1.5rem, 3vw, 2.25rem) 0 0;
  border: 1px solid var(--line);
  background: var(--paper);
}

.code-figure pre {
  margin: 0;
  padding: clamp(1rem, 2.4vw, 1.4rem);
  border-bottom: 1px solid var(--line);
  background: var(--ra-code);
  overflow-x: auto;
}

.code-figure code {
  font-family: var(--ra-mono);
  font-size: 0.775rem;
  line-height: 1.68;
  color: #2f3438;
  white-space: pre;
}

.code-figure figcaption {
  max-width: 68ch;
  padding: 0.85rem clamp(1rem, 2.4vw, 1.4rem);
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.6;
}

.code-figure figcaption code {
  font-size: 0.9em;
  color: var(--ink);
}

.code-figure .tok-kw { color: #2f5d8a; font-weight: 600; }
.code-figure .tok-tac { color: var(--ra-filter); }
.code-figure .tok-type,
.code-figure .tok-num { color: var(--ra-classic); }
.code-figure .tok-comment { color: #8a9296; }
.code-figure .tok-string { color: #7d6a3f; }
.code-figure .tok-sym { color: #2f5d8a; }

/* --------------------------------------------------------------- callout */

.callout {
  max-width: 62ch;
  margin-top: clamp(2rem, 4vw, 2.75rem);
  padding: clamp(1.15rem, 2.6vw, 1.6rem);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ra-filter);
  background: #fbfaf6;
}

.callout p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.72;
}

/* ------------------------------------------------------------ the 169 grid */

.grid-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1px;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  border: 1px solid var(--line);
  background: var(--line);
}

.grid-wrap {
  padding: clamp(1.1rem, 2.6vw, 1.6rem);
  background: var(--paper);
}

.grid-axes {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.75rem;
  color: var(--faint);
  font-size: 0.58rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.grid-axis-x::before { content: "↔ "; color: var(--ra-classic); }
.grid-axis-y::before { content: "↕ "; color: var(--ra-filter); }

.limit-grid {
  display: grid;
  gap: 2px;
  /* a fixed track, so 169 cells stay legible instead of collapsing to their
   * minimum when the column is narrow */
  grid-template-columns: auto repeat(13, 1.65rem) !important;
}

.grid-corner {
  width: 3.1rem;
}

.grid-tag {
  color: var(--faint);
  font-size: 0.52rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.grid-tag-x {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  justify-self: center;
  align-self: end;
  padding-bottom: 0.3rem;
}

.grid-tag-y {
  align-self: center;
  padding-right: 0.45rem;
  text-align: right;
}

.grid-cell {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid #e4e7e6;
  background: #f4f6f5;
  cursor: pointer;
  transition: background 90ms ease, border-color 90ms ease;
}

.grid-cell:hover {
  border-color: var(--ra-classic);
  background: #f0e4da;
}

.grid-cell[aria-pressed="true"] {
  border-color: #18282b;
  background: #18282b;
}

.grid-detail {
  display: flex;
  flex-direction: column;
  padding: clamp(1.1rem, 2.6vw, 1.75rem);
  background: #fbfaf6;
}

.grid-count {
  margin: 0;
  color: var(--faint);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.grid-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.9rem;
  margin: 0.9rem 0 1.4rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
}

.grid-pair span {
  display: block;
  color: var(--faint);
  font-size: 0.57rem;
  font-weight: 650;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.grid-pair strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.95rem;
  font-weight: 500;
}

.grid-label {
  margin: 0 0 0.4rem;
  font-size: 0.57rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.grid-label-classic { color: var(--ra-classic); }
.grid-label-filter {
  color: var(--ra-filter);
  margin-top: 1.4rem;
}

.grid-statement {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-left: 2px solid var(--ra-classic);
  background: var(--paper);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.65;
}

.grid-statement-filter {
  border-left-color: var(--ra-filter);
  color: var(--ink);
  font-family: var(--ra-mono);
  font-size: 0.79rem;
}

.project-section-body > .grid-payoff {
  max-width: 62ch;
  margin-top: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ------------------------------------------------------------ the axioms */

.axiom-list {
  counter-reset: axiom;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1px;
  margin: clamp(1.75rem, 3.5vw, 2.5rem) 0 0;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--line);
}

.axiom-list > li {
  counter-increment: axiom;
  padding: clamp(1.2rem, 2.8vw, 1.7rem);
  background: var(--paper);
}

.axiom-list > li::before {
  content: counter(axiom, decimal-leading-zero);
  display: block;
  color: var(--ra-filter);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.axiom-list h3 {
  margin: 0.55rem 0 0.6rem;
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.axiom-list p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.68;
}

.axiom-panel {
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  border: 1px solid var(--line);
  background: var(--paper);
}

.axiom-controls {
  padding: clamp(1rem, 2.4vw, 1.4rem);
  border-bottom: 1px solid var(--line);
}

.field-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.field-button {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.field-button:hover {
  border-color: var(--ra-filter);
  color: var(--ra-filter);
}

.field-button-primary {
  border-color: #26383b;
  background: #18282b;
  color: #f6f4ed;
}

.field-button-primary:hover {
  border-color: #18282b;
  background: #21353a;
  color: #f6f4ed;
}

.subset-board {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: clamp(1rem, 2.4vw, 1.4rem);
  border-bottom: 1px solid var(--line);
}

.subset-chip {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--ra-mono);
  font-size: 0.74rem;
  cursor: pointer;
  transition: color 110ms ease, background 110ms ease, border-color 110ms ease;
}

.subset-chip:hover {
  border-color: var(--ra-filter);
  color: var(--ra-filter);
}

.subset-chip[aria-pressed="true"] {
  border-color: var(--ra-filter);
  background: var(--ra-filter);
  color: #f6f4ed;
}

.axiom-checks {
  list-style: none;
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  background: var(--line);
}

.axiom-checks > li {
  display: grid;
  grid-template-columns: 1.5rem 12rem minmax(0, 1fr);
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.75rem clamp(1rem, 2.4vw, 1.4rem);
  background: var(--paper);
  font-size: 0.82rem;
}

.check-mark {
  font-weight: 700;
}

.check-ok .check-mark { color: #2f6d55; }
.check-bad .check-mark { color: #a8422f; }

.check-label {
  font-weight: 550;
}

.check-detail {
  color: var(--muted);
  font-size: 0.78rem;
}

.axiom-verdict {
  margin: 0;
  padding: 0.9rem clamp(1rem, 2.4vw, 1.4rem);
  border-top: 1px solid var(--line);
  color: #a8422f;
  font-size: 0.88rem;
  font-weight: 600;
}

.axiom-verdict.verdict-ok {
  color: #2f6d55;
}

/* ------------------------------------------------------- the preimage chain */

.chain-panel {
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  border: 1px solid var(--line);
  background: var(--paper);
}

.chain-track {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 0.4rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
}

.chain-space {
  flex: 1 1 9rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 0.9rem;
  border: 1px solid var(--line);
  border-top: 2px solid var(--ra-filter);
  background: var(--paper-deep);
  text-align: center;
}

.chain-space-name {
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1;
}

.chain-space-filter {
  color: var(--ra-filter);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.chain-space-set {
  min-height: 2.1rem;
  margin-top: 0.4rem;
  padding: 0.35rem 0.2rem;
  border: 1px dashed transparent;
  color: var(--faint);
  font-family: var(--ra-mono);
  font-size: 0.72rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.chain-space-set.chain-set-filled {
  border-color: #2d718f;
  background: rgba(45, 113, 143, 0.09);
  color: #2d718f;
  font-weight: 600;
}

.chain-map {
  align-self: center;
  padding: 0 0.2rem;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 0.95rem;
}

.chain-map::after {
  content: " →";
  color: var(--faint);
}

.chain-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: clamp(0.9rem, 2.2vw, 1.25rem);
}

.chain-caption {
  flex: 1 1 20rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.6;
}

/* ---------------------------------------------------------- findings grid */

.finding-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: clamp(2.25rem, 4.5vw, 3.25rem);
  border: 1px solid var(--line);
  background: var(--line);
}

.finding-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(1.3rem, 3vw, 1.9rem);
  background: #fbfaf6;
}

.finding-card h3 {
  margin: 0 0 0.7rem;
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.finding-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.7;
}

.project-aside {
  margin-top: clamp(2rem, 4vw, 2.75rem);
  padding: clamp(1.2rem, 2.8vw, 1.75rem);
  border-left: 2px solid var(--ra-classic);
  background: var(--paper-deep);
}

.project-aside .project-eyebrow {
  margin: 0;
}

.project-aside p + p {
  max-width: 62ch;
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.89rem;
  line-height: 1.7;
}

/* ------------------------------------------------------------ references */

.refs {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.refs h3 {
  margin: 1.75rem 0 0.7rem;
  color: var(--faint);
  font-size: 0.59rem;
  font-weight: 650;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.refs h3:first-child {
  margin-top: 0;
}

.refs p {
  max-width: 66ch;
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.65;
}

.refs a {
  color: var(--ra-filter);
}

.refs-note {
  color: var(--faint);
}

/* -------------------------------------------------------- call to action */

.project-cta {
  padding-block: clamp(3.25rem, 6vw, 5.5rem);
}

.project-cta h2 {
  margin-inline: 0 auto;
  max-width: 28ch;
  font-size: clamp(1.65rem, 3.6vw, 2.5rem);
  font-weight: 500;
  line-height: 1.16;
  letter-spacing: -0.025em;
}

.project-cta-links {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .grid-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .finding-grid,
  .project-cta-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .finding-grid,
  .project-cta-links {
    grid-template-columns: minmax(0, 1fr);
  }

  .axiom-checks > li {
    grid-template-columns: 1.5rem minmax(0, 1fr);
  }

  .check-detail {
    grid-column: 2;
  }

  .eq {
    padding: 0.8rem 0.85rem;
  }

  .eq img {
    zoom: 0.85;
  }

  .code-figure code,
  .hero-code code {
    font-size: 0.7rem;
  }
}

@media print {
  .project-toc,
  .grid-panel,
  .axiom-panel,
  .chain-panel {
    display: none;
  }
}
