/*
Theme Name: Benday
Theme URI: https://themeshaper.com/benday/
Author: Automattic
Author URI: https://automattic.com/
Description: Benday is a Pop Art blog theme for writing about ordinary things: flat colour cards, hard keylines and loud condensed headlines, with the reading kept clean.
Requires at least: 7.1
Tested up to: 7.1
Requires PHP: 7.2
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: benday
Tags: one-column, grid-layout, featured-images, full-site-editing, block-patterns, rtl-language-support, sticky-post, threaded-comments, translation-ready, wide-blocks, block-styles, style-variations, blog
*/

/*
 * Where Benday's CSS lives
 *
 * 1. Global Styles (theme.json "styles"): colours, type, spacing, borders.
 *    Anything the Styles panel can set goes there first.
 * 2. theme.json block CSS ("styles.blocks.<block>.css"): what Styles cannot
 *    express, such as the card colour loop in core/post-template. It loads on
 *    the front and in the Editor. WordPress compiles every rule there as
 *    ":root :where(...)", so all rules weigh the same and the later rule wins:
 *    keep their order when editing.
 * 3. Block styles (styles/blocks/*.json): Color Loop, Fill, Badges, Display,
 *    Dots. Their CSS prints only when a block uses the style.
 * 4. This file: front end only. The Editor loads assets/css/editor-style.css
 *    instead, so a rule that must also show in the Editor goes in both files.
 *
 * Sections: Ichi base, Cards, Marquee, Navigation overlay, Post navigation.
 */

/* ==========================================================================
   Ichi base (inherited, mirrored in editor-style.css)
   ========================================================================== */

@view-transition {
	navigation: auto;
}

