/*
Theme Name: Matt
Theme URI: https://oktrifianto.com/
Author: Rahmat Oktrifianto
Author URI: https://oktrifianto.com/
Description: A lean personal blog theme for fullstack developers. Dark by default with a light/dark toggle, sidebar, comments, and monospace code styles.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: matt
Tags: blog, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready, two-columns, dark-mode
*/

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root,
[data-theme="dark"] {
	--color-bg: #0f1115;
	--color-surface: #171a21;
	--color-surface-2: #1e2330;
	--color-border: #2a3142;
	--color-text: #e8eaed;
	--color-muted: #9aa0a6;
	--color-accent: #fdbd10;
	--color-accent-text: #0f1115;
	--color-link: #fdbd10;
	--color-link-hover: #ffd45c;
	--color-focus: #fdbd10;
	--font-sans: "Source Sans 3", system-ui, -apple-system, sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
	--content-width: 42rem;
	--sidebar-width: 16rem;
	--layout-max: 72rem;
	--space-1: 0.25rem;
	--space-2: 0.5rem;
	--space-3: 0.75rem;
	--space-4: 1rem;
	--space-5: 1.5rem;
	--space-6: 2rem;
	--space-7: 3rem;
	--radius: 0.375rem;
	--header-h: 4rem;
	--shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
	color-scheme: dark;
}

[data-theme="light"] {
	--color-bg: #f7f5f0;
	--color-surface: #ffffff;
	--color-surface-2: #f0ede6;
	--color-border: #ddd6c8;
	--color-text: #1a1c20;
	--color-muted: #5f6368;
	--color-accent: #fdbd10;
	--color-accent-text: #1a1c20;
	--color-link: #9a6f00;
	--color-link-hover: #6e4f00;
	--color-focus: #9a6f00;
	--shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
	color-scheme: light;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

html {
	scroll-behavior: smooth;
}

body {
	margin: 0;
	font-family: var(--font-sans);
	font-size: 1.0625rem;
	line-height: 1.65;
	color: var(--color-text);
	background: var(--color-bg);
	background-image:
		radial-gradient(ellipse 80% 50% at 50% -20%, rgba(253, 189, 16, 0.08), transparent),
		linear-gradient(180deg, var(--color-bg), var(--color-bg));
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

img,
video,
svg {
	max-width: 100%;
	height: auto;
	display: block;
}

a {
	color: var(--color-link);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.15em;
}

a:hover {
	color: var(--color-link-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

h1, h2, h3, h4, h5, h6 {
	line-height: 1.25;
	font-weight: 700;
	margin: 0 0 var(--space-4);
	color: var(--color-text);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.65rem); }
h3 { font-size: 1.2rem; }

p { margin: 0 0 var(--space-4); }

ul, ol {
	margin: 0 0 var(--space-4);
	padding-left: 1.25rem;
}

blockquote {
	margin: 0 0 var(--space-5);
	padding: var(--space-3) var(--space-4);
	border-left: 3px solid var(--color-accent);
	background: var(--color-surface);
	color: var(--color-muted);
}

hr {
	border: 0;
	border-top: 1px solid var(--color-border);
	margin: var(--space-6) 0;
}

table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: var(--space-5);
}

th, td {
	border: 1px solid var(--color-border);
	padding: var(--space-2) var(--space-3);
	text-align: left;
}

/* --------------------------------------------------------------------------
   Accessibility
   -------------------------------------------------------------------------- */

.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

.screen-reader-text:focus {
	background: var(--color-surface);
	clip: auto !important;
	clip-path: none;
	color: var(--color-text);
	display: block;
	font-size: 0.875rem;
	height: auto;
	left: var(--space-4);
	line-height: normal;
	padding: var(--space-3) var(--space-4);
	text-decoration: none;
	top: var(--space-4);
	width: auto;
	z-index: 100000;
}

.skip-link:focus {
	position: absolute;
	z-index: 100001;
}

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

.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: color-mix(in srgb, var(--color-bg) 92%, transparent);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--color-border);
	box-shadow: var(--shadow);
}

.site-header__inner {
	max-width: var(--layout-max);
	margin: 0 auto;
	padding: var(--space-3) var(--space-5);
	display: grid;
	grid-template-columns: 1fr auto;
	grid-template-areas:
		"brand actions"
		"nav nav";
	gap: var(--space-3) var(--space-4);
	align-items: center;
}

.site-branding {
	grid-area: brand;
	min-width: 0;
}

.site-title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.site-title a {
	color: var(--color-text);
	text-decoration: none;
}

.site-title a:hover {
	color: var(--color-accent);
}

.site-description {
	margin: var(--space-1) 0 0;
	font-size: 0.875rem;
	color: var(--color-muted);
}

