﻿/*
Theme Name: CRC Blueprint
Theme URI: https://www.crcblueprint.com/
Author: Andreas Porse
Author URI: https://www.crcblueprint.com/
Description: A calm, evidence-first block theme for The Colorectal Cancer Blueprint. Carries the book's navy and burnt-orange identity across the site, and styles the CRC Blueprint Research plugin's article blocks to match. Built for readers who are unwell: large type, high contrast, generous tap targets, no motion.
Requires at least: 6.2
Tested up to: 6.7
Requires PHP: 7.4
Version: 1.8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: crcbp-theme
Tags: blog, one-column, block-patterns, full-site-editing, accessibility-ready, custom-colors, editor-style
*/

/* -------------------------------------------------------------------------
   1. Tokens
   theme.json generates the --wp--preset--* variables. These are the extras
   the stylesheet needs, kept in one place so the palette has a single source.
   ---------------------------------------------------------------------- */

:root {
	--crc-navy: #1E3A5F;
	--crc-navy-soft: #E7ECF2;
	--crc-orange: #D87F4A;
	--crc-orange-soft: #FAEDE3;
	--crc-green: #0E5A2E;
	--crc-sage: #7FA88C;
	--crc-amber: #D4A017;
	--crc-ink: #1A1A1A;
	--crc-muted: #6B6256;
	--crc-line: #E0D8CC;
	--crc-panel: #F2ECE3;
	--crc-base: #FAF7F2;
	--crc-radius: 3px;
}

/* -------------------------------------------------------------------------
   2. Research plugin integration
   The CRC Blueprint Research plugin styles its article blocks from its own
   custom properties and ships a teal default. Redefining them here is all it
   takes to pull every research post into the book's navy/orange identity:
   no selector duplication, no specificity fight, and the plugin can update
   its layout freely without breaking the theme.
   ---------------------------------------------------------------------- */

/* `:root:root` rather than `:root`: the plugin defines the same properties at
   `:root`, so equal specificity would let stylesheet load order decide the
   winner. Doubling the pseudo-class raises specificity just enough to win
   deterministically, whichever order the two files happen to enqueue in. */
:root:root {
	--crcbp-teal: var(--crc-navy);
	--crcbp-teal-soft: var(--crc-navy-soft);
	--crcbp-amber: var(--crc-orange);
	--crcbp-amber-soft: var(--crc-orange-soft);
	--crcbp-ink: var(--crc-ink);
	--crcbp-muted: var(--crc-muted);
	--crcbp-line: var(--crc-line);
	--crcbp-panel: var(--crc-panel);
}

/* The plugin also defines a dark scheme. This site is deliberately light
   (warm paper, like the book), so hold the palette steady and only soften
   the panels for readers whose OS prefers dark. */
@media ( prefers-color-scheme: dark ) {
	:root:root {
		--crcbp-teal: var(--crc-navy);
		--crcbp-teal-soft: var(--crc-navy-soft);
		--crcbp-amber: var(--crc-orange);
		--crcbp-amber-soft: var(--crc-orange-soft);
		--crcbp-ink: var(--crc-ink);
		--crcbp-muted: var(--crc-muted);
		--crcbp-line: var(--crc-line);
		--crcbp-panel: var(--crc-panel);
	}
}

/* The plugin's article furniture, given the book's typographic manners. */
.crcbp-dek {
	font-size: 1.2em;
	line-height: 1.5;
	color: var(--crc-muted);
	border-left: 3px solid var(--crc-orange);
	padding-left: 1rem;
	margin-bottom: 1.75rem;
}

.crcbp-evidence {
	font-family: var(--wp--preset--font-family--ui);
	border-radius: var(--crc-radius);
}

.crcbp-evidence__label {
	letter-spacing: 0.02em;
}

.crcbp-infographic img,
.crcbp-infographic__image {
	border: 1px solid var(--crc-line);
	border-radius: var(--crc-radius);
}

.crcbp-snapshot caption {
	font-family: var(--wp--preset--font-family--ui);
	color: var(--crc-muted);
	text-align: left;
}

.crcbp-takeaways,
.crcbp-questions,
.crcbp-numbers,
.crcbp-limitations {
	border-radius: var(--crc-radius);
}

.crcbp-disclaimer {
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.9rem;
	line-height: 1.5;
	color: var(--crc-muted);
	border-top: 1px solid var(--crc-line);
	padding-top: 1rem;
	margin-top: 2.5rem;
}

/* -------------------------------------------------------------------------
   3. Evidence badge
   The book grades every intervention on three axes. This is that system as a
   web component, for use in pages and in hand-written posts. Colour is never
   the only signal: each level carries its text label.
   ---------------------------------------------------------------------- */

