/*
Theme Name: Riad Write
Theme URI: https://riad.blog
Author: Riad Benguella
Description: A minimal monospace writing theme built on IBM Plex Mono.
Requires at least: 6.3
Tested up to: 6.9
Requires PHP: 7.4
Version: 1.0.1
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: riad-write
Tags: block-patterns, one-column, custom-colors, custom-menu, editor-style, full-site-editing
*/

/* ===========================
   Base
   =========================== */

body {
	-moz-osx-font-smoothing: grayscale;
	-webkit-font-smoothing: antialiased;
}

/* Thin accent line at the very top of the page */
body::before {
	content: '';
	display: block;
	height: 2px;
	background: var(--wp--preset--color--foreground);
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 9999;
	pointer-events: none;
}

/* ===========================
   Links
   =========================== */

a {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.25ch;
	text-decoration-style: dotted;
	transition: opacity 0.2s ease;
}

a:hover,
a:focus {
	text-decoration-style: solid;
}

a:active {
	text-decoration: none;
}

/* ===========================
   Sidebar Layout
   =========================== */

.wp-block-columns.site-layout {
	align-items: flex-start !important;
	gap: 0 !important;
	min-height: 100vh;
	flex-wrap: nowrap;
}

/* The block uses align="full" which triggers negative margins and max-width:unset
   via the alignment helpers. Override specifically for site-layout to re-center it. */
.wp-site-blocks .wp-block-columns.site-layout.alignfull {
	max-width: 1000px !important;
	width: auto !important;
	margin-left: auto !important;
	margin-right: auto !important;
}

.wp-block-column.sidebar-column {
	flex: 0 0 250px !important;
	width: 250px !important;
	min-width: unset !important;
	position: sticky;
	top: 0;
	max-height: 100vh;
	overflow-y: auto;
}

.sidebar-inner {
	min-height: 100vh;
	padding: 1.25rem 3rem;
	padding-top: calc(1.25rem + 2.5rem + 5px);
	box-sizing: border-box;
	align-items: flex-end !important;
	text-align: right;
	border-right: 1px solid #E5E7EB;
}

.sidebar-inner .wp-block-site-title {
	text-transform: uppercase;
	letter-spacing: 0.06em;
	text-align: right !important;
	width: 100%;
}

/* Right-align sidebar content.
   text-align doesn't cascade through flex containers, so each element needs
   explicit treatment. Navigation/page-list items use display:flex so they need
   justify-content, not text-align. */
.sidebar-inner .wp-block-navigation__container {
	align-items: flex-end !important;
	gap: 0.35rem !important;
}

/* Page list items (the actual nav links) are flex containers */
.sidebar-inner .wp-block-pages-list__item,
.sidebar-inner .wp-block-navigation-item {
	justify-content: flex-end !important;
}

.sidebar-inner p {
	text-align: right !important;
	width: 100%;
}

.sidebar-inner .wp-block-social-links {
	justify-content: flex-end !important;
}

.wp-block-column.main-column {
	flex: 0 0 750px !important;
	width: 750px !important;
	min-width: unset !important;
	padding: 1.25rem 1.5rem;
	padding-top: calc(1.25rem + 2.5rem);
	padding-left: 3rem;
	box-sizing: border-box;
}

/* Left-align constrained content in main column (keep max-width, remove centering) */
.wp-block-column.main-column .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
	max-width: var(--wp--style--global--content-size) !important;
	margin-left: 0 !important;
	margin-right: auto !important;
}