.custom-logo-link {
	display: inline-block;
	margin-bottom: var(--space-2);
}

.custom-logo {
	max-height: 48px;
	width: auto;
}

.site-header__actions {
	grid-area: actions;
	display: flex;
	align-items: center;
	gap: var(--space-2);
}

.theme-toggle,
.menu-toggle {
	appearance: none;
	border: 1px solid var(--color-border);
	background: var(--color-surface);
	color: var(--color-text);
	border-radius: 50%;
	width: 44px;
	height: 44px;
	min-height: 44px;
	min-width: 44px;
	padding: 0;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font: inherit;
	font-size: 1.125rem;
	line-height: 1;
}

.theme-toggle:hover,
.menu-toggle:hover {
	border-color: var(--color-accent);
	color: var(--color-accent);
}

.theme-toggle__icon--sun {
	display: none;
}

[data-theme="light"] .theme-toggle__icon--moon {
	display: none;
}

[data-theme="light"] .theme-toggle__icon--sun {
	display: inline;
}

.menu-toggle__bars,
.menu-toggle__bars::before,
.menu-toggle__bars::after {
	display: block;
	width: 1.25rem;
	height: 2px;
	background: currentColor;
	position: relative;
}

.menu-toggle__bars::before,
.menu-toggle__bars::after {
	content: "";
	position: absolute;
	left: 0;
}

.menu-toggle__bars::before { top: -6px; }
.menu-toggle__bars::after { top: 6px; }

.primary-navigation {
	grid-area: nav;
	display: none;
}

.primary-navigation.is-open {
	display: block;
}

.primary-navigation ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
}

.primary-navigation a {
	display: block;
	padding: var(--space-3) var(--space-3);
	color: var(--color-text);
	text-decoration: none;
	border-radius: var(--radius);
	min-height: 44px;
}

.primary-navigation a:hover,
.primary-navigation .current-menu-item > a {
	background: var(--color-surface);
	color: var(--color-accent);
}

.primary-navigation .sub-menu {
	padding-left: var(--space-4);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.site-container {
	flex: 1 0 auto;
	width: 100%;
	max-width: var(--layout-max);
	margin: 0 auto;
	padding: var(--space-6) var(--space-5);
	display: grid;
	gap: var(--space-6);
	grid-template-columns: 1fr;
	box-sizing: border-box;
}

.site-main {
	min-width: 0;
}

.widget-area {
	min-width: 0;
}

/* --------------------------------------------------------------------------
   Entries
   -------------------------------------------------------------------------- */

.page-header {
	margin-bottom: var(--space-6);
	padding-bottom: var(--space-4);
	border-bottom: 1px solid var(--color-border);
}

.page-title {
	margin-bottom: var(--space-2);
}

.archive-description {
	color: var(--color-muted);
}

.entry {
	margin-bottom: var(--space-7);
	padding-bottom: var(--space-6);
	border-bottom: 1px solid var(--color-border);
}

.entry:last-of-type {
	border-bottom: 0;
}

.entry-title {
	margin-bottom: var(--space-2);
}

.entry-title a {
	color: var(--color-text);
	text-decoration: none;
}

.entry-title a:hover {
	color: var(--color-accent);
}

.entry-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35rem 0.5rem;
	font-size: 0.875rem;
	color: var(--color-muted);
	margin-bottom: var(--space-4);
}

.entry-meta .posted-on,
.entry-meta .byline {
	margin: 0;
}

.entry-meta .cat-links {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	align-items: center;
	margin-left: 0.15rem;
}

.entry-meta a {
	color: var(--color-muted);
	text-decoration: none;
}

.entry-meta a:hover {
	color: var(--color-accent);
}

.entry-meta .cat-pill {
	display: inline-flex;
	align-items: center;
	padding: 0.15em 0.7em;
	border-radius: 999px;
	background: color-mix(in srgb, var(--color-accent) 22%, transparent);
	color: var(--color-text);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.5;
	text-decoration: none;
}

.entry-meta .cat-pill:hover {
	background: var(--color-accent);
	color: var(--color-accent-text);
}

.entry-thumbnail {
	margin: 0 0 var(--space-5);
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--color-surface);
}

.entry-thumbnail img {
	width: 100%;
}

.entry-content > *:last-child,
.entry-summary > *:last-child {
	margin-bottom: 0;
}

.entry-content .alignwide {
	max-width: min(100%, 56rem);
}

.entry-content .alignfull {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
}

.entry-summary p {
	margin: 0;
}

.entry-summary .read-more {
	font-weight: 600;
	text-decoration: none;
	color: var(--color-accent);
	white-space: nowrap;
}

