/*
Theme Name: Origin Canvas
Theme URI: https://origin-blocks.github.io/origin-canvas/
Author: Origin
Author URI: https://github.com/origin-blocks
Description: A Full Site Editing WordPress block theme for sites that look designed, not assembled. Templates, patterns, typography, and color - one coherent system.
Requires at least: 7.0
Tested up to: 7.0
Requires PHP: 7.4
Version: 1.3.1
License: GNU General Public License v3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Text Domain: origin-canvas
Tags: blog, block-patterns, block-styles, custom-colors, custom-logo, custom-menu, editor-style, featured-images, full-site-editing, full-width-template, grid-layout, style-variations, threaded-comments, three-columns, translation-ready
*/

/* Baseline reset keeps browser defaults predictable until block styles take over. */
*, *::before, *::after {
	box-sizing: border-box;
}

* {
	margin: 0;
	padding: 0;
}

html {
	-moz-text-size-adjust: 100%;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	-moz-osx-font-smoothing: grayscale;
	-webkit-font-smoothing: antialiased;
	line-height: 1.5;
	min-height: 100vh;
}

ul,
ol {
	list-style: none;
}

/* Block list defaults override the global reset. */
ul.wp-block-list,
ol.wp-block-list,
.wp-block-list ul,
.wp-block-list ol {
	list-style-position: outside;
	padding-inline-start: var(--wp--preset--spacing--medium);
}

ul.wp-block-list,
.wp-block-list ul {
	list-style-type: disc;
}

ol.wp-block-list,
.wp-block-list ol {
	list-style-type: decimal;
}

/**
 * Comment bodies are freeform HTML with no layout container, so the global
 * margin + list-style resets above are not otherwise restored here.
 */
.wp-block-comment-content > * + * {
	margin-block-start: var(--wp--preset--spacing--medium);
}

.wp-block-comment-content ul,
.wp-block-comment-content ol {
	list-style-position: outside;
	padding-inline-start: var(--wp--preset--spacing--medium);
}

.wp-block-comment-content ul {
	list-style-type: disc;
}

.wp-block-comment-content ol {
	list-style-type: decimal;
}

/* Contain long unbreakable strings so they wrap inside the card. */
.wp-block-comment-content {
	overflow-wrap: break-word;
	word-break: break-word;
}

/* Preformatted/code wraps inside the card instead of overflowing. */
.wp-block-comment-content pre {
	overflow-wrap: break-word;
	white-space: pre-wrap;
}

a {
	text-decoration: none;
}

.origin-canvas-links-plain a {
	text-decoration: none;
}

mark.has-inline-color:not([style*="background" i]):not(.has-background):not([class*="-background-color"]) {
	background-color: transparent;
}

img,
picture,
video,
canvas,
svg {
	display: block;
	max-width: 100%;
}

button,
input,
select,
textarea {
	color: inherit;
	font: inherit;
	margin: 0;
}

button,
input,
optgroup,
select,
textarea {
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
}