@media (max-width: 599px) {
	.wp-block-column.sidebar-column {
		position: static;
		max-height: none;
		flex: 0 0 100% !important;
		width: 100% !important;
		min-width: unset !important;
	}

	.sidebar-inner {
		min-height: auto;
		padding: 1rem 0;
		border-right: none;
		flex-direction: row !important;
		align-items: center !important;
		flex-wrap: wrap;
		gap: 1rem 1.5rem;
	}

	.sidebar-inner .wp-block-site-title {
		text-align: left !important;
		width: auto;
	}

	/* Push social links + hamburger to the right as a group */
	.sidebar-inner .wp-block-social-links {
		order: 2;
		margin-left: auto !important;
	}

	.sidebar-inner .wp-block-navigation {
		order: 3;
	}

	/* Hamburger button */
	.sidebar-inner .wp-block-navigation__responsive-container-open {
		padding: 0;
		background: none;
		border: none;
		color: var(--wp--preset--color--foreground);
		cursor: pointer;
	}

	/* Nav overlay modal padding */
	.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
		padding: 2rem;
		padding-top: 5rem;
	}

	.wp-block-navigation__responsive-container-close {
		top: 2rem !important;
		right: 2rem !important;
	}

	.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
		margin-top: 3rem !important;
	}

	.sidebar-inner p {
		text-align: left !important;
		width: auto;
	}

	.sidebar-inner .wp-block-social-links {
		justify-content: flex-start !important;
	}

	/* Hide "Powered by" on mobile */
	.sidebar-inner > .wp-block-paragraph {
		display: none;
	}

	.wp-block-column.main-column {
		padding-left: 0;
		padding-right: 0;
	}
}

/* ===========================
   Navigation
   =========================== */

.wp-block-navigation .wp-block-navigation-item a {
	position: relative;
	text-decoration: none;
	background-image: linear-gradient(currentColor, currentColor);
	background-size: 0 1px;
	background-repeat: no-repeat;
	background-position: 0 100%;
	padding-bottom: 2px;
	transition: background-size 0.3s ease;
	letter-spacing: 0.04em;
}

.wp-block-navigation .wp-block-navigation-item a:hover,
.wp-block-navigation .wp-block-navigation-item a:focus {
	text-decoration: none;
	background-size: 100% 1px;
}

/* ===========================
   Site Title — blinking cursor
   =========================== */

.wp-block-site-title a {
	text-decoration: none;
	letter-spacing: 0.06em;
}

.wp-block-site-title a:hover {
	text-decoration: none;
}

.wp-block-site-title a::after {
	content: '_';
	animation: cursor-blink 1.1s step-end infinite;
	margin-left: 1px;
}

@keyframes cursor-blink {
	0%, 100% { opacity: 1; }
	50%       { opacity: 0; }
}

/* ===========================
   Post Title Link — draw-in underline
   =========================== */

.wp-block-post-title {
	padding-bottom: 2px;
	margin-bottom: 0 !important;
}

.wp-block-post-title a {
	text-decoration: none;
	background-image: linear-gradient(currentColor, currentColor);
	background-size: 0 1px;
	background-repeat: no-repeat;
	background-position: 0 100%;
	transition: background-size 0.35s ease;
}

.wp-block-post-title a:hover {
	text-decoration: none;
	background-size: 100% 1px;
}

/* ===========================
   Post list — tighter title/date spacing
   =========================== */

/* Pull date up close to title — list and single */
.wp-block-post-template .wp-block-post-date,
.wp-block-post-title + .wp-block-post-date {
	margin-top: 0.5rem !important;
}

/* Gap between date and excerpt — list view */
.wp-block-post-excerpt {
	margin-top: 2rem !important;
}

/* Single template: space between date/header group and post content */
.single .wp-block-post-content {
	margin-top: 2rem !important;
}

/* ===========================
   Post date — muted secondary color
   =========================== */

.wp-block-post-date,
.wp-block-post-date a {
	color: var(--wp--preset--color--secondary) !important;
	text-decoration: none;
}

.wp-block-post-date a:hover {
	text-decoration: underline;
	text-decoration-style: dotted;
}

/* ===========================
   Post list — subtle top rule
   =========================== */

.wp-block-post + .wp-block-post {
	border-top: 1px solid #E5E7EB;
	padding-top: 3rem;
}

