/*
Theme Name:   Księga Herbaty
Theme URI:    https://daniel.herbata.org/
Author:       Daniel.herbata.org
Description:  Minimalistyczny motyw-książka: strona główna to spis treści z rozdziałami (działami) i numerowanymi artykułami, inspirowany sekcją „Статьи” blacktearoom.ru. Zawiera szablony O mnie, Oferta i Portfolio oraz notkę o autorze pod artykułami. Współpracuje z wtyczką „Import z Facebooka (Księga)”.
Version:      1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License:      GPL-2.0-or-later
Text Domain:  ksiega
*/

/* ===================================================================
   Tokeny
   =================================================================== */
:root {
	--bg: #e0e0e0;
	--bg-soft: #d6d6d6;
	--paper: #ebebea;
	--ink: #1a1b1c;
	--ink-2: #4b4d50;
	--ink-3: #7a7c80;
	--line: rgba(26, 27, 28, .18);
	--line-strong: rgba(26, 27, 28, .55);
	--accent: #1a1b1c;

	--f-display: "Unbounded", system-ui, sans-serif;
	--f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

	--gutter: clamp(16px, 2.2vw, 32px);
	--maxw: 1440px;
	--read: 720px;
	--header-h: 72px;
}

/* Palety kolorów – wybór w Wygląd → Dostosuj → „Księga – ustawienia motywu” */
body.paleta-zielona {            /* stonowana zieleń, jak napar sencha */
	--bg: #dde0cf;
	--bg-soft: #d0d4bf;
	--paper: #e7e9db;
	--ink: #1d221b;
	--ink-2: #464d42;
	--ink-3: #737a6c;
	--line: rgba(29, 34, 27, .18);
	--line-strong: rgba(29, 34, 27, .55);
	--accent: #1d221b;
}
body.paleta-zolta {              /* przygaszona żółć, jak stary papier i jasny oolong */
	--bg: #e6dfc9;
	--bg-soft: #dbd2b7;
	--paper: #efe9d7;
	--ink: #231f17;
	--ink-2: #4f4839;
	--ink-3: #7d7562;
	--line: rgba(35, 31, 23, .18);
	--line-strong: rgba(35, 31, 23, .55);
	--accent: #231f17;
}

body.paleta-biala {              /* czysta biel */
	--bg: #ffffff;
	--bg-soft: #f0f0ee;
	--paper: #ffffff;
	--ink: #1a1b1c;
	--ink-2: #4b4d50;
	--ink-3: #75777b;
	--line: rgba(26, 27, 28, .14);
	--line-strong: rgba(26, 27, 28, .5);
	--accent: #1a1b1c;
}
/* Własne kolory: --bg i --ink ustawia motyw (Dostosuj), reszta liczy się sama. */
body.paleta-wlasna {
	--bg-soft: color-mix(in srgb, var(--bg) 92%, var(--ink));
	--paper: color-mix(in srgb, var(--bg) 70%, #fff);
	--ink-2: color-mix(in srgb, var(--ink) 78%, var(--bg));
	--ink-3: color-mix(in srgb, var(--ink) 55%, var(--bg));
	--line: color-mix(in srgb, var(--ink) 18%, transparent);
	--line-strong: color-mix(in srgb, var(--ink) 55%, transparent);
	--accent: var(--ink);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: var(--f-mono);
	font-size: 16px;
	line-height: 1.375;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--bg); }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.screen-reader-text {
	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; width: auto; height: auto; clip: auto; z-index: 100; background: var(--ink); color: var(--bg); padding: 8px 12px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

/* ===================================================================
   Nagłówek
   =================================================================== */
.site-header {
	position: sticky; top: 0; z-index: 50;
	background: color-mix(in srgb, var(--bg) 92%, transparent);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
}
.site-header__inner {
	height: var(--header-h);
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; justify-self: start; }
.brand__mark {
	width: 36px; height: 36px; flex: none;
	display: grid; place-items: center;
	border: 1.5px solid var(--ink);
	font-family: "Noto Serif SC", "Songti SC", serif; font-size: 20px; line-height: 1;
}
.brand__mark img { width: 100%; height: 100%; object-fit: contain; }
.brand__text { font-size: 11px; line-height: 1.15; letter-spacing: .02em; }
.brand__text strong { display: block; font-weight: 600; }

.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 22px; }
.main-nav a { font-size: 13px; text-decoration: none; padding: 4px 0; border-bottom: 1px solid transparent; }
.main-nav a:hover,
.main-nav .current-menu-item > a,
.main-nav .current_page_item > a,
.main-nav .current-menu-ancestor > a { border-bottom-color: var(--ink); }

