/*
Theme Name: Zitda Mosaic
Theme URI: https://zitdazitda.com
Author: 짓다.짙다.
Description: 사진이 모자이크로 펼쳐지는 블로그 테마. 사진을 누르면 다른 사진들이 밀려나며 글이 그 자리에서 천천히 선명하게 떠오릅니다. 페이지 이동이 없어도 주소는 글마다 따로 바뀌어, 공유와 뒤로 가기가 그대로 동작합니다.
Version: 1.8.0
Requires at least: 6.3
Tested up to: 7.1
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: zitda-mosaic
Tags: blog, photography, grid-layout, one-column, custom-menu, custom-logo, featured-images, threaded-comments
*/

:root {
	--bg: #f3f0ea;
	--panel: #fbfaf7;
	--ink: #1f1d1a;
	--muted: #8a847a;
	--line: #e2ddd3;
	--accent: #5a4632;
	--tile: #e4dfd5;
	--gap: 6px;
	--pad: clamp(12px, 3vw, 40px);
	--maxw: 1480px;
	--font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #151413;
		--panel: #1d1c1a;
		--ink: #ece8e1;
		--muted: #958e83;
		--line: #2e2c28;
		--accent: #d6b48e;
		--tile: #26241f;
	}
}

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

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

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: var(--font);
	font-size: 16px;
	line-height: 1.6;
	word-break: keep-all;
	overflow-wrap: anywhere;
	-webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; height: auto; }

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

/* ---------- Header ---------- */

.site-header {
	max-width: var(--maxw);
	margin: 0 auto;
	padding: clamp(28px, 6vw, 72px) var(--pad) clamp(20px, 4vw, 44px);
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px 32px;
}
.site-brand { display: flex; align-items: center; gap: 14px; }
.site-brand .custom-logo { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; display: block; }
.site-title {
	margin: 0;
	font-size: clamp(26px, 4vw, 38px);
	font-weight: 700;
	letter-spacing: -0.03em;
	line-height: 1.1;
}
.site-title a { text-decoration: none; }
.site-description { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 22px; }
.site-nav a {
	text-decoration: none;
	font-size: 15px;
	color: var(--muted);
	transition: color .2s;
}
.site-nav a:hover, .site-nav .current-menu-item a { color: var(--ink); }

/* ---------- Mosaic ---------- */

.site-main {
	max-width: var(--maxw);
	margin: 0 auto;
	padding: 0 var(--pad);
}

.archive-header { margin: 0 0 20px; }
.archive-title { margin: 0; font-size: 20px; font-weight: 600; color: var(--muted); }

/* Justified rows: every photo in a row shares one height and keeps its
   own proportions; rows fill the width. A row is never blown up more
   than 1.5×, so a short row simply ends early instead. */
.mosaic {
	--h: clamp(170px, 26vw, 360px);
	display: flex;
	flex-wrap: wrap;
	gap: var(--gap);
}
.mosaic::after { content: ""; flex-grow: 999999; }
@media (max-width: 700px) { .mosaic { --gap: 4px; } }

/* With the script: a grid of 24 fine columns; every photo is placed on
   exact cell lines (see pack() in mosaic.js). */
.mosaic.is-packed {
	display: grid;
	grid-template-columns: repeat(24, minmax(0, 1fr));
}
.mosaic.is-packed::after { display: none; }
.mosaic.is-packed .tile { max-width: none; }
.mosaic.is-packed .tile__link { aspect-ratio: auto; height: 100%; }

.tile {
	position: relative;
	min-width: 0;
	flex: var(--r, 1) 1 calc(var(--r, 1) * var(--h));
	max-width: calc(var(--r, 1) * var(--h) * 1.5);
	transition: opacity .7s ease, filter .7s ease;
}
.tile[hidden] { display: none; }

.tile__link {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: var(--r, 1);
	overflow: hidden;
	border-radius: 4px;
	transform: translateZ(0); /* keeps the corners rounded while the photo zooms (Safari) */
	background: var(--tile);
	text-decoration: none;
	color: inherit;
	outline-offset: -3px;
}
.tile__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 1.2s cubic-bezier(.2, .7, .2, 1);
}
.tile__link:hover .tile__img,
.tile__link:focus-visible .tile__img { transform: scale(1.045); }

