/*
Theme Name: Stock Tour
Theme URI: https://stock.kuronekoshop.jp/blog/
Description: Stand-alone block theme for the Stock Tour blog on stock.kuronekoshop.jp: article list, category archives, article pages, header and footer. The image library, asset pages and downloads are rendered by the Stock Tour plugin. Base design settings (colors, fonts, spacing) are carried over from Twenty Twenty-Five, so no parent theme is needed.
Author: Kuroneko Ajimeguri
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 8.1
Version: 2.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: stock-tour-theme
*/

/* ---------- Base rules carried over from Twenty Twenty-Five (GPL-2.0-or-later) ---------- */
a {
	text-decoration-thickness: 1px !important;
	text-underline-offset: .1em;
}
:where(.wp-site-blocks *:focus) {
	outline-width: 2px;
	outline-style: solid;
}
.wp-block-navigation .wp-block-navigation-item .wp-block-navigation-item__content { outline-offset: 4px; }
h1, h2, h3, h4, h5, h6, blockquote, caption, figcaption, p { text-wrap: pretty; }
.more-link { display: block; }
:where(pre) { overflow-x: auto; }


/* ---------- Base ---------- */
:root {
	--stt-ink: #1d1d1b;
	--stt-muted: #5f5f5a;
	--stt-line: #e3e0d8;
	--stt-surface: #f7f5f0;
	--stt-radius: 12px;
}

/* Typography is scoped to block-theme pages (.wp-site-blocks). The image library and
   download screens are standalone pages from the Stock Tour plugin and are not styled here. */
body:has(> .wp-site-blocks) {
	overflow-x: clip;
	background: #fff;
	color: var(--stt-ink);
}
.wp-site-blocks {
	font-size: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
	font-weight: 400;
	line-height: 1.75;
	letter-spacing: 0;
	color: var(--stt-ink);
}
.wp-site-blocks :where(h1, h2, h3, h4, h5, h6) {
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: 0;
}
.wp-site-blocks :where(h1, .wp-block-post-title:is(h1), .wp-block-query-title) {
	font-size: clamp(1.85rem, 1.5rem + 1.6vw, 2.6rem);
}
.wp-site-blocks a:where(:not(.wp-element-button)) { color: var(--stt-ink); text-underline-offset: .18em; }
.wp-site-blocks :where(a, button, summary):focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

/* ---------- Header ---------- */
.stt-header { border-bottom: 1px solid var(--stt-line); }
.stt-header .wp-block-site-title { font-size: 1.15rem; font-weight: 700; letter-spacing: 0; }
.stt-header .wp-block-site-title a { text-decoration: none; }
.stt-header .wp-block-navigation { font-size: 1rem; font-weight: 600; }
.stt-header .wp-block-navigation a { text-decoration: none; padding: .35rem 0; }
.stt-header .wp-block-navigation a:hover,
.stt-header .wp-block-navigation .current-menu-item > a { text-decoration: underline; }

/* ---------- Footer ---------- */
.stt-footer { border-top: 1px solid var(--stt-line); font-size: .95rem; }
.stt-footer .wp-block-navigation { gap: .4rem 1.25rem; font-size: .95rem; }
.stt-footer .wp-block-site-title { font-size: 1.05rem; font-weight: 700; }
.stt-footer .wp-block-navigation a { text-decoration: none; }
.stt-footer .wp-block-navigation a:hover { text-decoration: underline; }
.stt-footer p { margin: 0; color: var(--stt-muted); }

/* ---------- Listing header (blog index and category archives) ----------
   Order: category links, title, description. The links sit directly under the site
   header so they stay in the same place when switching categories, and the
   description keeps a fixed height so the cards also start at the same line. */