/* Font smoothing */
body {
	text-rendering: geometricprecision;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/*
 * Progressive enhancement to reduce widows and orphans
 * https://github.com/WordPress/gutenberg/issues/55190
 */
h3, h4, h5, h6, blockquote, caption, figcaption, p {
	text-wrap: pretty;
}

/* Large headings break into lines of similar length. */
h1, h2 {
	text-wrap: balance;
}

/*
 * Link styles
 * https://github.com/WordPress/gutenberg/issues/42319
 */
a {
	text-decoration-thickness: 1px !important;
	text-underline-offset: 0.1em;
}

/*
 * Change the position of the more block on the front, by making it a block level element.
 * https://github.com/WordPress/gutenberg/issues/65934
 */
.more-link {
	display: block;
}

/*
 * Prevents unnecessary scrollbars while handling long lines of preformatted text.
 * https://core.trac.wordpress.org/ticket/63875
 */
:where(pre) {
	overflow-x: auto;
}

/*
 * Make sure footers have no margin.
 * https://github.com/WordPress/gutenberg/issues/47637
 */
footer.wp-block-template-part {
	margin-block-start: 0 !important;
}

/* ==========================================================================
   Cards (front end only)
   Any Cover that is a Query Loop item: Mixed, Photo, Color and Note Cards.
   Their colours and labels live in theme.json (core/post-template) and in
   the Color Loop and Fill block styles. These rules stay out of the Editor
   on purpose, so the canvas stays clickable and still.
   ========================================================================== */

/*
 * Click anywhere: the date link is stretched over the whole card. The text
 * layer drops its own positioning so the stretched link fills the whole
 * Cover; as a flex item, its z-index still paints it over the image. The
 * category link stays clickable on top.
 */
.wp-block-post-template > li > .wp-block-cover > .wp-block-cover__inner-container {
	position: static;
	z-index: 1;
}

.wp-block-post-template > li > .wp-block-cover .wp-block-post-date a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.wp-block-post-template > li > .wp-block-cover .wp-block-post-terms a {
	position: relative;
	z-index: 1;
}

/*
 * Hover and keyboard focus: the card grows slightly and the plus icon makes
 * a quarter turn. In loops built from a Featured Image block instead of a
 * Cover (Post List, Archive, Search), the image zooms inside its frame and
 * the frame stays put. The plus needs the "card-plus" class on its Icon
 * block; that works in every loop, the Post List included.
 */
.wp-block-post-template > li > .wp-block-cover:hover,
.wp-block-post-template > li > .wp-block-cover:focus-within {
	transform: scale(1.03);
	z-index: 1;
}

.wp-block-post-template .wp-block-post-featured-image {
	overflow: hidden;
}

.wp-block-post-template > li:hover .wp-block-post-featured-image img,
.wp-block-post-template > li:focus-within .wp-block-post-featured-image img {
	transform: scale(1.03);
}

.wp-block-post-template > li:hover .card-plus svg,
.wp-block-post-template > li:focus-within .card-plus svg {
	transform: rotate(90deg);
}

@media (prefers-reduced-motion: no-preference) {
	.wp-block-post-template > li > .wp-block-cover,
	.wp-block-post-template .wp-block-post-featured-image img,
	.wp-block-post-template .card-plus svg {
		transition: transform 0.2s ease;
	}
}

/*
 * Post List, Archive and Search: a post without a featured image keeps only
 * its text box, which then lines up with the page heading instead of sitting
 * one padding in. The padding is an inline block style, hence !important.
 */
.wp-block-post-template > li > .wp-block-group:not(:has(> .wp-block-post-featured-image)) > .wp-block-group:has(.card-plus) {
	padding-inline-start: 0 !important;
}

/* ==========================================================================
   Marquee (mirrored in editor-style.css: keep both copies in sync)
   Add the class "marquee" to a Group that holds a Query Loop or a Row: the
   posts, or the Row's blocks, run in one line from right to left, pause on
   hover or keyboard focus, and stay still with reduced motion. Used by the
   Marquee Wrapper in Header Filters (Query Loop) and by a Row of paragraphs.
   ========================================================================== */

/* The row never sizes the wrapper: the wrapper only fills the space left. */
.marquee {
	overflow: hidden;
	contain: inline-size;
}

.marquee > .wp-block-query {
	min-width: 0;
}

/* A Row placed directly in the wrapper keeps its full length. */
.marquee > .wp-block-group {
	flex: none;
}

/*
 * One line of posts or blocks. A Row sets its own gap (Block spacing); the
 * post loop follows Styles > Layout > Block spacing.
 */
.marquee .wp-block-post-template,
.marquee > .wp-block-group {
	display: flex;
	flex-wrap: nowrap;
	width: max-content;
	max-width: none;
}

.marquee .wp-block-post-template {
	gap: var(--wp--style--block-gap);
}

.marquee .wp-block-post-template > li,
.marquee > .wp-block-group > * {
	flex: none;
	margin-block: 0;
}

/*
 * The row starts just past the right edge (padding of one wrapper width) and
 * moves by its own full width, so it leaves completely on the left before
 * looping. Speed: the duration of one pass.
 */
@media (prefers-reduced-motion: no-preference) {
	.marquee .wp-block-post-template,
	.marquee > .wp-block-group {
		padding-left: 100%;
		animation: benday-marquee 10s linear infinite;
	}

	.marquee:hover .wp-block-post-template,
	.marquee:focus-within .wp-block-post-template,
	.marquee:hover > .wp-block-group,
	.marquee:focus-within > .wp-block-group {
		animation-play-state: paused;
	}
}

@keyframes benday-marquee {
	to {
		transform: translateX(-100%);
	}
}

/* ==========================================================================
   Navigation overlay: push-down (front end only)
   While the menu is open, the overlay opens inside the header and pushes the
   page down instead of covering it. The header's logo and hamburger hide, and
   the overlay's first line (its own logo and the ×) takes their place: keep
   that line the same size as the header row in the Editor, so nothing jumps.
   Relies on the class "header-row" on the Header group (parts/header.html).
   Without it, the overlay opens full screen as usual.
   ========================================================================== */

/*
 * The hamburger's black circle (mirrored in editor-style.css). It lives here
 * because the Navigation block's own colour and spacing settings would also
 * style the open menu.
 */
.header-row .wp-block-navigation__responsive-container-open {
	padding: var(--wp--preset--spacing--30);
	border-radius: 50%;
	background-color: var(--wp--preset--color--theme-2);
	color: var(--wp--preset--color--theme-4);
}

/*
 * While open, only the overlay shows in the header. The overlay repeats the
 * header's padding, so the header drops its own (!important: the Editor
 * writes that padding inline).
 */
.header-row:has(.is-menu-open) {
	padding: 0 !important;
}

.header-row:has(.is-menu-open) > :not(.wp-block-navigation),
.header-row:has(.is-menu-open) > .wp-block-navigation > .wp-block-navigation__responsive-container-open {
	display: none;
}

.header-row:has(.is-menu-open) > .wp-block-navigation {
	flex-basis: 100%;
}

/* The overlay sits in the page instead of floating over it, and the page keeps scrolling. */
.header-row .wp-block-navigation__responsive-container.is-menu-open {
	position: static;
	width: 100%;
	height: auto;
	padding: 0;
	overflow: visible;
	z-index: auto;
	animation: none;
}

html.has-modal-open:has(.header-row .is-menu-open) {
	overflow: visible;
}

/*
 * While a menu overlay is open, WordPress drops Cover content behind its image
 * (z-index: auto), meant for overlays that cover the whole page. Here the page
 * stays in view below the menu, so Covers keep their usual z-index: 1 (the
 * post cards' title boxes vanished without it). Mirrors core's selector.
 */
html:has(.header-row .is-menu-open) body:not(.editor-styles-wrapper) .wp-block-cover:not(.wp-block-cover:has(.wp-block-cover__background + .wp-block-cover__inner-container)) .wp-block-cover__inner-container {
	z-index: 1;
}

/* ==========================================================================
   Post navigation (front end only)
   Single and Single (No Featured Image) pair each Previous/Next link with an
   arrow Icon block. On the newest and the oldest post one link has no post
   and renders empty, so its arrow hides and keeps its place in the row.
   ========================================================================== */

.wp-block-group:has(> .wp-block-post-navigation-link:empty) > .wp-block-icon {
	visibility: hidden;
}