/* Form fields */
input:not([type="button"]):not([type="reset"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
select,
textarea {
	background-color: var(--wp--preset--color--surface-base);
	border: 1px solid var(--wp--preset--color--input-border);
	border-radius: var(--wp--custom--radius--medium);
	color: var(--wp--preset--color--text-body);
	font-size: var(--wp--preset--font-size--regular);
	padding: var(--wp--preset--spacing--compact) var(--wp--preset--spacing--medium);
	transition: box-shadow 120ms ease, border-color 120ms ease;
	width: 100%;
}

/**
 * Compact search — the sidebar rail only.
 *
 * The site-wide field above is sized for a full-width form; in a 373px rail it
 * reads oversized, so the field and its button drop to 40. Only the padding is
 * here - the block's own fontSize support handles the type, and core/search has
 * no padding attribute to set it with. The 404 search keeps the default size.
 */
.origin-canvas-search-compact input.wp-block-search__input:not([type="button"]):not([type="reset"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]) {
	padding: 8px 12px;
}

.origin-canvas-search-compact .wp-block-search__button {
	padding: 8px 20px;
}

input:not([type="button"]):not([type="reset"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"])::placeholder,
textarea::placeholder {
	color: var(--wp--preset--color--text-muted);
}

input:not([type="button"]):not([type="reset"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
	border-color: var(--wp--preset--color--input-border);
}

input:not([type="button"]):not([type="reset"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus,
select:focus,
textarea:focus {
	border-color: var(--wp--preset--color--primary);
	box-shadow: 0 0 0 var(--wp--preset--spacing--extra-small) color-mix(in srgb, var(--wp--preset--color--primary) 25%, transparent);
	outline: none;
}

input:not([type="button"]):not([type="reset"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):disabled,
select:disabled,
textarea:disabled {
	background-color: var(--wp--preset--color--surface-muted);
	border-color: var(--wp--preset--color--input-border);
	color: var(--wp--preset--color--text-body);
	cursor: not-allowed;
}

/* Checkboxes and radios */
input[type="checkbox"],
input[type="radio"] {
	appearance: none;
	-webkit-appearance: none;
	background: var(--wp--preset--color--surface-base);
	border: 1px solid var(--wp--preset--color--input-border);
	cursor: pointer;
	height: 20px;
	margin: 0;
	position: relative;
	transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
	width: 20px;
}

input[type="checkbox"] {
	border-radius: var(--wp--custom--radius--small);
}

input[type="radio"] {
	border-radius: 50%;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
	background: var(--wp--preset--color--primary);
	border-color: var(--wp--preset--color--primary);
}

input[type="checkbox"]:checked::after {
	border: solid #fff;
	border-width: 0 2px 2px 0;
	content: "";
	height: 9px;
	left: 6px;
	position: absolute;
	top: 3px;
	transform: rotate(45deg);
	width: 5px;
}

input[type="radio"]:checked::after {
	background: #fff;
	border-radius: 50%;
	content: "";
	height: 8px;
	left: 50%;
	position: absolute;
	top: 50%;
	transform: translate(-50%, -50%);
	width: 8px;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
	border-color: var(--wp--preset--color--primary);
	box-shadow: 0 0 0 var(--wp--preset--spacing--extra-small) color-mix(in srgb, var(--wp--preset--color--primary) 25%, transparent);
	outline: none;
}

@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
	}
}

/* Dynamic post and archive support */
.origin-canvas-post-excerpt .wp-block-post-excerpt__more-link {
	align-items: center;
	display: inline-flex;
	font-weight: 600;
	gap: 0.25rem;
	text-decoration: none;
}

.origin-canvas-post-excerpt .wp-block-post-excerpt__more-link::after {
	content: "\2192";
}

/* Featured image fallback */
.origin-canvas-featured-fallback {
	display: block;
	overflow: hidden;
}

.origin-canvas-featured-fallback--list {
	height: 100%;
	width: 100%;
}

.origin-canvas-featured-fallback--list .origin-canvas-featured-fallback__media {
	background-color: var(--wp--preset--color--surface-base);
	background-image:
		linear-gradient(to left, var(--wp--preset--color--surface-muted) 0%, color-mix(in srgb, var(--wp--preset--color--primary) 28%, var(--wp--preset--color--surface-base) 72%) 100%);
}

.origin-canvas-featured-fallback--list img {
	display: block;
	height: 100%;
	object-fit: cover;
	width: 100%;
}

.origin-canvas-featured-fallback__link {
	display: block;
	height: 100%;
	width: 100%;
}

.origin-canvas-featured-fallback__media {
	--origin-canvas-featured-fallback-edge: linear-gradient(180deg, transparent 0%, var(--wp--preset--color--surface-muted) 100%);
	background-color: var(--wp--preset--color--surface-base);
	background-image:
		radial-gradient(circle at 18% 22%, color-mix(in srgb, var(--wp--preset--color--primary) 42%, transparent) 0%, transparent 55%),
		radial-gradient(circle at 72% 30%, color-mix(in srgb, var(--wp--preset--color--primary) 32%, transparent) 0%, transparent 62%),
		radial-gradient(circle at 48% 78%, color-mix(in srgb, var(--wp--preset--color--surface-muted) 82%, transparent) 0%, transparent 64%),
		var(--origin-canvas-featured-fallback-edge),
		linear-gradient(140deg, color-mix(in srgb, var(--wp--preset--color--surface-base) 92%, transparent) 0%, color-mix(in srgb, var(--wp--preset--color--surface-muted) 72%, transparent) 100%);
	display: block;
	height: 100%;
	width: 100%;
}

/* Equal-height post grid cards */
.origin-canvas-posts--stretch .wp-block-post {
	align-items: stretch;
	display: flex;
	flex-direction: column;
	height: 100%;
}

.origin-canvas-posts--stretch .wp-block-post > .wp-block-group {
	flex: 1;
}

.origin-canvas-posts--stretch .wp-block-post-template.is-layout-grid {
	align-items: stretch;
}

.origin-canvas-post-list-card {
	align-items: stretch;
	overflow: hidden;
}

.origin-canvas-post-list-card .is-vertically-aligned-center {
	align-self: stretch;
}

.origin-canvas-post-list-card .wp-block-post-featured-image {
	height: 100%;
	width: 100%;
}

.origin-canvas-post-list-card .wp-block-post-featured-image img {
	display: block;
	height: 100%;
	object-fit: cover;
	width: 100%;
}

/**
 * Sidebar.
 *
 * Widget-to-widget spacing is owned by the group's blockGap (the pattern /
 * theme.json), which WordPress emits as constrained-layout `> * + *
 * margin-block-start`. No flex/gap is set on the wrapper here: a hard flex
 * `gap` would STACK with that constrained margin (they are additive),
 * doubling the gap. The rules below target inner block sub-elements that
 * have no theme.json/blockGap hook, so they legitimately stay CSS.
 */
.origin-canvas-sidebar .wp-block-latest-posts__list,
.origin-canvas-sidebar .wp-block-categories-list,
.origin-canvas-sidebar .wp-block-archives-list,
.origin-canvas-sidebar .wp-block-latest-comments {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--medium);
	list-style: none;
	margin: 0;
	padding: 0;
}

.origin-canvas-sidebar .wp-block-latest-posts__featured-image {
	margin-bottom: var(--wp--preset--spacing--extra-small);
}

/* The title is an inline anchor by default; the date needs to sit under it. */
.origin-canvas-sidebar .wp-block-latest-posts__post-title {
	display: block;
}

/* Category rows. Core prints the post count as a bare text node after the
   link - there is no element to target - so the row is sized as a flex line
   and the count inherits the smaller rail type from the list itself. */
/* The term name and its count are separate blocks in a flex row, so the count
   needs no styling of its own - it just must not stretch. */
.origin-canvas-sidebar-categories .wp-block-term-count {
	flex: none;
}

/* Term names are chrome - a category or tag, never prose - so they carry no
   underline. The block renders as a paragraph, which puts core's
   `:root :where(p a)` rule on the link; theme.json cannot win that (its block
   styles match at the same specificity but load earlier), so the opt-out lives
   here, keyed to the block rather than to the sidebar. */
.wp-block-term-name a {
	text-decoration: none;
}

.origin-canvas-sidebar .wp-block-latest-posts__post-date,
.origin-canvas-sidebar .wp-block-latest-comments__comment-date {
	color: var(--wp--preset--color--text-body);
	font-size: var(--wp--preset--font-size--extra-small);
	font-weight: 400;
	margin-top: var(--wp--preset--spacing--extra-small);
}

@media (max-width: 781px) {
	.origin-canvas-sidebar {
		border-top: 1px solid var(--wp--preset--color--border);
		margin-top: var(--wp--preset--spacing--huge);
		padding-top: var(--wp--preset--spacing--huge);
	}
}

/* Pagination */
.wp-block-query-pagination,
.wp-block-comments-pagination {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--small);
	justify-content: center;
}

.wp-block-query-pagination-numbers,
.wp-block-comments-pagination-numbers {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--small);
}

.wp-block-query-pagination .page-numbers,
.wp-block-comments-pagination .page-numbers {
	min-inline-size: var(--wp--preset--spacing--extra-large);
}

.wp-block-query-pagination .page-numbers.current,
.wp-block-comments-pagination .page-numbers.current {
	align-items: center;
	background: var(--wp--preset--color--text-heading);
	border-radius: var(--wp--custom--radius--medium);
	color: var(--wp--preset--color--surface-base);
	cursor: default;
	display: inline-flex;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	justify-content: center;
	min-inline-size: var(--wp--preset--spacing--extra-large);
	padding: 0.875rem 1.25rem;
}

.wp-block-query-pagination .page-numbers.dots,
.wp-block-comments-pagination .page-numbers.dots {
	align-items: center;
	background: transparent;
	color: var(--wp--preset--color--text-body);
	cursor: default;
	display: inline-flex;
	min-inline-size: auto;
	padding: 0.875rem 0.5rem;
}

/**
 * Pagination number links stay plain (opt-in underline system). The selector applies in
 * both contexts, but only has an EFFECT in the block editor: core adds an underline to
 * .wp-block-query-pagination-numbers a solely via the block's editor.css. On the front end
 * the numbers are already undecorated (the global `a { text-decoration: none }` reset), so
 * this rule is a no-op there. Loaded into the editor iframe via add_editor_style('style.css').
 */
.wp-block-query-pagination-numbers .page-numbers,
.wp-block-comments-pagination-numbers .page-numbers {
	text-decoration: none;
}

/**
 * Table default font size - must be in CSS because core/table block.json
 * rewrites theme.json selectors to target inner <table>, making wrapper
 * defaults impossible via theme.json.
 */
.wp-block-table > table {
	font-size: var(--wp--preset--font-size--small);
}

.wp-block-table[class*="-font-size"] > table {
	font-size: inherit;
}

/**
 * Sticky header: when the header contains a sticky child, make the header
 * wrapper itself the sticky element (its containing block is the page flow, so
 * it can travel), admin-bar-aware, above page content. Front end only.
 */
body:not(.wp-admin) header:has(> .is-position-sticky) {
	position: sticky;
	top: calc(0px + var(--wp-admin--admin-bar--height, 0px));
	z-index: 100;
}

@media (max-width: 600px) {
	header:has(> .is-position-sticky) {
		top: 0;
	}
}

/**
 * TRANSITIONAL back-compat for the removed `display` font-family preset.
 * REMOVE: 1.5.0 at the earliest, and only if no Display-related report has
 * arrived since 1.3.0 shipped (the rules mirror current WordPress preset
 * output — re-check them if core changes how font-family presets are emitted).
 *
 * 1.3.0 dropped the `display` preset from theme.json: its stack was
 * byte-identical to `sans`, and matching by fontFamily string made the editor's
 * font control tick both entries. Content or global styles saved under earlier
 * versions may still reference it (block picks, or Display as a global font).
 * These two rules reproduce the exact CSS WordPress generated for the preset,
 * so that stored content keeps rendering Inter: the class rule out-ranks the
 * typography variations' heading rules exactly as before, and the var
 * definition keeps a global Display font resolving instead of falling through
 * to the browser default. Non-destructive — stored content is never touched;
 * loads in the editor canvas too via add_editor_style( 'style.css' ). Known
 * limitation: stylesheets loading after this one can override these rules at
 * equal specificity — deliberate targeting of a retired preset's internals is
 * treated as the customizer's intent.
 */
:root {
	--wp--preset--font-family--display: var(--wp--preset--font-family--sans);
}

.has-display-font-family {
	font-family: var(--wp--preset--font-family--display) !important;
}