.header-tools { justify-self: end; display: flex; align-items: center; gap: 14px; }
.header-search { position: relative; display: flex; align-items: center; }
.header-search input {
	width: 0; opacity: 0; transition: width .25s, opacity .2s;
	border: 0; border-bottom: 1px solid var(--ink); background: transparent;
	font: 13px var(--f-mono); padding: 4px 0; color: var(--ink);
}
.header-search.is-open input, .header-search input:focus { width: 180px; opacity: 1; }
.icon-btn { background: none; border: 0; padding: 6px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }
.nav-toggle { display: none; }

/* ===================================================================
   Nagłówek strony (hero) – jak „Статьи”
   =================================================================== */
.page-hero {
	display: grid;
	grid-template-columns: 1fr 1fr;
	align-items: center;
	gap: 32px;
	padding: clamp(80px, 16vh, 150px) 0 clamp(64px, 12vh, 120px);
}
.page-hero__title {
	font-family: var(--f-display);
	font-weight: 400;
	font-size: clamp(36px, 4.4vw, 64px);
	line-height: 1.05;
	letter-spacing: -.01em;
	margin: 0;
}
.page-hero__text { font-size: 13px; line-height: 1.7; max-width: 300px; justify-self: center; text-indent: 3.5em; margin: 0; }

/* ===================================================================
   Strona główna – spis treści książki
   =================================================================== */
.toc-layout {
	display: grid;
	grid-template-columns: minmax(200px, 1fr) 2fr;
	gap: 32px;
	padding-bottom: 120px;
}
.toc-aside { position: relative; }
.toc-aside__sticky { position: sticky; top: calc(var(--header-h) + 16px); }
.label { font-weight: 700; font-size: 16px; margin: 0 0 22px; }

.chapter-nav { list-style: none; margin: 0 0 40px; padding: 0; }
.chapter-nav li { margin: 0 0 6px; }
.chapter-nav a { font-size: 13px; text-decoration: none; display: inline-flex; gap: 8px; }
.chapter-nav a:hover, .chapter-nav a.is-active { text-decoration: underline; }
.chapter-nav .num { color: var(--ink-3); min-width: 2.6em; }
.chapter-nav .cnt { color: var(--ink-3); }

.toc-filter { position: relative; margin-bottom: 40px; max-width: 280px; }
.toc-filter input {
	width: 100%; border: 0; border-bottom: 1px solid var(--line-strong); background: transparent;
	font: 13px var(--f-mono); color: var(--ink); padding: 8px 24px 8px 0;
}
.toc-filter input::placeholder { color: var(--ink-3); }
.toc-filter svg { position: absolute; right: 0; top: 8px; width: 16px; height: 16px; }

.toc-tags { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.toc-tags a { text-decoration: none; }
.toc-tags a:hover { text-decoration: underline; }

.chapter { margin: 0 0 56px; }
.chapter__head {
	display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
	padding: 0 0 22px; margin: 0;
	border-bottom: 1px solid var(--line);
}
.chapter__head h2 { font: 700 16px/1.375 var(--f-mono); margin: 0; }
.chapter__head .chapter__roman { color: var(--ink-3); font-weight: 400; margin-right: .6em; }
.chapter__head .chapter__meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.chapter__desc { font-size: 13px; color: var(--ink-2); margin: 14px 0 4px; max-width: 60ch; }

.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-item { border-bottom: 1px solid var(--line); }
.toc-item__btn {
	width: 100%; background: none; border: 0; cursor: pointer; text-align: left;
	display: grid; grid-template-columns: 72px 1fr 24px; align-items: center; gap: 16px;
	padding: 18px 0;
}
.toc-item__num { font: 400 22px/30px var(--f-mono); }
.toc-item__title { font: 400 22px/30px var(--f-display); letter-spacing: -.005em; }
.toc-item__icon { width: 24px; height: 24px; transition: transform .25s ease; }
.toc-item.is-open .toc-item__icon { transform: rotate(45deg); }
.toc-item__btn:hover .toc-item__title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }

.toc-item__panel {
	display: grid; grid-template-rows: 0fr;
	transition: grid-template-rows .3s ease;
}
.toc-item.is-open .toc-item__panel { grid-template-rows: 1fr; }
.toc-item__panel > div { overflow: hidden; }
.toc-item__body {
	display: grid; grid-template-columns: 72px 1fr; gap: 16px;
	padding: 0 0 26px;
}
.toc-item__inner { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: start; }
.toc-item__meta { font-size: 12px; color: var(--ink-3); margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.toc-item__excerpt { font-size: 14px; line-height: 1.65; margin: 0 0 16px; color: var(--ink-2); max-width: 62ch; }
.toc-item__thumbs { display: flex; gap: 6px; }
.toc-item__thumbs figure { margin: 0; width: 92px; height: 92px; background: var(--bg-soft); overflow: hidden; }
.toc-item__thumbs img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.15); }
.toc-item__thumbs figure.is-broken { display: none; }

.read-link {
	display: inline-flex; align-items: center; gap: 10px;
	font-size: 13px; text-decoration: none;
	border: 1px solid var(--ink); padding: 10px 18px;
	transition: background .2s, color .2s;
}
.read-link:hover { background: var(--ink); color: var(--bg); }

.toc-item[hidden], .chapter[hidden] { display: none; }
.toc-empty { font-size: 14px; color: var(--ink-3); padding: 24px 0; }

/* ===================================================================
   Artykuł – „strona książki”
   =================================================================== */
.article { padding-top: 56px; padding-bottom: 80px; }
.crumbs { font-size: 12px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 56px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.article__head { display: grid; grid-template-columns: 1fr 2fr; gap: 32px; margin-bottom: 56px; }
.article__page { font: 400 clamp(56px, 8vw, 120px)/1 var(--f-mono); letter-spacing: -.04em; color: var(--ink); opacity: .9; }
.article__page small { display: block; font-size: 12px; letter-spacing: 0; color: var(--ink-3); margin-top: 10px; }
.article__title { font: 400 clamp(28px, 3.4vw, 48px)/1.12 var(--f-display); margin: 0 0 24px; letter-spacing: -.01em; }
.article__meta { font-size: 12px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 6px 20px; }
.article__meta a { color: inherit; }

.article__grid { display: grid; grid-template-columns: 1fr 2fr; gap: 32px; }
.article__side { font-size: 12px; color: var(--ink-3); }
.article__side-sticky { position: sticky; top: calc(var(--header-h) + 24px); display: grid; gap: 22px; }
.article__side .label { font-size: 13px; color: var(--ink); margin: 0 0 8px; }
.article__side ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.article__side ol a { text-decoration: none; display: flex; gap: 8px; }
.article__side ol a:hover { color: var(--ink); text-decoration: underline; }
.article__side ol .is-current { color: var(--ink); font-weight: 700; }
.article__side ol .n { min-width: 2.6em; }

.prose { max-width: var(--read); font-size: 15px; line-height: 1.8; }
.prose > * { margin: 0 0 1.25em; }
.article .prose > p:first-child::first-letter {
	font-family: var(--f-display); float: left; font-size: 3.4em; line-height: .9;
	padding: .08em .12em 0 0;
}
.prose h2, .prose h3 { font-family: var(--f-display); font-weight: 400; line-height: 1.25; margin-top: 2em; }
.prose h2 { font-size: 26px; } .prose h3 { font-size: 20px; }
.prose a { word-break: break-word; }
.prose blockquote { margin-left: 0; padding-left: 20px; border-left: 2px solid var(--ink); font-style: italic; }
.prose img { margin: 2em 0; }
.prose ul, .prose ol { padding-left: 1.3em; }

/* Galeria zdjęć z Facebooka (wyświetlane zdalnie) */
.fbi-gallery {
	display: grid; gap: 8px; margin: 48px 0 8px;
	grid-template-columns: repeat(2, 1fr);
}
.fbi-gallery--1 { grid-template-columns: 1fr; }
.fbi-gallery--3 .fbi-gallery__item:first-child { grid-column: 1 / -1; }
.fbi-gallery__item { margin: 0; background: var(--bg-soft); overflow: hidden; }
.fbi-gallery__item a { display: block; height: 100%; cursor: zoom-in; }
.fbi-gallery__item img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4 / 3; transition: transform .5s ease; margin: 0; }
.fbi-gallery--1 .fbi-gallery__item img { aspect-ratio: auto; max-height: 80vh; object-fit: contain; }
.fbi-gallery__item:hover img { transform: scale(1.02); }
.fbi-gallery__item.is-broken { display: none; }
.fbi-more { font-size: 12px; color: var(--ink-3); }
.fbi-video { position: relative; aspect-ratio: 16 / 9; margin: 40px 0; background: var(--bg-soft); }
.fbi-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.source-note { font-size: 12px; color: var(--ink-3); margin-top: 32px; }