/* ===========================
   Scroll animation
   CSS defines final visible state; JS adds scroll-hidden to off-screen items
   =========================== */

.wp-block-post {
	transition: opacity 0.55s ease, transform 0.55s ease;
}

.wp-block-post.scroll-hidden {
	opacity: 0;
	transform: translateY(14px);
}

/* ===========================
   Search & File Block buttons
   =========================== */

.wp-block-search__button,
.wp-block-file .wp-block-file__button {
	background-color: var(--wp--preset--color--foreground);
	border-radius: 0;
	border: none;
	color: var(--wp--preset--color--background);
	font-size: var(--wp--preset--font-size--small);
	padding: calc(.667em + 2px) calc(1.333em + 2px);
	letter-spacing: 0.05em;
}

.wp-block-search__button:hover,
.wp-block-file .wp-block-file__button:hover,
.wp-block-button__link:hover {
	opacity: 0.75;
}

/* ===========================
   Alignment helpers
   =========================== */

.wp-site-blocks,
body > .is-root-container,
.edit-post-visual-editor__post-title-wrapper,
.wp-block-group.alignfull,
.wp-block-group.has-background,
.wp-block-columns.alignfull.has-background,
.wp-block-cover.alignfull,
.is-root-container .wp-block[data-align='full'] > .wp-block-group,
.is-root-container .wp-block[data-align='full'] > .wp-block-columns.has-background,
.is-root-container .wp-block[data-align='full'] > .wp-block-cover {
	padding-left: var(--wp--custom--spacing--outer);
	padding-right: var(--wp--custom--spacing--outer);
}

.wp-site-blocks .alignfull,
.wp-site-blocks > .wp-block-group.has-background,
.wp-site-blocks > .wp-block-cover,
.wp-site-blocks > .wp-block-template-part > .wp-block-group.has-background,
.wp-site-blocks > .wp-block-template-part > .wp-block-cover,
body > .is-root-container > .wp-block-cover,
body > .is-root-container > .wp-block-template-part > .wp-block-group.has-background,
body > .is-root-container > .wp-block-template-part > .wp-block-cover,
.is-root-container .wp-block[data-align="full"] {
	margin-left: calc(-1 * var(--wp--custom--spacing--outer)) !important;
	margin-right: calc(-1 * var(--wp--custom--spacing--outer)) !important;
	max-width: unset;
	width: unset;
}

.wp-site-blocks .wp-block-columns .wp-block-column .alignfull,
.is-root-container .wp-block-columns .wp-block-column .wp-block[data-align="full"],
.wp-site-blocks .alignfull:not(.wp-block-group) .alignfull,
.is-root-container .wp-block[data-align="full"] > *:not(.wp-block-group) .wp-block[data-align="full"] {
	margin-left: auto !important;
	margin-right: auto !important;
	width: inherit;
}

/* ===========================
   Comment list
   =========================== */

ol.commentlist,
ol.commentlist li {
	list-style: none !important;
	padding-left: 0;
	counter-increment: none !important;
	counter-reset: none !important;
}

.wp-block-post-comments ol.commentlist li::before,
.wp-block-post-comments ol.commentlist li::marker,
ol.commentlist li::before,
ol.commentlist li::marker {
	content: '' !important;
	display: none !important;
}

ol.commentlist > li + li {
	border-top: 1px solid #E5E7EB;
	margin-top: 2rem;
	padding-top: 2rem;
}

.comment-author {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.2rem;
}

.comment-author img.avatar {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	flex-shrink: 0;
}

.comment-author .fn {
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
}

.comment-author .fn a {
	text-decoration: none;
}

.comment-author .fn a:hover {
	text-decoration: underline;
	text-decoration-style: dotted;
}

.comment-author .says {
	display: none;
}

.comment-metadata {
	margin-bottom: 0.75rem;
}

.comment-metadata a {
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--secondary);
	text-decoration: none;
}