.stt-listing nav[aria-label="Article categories"] {
	display: flex !important;
	flex-wrap: wrap;
	gap: .5rem !important;
	margin-top: 0 !important;
	margin-bottom: 2rem !important;
}
.stt-listing nav[aria-label="Article categories"] a {
	display: inline-block;
	padding: .45rem .9rem;
	border: 1px solid var(--stt-line);
	border-radius: 999px;
	font-size: .95rem;
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
	color: var(--stt-ink);
	background: #fff;
}
.stt-listing nav[aria-label="Article categories"] a:hover { border-color: var(--stt-ink); }
.stt-listing nav[aria-label="Article categories"] a[aria-current] {
	background: var(--stt-ink);
	border-color: var(--stt-ink);
	color: #fff;
}
.stt-listing :is(h1.wp-block-heading, h1.wp-block-query-title, h1.wp-block-post-title) {
	margin-top: 0 !important;
	margin-bottom: 0 !important;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.stt-listing .wp-block-term-description,
.stt-listing .stt-listing-intro,
.stt-listing .wp-block-post-content > p:first-of-type {
	min-height: calc(2 * 1.6em);
	margin-top: .75rem !important;
	margin-bottom: 2rem !important;
	font-size: 1rem;
	line-height: 1.6;
	color: var(--stt-muted);
}
.stt-listing .wp-block-term-description p { margin: 0; }
.stt-listing .wp-block-post-content > p { color: var(--stt-muted); }

/* /blog/ shown as a page: put the category links from the page body above the title. */
.stt-listing-page { display: flex; flex-direction: column; }
.stt-listing-page > * { margin-block: 0; }
.stt-listing-page > .wp-block-post-content { display: contents; }
.stt-listing-page nav[aria-label="Article categories"] { order: -1; }

@media (max-width: 600px) {
	.stt-listing :is(h1.wp-block-heading, h1.wp-block-query-title, h1.wp-block-post-title) { font-size: 1.75rem !important; }
	.stt-listing .wp-block-term-description,
	.stt-listing .stt-listing-intro,
	.stt-listing .wp-block-post-content > p:first-of-type { min-height: calc(3 * 1.6em); }
}

/* ---------- Article cards ---------- */
.stt-listing .wp-block-post-template {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
	gap: 1.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}
.stt-listing .wp-block-post-template > li {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: .6rem;
	margin: 0 !important;
	padding: 0 0 1.25rem;
	border: 1px solid var(--stt-line);
	border-radius: var(--stt-radius);
	background: #fff;
	overflow: hidden;
}
.stt-listing .wp-block-post-template > li > * { margin: 0 1.25rem !important; }
.stt-listing .wp-block-post-template > li > .stt-card-media { margin: 0 !important; }
.stt-listing .wp-block-post-template > li > .stt-card-cat:first-child { margin-top: 1.25rem !important; }

.stt-card-media {
	position: relative;
	display: block;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	background: var(--stt-surface);
	border-bottom: 1px solid var(--stt-line);
}
.stt-card-media img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain; /* show the whole image: example images often contain text */
}
.stt-card-cat {
	font-size: .78rem;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--stt-muted);
}
.stt-card-cat a { color: inherit; text-decoration: none; position: relative; z-index: 2; }
.stt-card-cat a:hover { text-decoration: underline; }
.stt-listing .wp-block-post-template .wp-block-post-title {
	font-size: clamp(1.15rem, 1.05rem + .4vw, 1.35rem);
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0;
}
.stt-listing .wp-block-post-template .wp-block-post-title a { text-decoration: none; }
/* Whole card is clickable through the title link. */
.stt-listing .wp-block-post-template .wp-block-post-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.stt-listing .wp-block-post-template li:hover .wp-block-post-title a { text-decoration: underline; }
.stt-listing .wp-block-post-template li:has(.wp-block-post-title a:focus-visible) { outline: 2px solid var(--stt-ink); outline-offset: 2px; }
.stt-listing .wp-block-post-title a:focus-visible { outline: none; }
.stt-listing .wp-block-post-excerpt { font-size: .98rem; line-height: 1.6; color: var(--stt-muted); }
.stt-listing .wp-block-post-excerpt__excerpt {
	margin: 0;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 4;
	line-clamp: 4;
	overflow: hidden;
}
.stt-listing .wp-block-post-excerpt__more-text { margin: .6rem 0 0; font-weight: 600; font-size: .95rem; }
.stt-listing .wp-block-post-excerpt__more-link { color: var(--stt-ink); position: relative; z-index: 2; }
.stt-listing .wp-block-post-date { font-size: .85rem; color: var(--stt-muted); margin-top: auto !important; }