/* Notka o autorze */
.author-box {
	margin: 64px 0 0; padding: 32px 0 0; border-top: 1px solid var(--line-strong);
	display: grid; grid-template-columns: 96px 1fr; gap: 24px; max-width: var(--read);
}
.author-box__img { width: 96px; height: 96px; object-fit: cover; filter: grayscale(1); background: var(--bg-soft); }
.author-box__label { font-size: 12px; color: var(--ink-3); margin: 0 0 6px; }
.author-box__name { font: 400 20px/1.3 var(--f-display); margin: 0 0 10px; }
.author-box__bio { font-size: 13px; line-height: 1.7; margin: 0 0 12px; color: var(--ink-2); }
.author-box__links { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12px; }

/* Nawigacja stron */
.page-turn {
	display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 80px;
	background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.page-turn a, .page-turn span { background: var(--bg); padding: 28px 0; text-decoration: none; display: block; }
.page-turn__next { text-align: right; }
.page-turn small { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.page-turn strong { font: 400 18px/1.3 var(--f-display); }
.page-turn a:hover strong { text-decoration: underline; text-underline-offset: 4px; }
.page-turn__toc { grid-column: 1 / -1; text-align: center; font-size: 13px; padding: 18px 0 !important; }

/* Lightbox */
.lb { position: fixed; inset: 0; z-index: 200; background: rgba(16, 16, 17, .94); display: none; align-items: center; justify-content: center; }
.lb.is-open { display: flex; }
.lb img { max-width: 92vw; max-height: 88vh; width: auto; height: auto; }
.lb button { position: absolute; background: none; border: 0; color: #eee; cursor: pointer; font: 28px/1 var(--f-mono); padding: 16px; }
.lb__close { top: 8px; right: 12px; }
.lb__prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb__next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb__count { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #bbb; font-size: 12px; }

/* ===================================================================
   Strony: O mnie, Oferta, Portfolio
   =================================================================== */
.page-body { display: grid; grid-template-columns: 1fr 2fr; gap: 32px; padding-bottom: 120px; }
.page-body__side { font-size: 13px; color: var(--ink-2); }
.page-body__side img { width: 100%; max-width: 320px; filter: grayscale(1); margin-bottom: 16px; }

.prose .offer-list, .offer-list { list-style: none; margin: 32px 0 0; padding: 0; }
.offer-item { border-top: 1px solid var(--line); padding: 28px 0; display: grid; grid-template-columns: 72px 1fr auto; gap: 16px; }
.offer-item:last-child { border-bottom: 1px solid var(--line); }
.offer-item__num { font: 22px/30px var(--f-mono); }
.offer-item h3 { font: 400 22px/30px var(--f-display); margin: 0 0 10px; }
.offer-item p { font-size: 14px; line-height: 1.65; color: var(--ink-2); margin: 0; max-width: 56ch; }
.offer-item__price { font-size: 14px; white-space: nowrap; }

.prose .portfolio-grid, .portfolio-grid { margin-top: 32px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 40px 24px; }
.portfolio-card { margin: 0; }
.portfolio-card__img { aspect-ratio: 4 / 3; background: var(--bg-soft); display: grid; place-items: center; overflow: hidden; margin-bottom: 14px; }
.portfolio-card__img img { width: 100%; height: 100%; object-fit: cover; }
.portfolio-card__img span { font: 48px var(--f-display); color: var(--ink-3); }
.portfolio-card h3 { font: 400 20px/1.3 var(--f-display); margin: 0 0 6px; }
.portfolio-card p { font-size: 13px; line-height: 1.6; color: var(--ink-2); margin: 0; }
.portfolio-card .tag { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; display: block; }

.contact-cta { margin-top: 56px; padding: 32px; border: 1px solid var(--ink); display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
.contact-cta p { margin: 0; font: 400 20px/1.3 var(--f-display); }

/* Archiwum / wyszukiwanie */
.archive-list .toc-item__btn { cursor: default; }
.archive-list a.toc-item__btn { text-decoration: none; }
.pagination { display: flex; gap: 14px; margin-top: 40px; font-size: 14px; }
.pagination .current { font-weight: 700; text-decoration: underline; }

/* ===================================================================
   Stopka
   =================================================================== */
.site-footer { border-top: 1px solid var(--line-strong); padding: 48px 0 40px; font-size: 12px; }
.site-footer__inner { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 32px; }
.site-footer h4 { font-size: 13px; margin: 0 0 12px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer__bottom { display: flex; justify-content: space-between; margin-top: 48px; color: var(--ink-3); gap: 16px; flex-wrap: wrap; }

/* ===================================================================
   Responsywność
   =================================================================== */
@media (max-width: 960px) {
	.site-header__inner { grid-template-columns: auto 1fr auto; }
	.nav-toggle { display: inline-grid; }
	.main-nav { position: fixed; inset: var(--header-h) 0 auto 0; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px var(--gutter) 24px; display: none; }
	.main-nav.is-open { display: block; }
	.main-nav ul { flex-direction: column; gap: 0; }
	.main-nav a { display: block; font-size: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
	.header-tools { grid-column: 3; }
	.page-hero { grid-template-columns: 1fr; gap: 20px; padding: 56px 0 48px; }
	.page-hero__text { justify-self: start; text-indent: 0; max-width: 46ch; }
	.toc-layout, .article__head, .article__grid, .page-body { grid-template-columns: 1fr; }
	.toc-aside__sticky, .article__side-sticky { position: static; }
	.chapter-nav { columns: 2; column-gap: 16px; }
	.article__side { order: 2; }
	.article__head { gap: 8px; margin-bottom: 32px; }
	.site-footer__inner { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
	.toc-item__btn { grid-template-columns: 40px 1fr 20px; gap: 10px; padding: 16px 0; }
	.toc-item__num { font-size: 15px; }
	.toc-item__title { font-size: 17px; line-height: 24px; }
	.toc-item__body { grid-template-columns: 1fr; padding-left: 50px; }
	.toc-item__inner { grid-template-columns: 1fr; }
	.toc-item__thumbs figure { width: 72px; height: 72px; }
	.chapter-nav { columns: 1; }
	.prose { font-size: 15px; }
	.fbi-gallery { grid-template-columns: 1fr; }
	.author-box { grid-template-columns: 64px 1fr; gap: 16px; }
	.author-box__img { width: 64px; height: 64px; }
	.offer-item { grid-template-columns: 40px 1fr; }
	.offer-item__price { grid-column: 2; }
	.portfolio-grid { grid-template-columns: 1fr; }
	.page-turn { grid-template-columns: 1fr; }
	.page-turn__next { text-align: left; }
	.brand__text { display: none; }
}

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

@media print {
	.site-header, .site-footer, .article__side, .page-turn, .author-box__links { display: none; }
	body { background: #fff; }
}

/* Komentarze */
.comments { margin-top: 64px; max-width: var(--read); font-size: 13px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 40px; }
.comment-list li { border-top: 1px solid var(--line); padding: 20px 0; }
.comment-list .avatar { float: left; margin-right: 12px; filter: grayscale(1); }
.comment-meta { font-size: 12px; color: var(--ink-3); }
.comment-form label { display: block; font-size: 12px; margin-bottom: 4px; }
.comment-form input[type=text], .comment-form input[type=email], .comment-form input[type=url], .comment-form textarea {
	width: 100%; background: transparent; border: 1px solid var(--line-strong); padding: 10px; font: 14px var(--f-mono); color: var(--ink);
}
.comment-form .read-link { background: none; cursor: pointer; }
