/*
Theme Name: BWZ Fumito
Theme URI: https://bwz.jp/themes/bwz-fumito/
Author: BWZ
Author URI: https://bwz.jp/
Description: BWZ Fumito is a lightweight block theme for Japanese blogs and reviews that gives photographs and writing equal care. It offers a calm single-column reading layout, a two-column post grid, and a small set of block patterns for photo notes, side-by-side comparisons, reviews, information tables, and step-by-step guides. It uses system fonts and standard blocks only, and needs no plugins.
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 7.4
Version: 0.1.3
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: bwz-fumito
Tags: blog, photography, one-column, grid-layout, block-patterns, block-styles, custom-colors, custom-logo, custom-menu, editor-style, featured-images, full-site-editing, threaded-comments, translation-ready, wide-blocks
*/

/*
 * Most styles are defined in theme.json. This file only covers what theme.json
 * cannot express: Japanese text handling, focus indicators, form fields,
 * tables, comments, and a few layout details. It is loaded on the front end
 * and in the editor.
 *
 * Contents:
 * 1. Text and links
 * 2. Focus and accessibility
 * 3. Header and navigation
 * 4. Post grid
 * 5. Single posts and pages
 * 6. Content blocks (images, galleries, tables, code, quotes, lists)
 * 7. Forms (search, comments, password)
 * 8. Comments
 * 9. Pagination
 * 10. Block style variations
 */

/* 1. Text and links
--------------------------------------------- */

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

body {
	/* Japanese line breaking: keep kinsoku rules, break long URLs only when needed. */
	line-break: strict;
	overflow-wrap: break-word;
	word-break: normal;
	/* Adds a small space between Japanese and Latin letters or numbers where supported. */
	text-autospace: normal;
}

:where(code, kbd, pre, samp) {
	text-autospace: no-autospace;
}

:where(h1, h2, h3, h4, h5, h6, .wp-block-site-title, .wp-block-post-title) {
	/* Proportional kana for headings (no effect on Latin text). */
	font-feature-settings: "palt";
	letter-spacing: 0.02em;
}

:where(a:not(.wp-element-button)) {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

:where(a:not(.wp-element-button)):hover {
	text-decoration-thickness: 2px;
}

:where(code, kbd, samp) {
	font-family: var(--wp--preset--font-family--mono);
}

:where(p, li, dd, td, th, figcaption, .wp-block-comment-content) > code,
:where(p, li, dd, td, th, figcaption) kbd {
	padding: 0.1em 0.35em;
	border-radius: 2px;
	background-color: var(--wp--preset--color--base-2);
	font-size: 0.875em;
}

mark:not(.has-inline-color) {
	background-color: #fff2a8;
	color: inherit;
}

/* 2. Focus and accessibility
--------------------------------------------- */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
.wp-block-table:focus-visible,
.wp-element-button:focus-visible,
.wp-block-navigation-item__content:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

:where(input, select, textarea):focus {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 1px;
}

/* 3. Header and navigation
--------------------------------------------- */

.wp-block-site-title {
	overflow-wrap: anywhere;
}

/* The second selector outranks WordPress's own border colour for menus without a background. */
.wp-block-navigation .wp-block-navigation__submenu-container,
.wp-block-navigation:not(.has-background) .has-child .wp-block-navigation__submenu-container {
	border-color: var(--wp--preset--color--border);
}

/* Dropdown menus: keep short labels on one line (the menu widens instead of wrapping mid-phrase). */
.wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	white-space: nowrap;
}

/* The open mobile menu lists items from the left, with submenus indented below their parent.
   (The menu list itself also carries the justification class, so it is set on both.) */
.wp-block-navigation__responsive-container.is-menu-open,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation {
	--navigation-layout-justification-setting: flex-start;
	--navigation-layout-justify: flex-start;
	--navigation-layout-align: flex-start;
}

.wp-block-navigation__responsive-container.is-menu-open {
	padding-top: var(--wp--preset--spacing--40);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-top: var(--wp--preset--spacing--50);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	font-size: var(--wp--preset--font-size--medium);
}

/* No extra gap between the main content and the footer (main has its own padding). */
.wp-site-blocks > footer.wp-block-template-part {
	margin-top: 0;
}

/* 4. Post grid
--------------------------------------------- */

/* The visually hidden page heading should not push the list down. */
main > .screen-reader-text:first-child + * {
	margin-top: 0;
}

/* Long words or URLs in a card must not widen the grid column. */
.wp-block-post-template > .wp-block-post {
	min-width: 0;
}

.wp-block-post-template .wp-block-post-featured-image {
	margin-bottom: 0;
}