.comment-metadata a:hover {
	text-decoration: underline;
	text-decoration-style: dotted;
}

#cancel-comment-reply-link {
	margin-left: 0.75rem;
}

.comment-reply-link {
	display: inline-block;
	margin-top: 0.5rem;
	font-size: var(--wp--preset--font-size--x-small);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	text-decoration: none;
	color: var(--wp--preset--color--secondary);
}

.comment-reply-link:hover {
	color: var(--wp--preset--color--foreground);
}

ol.commentlist .children {
	list-style: none;
	padding-left: 1.5rem;
	margin-top: 1.5rem;
	border-left: 2px solid #E5E7EB;
}

ol.commentlist .children li + li {
	border-top: 1px solid #E5E7EB;
	margin-top: 1.5rem;
	padding-top: 1.5rem;
}

/* ===========================
   Forms (comment form + contact form)
   =========================== */

/* Field wrappers */
.grunion-field-wrap,
.comment-form p {
	margin-bottom: 1.25rem;
}

/* Labels */
.grunion-field-label,
.comment-form label {
	display: block;
	margin-bottom: 0.35rem;
	font-size: var(--wp--preset--font-size--small);
}

/* Inputs & textareas */
.grunion-field,
.comment-form input:not([type="submit"]):not([type="checkbox"]),
.comment-form textarea {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	padding: 0.65em 0.875em;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	border: 1px solid #E5E7EB;
	border-radius: 0;
	background: var(--wp--preset--color--background);
	color: var(--wp--preset--color--foreground);
	box-sizing: border-box;
}

/* Jetpack overrides .grunion-field padding via .contact-form .grunion-field.
   Match that feel for comment form inputs explicitly.
   .wp-block-post-comments prefix wins over block-library specificity. */
.wp-block-post-comments .comment-form input:not([type="submit"]):not([type="checkbox"]),
.wp-block-post-comments .comment-form textarea {
	padding: 0.75em 1em !important;
}

/* Textareas */
textarea.grunion-field,
.comment-form textarea {
	height: 8rem;
	resize: vertical;
}

/* Focus */
.grunion-field:focus,
.comment-form input:not([type="submit"]):not([type="checkbox"]):focus,
.comment-form textarea:focus {
	outline: none;
	border-color: var(--wp--preset--color--foreground);
}

/* Submit buttons */
.contact-form .pushbutton-wide,
.comment-form #submit {
	background-color: var(--wp--preset--color--foreground);
	border: none;
	border-radius: 0;
	color: var(--wp--preset--color--background);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	padding: 0.875em 1.25em;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	cursor: pointer;
	width: auto;
}

.contact-form .pushbutton-wide:hover,
.comment-form #submit:hover {
	opacity: 0.75;
}

/* Cookies consent checkbox alignment */
.wp-block-post-comments .comment-form-cookies-consent #wp-comment-cookies-consent {
	margin-top: 0.2em;
}

.wp-block-post-comments h3#comments {
	margin-top: var(--wp--style--block-gap);
}

.wp-block-post-comments .navigation + .comment-respond {
	margin-top: calc(3 * var(--wp--style--block-gap));
}

/* ===========================
   Drop cap
   =========================== */

.has-drop-cap:not(:focus)::first-letter {
	font-size: 3em;
	font-weight: 400;
	margin: 0.2em 0.1em 0 0;
}

/* ===========================
   Code blocks — elevated style
   =========================== */

pre,
code,
.wp-block-code {
	background: #F8F9FA;
	border: 1px solid #E5E7EB;
	border-radius: 2px;
}

pre code {
	background: none;
	border: none;
	border-radius: 0;
	padding: 0;
}

.wp-block-code {
	padding: 1.25em 1.5em;
}

/* ===========================
   Pullquote & Quote
   =========================== */

.wp-block-pullquote {
	border-color: #E5E7EB;
}

