/*
Theme Name: Terre Verte Photo
Theme URI: https://photo.terre-verte.site/
Description: 写真を主役にした静かな写真集テーマ。余白の多いレイアウト、大きな写真、ライトボックス、黒背景。
Author: Photo Gallery
Version: 1.3.1
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: terre-verte-photo
*/

/* ===============================
   Tokens
   =============================== */
:root {
	color-scheme: dark;
	--bg: #000000;
	--bg-soft: #141414;
	--ink: #e8e6e1;
	--ink-soft: #a6a39c;
	--line: #2a2a28;
	--accent: #9dbba8; /* terre verte */
	--overlay: rgba(0, 0, 0, 0.97);

	--font-serif: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
	--font-sans: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
	--font-latin: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
	--font-display: "Lobster", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;

	--w-text: 640px;
	--w-photo: 1000px; /* photos are exported at 1000px: never enlarge */
	--w-wide: 1560px;
	--gutter: clamp(16px, 4vw, 48px);
	--gap-photo: clamp(40px, 8vw, 120px);
}

/* ===============================
   Base
   =============================== */
*, *::before, *::after { box-sizing: border-box; }

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

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: var(--font-sans);
	font-size: 16px;
	line-height: 2;
	letter-spacing: 0.04em;
	-webkit-font-smoothing: antialiased;
	transition: background-color .4s ease, color .4s ease;
}

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

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

.screen-reader-text,
.skip-link:not(:focus) {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}
.skip-link:focus {
	position: fixed; top: 8px; left: 8px; z-index: 1000;
	background: var(--ink); color: var(--bg); padding: 8px 16px;
}

/* ===============================
   Header
   =============================== */
.site-header {
	position: sticky;
	top: 0;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	padding: 20px var(--gutter);
	background: color-mix(in srgb, var(--bg) 88%, transparent);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	transition: transform .4s ease, background-color .4s ease;
}
.site-header.is-hidden { transform: translateY(-100%); }

.site-branding { display: flex; align-items: baseline; gap: 16px; min-width: 0; }

.site-title {
	margin: 0;
	font-family: var(--font-latin);
	font-size: 26px;
	font-weight: 500;
	letter-spacing: 0.08em;
	line-height: 1.2;
	white-space: nowrap;
}
.site-description {
	margin: 0;
	font-size: 12px;
	color: var(--ink-soft);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.header-nav { display: flex; align-items: center; gap: 8px; }

.primary-menu {
	display: flex;
	gap: 28px;
	margin: 0 16px 0 0;
	padding: 0;
	list-style: none;
	font-family: var(--font-latin);
	font-size: 17px;
	letter-spacing: 0.1em;
}
.primary-menu a { position: relative; }
.primary-menu .current-menu-item > a,
.primary-menu .current-cat > a { color: var(--accent); }

.icon-button {
	display: inline-grid;
	place-items: center;
	width: 40px; height: 40px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--ink);
	cursor: pointer;
	border-radius: 50%;
}
.icon-button:hover { color: var(--accent); }
.icon-button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.4; }

.menu-toggle { display: none; }

/* Search panel */
.search-panel {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: grid;
	place-items: center;
	padding: var(--gutter);
	background: color-mix(in srgb, var(--bg) 96%, transparent);
	opacity: 0;
	visibility: hidden;
	transition: opacity .3s ease, visibility .3s;
}
.search-panel.is-open { opacity: 1; visibility: visible; }
.search-panel .icon-button { position: absolute; top: 20px; right: var(--gutter); }

.search-form { display: flex; width: min(560px, 100%); border-bottom: 1px solid var(--ink); }
.search-form input[type="search"] {
	flex: 1;
	min-width: 0;
	padding: 12px 0;
	border: 0;
	background: transparent;
	color: var(--ink);
	font: inherit;
	font-size: 18px;
}
.search-form input[type="search"]:focus { outline: none; }
.search-form button { border: 0; background: none; color: var(--ink); cursor: pointer; padding: 0 4px; }
.search-form button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.4; }

/* ===============================
   Layout
   =============================== */
.site-main { min-height: 60vh; }

.container { width: min(100% - var(--gutter) * 2, var(--w-wide)); margin-inline: auto; }

/* ===============================
   Home: intro
   =============================== */
.intro {
	width: min(100% - var(--gutter) * 2, var(--w-wide));
	margin: clamp(40px, 7vw, 88px) auto clamp(40px, 6vw, 72px);
	text-align: center;
	font-family: var(--font-serif);
	font-size: 14px;
	line-height: 2.2;
	color: var(--ink-soft);
}

/* ===============================
   Section heading / category filter
   =============================== */
