/*
Theme Name: Into the Why
Theme URI: https://www.intothewhy.com
Author: Luca Attolini
Description: Tema a blocchi di Into the Why. Scuro di default con interruttore verso il chiaro, Newsreader e IBM Plex Mono caricati dal server.
Version: 0.1.6
Requires at least: 6.5
Requires PHP: 7.4
License: GNU General Public License v2 or later
Text Domain: intothewhy
*/

/* ================= colori: scuro di default ================= */
:root {
	--bg: #141413;
	--text: #E8E4DA;
	--muted: #9A958A;
	--rule: #2E2C29;
	--mark: #2C2A26;
	--green: #B0EA0D;
	--grad: linear-gradient(90deg, #3a4a08 0%, #b0ea0d 100%);
	--grad-text: linear-gradient(90deg, #E8E4DA 0%, #b0ea0d 100%);
	--grad-v: linear-gradient(180deg, #3a4a08 0%, #b0ea0d 100%);
	--serif: Newsreader, Georgia, "Times New Roman", serif;
	--mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
	color-scheme: dark;
}
:root[data-theme="light"] {
	--bg: #FAF8F3;
	--text: #1C1B19;
	--muted: #6B675F;
	--rule: #E2DDD2;
	--mark: #ECE6D8;
	--grad: linear-gradient(90deg, #0b0b0b 0%, #b0ea0d 100%);
	--grad-text: linear-gradient(90deg, #0b0b0b 0%, #5f8a00 55%, #b0ea0d 100%);
	--grad-v: linear-gradient(180deg, #0b0b0b 0%, #b0ea0d 100%);
	color-scheme: light;
}

html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--serif);
	font-size: 20px;
	line-height: 1.65;
	text-rendering: optimizeLegibility;
	transition: background-color .25s ease, color .25s ease;
}
.editor-styles-wrapper { background: var(--bg); color: var(--text); font-family: var(--serif); }

/* ================= link: sottolineatura che si riempie di sfumatura ================= */
a { color: inherit; }
a:where(:not(.wp-element-button)) {
	text-decoration: none;
	background-image: linear-gradient(var(--muted), var(--muted)), var(--grad);
	background-size: 100% 1px, 0% 2px;
	background-position: 0 100%, 0 100%;
	background-repeat: no-repeat;
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
	padding-bottom: 1px;
	transition: background-size .35s ease;
}
a:where(:not(.wp-element-button)):hover { background-size: 100% 1px, 100% 2px; }
.site-nav a, .site-footer a, .essay-list a, .read a, .start a, .toc a, .wp-block-post-title a, .filters a, .tag a {
	background-size: 0% 1px, 0% 2px;
}
.site-nav a:hover, .site-footer a:hover, .essay-list a:hover, .read a:hover, .start a:hover, .toc a:hover, .wp-block-post-title a:hover, .filters a:hover, .tag a:hover {
	background-size: 0% 1px, 100% 2px;
}

/* ================= etichette monospace ================= */
.label, .meta, .site-nav, .toc, .site-footer, .micro, .read-label, .more, .filters, .date, .tag, .theme-switch {
	font-family: var(--mono);
}
.label, .read-label {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .1em;
	color: var(--muted);
	margin: 0;
}

/* ================= header ================= */
.site-header { padding-top: 36px; padding-bottom: 28px; border-bottom: 1px solid var(--rule); }
.site-header__inner { max-width: 680px; margin: 0 auto; align-items: baseline !important; gap: 16px; }
.site-name { margin: 0; font-weight: 700; font-size: 22px; letter-spacing: -.01em; line-height: 1.2; }
.site-name a {
	color: transparent;
	background-image: var(--grad-text), linear-gradient(var(--text), var(--text)) !important;
	background-size: 0% 100%, 100% 100% !important;
	background-position: 0 0, 0 0 !important;
	-webkit-background-clip: text;
	background-clip: text;
	padding: 0;
	transition: background-size .45s ease;
}
.site-name a:hover { background-size: 100% 100%, 100% 100% !important; }
.site-nav { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.site-nav .wp-block-navigation__container { gap: 18px; }
.site-nav a { color: var(--muted); }
.site-nav a:hover { color: var(--text); }

/* ================= divisore e blocchi ================= */
.divider { width: 56px; height: 1px; background: var(--muted); margin: 64px auto !important; opacity: .6; }
.block h2, .territories h2 { font-size: 32px; line-height: 1.2; margin: 8px 0 18px; font-weight: 600; }
.block p { margin: 0 0 18px; }
.trials { padding-left: 18px; border-left: 2px solid transparent; border-image: var(--grad-v) 1; line-height: 1.75; }
.trials strong { font-family: var(--mono); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--text); }

/* ================= home ================= */
.hero { padding-top: 72px; }
.hero h1 { font-size: 50px; line-height: 1.08; margin: 0 0 22px; font-weight: 600; letter-spacing: -.015em; }
.hero-truths { font-size: 24px; line-height: 1.5; margin: 0 0 18px; font-style: italic; }
.hero-sub { font-size: 22px; line-height: 1.5; color: var(--muted); margin: 0 0 28px; }
.signup { display: flex; gap: 10px; flex-wrap: wrap; margin: 0; }
.signup input {
	flex: 1 1 240px; font-family: var(--mono); font-size: 15px; padding: 12px 14px;
	background: transparent; border: 1px solid var(--muted); color: var(--text);
}
.signup button {
	font-family: var(--mono); font-size: 14px; text-transform: uppercase; letter-spacing: .08em;
	padding: 12px 20px; background: var(--text); color: var(--bg); border: 1px solid var(--text); cursor: pointer;
}
.signup button:hover { color: var(--green); }
.signup.is-closed input, .signup.is-closed button { opacity: .45; cursor: not-allowed; }
.signup.is-closed button:hover { color: var(--bg); }
.nl-note { font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 10px 0 0 !important; }
.micro { font-size: 12px; color: var(--muted); margin: 10px 0 0 !important; }

.territories h2 { padding-bottom: 14px; border-bottom: 1px solid var(--text); margin-bottom: 32px; }
.terr { margin-bottom: 40px; }
.terr .num { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .08em; margin: 0; }
.terr h3 { font-size: 26px; margin: 4px 0 8px; font-weight: 600; }
.terr p.desc { font-size: 18px; line-height: 1.55; color: var(--muted); margin: 0 0 16px; }
.terr:hover .num { color: var(--green); }
.read-label { margin-bottom: 6px; }
.read { list-style: none; margin: 0; padding: 0; }
.read li { padding: 5px 0 5px 26px; position: relative; }
.read li::before { content: "\2192"; position: absolute; left: 0; top: 7px; font-family: var(--mono); font-size: 15px; color: var(--muted); transition: transform .2s ease, color .2s ease; }
.read li:hover::before { transform: translateX(4px); color: var(--green); }
.read .wp-block-post-title { font-size: 18px; line-height: 1.4; margin: 0; font-weight: 400; }
.read-empty { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.start { list-style: none; margin: 8px 0 0; padding: 0; counter-reset: s; }
.start > li { counter-increment: s; display: grid; grid-template-columns: 48px 1fr; padding: 16px 0; border-bottom: 1px dotted var(--rule); }
.start > li::before { content: counter(s, decimal-leading-zero); font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 6px; grid-row: span 2; }
.start > li:hover::before { color: var(--green); }
.start .wp-block-post-title { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 0; }
.start .wp-block-post-excerpt { margin: 0; }
.start .wp-block-post-excerpt__excerpt { font-size: 17px; color: var(--muted); margin: 6px 0 0; }
.more { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; margin-top: 40px !important; }
.todo { font-family: var(--mono); font-size: 14px; color: var(--muted); border: 1px dashed var(--rule); padding: 12px 14px; }

/* ================= newsletter ================= */
.newsletter { margin: 64px 0 24px; padding: 28px 0; border-top: 1px solid var(--text); border-bottom: 1px solid var(--text); }
.newsletter.home-close { border: none; padding: 0; }
.newsletter h3 { font-size: 24px; margin: 6px 0 8px; font-weight: 600; }
.newsletter p { margin: 0 0 18px; font-size: 18px; color: var(--muted); }

/* ================= essays: archivio ================= */
.archive-head { padding: 56px 0 8px; }
.archive-head h1 { font-size: 44px; line-height: 1.1; margin: 8px 0 14px; font-weight: 600; }
.archive-head .lead { font-size: 22px; line-height: 1.5; color: var(--muted); margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 8px 0 24px; border-bottom: 1px solid var(--rule); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.filters p { margin: 0; }
.filters a { color: var(--muted); }
.filters a:hover { color: var(--text); }
.essay-list { list-style: none; margin: 0; padding: 0; }
.essay-list > li { display: grid; grid-template-columns: 92px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px dotted var(--rule); }
.essay-list .date { font-size: 13px; color: var(--muted); padding-top: 5px; margin: 0; }
.essay-list .wp-block-post-title { font-size: 20px; line-height: 1.35; margin: 0; font-weight: 400; }
.tag { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 2px 0 0; }
.tag a { color: var(--muted); }
.wp-block-query-pagination { font-family: var(--mono); font-size: 13px; margin-top: 32px; }

/* ================= articolo ================= */
.article-head { padding: 56px 0 24px; }
.meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0; font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.meta > * { margin: 0 !important; }
.meta > * + *::before { content: "/"; margin: 0 8px; color: var(--muted); }
.meta .territory, .meta .territory a { color: var(--text); text-transform: uppercase; letter-spacing: .08em; }
.article-head .wp-block-post-title { font-size: 44px; line-height: 1.12; letter-spacing: -.015em; margin: 14px 0 18px; font-weight: 700; }
.dek, .dek p { font-size: 23px; line-height: 1.45; color: var(--muted); font-style: italic; margin: 0; }

.entry-content h2 { font-size: 28px; line-height: 1.25; margin: 56px 0 12px; scroll-margin-top: 24px; font-weight: 600; }
.entry-content h3 { font-size: 23px; line-height: 1.3; margin: 40px 0 10px; font-weight: 600; }
.entry-content p { margin: 0 0 22px; hyphens: auto; }
.entry-content strong { font-weight: 600; }
.entry-content ul, .entry-content ol { padding-left: 1.2em; margin: 0 0 22px; }
.entry-content li { margin-bottom: 8px; }
.entry-content ol li::marker { font-family: var(--mono); font-size: 15px; color: var(--green); }
.entry-content mark { background: var(--mark); color: inherit; padding: 0 2px; }
.wp-block-quote { margin: 32px 0; padding: 2px 0 2px 22px; border-left: 2px solid transparent; border-image: var(--grad-v) 1; font-style: italic; }
.wp-block-quote p { margin: 0; }
.wp-block-quote cite { display: block; margin-top: 8px; font-family: var(--mono); font-size: 13px; font-style: normal; color: var(--muted); }
.wp-block-pullquote { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 32px 0; font-size: 28px; }
.wp-block-separator { border: none !important; background: none !important; text-align: center; margin: 48px auto !important; color: var(--muted); height: auto !important; }
.wp-block-separator::after { content: "\2042"; font-size: 22px; }
.wp-block-image, .entry-content figure { margin: 40px 0; }
.wp-element-caption, figcaption { font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.wp-block-footnotes { font-size: 15px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 18px; margin-top: 48px; }
.entry-content sup a { font-family: var(--mono); font-size: 12px; background: none; color: var(--green); }
.toc-inline { margin: 8px 0 40px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 14px 0; font-size: 16px; }
.toc-inline summary { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); cursor: pointer; list-style: none; }
.toc-inline summary::-webkit-details-marker { display: none; }
.toc-inline summary::after { content: " +"; color: var(--green); }
.toc-inline[open] summary::after { content: " \2212"; }
.toc-inline ol { margin: 14px 0 0; padding-left: 1.2em; }
.toc-inline ul { margin: 4px 0 6px; padding-left: 1.1em; list-style: none; }
.toc-inline li { margin: 4px 0; line-height: 1.4; }
.toc-inline ul li { font-size: 15px; color: var(--muted); }
.toc-inline a { background-size: 0% 1px, 0% 2px; }
.toc-inline a:hover { background-size: 0% 1px, 100% 2px; }
.back { font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }

/* indice laterale (costruito dallo script sui titoli H2) */
.toc { display: none; }
@media (min-width: 1240px) {
	.toc {
		display: block; position: fixed; top: 120px; left: calc(50% - 340px - 260px); width: 210px;
		font-size: 12.5px; line-height: 1.5; z-index: 5;
		/* sugli articoli lunghi l'indice non esce dallo schermo: scorre al suo interno */
		max-height: calc(100vh - 160px); overflow-y: auto; overflow-x: hidden;
		padding: 0 10px 40px 4px; scrollbar-width: none; transition: opacity .25s ease;
		-webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
		mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
	}
	.toc::-webkit-scrollbar { display: none; }
	.toc .label { display: block; margin-bottom: 12px; }
	.toc ol { list-style: none; margin: 0; padding: 0 0 0 16px; counter-reset: toc; position: relative; border-left: 1px solid var(--rule); }
	.toc li { counter-increment: toc; margin-bottom: 8px; transition: transform .25s ease; }
	.toc li:hover { transform: translateX(6px); }
	.toc a { color: var(--muted); display: flex; gap: 8px; transition: color .25s ease, background-size .35s ease; }
	.toc a::before { content: counter(toc, decimal-leading-zero); color: var(--rule); transition: color .25s ease; }
	.toc li:hover a::before, .toc a.active::before { color: var(--green); }
	.toc a.active { color: var(--text); font-weight: 500; }
	.toc li.done a { opacity: .55; }
	.toc li.done a::before { content: "\2713"; color: var(--green); min-width: 1.4em; }
	.toc-indicator { position: absolute; left: -2px; width: 3px; top: 0; height: 0; border-radius: 2px; background: var(--grad-v); transition: top .35s ease, height .35s ease; }
}

/* barra di lettura */
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--grad); z-index: 20; }

/* ================= footer ================= */
.site-footer { font-size: 12.5px; color: var(--muted); padding-top: 32px; padding-bottom: 56px; margin-top: 64px; border-top: 1px solid var(--rule); }
.site-footer__inner { max-width: 680px; margin: 0 auto; }
.site-footer p { margin: 0; }

/* ================= interruttore tema ================= */
.theme-switch {
	position: fixed; right: 20px; bottom: 20px; z-index: 30; display: flex; align-items: center; gap: 8px;
	padding: 0; background: none; border: none; cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.theme-switch .track {
	position: relative; width: 52px; height: 28px; border-radius: 14px; border: 1px solid var(--muted); background: var(--bg);
	display: flex; align-items: center; justify-content: space-between; padding: 0 7px; font-size: 12px; line-height: 1; color: var(--muted);
}
.theme-switch .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); transition: transform .2s ease; }
.theme-switch[aria-checked="true"] .knob { transform: translateX(24px); }
.theme-switch:focus-visible .track { outline: 2px solid var(--text); outline-offset: 2px; }

/* ================= telefono ================= */
@media (max-width: 600px) {
	body { font-size: 18px; }
	.hero { padding-top: 48px; }
	.hero h1 { font-size: 36px; }
	.hero-sub { font-size: 19px; }
	.block h2, .territories h2 { font-size: 26px; }
	.article-head .wp-block-post-title, .archive-head h1 { font-size: 34px; }
	.dek, .dek p { font-size: 20px; }
	.entry-content h2 { font-size: 24px; }
	.essay-list > li { grid-template-columns: 1fr; gap: 2px; }
	.start .wp-block-post-title { font-size: 19px; }
	.divider { margin: 48px auto !important; }
}