.wp-block-quote {
	border-color: #D1D5DB;
}

/* ===========================
   Separator
   =========================== */

.wp-block-separator {
	border-color: #E5E7EB;
}

/* ===========================
   Pagination
   =========================== */

.wp-block-query-pagination a {
	text-decoration: none;
	font-size: var(--wp--preset--font-size--small);
	letter-spacing: 0.04em;
}

.wp-block-query-pagination a:hover {
	text-decoration: underline;
}

/* ===========================
   Projects Timeline
   =========================== */

.timeline {
	position: relative;
}

.timeline-era {
	position: relative;
	padding-left: 2.5rem;
	padding-bottom: 3rem;
}

/* Vertical connecting line */
.timeline-era::before {
	content: '';
	position: absolute;
	left: 0.2rem;
	top: 0.65em;
	bottom: 0;
	width: 1px;
	background: #E5E7EB;
}

.timeline-era:last-child::before {
	bottom: 40%;
}

/* Era dot marker */
.timeline-year {
	position: relative;
	font-size: var(--wp--preset--font-size--x-small) !important;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--wp--preset--color--secondary) !important;
	margin-bottom: 0.5rem !important;
	line-height: 1.4 !important;
}

.timeline-year::before {
	content: '';
	position: absolute;
	left: -2.5rem;
	top: 50%;
	transform: translateY(-50%);
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--wp--preset--color--foreground);
}

.timeline-projects {
	display: flex;
	flex-direction: column;
	gap: 0 !important;
}

.timeline-project {
	padding-top: 1.5rem;
	padding-bottom: 1.5rem;
	border-bottom: 1px solid #E5E7EB;
	transition: opacity 0.5s ease, transform 0.5s ease;
}

.timeline-project:first-child {
	border-top: 1px solid #E5E7EB;
}

.timeline-project.scroll-hidden {
	opacity: 0;
	transform: translateX(-12px);
}

.timeline-project .wp-block-heading {
	margin-bottom: 0.4rem !important;
	font-size: var(--wp--preset--font-size--medium) !important;
}

.timeline-project .wp-block-heading a {
	text-decoration: none;
	background-image: linear-gradient(currentColor, currentColor);
	background-size: 0 1px;
	background-repeat: no-repeat;
	background-position: 0 100%;
	transition: background-size 0.3s ease;
}

.timeline-project .wp-block-heading a:hover {
	text-decoration: none;
	background-size: 100% 1px;
}

.timeline-project .wp-block-paragraph {
	margin-top: 0 !important;
	margin-bottom: 0 !important;
	color: var(--wp--preset--color--secondary);
}

/* Featured / highlighted projects — accent title color + bold */

.timeline-project--featured .wp-block-heading {
	color: #1d4ed8 !important;
	font-weight: 700 !important;
}

.timeline-project--featured .wp-block-heading a {
	color: #1d4ed8 !important;
	font-weight: 700;
	background-image: linear-gradient(#1d4ed8, #1d4ed8) !important;
}

/* Desktop: pull timeline left so dots sit on the sidebar separator.
   Must beat the `margin-left: 0 !important` applied to constrained-layout
   children — using a more specific selector (4 classes vs 3+:where). */
@media (min-width: 600px) {
	.wp-block-column.main-column .is-layout-constrained > .timeline {
		margin-left: -3rem !important;
	}

	.timeline-era {
		padding-left: 3rem; /* exactly offsets the -3rem timeline shift → text aligns with content */
	}

	/* Connecting line not needed on desktop — the sidebar separator is the spine */
	.timeline-era::before {
		display: none;
	}

	.timeline-year::before {
		left: calc(-3rem - 4px);
	}
}

/* ===========================
   Reduced motion
   =========================== */

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

	.wp-block-post.scroll-hidden {
		opacity: 1 !important;
		transform: none !important;
	}
}

/* About page avatar */
.about-avatar img {
	border-radius: 50%;
}