.eyebrow {
	display: inline-block;
	font-family: var(--font-latin);
	font-size: 14px;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--ink-soft);
}

.section-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px 32px;
	margin: 0 0 40px;
	padding-bottom: 16px;
	border-bottom: 1px solid var(--line);
}
.section-head h1, .section-head h2 {
	margin: 0;
	font-family: var(--font-latin);
	font-weight: 400;
	font-size: clamp(28px, 3.4vw, 40px);
	letter-spacing: 0.08em;
	line-height: 1.3;
}
.section-head .archive-description { width: 100%; margin: 0; color: var(--ink-soft); font-size: 14px; }

.cat-filter { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0; padding: 0; list-style: none; font-family: var(--font-latin); font-size: 16px; letter-spacing: .1em; }
.cat-filter a { color: var(--ink-soft); }
.cat-filter a:hover, .cat-filter .is-current a { color: var(--ink); }
.cat-filter .is-current a { border-bottom: 1px solid currentColor; }

/* ===============================
   Post grid
   =============================== */
.post-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: clamp(40px, 5vw, 72px) clamp(20px, 3vw, 40px);
	margin: 0 0 clamp(56px, 8vw, 96px);
}
.post-grid.is-archive { margin-top: 0; }

.card { min-width: 0; }
.card a { display: block; }
.card-thumb {
	position: relative;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: var(--bg-soft);
}
.card-thumb img {
	width: 100%; height: 100%;
	object-fit: cover;
	transition: transform 1.2s cubic-bezier(.2,.7,.2,1), filter .6s ease;
}
.card a:hover .card-thumb img { transform: scale(1.035); }
.card-thumb .count {
	position: absolute; right: 10px; bottom: 10px;
	padding: 0 10px;
	font-family: var(--font-latin);
	font-size: 13px;
	letter-spacing: .1em;
	color: #fff;
	background: rgba(0,0,0,.35);
	backdrop-filter: blur(4px);
}
.card-thumb.is-empty { display: grid; place-items: center; color: var(--ink-soft); font-family: var(--font-latin); }

.card-meta {
	display: flex;
	gap: 16px;
	margin-top: 16px;
	font-family: var(--font-latin);
	font-size: 12px;
	letter-spacing: .08em;
	color: var(--ink-soft);
	text-transform: uppercase;
}
.card-title {
	margin: 4px 0 0;
	font-family: var(--font-serif);
	font-size: 16px;
	font-weight: 500;
	line-height: 1.7;
	letter-spacing: .06em;
}
.card a:hover .card-title { color: var(--accent); }


/* ===============================
   Pagination
   =============================== */
.pagination { margin: 0 0 clamp(64px, 10vw, 120px); font-family: var(--font-latin); font-size: 17px; }
.pagination .nav-links { display: flex; justify-content: center; align-items: center; gap: 8px; }
.pagination .page-numbers { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px; color: var(--ink-soft); }
.pagination .page-numbers.current { color: var(--ink); border-bottom: 1px solid var(--ink); }
.pagination a.page-numbers:hover { color: var(--ink); }

/* ===============================
   Single
   =============================== */
.entry-header {
	width: min(100% - var(--gutter) * 2, var(--w-text));
	margin: clamp(56px, 10vw, 128px) auto clamp(40px, 6vw, 72px);
	text-align: center;
}
.entry-header .eyebrow a:hover { color: var(--accent); }
.entry-title {
	margin: 12px 0 16px;
	font-family: var(--font-serif);
	font-weight: 500;
	font-size: clamp(24px, 3.4vw, 36px);
	line-height: 1.6;
	letter-spacing: .06em;
	word-break: auto-phrase;
}
.entry-date { font-family: var(--font-latin); font-size: 15px; letter-spacing: .16em; color: var(--ink-soft); }

.entry-content {
	width: min(100% - var(--gutter) * 2, var(--w-photo));
	margin: 0 auto;
	font-family: var(--font-serif);
	font-size: 16px;
	line-height: 2.1;
}

/* text stays narrow, photos go wide */
.entry-content > :where(p, h2, h3, h4, h5, ul, ol, blockquote, pre, table, hr, .wp-block-quote, .wp-block-buttons, .wp-block-embed) {
	max-width: var(--w-text);
	margin-left: auto;
	margin-right: auto;
}
.entry-content > p { margin-top: 0; margin-bottom: 1.6em; }
.entry-content h2, .entry-content h3 {
	margin-top: 3em;
	margin-bottom: 1.2em;
	font-weight: 500;
	letter-spacing: .1em;
	line-height: 1.7;
}
.entry-content h2 { font-size: 22px; text-align: center; }
.entry-content h3 { font-size: 18px; }
.entry-content a { border-bottom: 1px solid var(--line); }
.entry-content a:has(img) { border: 0; }
.entry-content blockquote { padding-left: 1.5em; border-left: 1px solid var(--line); color: var(--ink-soft); }
.entry-content hr { border: 0; height: 1px; background: var(--line); margin-top: 4em; margin-bottom: 4em; }