.crc-badges {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 1.25rem 0;
	padding: 0;
	list-style: none;
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.9rem;
}

.crc-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.4rem 0.75rem;
	border: 1px solid var(--crc-line);
	border-radius: var(--crc-radius);
	background: #fff;
}

.crc-badge__dot {
	width: 0.7rem;
	height: 0.7rem;
	border-radius: 50%;
	flex: 0 0 auto;
}

.crc-badge__axis {
	color: var(--crc-muted);
}

.crc-badge__level {
	font-weight: 600;
	color: var(--crc-ink);
}

.crc-badge--speculative .crc-badge__dot { background: #C0392B; }
.crc-badge--low        .crc-badge__dot { background: #E67E22; }
.crc-badge--medium     .crc-badge__dot { background: #D4A017; }
.crc-badge--high       .crc-badge__dot { background: #27AE60; }
.crc-badge--very-high  .crc-badge__dot { background: #0E5A2E; }

/* -------------------------------------------------------------------------
   4. Landing-page components
   ---------------------------------------------------------------------- */

.crc-hero {
	border-bottom: 1px solid var(--crc-line);
}

.crc-hero__cover img {
	box-shadow: 0 2px 14px rgba( 30, 58, 95, 0.16 );
	border-radius: 2px;
}

.crc-eyebrow {
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.85rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--crc-orange);
}

/* Trust row: the book's numbers, stated plainly. */
.crc-facts {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 8rem, 1fr ) );
	gap: 1.5rem 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
	text-align: center;
}

.crc-fact__value {
	display: block;
	font-size: 2rem;
	font-weight: 600;
	line-height: 1.1;
	color: var(--crc-navy);
}

.crc-fact__label {
	display: block;
	margin-top: 0.3rem;
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.9rem;
	line-height: 1.35;
	color: var(--crc-muted);
}

/* Newsletter block. Drop the provider's embed inside .crc-signup__form. */
.crc-signup {
	background: var(--crc-navy);
	color: #fff;
	border-radius: var(--crc-radius);
	padding: clamp( 1.75rem, 4vw, 3rem );
}

.crc-signup h2,
.crc-signup h3 {
	color: #fff;
	margin-top: 0;
}

.crc-signup p {
	color: #E4E9EF;
}

.crc-signup a {
	color: #fff;
}

.crc-signup__form {
	margin-top: 1.25rem;
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
}

.crc-signup__form input[type="email"],
.crc-signup__form input[type="text"] {
	flex: 1 1 16rem;
	min-height: 3rem;
	padding: 0.75rem 0.9rem;
	font-size: 1.0625rem;
	font-family: var(--wp--preset--font-family--ui);
	color: var(--crc-ink);
	background: #fff;
	border: 1px solid transparent;
	border-radius: var(--crc-radius);
}

.crc-signup__form button,
.crc-signup__form input[type="submit"] {
	min-height: 3rem;
	padding: 0.75rem 1.4rem;
	font-family: var(--wp--preset--font-family--ui);
	font-size: 1rem;
	font-weight: 600;
	color: #fff;
	background: var(--crc-orange);
	border: 0;
	border-radius: var(--crc-radius);
	cursor: pointer;
}

.crc-signup__form button:hover,
.crc-signup__form input[type="submit"]:hover {
	background: #C46E3B;
}

.crc-signup__note {
	margin-top: 0.9rem;
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.85rem;
	line-height: 1.5;
	color: #C9D3DE;
}

/* Signup outcomes. Both are announced to screen readers by the plugin (role
   status / role alert), so they must be visible as well as legible.

   Scoped under .crc-signup deliberately. These render inside the navy panel,
   where `.crc-signup p` sets a pale text colour for contrast against navy. At
   equal-looking specificity that rule (0,1,1) would beat a bare
   `.crc-signup__ok` (0,1,0) and leave near-white text on a white box. */
.crc-signup .crc-signup__ok,
.crc-signup .crc-signup__error {
	margin: 1.25rem 0 0;
	padding: 0.85rem 1rem;
	border-radius: var(--crc-radius);
	font-family: var(--wp--preset--font-family--ui);
	font-size: 1rem;
	line-height: 1.5;
	background: #FFFFFF;
}

.crc-signup .crc-signup__ok {
	color: #14472A;
	border-left: 4px solid #27AE60;
}

.crc-signup .crc-signup__error {
	color: #8A2A1B;
	border-left: 4px solid #C0392B;
}

/* -------------------------------------------------------------------------
   5. Post cards and archive
   ---------------------------------------------------------------------- */

.crc-card {
	background: #fff;
	border: 1px solid var(--crc-line);
	border-radius: var(--crc-radius);
	overflow: hidden;
	height: 100%;
}

.crc-card img {
	width: 100%;
	height: auto;
	display: block;
}

.crc-meta {
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.85rem;
	color: var(--crc-muted);
}

/* Topic and evidence terms as quiet chips. */
.wp-block-post-terms a,
.crc-chip {
	display: inline-block;
	padding: 0.15rem 0.55rem;
	margin-right: 0.3rem;
	background: var(--crc-navy-soft);
	color: var(--crc-navy);
	border-radius: 2px;
	font-size: 0.8rem;
	text-decoration: none;
}

.wp-block-post-terms a:hover,
.crc-chip:hover {
	background: var(--crc-orange-soft);
	color: #A2521F;
}

/* Research topic filter bar. Horizontal chips that wrap on narrow screens
   rather than turning into a scroller, so nothing is hidden off-edge. */
.crc-filter {
	margin: 0 0 var(--wp--preset--spacing--40, 2rem);
	padding-bottom: 0.9rem;
	border-bottom: 1px solid var(--crc-line);
}

.crc-filter ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.crc-filter__item {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	min-height: 2.5rem;
	padding: 0.4rem 0.85rem;
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.92rem;
	line-height: 1.3;
	color: var(--crc-navy);
	background: #fff;
	border: 1px solid var(--crc-line);
	border-radius: 999px;
	text-decoration: none;
}

.crc-filter__item:hover {
	border-color: var(--crc-orange);
	color: #A2521F;
}

/* The active topic is marked by fill and weight as well as colour, so the
   selection survives greyscale and colour blindness. */
.crc-filter__item.is-current {
	background: var(--crc-navy);
	border-color: var(--crc-navy);
	color: #fff;
	font-weight: 600;
}

.crc-filter__count {
	font-size: 0.8rem;
	opacity: 0.7;
	font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
   Book page: contents list
   ---------------------------------------------------------------------- */

.crc-toc {
	margin: 0;
	padding: 0;
	list-style: none;
	columns: 2;
	column-gap: var(--wp--preset--spacing--50, 3rem);
}

@media ( max-width: 600px ) {
	.crc-toc {
		columns: 1;
	}
}

.crc-toc li {
	break-inside: avoid;
	display: flex;
	gap: 0.6rem;
	padding: 0.3rem 0;
	line-height: 1.4;
}

.crc-toc__num {
	flex: 0 0 1.6rem;
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.85rem;
	color: var(--crc-orange);
	font-variant-numeric: tabular-nums;
	padding-top: 0.15rem;
}

.crc-part {
	margin: var(--wp--preset--spacing--40, 2rem) 0 0.75rem;
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--crc-navy);
	padding-bottom: 0.4rem;
	border-bottom: 2px solid var(--crc-orange);
}

/* Buy links sit side by side and stay finger-sized. */
.crc-buy {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin: var(--wp--preset--spacing--40, 2rem) 0;
	padding: 0;
	list-style: none;
}

.crc-buy__link {
	display: inline-flex;
	flex-direction: column;
	min-height: 3.25rem;
	padding: 0.7rem 1.4rem;
	border-radius: var(--crc-radius);
	font-family: var(--wp--preset--font-family--ui);
	text-decoration: none;
	background: var(--crc-navy);
	color: #fff;
}

.crc-buy__link:hover {
	background: var(--crc-orange);
	color: #fff;
}

.crc-buy__format {
	font-weight: 600;
	font-size: 1rem;
}

.crc-buy__meta {
	font-size: 0.82rem;
	opacity: 0.85;
}

/* The pay-what-you-want route is the one to take, so it is visually the
   loudest: orange fill, larger text. The retail links below it are quieter
   outlines, present for people who want Kindle or print. */
.crc-buy__link--primary {
	background: var(--crc-orange);
	padding: 0.9rem 1.8rem;
}

.crc-buy__link--primary:hover {
	background: var(--crc-navy);
}

.crc-buy__link--primary .crc-buy__format {
	font-size: 1.1rem;
}

.crc-buy--secondary {
	margin-top: 0.5rem;
}

.crc-buy--secondary .crc-buy__link {
	background: transparent;
	color: var(--crc-navy);
	border: 1px solid var(--crc-navy);
	justify-content: center;
	min-height: 2.75rem;
	padding: 0.55rem 1.1rem;
}

.crc-buy--secondary .crc-buy__link:hover {
	background: var(--crc-navy);
	color: #fff;
}

.crc-buy__aside {
	margin: 1.75rem 0 0;
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.92rem;
	color: var(--crc-muted);
}

/* Affiliate disclosure. Required to sit near the links it refers to, so it is
   quiet but not hidden: same size as body small text, not grey-on-grey. */
.crc-buy__disclosure {
	margin: 0.9rem 0 0;
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.85rem;
	line-height: 1.5;
	color: var(--crc-muted);
	max-width: 34rem;
}

/* Inline PDF reader for the sample chapter. Embedded PDFs are close to
   unusable on a phone: no pinch-zoom in many in-app browsers, and the viewer
   chrome eats the screen. So the reader is desktop-only and the buttons above
   it carry the job everywhere else. */
.crc-pdf {
	display: none;
	margin-top: var(--wp--preset--spacing--40, 2rem);
}

.crc-pdf__object {
	width: 100%;
	height: 78vh;
	min-height: 420px;
	border: 1px solid var(--crc-line);
	border-radius: var(--crc-radius);
	background: #fff;
}

@media ( min-width: 782px ) {
	.crc-pdf {
		display: block;
	}
}

.crc-buy--sample {
	margin-bottom: 0;
}

/* A figure that supports the text rather than interrupting it. Held to the
   reading measure instead of running full wide, so a two-panel diagram does
   not dominate the section it belongs to. */
.crc-fig--inline {
	max-width: 34rem;
	margin-inline: auto;
}

/* Back cover, shown as a physical object rather than a flat graphic. */
.crc-backcover img {
	border-radius: 2px;
	box-shadow: 0 2px 14px rgba( 30, 58, 95, 0.16 );
}

/* Portrait: round, modest, and never larger than it needs to be. */
.crc-portrait img {
	border-radius: 50%;
	max-width: 260px;
	width: 100%;
	height: auto;
	border: 4px solid #fff;
	box-shadow: 0 2px 14px rgba( 30, 58, 95, 0.14 );
}

/* Figures lifted from the book sit on white with a hairline, so the book's
   own warm-paper background does not clash with the page. */
.wp-block-image.alignwide img {
	border: 1px solid var(--crc-line);
	border-radius: var(--crc-radius);
	background: #fff;
}

/* -------------------------------------------------------------------------
   6. Reading comfort
   Readers are often fatigued, sometimes on a phone in a hospital chair, and
   chemotherapy neuropathy makes small targets hard to hit. These rules are
   requirements, not polish.
   ---------------------------------------------------------------------- */

body {
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

/* Never justify: ragged right is easier to track when tired, and avoids the
   rivers that justification opens up at narrow widths. */
p, li {
	text-align: left;
	hyphens: none;
}

.entry-content p,
.wp-block-post-content p {
	max-width: 40rem;
}

/* Generous, visible focus. Keyboard users must always know where they are. */
:where( a, button, input, select, textarea, [tabindex] ):focus-visible {
	outline: 3px solid var(--crc-orange);
	outline-offset: 2px;
	border-radius: 2px;
}

/* Comfortable hit areas in navigation and lists of links. */
.wp-block-navigation a,
.wp-block-post-terms a,
.crc-footer a {
	padding-block: 0.35rem;
	display: inline-block;
	min-height: 1.5rem;
}

/* Skip link, visible the moment it is focused. */
.crc-skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 999;
	padding: 0.75rem 1.25rem;
	background: var(--crc-navy);
	color: #fff;
	font-family: var(--wp--preset--font-family--ui);
	text-decoration: none;
}

.crc-skip-link:focus {
	left: 0;
}

/* Images never overflow, and tables scroll rather than break the page. */
img {
	max-width: 100%;
	height: auto;
}

.wp-block-table,
.crcbp-snapshot-wrap {
	overflow-x: auto;
}

/* No motion. Nothing on this site needs to move, and vestibular symptoms are
   common during treatment. */
@media ( prefers-reduced-motion: reduce ) {
	*,
	*::before,
	*::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}
}

/* -------------------------------------------------------------------------
   7. Header and footer
   ---------------------------------------------------------------------- */

.crc-header {
	border-bottom: 1px solid var(--crc-line);
	background: var(--crc-base);
}

.crc-footer {
	border-top: 1px solid var(--crc-line);
	background: var(--crc-panel);
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.92rem;
}

.crc-footer a {
	color: var(--crc-navy);
}

/* The medical disclaimer is legally and ethically load-bearing. Keep it
   readable rather than shrinking it into the fine print. */
.crc-disclaimer {
	font-size: 0.9rem;
	line-height: 1.55;
	color: var(--crc-muted);
	border-left: 3px solid var(--crc-amber);
	padding: 0.75rem 0 0.75rem 1rem;
	margin: 0;
}

/* -------------------------------------------------------------------------
   8. Print
   ---------------------------------------------------------------------- */

@media print {
	.crc-header,
	.crc-footer,
	.crc-signup,
	.wp-block-navigation {
		display: none !important;
	}

	body {
		background: #fff;
		color: #000;
		font-size: 11pt;
	}
}