.tile__title {
	position: absolute;
	left: 0; right: 0; bottom: 0;
	padding: 28px 14px 12px;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
	background: linear-gradient(transparent, rgba(0, 0, 0, .55));
	opacity: 0;
	transform: translateY(6px);
	transition: opacity .35s ease, transform .35s ease;
	pointer-events: none;
}
.tile__link:hover .tile__title,
.tile__link:focus-visible .tile__title { opacity: 1; transform: none; }

.tile--text .tile__link { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.tile__text {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	gap: 8px;
	height: 100%;
	padding: 16px;
}
.tile__text-title { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.3; }
.tile__text-excerpt {
	font-size: 13px;
	color: var(--muted);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* While a post is open, the other tiles step back. */
.mosaic.has-open .tile { opacity: .42; filter: saturate(.5); }
.mosaic.has-open .tile:hover { opacity: 1; filter: none; }

.tile.is-loading .tile__link::after {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--bg);
	animation: zitda-pulse 1s ease-in-out infinite alternate;
}
@keyframes zitda-pulse { from { opacity: 0; } to { opacity: .35; } }

.tile.is-new { animation: zitda-in .9s ease both; }
@keyframes zitda-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Opened post inside the mosaic ---------- */

.panel {
	flex: 1 0 100%;
	grid-column: 1 / -1;
	position: relative;
	z-index: 1;
}
.panel__inner { background: var(--panel); border-radius: 4px; padding: 0 0 clamp(40px, 6vw, 80px); }

.panel__bar {
	position: sticky;
	top: 12px;
	z-index: 3;
	height: 0;
	display: flex;
	justify-content: flex-end;
	padding-right: 12px;
}
.panel__close {
	margin-top: 12px;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: color-mix(in srgb, var(--panel) 82%, transparent);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	color: var(--ink);
	cursor: pointer;
	display: grid;
	place-items: center;
	box-shadow: 0 1px 6px rgba(0, 0, 0, .12);
	transition: transform .2s ease;
}
.panel__close:hover { transform: rotate(90deg); }
.panel__close svg { width: 18px; height: 18px; }

.panel.is-closing { pointer-events: none; }

/* Slow, soft arrival of the words */
.panel .reveal {
	opacity: 0;
	filter: blur(14px);
	transform: translateY(18px);
	transition:
		opacity 1.4s ease var(--d, 0s),
		filter 1.9s ease var(--d, 0s),
		transform 1.6s cubic-bezier(.2, .7, .2, 1) var(--d, 0s);
}
.panel.is-revealed .reveal { opacity: 1; filter: blur(0); transform: none; }

.panel .entry__hero-img { transform: scale(1.04); transition: transform 2.2s cubic-bezier(.2, .7, .2, 1); }
.panel.is-revealed .entry__hero-img { transform: none; }

/* ---------- Entry (post / page) ---------- */

.entry__hero {
	margin: 0 0 clamp(32px, 5vw, 56px);
	overflow: hidden;
	display: flex;
	justify-content: center;
	padding: clamp(0px, 3vw, 40px) clamp(0px, 3vw, 40px) 0;
}
.entry__hero-img {
	display: block;
	width: min(100%, calc(62vh * var(--r, 1.5)));
	height: auto;
	aspect-ratio: var(--r, 1.5);
	object-fit: cover;
	background-size: cover;
	background-position: center;
	border-radius: 4px;
}

.entry__header,
.entry__content {
	max-width: 680px;
	margin-left: auto;
	margin-right: auto;
	padding: 0 20px;
}
.entry__header { text-align: center; margin-bottom: clamp(28px, 4vw, 44px); }
.entry__header:first-child { padding-top: clamp(48px, 7vw, 88px); }
.entry__title {
	margin: 0;
	font-size: clamp(26px, 3.6vw, 40px);
	font-weight: 700;
	letter-spacing: -0.03em;
	line-height: 1.25;
	outline: none;
}
.entry__date { display: inline-block; margin-top: 12px; color: var(--muted); font-size: 14px; }

.entry__content {
	font-size: 17.5px;
	line-height: 1.9;
}
.entry__content > * { margin-top: 0; margin-bottom: 1.4em; }
.entry__content h2, .entry__content h3 { line-height: 1.4; letter-spacing: -0.02em; margin-top: 2em; }
.entry__content a { color: var(--accent); text-underline-offset: 3px; }
.entry__content img { display: block; height: auto; border-radius: 3px; }
.entry__content figure { margin-left: 0; margin-right: 0; }
.entry__content figcaption, .entry__content .wp-element-caption { font-size: 13px; color: var(--muted); text-align: center; margin-top: 8px; }
.entry__content blockquote {
	margin-left: 0;
	padding-left: 20px;
	border-left: 2px solid var(--line);
	color: var(--muted);
}
.entry__content hr { border: 0; border-top: 1px solid var(--line); margin: 3em auto; width: 60px; }
.entry__content iframe { max-width: 100%; }
.entry__content .alignwide {
	width: min(1040px, calc(100vw - 2 * var(--pad)));
	max-width: none;
	margin-left: 50%;
	transform: translateX(-50%);
}
.entry__content .alignfull {
	width: min(var(--maxw), 100vw);
	max-width: none;
	margin-left: 50%;
	transform: translateX(-50%);
}
.panel .entry__content .alignfull { width: calc(100% + 40px); margin-left: -20px; transform: none; }

/* Jetpack share buttons: keep their own look, just give them some air */
.entry__content .sharedaddy,
.entry__content .wp-block-jetpack-sharing-buttons { margin-top: 3em; }
.entry__content .sharedaddy a,
.entry__content .wp-block-jetpack-sharing-buttons a { text-decoration: none; }

/* ---------- Single page ---------- */

.site-main--single .entry { background: var(--panel); padding-bottom: clamp(40px, 6vw, 80px); }
.site-main--single .entry__hero { margin-top: 0; }

.comments, .post-navigation, .back-home {
	max-width: 680px;
	margin: 48px auto 0;
	padding: 0 20px;
}
.comments__title { font-size: 18px; }
.comment-list { padding-left: 0; list-style: none; }
.comment-list .children { list-style: none; padding-left: 24px; }
.comment-body { padding: 16px 0; border-bottom: 1px solid var(--line); }
.comment-meta { font-size: 13px; color: var(--muted); }
.comment-meta img { border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form input[type="url"], .comment-form textarea,
.search-field {
	width: 100%;
	padding: 10px 12px;
	font: inherit;
	color: inherit;
	background: var(--panel);
	border: 1px solid var(--line);
}
.comment-form .submit, .search-submit {
	padding: 10px 20px;
	font: inherit;
	border: 0;
	background: var(--ink);
	color: var(--bg);
	cursor: pointer;
}
.post-navigation .nav-links { display: flex; justify-content: space-between; gap: 20px; }
.post-navigation a { text-decoration: none; }
.nav-label { display: block; font-size: 12px; color: var(--muted); }
.back-home a { color: var(--muted); font-size: 14px; }

/* ---------- More & footer ---------- */

.mosaic-more { text-align: center; padding: 40px 0 10px; }
.mosaic-more a {
	display: inline-block;
	padding: 10px 26px;
	border: 1px solid var(--line);
	border-radius: 999px;
	text-decoration: none;
	color: var(--muted);
	font-size: 14px;
}
.mosaic-more.is-loading a { opacity: .5; pointer-events: none; }

.empty { color: var(--muted); padding: 60px 0; text-align: center; }

.site-footer {
	max-width: var(--maxw);
	margin: 0 auto;
	padding: 60px var(--pad) 48px;
	color: var(--muted);
	font-size: 13px;
	text-align: center;
}
.site-footer .widget-title { font-size: 13px; }
.site-info { margin: 12px 0 0; }

/* ---------- Less motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.tile, .tile__img, .tile__title, .panel .reveal, .panel .entry__hero-img { transition: none !important; }
	.panel .reveal { filter: none; transform: none; }
	.tile.is-new, .tile.is-loading .tile__link::after { animation: none; }
}