/* photos */
.entry-content img {
	margin-left: auto;
	margin-right: auto;
	max-height: 92vh;
	width: auto;
}
.entry-content > p:has(> img, > a > img),
.entry-content > a:has(img),
.entry-content > img,
.entry-content figure.wp-block-image,
.entry-content .wp-block-image {
	max-width: none;
	margin: 0 auto var(--gap-photo);
}
/* consecutive images separated by <br> within one paragraph */
.entry-content p:has(img) br { display: none; }
.entry-content p:has(img) > a, .entry-content p:has(img) > img { display: block; margin-bottom: var(--gap-photo); }
.entry-content p:has(img) > :last-child { margin-bottom: 0; }

.entry-content figure { margin: 0 auto var(--gap-photo); }
.entry-content figcaption,
.entry-content .wp-element-caption {
	margin-top: 14px;
	text-align: center;
	font-family: var(--font-sans);
	font-size: 13px;
	letter-spacing: .08em;
	color: var(--ink-soft);
}
.entry-content .alignwide { width: min(100vw - var(--gutter) * 2, var(--w-photo)); max-width: none; margin-left: 50%; transform: translateX(-50%); }
.entry-content .alignfull { width: min(100vw, var(--w-photo)); max-width: none; margin-left: 50%; transform: translateX(-50%); }
.entry-content .alignfull img, .entry-content .alignwide img { width: auto; max-width: min(100%, var(--w-photo)); }

/* image appears on scroll */
.js .entry-content img.fade { opacity: 0; transform: translateY(16px); transition: opacity 1.1s ease, transform 1.1s cubic-bezier(.2,.7,.2,1); }
.js .entry-content img.fade.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
	.js .entry-content img.fade { opacity: 1; transform: none; transition: none; }
}

/* WordPress gallery block */
.entry-content .wp-block-gallery { max-width: none; gap: clamp(8px, 1.2vw, 16px); margin-bottom: var(--gap-photo); }
.entry-content .wp-block-gallery img { max-height: none; width: 100%; max-width: var(--w-photo); }
.entry-content .wp-block-gallery figure { margin: 0 !important; }

.entry-content .wp-block-columns { max-width: none; gap: clamp(16px, 3vw, 40px); }

/* zoomable */
.entry-content a[data-lightbox] { cursor: zoom-in; }

/* ===============================
   Post footer / navigation
   =============================== */
.entry-footer {
	width: min(100% - var(--gutter) * 2, var(--w-text));
	margin: 0 auto clamp(56px, 8vw, 96px);
	padding-top: 32px;
	border-top: 1px solid var(--line);
	text-align: center;
	font-size: 13px;
	color: var(--ink-soft);
}
.entry-footer .tags a { margin: 0 8px; }

.post-nav {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 24px;
	width: min(100% - var(--gutter) * 2, var(--w-photo));
	margin: 0 auto clamp(56px, 8vw, 96px);
}
.post-nav a { display: grid; grid-template-columns: 120px 1fr; gap: 20px; align-items: center; }
.post-nav .next a { grid-template-columns: 1fr 120px; text-align: right; }
.post-nav .next a .post-nav-thumb { order: 2; }
.post-nav-thumb { aspect-ratio: 1; overflow: hidden; background: var(--bg-soft); }
.post-nav-thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-nav-label { display: block; font-family: var(--font-latin); font-size: 13px; letter-spacing: .16em; color: var(--ink-soft); text-transform: uppercase; }
.post-nav-title { font-family: var(--font-serif); font-size: 15px; line-height: 1.7; }

.related { margin-bottom: clamp(56px, 8vw, 96px); }
.related .post-grid { margin-bottom: 0; }

/* ===============================
   Comments (minimal)
   =============================== */
.comments-area { width: min(100% - var(--gutter) * 2, var(--w-text)); margin: 0 auto 96px; font-size: 14px; }
.comments-area input, .comments-area textarea { width: 100%; padding: 10px; font: inherit; color: var(--ink); background: var(--bg-soft); border: 1px solid var(--line); }
.comments-area .submit { width: auto; padding: 10px 32px; cursor: pointer; }

/* ===============================
   Footer
   =============================== */