.wp-block-post-template .wp-block-post-featured-image img {
	background-color: var(--wp--preset--color--base-2);
}

.wp-block-post-template .wp-block-post-excerpt__excerpt {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
}

.wp-block-post-template .wp-block-post-title + .wp-block-post-excerpt {
	margin-top: var(--wp--preset--spacing--20);
}

/* 5. Single posts and pages
--------------------------------------------- */

/* Keep the bottom margin of the last block (such as an image caption) inside the content.
   Newer versions of WordPress set this themselves; WordPress 6.6 does not. */
.wp-block-post-content {
	display: flow-root;
}

/* Show the whole featured image; tall photos are limited to the screen height instead of being cropped. */
.wp-block-post-featured-image.bwz-fumito-featured-image img {
	display: block;
	width: auto;
	max-width: 100%;
	max-height: 80vh;
	margin-right: auto;
	margin-left: auto;
}

:where(.wp-block-post-content) > h2.wp-block-heading {
	margin-top: var(--wp--preset--spacing--60);
	padding-bottom: 0.35em;
	border-bottom: 1px solid var(--wp--preset--color--border);
}

:where(.wp-block-post-content) > h3.wp-block-heading {
	margin-top: var(--wp--preset--spacing--50);
}

:where(.wp-block-post-content) > :is(h4, h5, h6).wp-block-heading {
	margin-top: var(--wp--preset--spacing--40);
}

/* Tags shown as small labels. */
.bwz-fumito-tags .wp-block-post-terms__separator {
	display: none;
}

.bwz-fumito-tags.wp-block-post-terms {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
}

/* Long words without spaces (tag names, commenter names) wrap instead of widening the page. */
.wp-block-post-terms,
.wp-block-comment-author-name,
.wp-block-post-author__name {
	overflow-wrap: anywhere;
}

.bwz-fumito-tags.wp-block-post-terms a {
	display: inline-block;
	max-width: 100%;
	padding: 0.2em 0.75em;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 2px;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.bwz-fumito-tags.wp-block-post-terms a:hover {
	border-color: currentColor;
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
}

/* Previous / next post links. */
.bwz-fumito-post-navigation > * {
	flex: 1 1 16rem;
	max-width: 100%;
}

.bwz-fumito-post-navigation .post-navigation-link-next {
	margin-left: auto;
	text-align: right;
}

.bwz-fumito-post-navigation .post-navigation-link__label {
	display: block;
	color: var(--wp--preset--color--contrast-2);
	font-size: var(--wp--preset--font-size--x-small);
}

/* Author box. */
.wp-block-post-author {
	gap: var(--wp--preset--spacing--30);
}

.wp-block-post-author__avatar {
	margin-right: 0;
}

/* Avatars are inline images; without this, the line's descender space makes the box 9px taller. */
.wp-block-post-author__avatar img {
	display: block;
}

.wp-block-post-author__name {
	font-weight: 700;
}

.wp-block-post-author__bio {
	margin-top: 0.25em;
	color: var(--wp--preset--color--contrast-2);
	font-size: var(--wp--preset--font-size--small);
}

/* WordPress prints the paragraph even when the author has no biography. */
.wp-block-post-author__bio:empty {
	display: none;
}

/* Page links for posts split into several pages. */
.post-nav-links,
.page-links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5em;
	font-size: var(--wp--preset--font-size--small);
}

/* 6. Content blocks
--------------------------------------------- */

/* Lists. border-box keeps lists without a class (classic content) inside the content width;
   WordPress adds it only on pages that contain a List block. */
:where(.wp-block-post-content, .wp-block-comment-content) :where(ul, ol) {
	box-sizing: border-box;
	padding-left: 1.5em;
}

:where(.wp-block-post-content, .wp-block-comment-content) :where(li > ul, li > ol) {
	margin-top: 0.25em;
	margin-bottom: 0;
}

:where(.wp-block-post-content, .wp-block-comment-content) li + li {
	margin-top: 0.25em;
}

/* Images and captions: no filters or rounded corners are added to photos. */
.alignfull > figcaption,
.alignfull > .wp-element-caption {
	padding-right: var(--wp--style--root--padding-right, 1rem);
	padding-left: var(--wp--style--root--padding-left, 1rem);
}

.wp-block-image figcaption,
.wp-block-gallery > .blocks-gallery-caption,
.wp-block-embed figcaption,
.wp-block-video figcaption,
.wp-block-audio figcaption,
.wp-block-table figcaption {
	margin-top: 0.6em;
}

