/*
Theme Name: Talha Kose
Theme URI: https://talhakose.com
Author: Talha Kose
Description: Personal writing site. Geist, monochrome, 12-column grid.
Version: 0.2.2
Requires at least: 6.6
Requires PHP: 8.0
License: GPL-2.0-or-later
Text Domain: talhakose
*/

/* Grid: 12 columns. Labels sit in 1–3, content in 4–12. Stacks to one column on phones. */

body {
	font-kerning: normal;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

.wp-site-blocks > *,
.tk-home > * {
	margin-block: 0;
}

::selection {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 3px;
}

a {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

.tk-grid {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	column-gap: 24px;
	max-width: 1200px;
	margin-inline: auto;
}

.tk-grid > * {
	margin-block: 0;
}

.tk-lab {
	grid-column: 1 / 4;
	min-width: 0;
}

.tk-main {
	grid-column: 4 / 13;
	min-width: 0;
}

/* Small UI text: dates, labels, navigation, footer. */
.tk-meta,
.tk-year__label,
.tk-row__meta,
.tk-post-meta,
.tk-foot,
.tk-now__label,
.tk-consent {
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
	color: var(--wp--preset--color--muted);
	font-variant-numeric: tabular-nums;
}

/* Header */
.tk-head {
	align-items: baseline;
	padding-block: 26px;
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.tk-head .tk-main {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
}

.tk-head .tk-main > * {
	margin-block: 0;
}

.tk-search {
	flex: none;
	width: 11rem;
}

.tk-search .wp-block-search__input {
	padding: 5px 9px;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
	color: var(--wp--preset--color--contrast);
	background: transparent;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 3px;
	outline: none;
}

.tk-search .wp-block-search__input::placeholder {
	color: var(--wp--preset--color--muted);
	opacity: 1;
}

.tk-search .wp-block-search__input:focus {
	border-color: var(--wp--preset--color--contrast);
}

/* Core forces nav links to inherit their color, so it's set on the parents. */
nav.tk-nav {
	color: var(--wp--preset--color--muted);
}

.tk-nav li:hover,
.blog .tk-nav li:first-child,
.single-post .tk-nav li:first-child,
.tk-page-about .tk-nav li:nth-child(2) {
	color: var(--wp--preset--color--contrast);
}

/* Home */
.tk-hello {
	padding-block: clamp(56px, 9vw, 112px) clamp(48px, 7vw, 88px);
}

.tk-hello__text {
	font-size: var(--wp--preset--font-size--x-large);
	line-height: 1.28;
	letter-spacing: -0.018em;
	max-width: 30ch;
	text-wrap: balance;
}

.tk-year {
	align-items: first baseline;
	padding-block: 22px 26px;
	border-top: 1px solid var(--wp--preset--color--line);
}

.tk-year__label {
	margin: 0;
	font-weight: 400;
	letter-spacing: 0;
}

.tk-year__posts {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tk-year__posts li + li {
	border-top: 1px solid var(--wp--preset--color--line);
}

.tk-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 20px;
	padding-block: 12px;
	text-decoration: none;
	color: var(--wp--preset--color--contrast);
}

.tk-row__title {
	min-width: 0;
	font-weight: 500;
	letter-spacing: -0.012em;
	text-wrap: pretty;
}

.tk-row:hover {
	color: var(--wp--preset--color--contrast);
}

.tk-row:hover .tk-row__title {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.22em;
}

.tk-row__meta {
	flex: none;
}

/* From page 2 on, the list starts right under the header. */
.paged .tk-hello {
	display: none;
}

.paged .tk-index .tk-year:first-child {
	border-top: 0;
}

/* Page numbers */
.tk-pager {
	align-items: baseline;
	padding-block: 20px;
	border-top: 1px solid var(--wp--preset--color--line);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
	color: var(--wp--preset--color--muted);
	font-variant-numeric: tabular-nums;
}

.tk-pager__links {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px 20px;
}

.tk-pager__numbers {
	display: flex;
	flex-wrap: wrap;
	gap: 2px 12px;
}

.tk-pager a {
	color: inherit;
	text-decoration: none;
}

.tk-pager a:hover {
	color: var(--wp--preset--color--contrast);
	text-decoration: underline;
}

.tk-pager__current {
	font-weight: 500;
	color: var(--wp--preset--color--contrast);
}

.tk-pager__off {
	opacity: 0.4;
}

/* Search results */
.tk-results {
	padding-block: clamp(48px, 8vw, 96px) clamp(32px, 5vw, 48px);
}

.tk-results .tk-title {
	max-width: none;
	overflow-wrap: anywhere;
}

.tk-results .tk-meta {
	margin: 14px 0 0;
}

.tk-results .tk-meta a {
	color: inherit;
}

/* Single post and pages */
.tk-post,
.tk-page {
	padding-block: clamp(48px, 8vw, 96px) clamp(64px, 9vw, 120px);
}

.tk-post-meta {
	display: grid;
	gap: 4px;
	align-content: start;
	padding-top: 0.55em;
}

.tk-post-meta__back {
	margin-bottom: 20px;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.tk-post-meta__back:hover {
	text-decoration: underline;
}

.tk-title {
	margin: 0;
	max-width: 20ch;
	text-wrap: balance;
}

.tk-prose {
	max-width: 65ch;
	margin-top: 40px;
}

.tk-prose > * {
	margin-block: 0;
}

.tk-prose > * + * {
	margin-block-start: 1.15em;
}

.tk-prose > h2,
.tk-prose > h3 {
	margin-block-start: 2.2em;
	text-wrap: balance;
}

.tk-prose p {
	text-wrap: pretty;
	hanging-punctuation: first;
}

.tk-prose ul,
.tk-prose ol {
	padding-left: 1.2em;
}

.tk-prose li + li {
	margin-top: 0.4em;
}

/* Sized here because theme.json would turn an em font size into a fluid one. */
.tk-prose blockquote {
	margin-inline: 0;
	font-size: 1.22em;
	line-height: 1.45;
}

.tk-prose blockquote p {
	margin: 0;
}

.tk-prose blockquote cite {
	display: block;
	margin-top: 0.6em;
	font-size: var(--wp--preset--font-size--small);
	font-style: normal;
	color: var(--wp--preset--color--muted);
}

.tk-prose :not(pre) > code {
	font-family: var(--wp--preset--font-family--geist-mono);
	font-size: 0.86em;
	background: var(--wp--preset--color--subtle);
	padding: 0.12em 0.35em;
	border-radius: 3px;
}

.tk-prose figure {
	margin-inline: 0;
}

.tk-prose figcaption {
	margin-top: 8px;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.is-style-lead {
	font-size: 1.22em;
	line-height: 1.5;
	max-width: 34ch;
	text-wrap: pretty;
}

.tk-title + .tk-prose > .is-style-lead:first-child {
	margin-top: -12px;
	margin-bottom: 40px;
}

/* Now pattern */
.tk-now__row {
	display: grid;
	grid-template-columns: 9rem minmax(0, 1fr);
	gap: 16px;
	padding-block: 12px;
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.tk-now__row > * {
	margin: 0;
}

.tk-now__label {
	padding-top: 0.2em;
}

/* Footer */
.tk-foot {
	padding-block: 28px 36px;
	border-top: 1px solid var(--wp--preset--color--line);
}

.tk-foot a {
	color: inherit;
	text-decoration: none;
}

.tk-foot a:hover {
	color: var(--wp--preset--color--contrast);
}

.tk-foot__links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 24px;
}

body:not(.tk-privacy-on) .tk-privacy-link {
	display: none;
}

/* Cookie notice */
.tk-consent {
	position: fixed;
	right: calc(20px + env(safe-area-inset-right, 0px));
	bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	z-index: 100;
	box-sizing: border-box;
	width: min(380px, calc(100vw - 40px));
	display: grid;
	gap: 14px;
	padding: 18px;
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 6px;
	box-shadow: 0 10px 30px rgb(20 20 20 / 0.08);
	line-height: 1.55;
}

.tk-consent[hidden] {
	display: none;
}

.tk-consent p {
	margin: 0;
}

.tk-consent a {
	color: inherit;
}

.tk-consent strong {
	display: block;
	margin-bottom: 2px;
	font-weight: 500;
	color: var(--wp--preset--color--contrast);
}

.tk-consent__actions {
	display: flex;
	gap: 8px;
}

.tk-consent__actions button {
	flex: 1;
	padding: 9px 12px;
	font: inherit;
	color: var(--wp--preset--color--contrast);
	background: transparent;
	border: 1px solid var(--wp--preset--color--contrast);
	border-radius: 3px;
	cursor: pointer;
}

.tk-consent__actions button:hover {
	background: var(--wp--preset--color--subtle);
}

.tk-consent__actions [data-consent="granted"] {
	color: var(--wp--preset--color--base);
	background: var(--wp--preset--color--contrast);
}

.tk-consent__actions [data-consent="granted"]:hover {
	background: var(--wp--preset--color--muted);
	border-color: var(--wp--preset--color--muted);
}

@media (max-width: 680px) {
	.tk-grid {
		grid-template-columns: minmax(0, 1fr);
		row-gap: 12px;
	}

	.tk-lab,
	.tk-main {
		grid-column: 1 / -1;
	}

	/* Name, nav and a search icon share one row. */
	.tk-head {
		position: relative;
		display: flex;
		align-items: center;
		gap: 16px;
	}

	.tk-head .tk-lab {
		flex: none;
	}

	.tk-head .tk-main {
		flex: 1;
		align-items: center;
	}

	.tk-nav {
		flex: none;
	}

	/* The box is the icon until tapped. The 40px target overhangs so the icon lines up with the right edge. */
	.tk-search {
		width: 40px;
		margin-right: -9px;
	}

	.tk-search .wp-block-search__input {
		width: 40px;
		height: 40px;
		min-width: 0;
		padding: 0;
		font-size: 1rem; /* Below 16px, iPhones zoom the page when the box is tapped. */
		color: transparent;
		cursor: pointer;
		background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23686868' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='5.25'/%3E%3Cpath d='m12 12 4 4'/%3E%3C/svg%3E") center no-repeat;
		border-color: transparent;
	}

	.tk-search .wp-block-search__input::placeholder {
		color: transparent;
	}

	/* Tapped: it opens over the name and nav. Tapping elsewhere closes it. */
	.tk-search:focus-within {
		position: absolute;
		top: 50%;
		right: 0;
		left: 0;
		z-index: 1;
		width: auto;
		margin: 0;
		background: var(--wp--preset--color--base);
		transform: translateY(-50%);
	}

	.tk-search .wp-block-search__input:focus {
		width: 100%;
		padding: 5px 9px;
		color: var(--wp--preset--color--contrast);
		cursor: text;
		background: transparent;
		border-color: var(--wp--preset--color--contrast);
	}

	.tk-search .wp-block-search__input:focus::placeholder {
		color: var(--wp--preset--color--muted);
	}

	.tk-post-meta {
		display: flex;
		flex-wrap: wrap;
		gap: 4px 16px;
		padding-top: 0;
	}

	.tk-post-meta__back {
		flex-basis: 100%;
		margin-bottom: 8px;
	}

	.tk-now__row {
		grid-template-columns: minmax(0, 1fr);
		gap: 2px;
	}

	.tk-consent {
		right: calc(12px + env(safe-area-inset-right, 0px));
		bottom: calc(12px + env(safe-area-inset-bottom, 0px));
		width: calc(100vw - 24px);
	}
}