/* Pagination */
.stt-listing .wp-block-query-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	margin-top: 2.5rem;
	gap: .5rem;
	justify-content: center;
	font-size: 1rem;
	font-weight: 600;
}
.stt-listing .wp-block-query-pagination a,
.stt-listing .wp-block-query-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.75rem;
	min-height: 2.75rem;
	padding: 0 .75rem;
	border: 1px solid var(--stt-line);
	border-radius: 999px;
	text-decoration: none;
}
.stt-listing .wp-block-query-pagination .page-numbers.current { background: var(--stt-ink); border-color: var(--stt-ink); color: #fff; }
.stt-listing .wp-block-query-pagination-numbers { display: flex; gap: .5rem; }

/* ---------- Article page ---------- */
.stt-article-meta {
	font-size: .9rem;
	color: var(--stt-muted);
	gap: .4rem .75rem;
}
.stt-article-meta a { color: inherit; font-weight: 600; }
.stt-article .wp-block-post-title { letter-spacing: 0; }

.stt-article .wp-block-post-content {
	overflow-wrap: break-word;
}
.stt-article .wp-block-post-content > * { margin-block-start: 1.25em; }
.stt-article .wp-block-post-content :where(h2) {
	margin-top: 2.4em;
	margin-bottom: .6em;
	font-size: clamp(1.4rem, 1.2rem + .8vw, 1.75rem);
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0;
}
.stt-article .wp-block-post-content :where(h3) {
	margin-top: 1.9em;
	margin-bottom: .5em;
	font-size: clamp(1.15rem, 1.05rem + .4vw, 1.3rem);
	font-weight: 700;
	line-height: 1.35;
}
.stt-article .wp-block-post-content :where(ul, ol) { padding-left: 1.4em; }
.stt-article .wp-block-post-content li + li { margin-top: .35em; }

/* Images: always the original aspect ratio, never cropped. */
.stt-article .wp-block-post-content img,
.stt-article .wp-block-post-featured-image img {
	max-width: 100%;
	height: auto !important;
	object-fit: contain !important;
}
.stt-article .wp-block-post-content figure { margin-left: auto; margin-right: auto; }
.stt-article .wp-block-post-content figure img { margin-inline: auto; }
.stt-article .wp-block-post-content figcaption {
	margin-top: .55rem;
	font-size: .9rem;
	line-height: 1.55;
	color: var(--stt-muted);
	text-align: center;
}

/* Image collections written as a list of figures: two columns on wider screens. */
.stt-article .wp-block-post-content ul:has(> li > figure) {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
	gap: 1.5rem 1.25rem;
	padding: 0;
	list-style: none;
	align-items: start;
}
.stt-article .wp-block-post-content ul:has(> li > figure) > li { margin: 0; }
.stt-article .wp-block-post-content ul:has(> li > figure) figure { margin: 0; }
.stt-article .wp-block-post-content ul:has(> li > figure) img { display: block; width: 100%; border-radius: 8px; }

/* Tables: scroll inside their own area, not the page. */
.stt-article .wp-block-post-content table {
	border-collapse: collapse;
	font-size: .95rem;
	line-height: 1.5;
}
.stt-article .wp-block-post-content > table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}
.stt-article .wp-block-post-content div:has(> table) {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}
.stt-article .wp-block-post-content th,
.stt-article .wp-block-post-content td {
	min-width: 8.5rem;
	padding: .65rem .75rem;
	border-bottom: 1px solid var(--stt-line);
	text-align: left;
	vertical-align: top;
}
.stt-article .wp-block-post-content th { background: var(--stt-surface); font-weight: 700; }
.stt-article .wp-block-post-content :where(.wp-block-table) { overflow-x: auto; }

/* Library call to action */
.stt-library-cta {
	border-radius: var(--stt-radius);
	background: var(--stt-surface);
	border: 1px solid var(--stt-line);
}
.stt-library-cta h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: 0; margin: 0; }
.stt-library-cta p { margin: .5rem 0 0; color: var(--stt-muted); }

.stt-related h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: 0; }

@media (max-width: 600px) {
	.stt-listing .wp-block-post-template { gap: 1rem; }
	.stt-article .wp-block-post-content th,
	.stt-article .wp-block-post-content td { min-width: 7.5rem; }
}