/* Left/right aligned images and captions start at the edge of the text column, not the screen. */
.wp-block-post-content.is-layout-constrained > .alignleft {
	margin-left: max(0px, calc((100% - var(--wp--style--global--content-size)) / 2));
}

.wp-block-post-content.is-layout-constrained > .alignright {
	margin-right: max(0px, calc((100% - var(--wp--style--global--content-size)) / 2));
}

.wp-block-post-content::after {
	display: block;
	clear: both;
	content: "";
}

/* Content written with the classic editor (captions and aligned images inside paragraphs). */
.wp-caption {
	max-width: min(100%, var(--wp--style--global--content-size, 100%));
}

.wp-caption img {
	display: block;
	max-width: 100%;
	height: auto;
}

.wp-caption .wp-caption-text {
	margin-top: 0.6em;
	color: var(--wp--preset--color--contrast-2);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.65;
}

:where(.wp-block-post-content) :where(p, div) > img.alignleft {
	float: left;
	margin: 0.3em 1.5em 0.75em 0;
}

:where(.wp-block-post-content) :where(p, div) > img.alignright {
	float: right;
	margin: 0.3em 0 0.75em 1.5em;
}

:where(.wp-block-post-content) img.aligncenter {
	display: block;
	margin-right: auto;
	margin-left: auto;
}

@media (max-width: 600px) {
	/* Keep some room for text next to floated images on small screens. */
	:where(.wp-block-post-content) :is(.alignleft, .alignright):not(.wp-block-pullquote) {
		max-width: 50%;
	}
}

/* Embedded media with a fixed width (for example iframes in older posts) must fit the screen. */
:where(.wp-block-post-content, .wp-block-comment-content) :where(iframe, embed, object, video) {
	max-width: 100%;
}

/* Images with a fixed size in a row (for example the profile pattern) keep their size on small screens. */
.is-layout-flex > .wp-block-image.is-resized {
	flex-shrink: 0;
}

/* Gallery caption under the whole gallery. */
.wp-block-gallery > .blocks-gallery-caption {
	flex-basis: 100%;
}

/* Tables: scroll sideways inside the table area only. */
.wp-block-table {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.wp-block-table table {
	border-collapse: collapse;
}

.wp-block-table :where(th, td) {
	min-width: 5em;
	padding: 0.5em 0.75em;
	border: 1px solid var(--wp--preset--color--border);
	text-align: left;
	vertical-align: top;
}

.wp-block-table :where(thead, tfoot) {
	border-width: 0;
}

.wp-block-table :where(thead th, tbody th, tfoot td) {
	background-color: var(--wp--preset--color--base-2);
	font-weight: 700;
}

.wp-block-table.is-style-stripes {
	border-bottom: 0;
}

.wp-block-table.is-style-stripes :where(th, td) {
	border-color: var(--wp--preset--color--border);
}

.wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
	background-color: var(--wp--preset--color--base-2);
}

@media (max-width: 600px) {
	/* On small screens, let wide tables keep readable columns and scroll instead. */
	.wp-block-table table.has-fixed-layout {
		table-layout: auto;
	}
}

/* Code */
.wp-block-code code {
	overflow-wrap: anywhere;
}

/* Quotes */
.wp-block-quote cite,
.wp-block-pullquote cite {
	display: block;
	margin-top: 0.75em;
}

.wp-block-quote > :first-child {
	margin-top: 0;
}

/* Separator */
.wp-block-separator:not(.is-style-dots) {
	border-top-width: 1px;
	border-bottom-width: 0;
}

/* Details */
.wp-block-details summary {
	cursor: pointer;
	font-weight: 700;
}

/* 7. Forms
--------------------------------------------- */

:where(input:not([type="submit"], [type="checkbox"], [type="radio"], [type="button"], [type="file"]), select, textarea) {
	box-sizing: border-box;
	max-width: 100%;
	padding: 0.5em 0.75em;
	border: 1px solid var(--wp--preset--color--contrast-2);
	border-radius: 2px;
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	font-family: inherit;
	font-size: max(1rem, 1em);
	line-height: 1.6;
}

.wp-block-search__input {
	border-color: var(--wp--preset--color--contrast-2);
}

/* At least 16px so that phones do not zoom in when the field is tapped. WordPress 6.6 applies
   the block's small font size to the field itself, so this needs a stronger selector. */
.wp-block-search .wp-block-search__input {
	font-size: max(1rem, 1em);
}

.wp-block-search__button-inside .wp-block-search__inside-wrapper {
	border-color: var(--wp--preset--color--contrast-2);
}

.post-password-form {
	display: flex;
	flex-direction: column;
	gap: 0.75em;
}