.site-footer {
	padding: 48px var(--gutter) 40px;
	border-top: 1px solid var(--line);
	text-align: center;
	color: var(--ink-soft);
	font-size: 12px;
}
.footer-title { display: block; margin-bottom: 8px; font-family: var(--font-latin); font-size: 22px; letter-spacing: .1em; color: var(--ink); }
.footer-menu { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 24px; margin: 16px 0; padding: 0; list-style: none; font-family: var(--font-latin); font-size: 15px; letter-spacing: .1em; }
.copyright { font-family: var(--font-latin); font-size: 13px; letter-spacing: .12em; }

.to-top {
	position: fixed; right: 20px; bottom: 20px; z-index: 40;
	background: color-mix(in srgb, var(--bg) 85%, transparent);
	opacity: 0; visibility: hidden;
	transition: opacity .3s, visibility .3s;
}
.to-top.is-visible { opacity: 1; visibility: visible; }

/* ===============================
   Lightbox
   =============================== */
.lightbox {
	position: fixed; inset: 0; z-index: 500;
	display: grid; place-items: center;
	background: var(--overlay);
	opacity: 0; visibility: hidden;
	transition: opacity .35s ease, visibility .35s;
	touch-action: pan-y;
}
.lightbox.is-open { opacity: 1; visibility: visible; }
.lightbox-img {
	max-width: calc(100vw - 32px);
	max-height: calc(100vh - 120px);
	width: auto; height: auto;
	object-fit: contain;
	opacity: 0;
	transition: opacity .4s ease;
	user-select: none;
	-webkit-user-drag: none;
}
.lightbox-img.is-loaded { opacity: 1; }
.lightbox .icon-button { position: absolute; color: #ddd; }
.lightbox .icon-button:hover { color: #fff; }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lightbox-counter { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-family: var(--font-latin); font-size: 14px; letter-spacing: .2em; color: #aaa; }
.lightbox-caption { position: absolute; bottom: 38px; left: 16px; right: 16px; text-align: center; font-size: 13px; color: #ccc; }
body.lightbox-open { overflow: hidden; }

/* ===============================
   404 / search / empty
   =============================== */
.not-found { width: min(100% - var(--gutter) * 2, var(--w-text)); margin: 120px auto; text-align: center; }
.not-found .search-form { margin: 40px auto 0; }

/* ===============================
   Responsive
   =============================== */
@media (max-width: 1023px) {
	.post-grid { grid-template-columns: repeat(2, 1fr); }
	.site-description { display: none; }
}

@media (max-width: 720px) {
	.site-header { padding: 14px var(--gutter); }
	.site-title { font-size: 22px; }
	.menu-toggle { display: inline-grid; }
	.primary-menu {
		position: fixed; inset: 68px 0 auto 0;
		flex-direction: column; gap: 0;
		margin: 0; padding: 8px var(--gutter) 24px;
		background: var(--bg);
		border-bottom: 1px solid var(--line);
		font-size: 20px;
		transform: translateY(-8px);
		opacity: 0; visibility: hidden;
		transition: opacity .25s, transform .25s, visibility .25s;
	}
	.primary-menu a { display: block; padding: 10px 0; }
	.site-header.menu-open .primary-menu { opacity: 1; visibility: visible; transform: none; }

	.post-grid { grid-template-columns: 1fr; }
	.section-head { margin-bottom: 28px; }

	.entry-content { width: 100%; }
	.entry-content > :where(p, h2, h3, h4, h5, ul, ol, blockquote, pre, table, hr) { padding-left: var(--gutter); padding-right: var(--gutter); }
	.entry-content > p:has(img) { padding: 0; }
	.entry-content img { max-height: none; width: 100%; }
	.entry-content figcaption { padding: 0 var(--gutter); }

	.post-nav { grid-template-columns: 1fr; }
	.post-nav a, .post-nav .next a { grid-template-columns: 80px 1fr; text-align: left; }
	.post-nav .next a .post-nav-thumb { order: 0; }

	.lightbox-prev, .lightbox-next { display: none; }
	.lightbox-img { max-width: 100vw; max-height: calc(100vh - 120px); }
}

/* ===============================
   Display font (titles & headings): Lobster
   Lobster has Latin glyphs only; Japanese falls back to the gothic font.
   =============================== */
.site-title,
.footer-title,
.section-head h1,
.section-head h2,
.entry-title,
.card-title,
.post-nav-title,
.entry-content h2,
.entry-content h3,
.not-found .entry-title {
	font-family: var(--font-display);
	font-weight: 400;
	letter-spacing: .02em;
}
.site-title { font-size: 28px; }
.footer-title { font-size: 26px; }
.card-title { font-size: 17px; }
@media (max-width: 720px) { .site-title { font-size: 24px; } }

/* intro on one line where the screen is wide enough */
@media (min-width: 900px) { .intro p { white-space: nowrap; } }