.entry-summary .read-more:hover {
	color: var(--color-link-hover);
}

.tag-links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35rem 0.5rem;
	font-size: 0.875rem;
	color: var(--color-muted);
	margin-top: var(--space-5);
}

.tag-links__label {
	margin-right: 0.15rem;
}

.tag-links .tag-pill {
	display: inline-flex;
	align-items: center;
	padding: 0.15em 0.7em;
	border-radius: 999px;
	background: color-mix(in srgb, var(--color-accent) 22%, transparent);
	color: var(--color-text);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.5;
	text-decoration: none;
}

.tag-links .tag-pill:hover {
	background: var(--color-accent);
	color: var(--color-accent-text);
}

/* --------------------------------------------------------------------------
   Code (plugin-friendly)
   -------------------------------------------------------------------------- */

code,
kbd,
samp {
	font-family: var(--font-mono);
	font-size: 0.9em;
	background: var(--color-surface-2);
	padding: 0.1em 0.35em;
	border-radius: 0.25rem;
}

pre {
	font-family: var(--font-mono);
	font-size: 0.875rem;
	line-height: 1.55;
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	padding: var(--space-4);
	overflow-x: auto;
	margin: 0 0 var(--space-5);
	-webkit-overflow-scrolling: touch;
}

pre code {
	background: transparent;
	padding: 0;
	font-size: inherit;
	border-radius: 0;
}

/* --------------------------------------------------------------------------
   Pagination & post nav
   -------------------------------------------------------------------------- */

.pagination,
.nav-links,
.post-navigation .nav-links,
.comment-navigation .nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-3);
	align-items: center;
	justify-content: space-between;
	margin: var(--space-6) 0;
}

.pagination .nav-links {
	width: 100%;
	justify-content: center;
}

.page-numbers,
.comment-navigation a,
.pagination a,
.pagination span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0 var(--space-4);
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	background: var(--color-surface);
	color: var(--color-text);
	text-decoration: none;
	font-size: 0.9375rem;
}

.page-numbers:hover,
.comment-navigation a:hover,
.pagination a:hover {
	border-color: var(--color-accent);
	color: var(--color-accent);
}

.page-numbers.current {
	background: var(--color-accent);
	border-color: var(--color-accent);
	color: var(--color-accent-text);
	font-weight: 700;
}

.post-navigation {
	margin: var(--space-7) 0;
	padding-top: var(--space-5);
	border-top: 1px solid var(--color-border);
}

.post-navigation .nav-links {
	align-items: stretch;
}

.post-navigation .nav-previous,
.post-navigation .nav-next {
	flex: 1 1 12rem;
	max-width: calc(50% - 0.5rem);
}

.post-navigation a {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--space-1);
	min-height: 44px;
	height: 100%;
	padding: var(--space-3) var(--space-4);
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	background: var(--color-surface);
	color: var(--color-text);
	text-decoration: none;
}

.post-navigation .nav-next a {
	align-items: flex-end;
	text-align: right;
	margin-left: auto;
}

.post-navigation a:hover {
	border-color: var(--color-accent);
}

.post-navigation .nav-subtitle {
	display: block;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--color-muted);
	line-height: 1.3;
}

.post-navigation a:hover .nav-subtitle {
	color: var(--color-accent);
}

.post-navigation .nav-title {
	display: block;
	font-weight: 600;
	font-size: 0.9375rem;
	line-height: 1.35;
	color: var(--color-text);
	overflow-wrap: anywhere;
}