.post-password-form label {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5em;
}

.post-password-form input[type="submit"] {
	padding: 0.625em 1.25em;
	border: 0;
	border-radius: 2px;
	background-color: var(--wp--preset--color--charcoal);
	color: var(--wp--preset--color--base);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	cursor: pointer;
}

.post-password-form input[type="submit"]:hover,
.post-password-form input[type="submit"]:focus {
	background-color: var(--wp--preset--color--contrast-2);
}

/* 8. Comments
--------------------------------------------- */

.wp-block-comments .comment-form :where(label) {
	display: block;
	margin-bottom: 0.25em;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
}

.wp-block-comments .comment-form .comment-form-cookies-consent label {
	display: inline;
	font-weight: 400;
}

.wp-block-comments .comment-form :where(input:not([type="submit"], [type="checkbox"]), textarea) {
	width: 100%;
}

/* WordPress 6.6's own padding outranks the general field style; restate it for the comment form. */
.wp-block-comments .comment-form :where(input:not([type="submit"], [type="checkbox"]), textarea) {
	padding: 0.5em 0.75em;
}

.wp-block-comments .comment-notes,
.wp-block-comments .logged-in-as {
	color: var(--wp--preset--color--contrast-2);
	font-size: var(--wp--preset--font-size--small);
}

.wp-block-comment-template .comment {
	margin-bottom: var(--wp--preset--spacing--40);
}

.wp-block-comment-template .children {
	margin-top: var(--wp--preset--spacing--40);
}

.wp-block-comment-template .bwz-fumito-comment-body {
	min-width: 0;
}

.wp-block-comment-content {
	overflow-wrap: anywhere;
}

.wp-block-comment-content > :first-child {
	margin-top: 0.25em;
}

.wp-block-comment-content > :last-child {
	margin-bottom: 0.25em;
}

.wp-block-comment-template .comment-awaiting-moderation {
	color: var(--wp--preset--color--contrast-2);
	font-size: var(--wp--preset--font-size--small);
}

@media (max-width: 600px) {
	.wp-block-comment-template ol {
		padding-left: 1rem;
	}
}

/* 9. Pagination
--------------------------------------------- */

/* Space above the post list pagination, the same as between rows of the grid.
   (The Pagination block has no margin setting of its own.) */
.wp-block-query .wp-block-query-pagination {
	margin-top: var(--wp--preset--spacing--60);
}

/* WordPress 6.6 adds 0.5em margins to each part; the flex gap already spaces them. */
.wp-block-query-pagination > :is(.wp-block-query-pagination-previous, .wp-block-query-pagination-numbers, .wp-block-query-pagination-next),
.wp-block-comments-pagination > :is(.wp-block-comments-pagination-previous, .wp-block-comments-pagination-numbers, .wp-block-comments-pagination-next) {
	margin-right: 0;
	margin-bottom: 0;
}

.wp-block-query-pagination-numbers .page-numbers,
.wp-block-comments-pagination-numbers .page-numbers,
.post-nav-links .post-page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 2.75em;
	min-height: 2.75em;
	padding: 0 0.5em;
}

.wp-block-query-pagination-numbers .page-numbers.current,
.wp-block-comments-pagination-numbers .page-numbers.current,
.post-nav-links .post-page-numbers.current {
	border: 1px solid currentColor;
	border-radius: 2px;
	font-weight: 700;
}

.wp-block-query-pagination > a,
.wp-block-comments-pagination > a {
	display: inline-flex;
	align-items: center;
	min-height: 2.75em;
}

/* 10. Block style variations
--------------------------------------------- */

/* Gallery: "Captions below images" — keeps photos clear of overlaid text. */
.wp-block-gallery.is-style-bwz-fumito-captions-below figure.wp-block-image:not(#individual-image) {
	justify-content: flex-start;
}

.wp-block-gallery.is-style-bwz-fumito-captions-below figure.wp-block-image:has(figcaption)::before {
	content: none;
}

.wp-block-gallery.is-style-bwz-fumito-captions-below figure.wp-block-image figcaption {
	position: static;
	box-sizing: border-box;
	width: 100%;
	max-height: none;
	margin-top: 0.4em;
	padding: 0;
	overflow: visible;
	background: none;
	color: var(--wp--preset--color--contrast-2);
	font-size: var(--wp--preset--font-size--x-small);
	line-height: 1.6;
	text-align: left;
	text-shadow: none;
}

.wp-block-gallery.is-style-bwz-fumito-captions-below figure.wp-block-image figcaption a {
	color: inherit;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		scroll-behavior: auto !important;
	}
}