.post-navigation a:hover .nav-title {
	color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   Sidebar / widgets
   -------------------------------------------------------------------------- */

.widget {
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	padding: var(--space-4);
	margin-bottom: var(--space-4);
}

.widget-title {
	font-size: 1rem;
	margin-bottom: var(--space-3);
	padding-bottom: var(--space-2);
	border-bottom: 2px solid var(--color-accent);
}

.widget ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.widget li {
	padding: var(--space-2) 0;
	border-bottom: 1px solid var(--color-border);
}

.widget li:last-child {
	border-bottom: 0;
}

.widget a {
	color: var(--color-text);
	text-decoration: none;
}

.widget a:hover {
	color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   Comments & forms
   -------------------------------------------------------------------------- */

.comments-area {
	margin-top: var(--space-7);
	padding-top: var(--space-5);
	border-top: 1px solid var(--color-border);
}

.comment-list {
	list-style: none;
	margin: 0 0 var(--space-6);
	padding: 0;
}

.comment-list .children {
	list-style: none;
	margin: var(--space-4) 0 0;
	padding-left: var(--space-5);
	border-left: 2px solid var(--color-border);
}

.comment-body {
	padding: var(--space-4);
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	margin-bottom: var(--space-4);
}

.comment-meta {
	font-size: 0.875rem;
	color: var(--color-muted);
	margin-bottom: var(--space-3);
}

.comment-author .avatar {
	border-radius: 50%;
	float: left;
	margin-right: var(--space-3);
}

.comment-content > *:last-child {
	margin-bottom: 0;
}

.comment-reply-title,
.comments-title {
	margin-bottom: var(--space-4);
}

.comment-form label {
	display: block;
	font-size: 0.875rem;
	margin-bottom: var(--space-1);
	font-weight: 600;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
	width: 100%;
	max-width: 100%;
	padding: var(--space-3);
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	background: var(--color-surface);
	color: var(--color-text);
	font: inherit;
	margin-bottom: var(--space-4);
}

.comment-form textarea {
	min-height: 8rem;
	resize: vertical;
}

.button,
.comment-form input[type="submit"],
.wp-block-button__link {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0 var(--space-5);
	border: 0;
	border-radius: var(--radius);
	background: var(--color-accent);
	color: var(--color-accent-text);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	text-decoration: none;
}

.button:hover,
.comment-form input[type="submit"]:hover {
	filter: brightness(1.05);
	color: var(--color-accent-text);
}

/* Unified search control (classic form + Search block) */
.search-form,
.wp-block-search {
	margin: 0;
}

.search-form__group,
.wp-block-search__inside-wrapper {
	display: flex;
	align-items: stretch;
	width: 100%;
	min-height: 44px;
	border: 1px solid var(--color-border);
	border-radius: 999px;
	background: var(--color-bg);
	overflow: hidden;
	transition: border-color 0.15s ease;
}

.search-form__group:focus-within,
.wp-block-search__inside-wrapper:focus-within {
	border-color: var(--color-accent);
}

.search-form__input,
.wp-block-search__input {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	padding: 0 var(--space-4);
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--color-text);
	font: inherit;
	font-size: 0.9375rem;
	line-height: 1.4;
	appearance: none;
}

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

.search-form__input:focus,
.wp-block-search__input:focus {
	outline: none;
}

.search-form__submit,
.wp-block-search__button {
	appearance: none;
	flex: 0 0 auto;
	margin: 3px;
	padding: 0 var(--space-4);
	min-height: calc(44px - 6px);
	border: 0;
	border-radius: 999px;
	background: var(--color-accent);
	color: var(--color-accent-text);
	font: inherit;
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	cursor: pointer;
	line-height: 1;
}

.search-form__submit:hover,
.wp-block-search__button:hover {
	filter: brightness(1.06);
	color: var(--color-accent-text);
}

.wp-block-search__label {
	display: block;
	font-size: 0.875rem;
	font-weight: 600;
	margin-bottom: var(--space-2);
}

.wp-block-search__button:focus-visible,
.search-form__submit:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
	border-top: 1px solid var(--color-border);
	margin-top: auto;
	padding: var(--space-5);
	background: var(--color-surface);
}

.site-footer__inner {
	max-width: var(--layout-max);
	margin: 0 auto;
	text-align: center;
}

.site-footer__copy {
	margin: 0;
	font-size: 0.875rem;
	color: var(--color-muted);
}

.site-footer a {
	color: var(--color-text);
	text-decoration: none;
}

.site-footer a:hover {
	color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   Desktop
   -------------------------------------------------------------------------- */

@media (min-width: 768px) {
	.site-header__inner {
		grid-template-columns: auto 1fr auto;
		grid-template-areas: "brand nav actions";
	}

	.menu-toggle {
		display: none;
	}

	.primary-navigation {
		display: block;
		justify-self: end;
		margin-right: var(--space-2);
	}

	.primary-navigation ul {
		flex-direction: row;
		align-items: center;
		gap: var(--space-1);
	}

	.primary-navigation .sub-menu {
		position: absolute;
		padding-left: 0;
		min-width: 12rem;
		background: var(--color-surface);
		border: 1px solid var(--color-border);
		border-radius: var(--radius);
		padding: var(--space-2);
		display: none;
		z-index: 20;
	}

	.primary-navigation li {
		position: relative;
	}

	.primary-navigation li:hover > .sub-menu,
	.primary-navigation li:focus-within > .sub-menu {
		display: block;
	}

	body.has-sidebar .site-container {
		grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
		align-items: start;
		gap: var(--space-7);
	}

	body.no-sidebar .site-container {
		grid-template-columns: minmax(0, var(--content-width));
		justify-content: center;
	}
}

@media (min-width: 960px) {
	body.has-sidebar .site-container {
		grid-template-columns: minmax(0, 1fr) 18rem;
	}
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
