/*
Theme Name: Tech Tutorials
Theme URI: https://runoops.com
Author: runoops
Description: Classic theme for technical tutorials — nav portal, sorted tutorial sidebar, TOC and comments ready.
Version: 1.0.0
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 7.4
Text Domain: tech-tutorials
Tags: blog, education, custom-menu, featured-images, threaded-comments
*/

:root {
	--tt-bg: #f4f6f8;
	--tt-surface: #ffffff;
	--tt-text: #1a1f2c;
	--tt-muted: #5c6578;
	--tt-border: #d8dee9;
	--tt-accent: #0b6e4f;
	--tt-accent-soft: #e6f4ef;
	--tt-code-bg: #0f172a;
	--tt-code-fg: #e2e8f0;
	--tt-radius: 8px;
	--tt-max: 1180px;
	--tt-sidebar: 260px;
	--tt-font: "Source Sans 3", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
	--tt-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

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

html {
	scroll-behavior: smooth;
}

body {
	margin: 0;
	font-family: var(--tt-font);
	font-size: 16px;
	line-height: 1.7;
	color: var(--tt-text);
	background: var(--tt-bg);
}

a {
	color: var(--tt-accent);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

img {
	max-width: 100%;
	height: auto;
}

.tt-container {
	width: min(100% - 2rem, var(--tt-max));
	margin-inline: auto;
}

.tt-site-header {
	background: var(--tt-surface);
	border-bottom: 1px solid var(--tt-border);
	position: sticky;
	top: 0;
	z-index: 100;
	overflow: visible;
}

.tt-site-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1.5rem;
	padding: 0.85rem 0;
}

.tt-brand {
	font-size: 1.35rem;
	font-weight: 700;
	color: var(--tt-text);
	letter-spacing: -0.02em;
	display: inline-flex;
	align-items: center;
}

.tt-brand:hover {
	text-decoration: none;
	color: var(--tt-accent);
}

.tt-brand__logo {
	display: block;
	height: 32px;
	width: auto;
	max-width: 220px;
}

.tt-header-menus {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0.35rem;
	min-width: 0;
}

.tt-nav {
	position: relative;
}

.tt-nav > ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 0.25rem 1.1rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.tt-nav > ul > li {
	position: relative;
}

.tt-nav a {
	display: block;
	position: relative;
	color: var(--tt-muted);
	font-weight: 600;
	font-size: 0.95rem;
	text-decoration: none;
}

.tt-nav--top a {
	font-size: 0.8rem;
	font-weight: 500;
}

.tt-nav a:hover,
.tt-nav .current-menu-item > a,
.tt-nav .current-menu-parent > a {
	color: var(--tt-accent);
	text-decoration: none;
}

/* Dropdown caret */
.tt-nav > ul > li.menu-item-has-children > a {
	padding-right: 0.95rem;
}

.tt-nav > ul > li.menu-item-has-children > a::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 0;
	width: 0;
	height: 0;
	margin-top: -2px;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
	transition: transform 0.2s ease;
}

.tt-nav > ul > li.menu-item-has-children:hover > a::after {
	transform: rotate(180deg);
}

/* Second-level dropdown panel */
.tt-nav .sub-menu {
	visibility: hidden;
	opacity: 0;
	position: absolute;
	top: 100%;
	left: 50%;
	z-index: 120;
	display: flex;
	flex-wrap: wrap;
	width: min(280px, 70vw);
	margin: 0.35rem 0 0;
	padding: 0.4rem 0;
	list-style: none;
	background: var(--tt-surface);
	border: 1px solid var(--tt-border);
	border-radius: var(--tt-radius);
	box-shadow: 0 8px 24px rgba(26, 31, 44, 0.12);
	transform: translateX(-50%) translateY(-4px);
	transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.tt-nav .sub-menu::before,
.tt-nav .sub-menu::after {
	content: "";
	position: absolute;
	left: 50%;
	margin-left: -5px;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
}

.tt-nav .sub-menu::before {
	top: -6px;
	border-bottom: 6px solid var(--tt-border);
}

.tt-nav .sub-menu::after {
	top: -5px;
	border-bottom: 6px solid var(--tt-surface);
}

.tt-nav .sub-menu li {
	width: 50%;
}

.tt-nav .sub-menu a {
	padding: 0.45rem 0.85rem;
	font-size: 0.85rem;
	font-weight: 500;
	color: var(--tt-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tt-nav .sub-menu a:hover {
	background: var(--tt-accent-soft);
	color: var(--tt-accent);
	text-decoration: none;
}

.tt-nav > ul > li:hover > .sub-menu {
	visibility: visible;
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

/* Nested third level (flyout) */
.tt-nav .sub-menu .sub-menu {
	top: -0.4rem;
	left: 100%;
	margin: 0 0 0 0.25rem;
	transform: translateX(-4px) translateY(0);
}

.tt-nav .sub-menu .sub-menu::before,
.tt-nav .sub-menu .sub-menu::after {
	display: none;
}

.tt-nav .sub-menu li:hover > .sub-menu {
	visibility: visible;
	opacity: 1;
	transform: translateX(0) translateY(0);
}

@media (max-width: 720px) {
	.tt-nav .sub-menu {
		left: auto;
		right: 0;
		transform: translateX(0) translateY(-4px);
	}

	.tt-nav > ul > li:hover > .sub-menu {
		transform: translateX(0) translateY(0);
	}

	.tt-nav .sub-menu li {
		width: 100%;
	}
}

.tt-site-footer {
	margin-top: 3rem;
	padding: 2rem 0;
	border-top: 1px solid var(--tt-border);
	background: var(--tt-surface);
	color: var(--tt-muted);
	font-size: 0.9rem;
	text-align: center;
}

.tt-footer-extra {
	margin-top: 0.5rem;
}

.tt-asb {
	margin: 1rem 0;
	text-align: center;
	overflow: hidden;
	line-height: 1.5;
}

.tt-asb img {
	max-width: 100%;
	height: auto;
}

.tt-asb-post-footer {
	margin-top: 1.25rem;
	padding: 0.75rem 1rem;
	text-align: left;
	background: var(--tt-bg);
	border-radius: 6px;
	font-size: 0.95rem;
}

/* ---- Portal (sites home) ---- */
.tt-portal {
	padding: 1.5rem 0 3rem;
}

.tt-portal__layout {
	display: grid;
	grid-template-columns: 220px 1fr;
	gap: 1.5rem;
	align-items: start;
}

.tt-portal-nav {
	position: sticky;
	top: 4.5rem;
	background: var(--tt-surface);
	border: 1px solid var(--tt-border);
	border-radius: var(--tt-radius);
	padding: 0.75rem;
	max-height: calc(100vh - 6rem);
	overflow: auto;
}

.tt-portal-nav__title {
	font-size: 0.85rem;
	font-weight: 700;
	margin: 0 0 0.5rem;
	padding: 0.35rem 0.5rem;
	color: var(--tt-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.tt-portal-nav a {
	display: block;
	padding: 0.4rem 0.55rem;
	border-radius: 6px;
	color: var(--tt-text);
	font-size: 0.92rem;
}

.tt-portal-nav a:hover {
	background: var(--tt-accent-soft);
	text-decoration: none;
}

.tt-fav-section {
	background: var(--tt-surface);
	border: 1px solid var(--tt-border);
	border-radius: var(--tt-radius);
	padding: 1rem 1.15rem 1.25rem;
	margin-bottom: 1.25rem;
}

.tt-fav-section__title {
	margin: 0 0 0.85rem;
	font-size: 1.15rem;
	scroll-margin-top: 5rem;
}

.tt-site-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 0.75rem;
}

.tt-site-card {
	display: flex;
	gap: 0.75rem;
	align-items: center;
	padding: 0.75rem;
	border: 1px solid var(--tt-border);
	border-radius: var(--tt-radius);
	background: #fafbfc;
	color: var(--tt-text);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tt-site-card:hover {
	border-color: var(--tt-accent);
	box-shadow: 0 4px 14px rgba(11, 110, 79, 0.08);
	text-decoration: none;
}

.tt-site-card__icon {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	background: #e8ecf2;
}

.tt-site-card__title {
	font-weight: 700;
	font-size: 0.95rem;
	line-height: 1.3;
}

.tt-site-card__desc {
	margin: 0.2rem 0 0;
	font-size: 0.8rem;
	color: var(--tt-muted);
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---- Tutorial single ---- */
.tt-tutorial {
	padding: 1.25rem 0 3rem;
}

.tt-tutorial__layout {
	display: grid;
	grid-template-columns: var(--tt-sidebar) minmax(0, 1fr);
	gap: 1.5rem;
	align-items: start;
}

.tt-tutorial-list {
	position: sticky;
	top: 4.5rem;
	background: var(--tt-surface);
	border: 1px solid var(--tt-border);
	border-radius: var(--tt-radius);
	padding: 0.85rem 0.65rem;
	max-height: calc(100vh - 6rem);
	overflow: auto;
	font-size: 0.88rem;
}

.tt-tutorial-list h3 {
	margin: 0 0 0.55rem;
	padding: 0 0.4rem;
	font-size: 0.95rem;
}

.tt-tutorial-list .separation {
	margin: 0.85rem 0 0.4rem;
	padding: 0.35rem 0.4rem;
	font-size: 0.82rem;
	color: var(--tt-muted);
	background: var(--tt-bg);
	border-radius: 4px;
}

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

.tt-tutorial-list li a {
	display: block;
	padding: 0.32rem 0.45rem;
	border-radius: 4px;
	color: var(--tt-text);
	line-height: 1.4;
}

.tt-tutorial-list li.active a,
.tt-tutorial-list li a:hover {
	background: var(--tt-accent-soft);
	color: var(--tt-accent);
	text-decoration: none;
	font-weight: 600;
}

.tt-article {
	background: var(--tt-surface);
	border: 1px solid var(--tt-border);
	border-radius: var(--tt-radius);
	padding: 1.5rem 1.75rem 2rem;
}

.tt-article__title {
	margin: 0 0 0.75rem;
	font-size: clamp(1.45rem, 2.4vw, 1.9rem);
	line-height: 1.3;
	letter-spacing: -0.02em;
	text-align: center;
}

.tt-article__meta {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 0.5rem 1rem;
	margin-bottom: 1.25rem;
	font-size: 0.88rem;
	color: var(--tt-muted);
	text-align: right;
}

.tt-parent-link {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin-bottom: 1rem;
	font-size: 0.9rem;
}

.tt-content {
	font-size: 1.02rem;
}

.tt-content h2,
.tt-content h3,
.tt-content h4 {
	scroll-margin-top: 5rem;
	margin-top: 1.6em;
	line-height: 1.35;
}

.tt-content pre,
.tt-content code {
	font-family: var(--tt-mono);
}

.tt-content code {
	font-size: 0.9em;
	background: #eef2f7;
	padding: 0.12em 0.35em;
	border-radius: 4px;
}

.tt-content pre {
	background: var(--tt-code-bg);
	color: var(--tt-code-fg);
	padding: 1rem 1.1rem;
	border-radius: var(--tt-radius);
	overflow-x: auto;
	line-height: 1.55;
}

.tt-content pre code {
	background: transparent;
	padding: 0;
	color: inherit;
}

.tt-content blockquote {
	margin: 1.25em 0;
	padding: 0.75rem 1rem;
	border-left: 4px solid var(--tt-accent);
	background: var(--tt-accent-soft);
}

.tt-content table {
	width: 100%;
	border-collapse: collapse;
	margin: 1.25em 0;
	font-size: 0.95rem;
}

.tt-content th,
.tt-content td {
	border: 1px solid var(--tt-border);
	padding: 0.5rem 0.65rem;
}

.tt-content img {
	border-radius: 6px;
}

.tt-tags {
	margin-top: 1.5rem;
	padding-top: 1rem;
	border-top: 1px solid var(--tt-border);
	font-size: 0.9rem;
}

.tt-copyright {
	margin-top: 1.25rem;
	padding: 0.85rem 1rem;
	font-size: 0.9rem;
	color: var(--tt-muted);
	background: var(--tt-bg);
	border-radius: 6px;
}

.tt-article-nav {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 1rem;
	margin-top: 1.5rem;
	padding-top: 1rem;
	border-top: 1px solid var(--tt-border);
	font-size: 0.95rem;
}

.tt-article-nav .article-nav-prev {
	flex: 1;
	text-align: left;
}

.tt-article-nav .article-nav-next {
	flex: 1;
	text-align: right;
}

.tt-comments {
	margin-top: 2rem;
}

/* Easy TOC compatibility */
.ez-toc-title,
#ez-toc-container {
	scroll-margin-top: 5rem;
}

#ez-toc-container {
	background: var(--tt-bg) !important;
	border: 1px solid var(--tt-border) !important;
	border-radius: var(--tt-radius);
}

/* ---- Archives / lists ---- */
.tt-archive {
	padding: 1.5rem 0 3rem;
}

.tt-archive__title {
	margin: 0 0 1.25rem;
	font-size: 1.6rem;
}

.tt-post-card {
	display: block;
	background: var(--tt-surface);
	border: 1px solid var(--tt-border);
	border-radius: var(--tt-radius);
	padding: 1.1rem 1.25rem;
	margin-bottom: 0.85rem;
	color: var(--tt-text);
}

.tt-post-card:hover {
	border-color: var(--tt-accent);
	text-decoration: none;
}

.tt-post-card__title {
	margin: 0 0 0.35rem;
	font-size: 1.15rem;
}

.tt-post-card__excerpt {
	margin: 0;
	color: var(--tt-muted);
	font-size: 0.92rem;
}

.tt-pagination {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin-top: 1.5rem;
}

.tt-pagination a,
.tt-pagination span {
	display: inline-block;
	padding: 0.35rem 0.7rem;
	border: 1px solid var(--tt-border);
	border-radius: 6px;
	background: var(--tt-surface);
}

.tt-pagination .current {
	background: var(--tt-accent);
	border-color: var(--tt-accent);
	color: #fff;
}

.tt-sites-single {
	padding: 1.5rem 0 3rem;
}

.tt-sites-single__card {
	background: var(--tt-surface);
	border: 1px solid var(--tt-border);
	border-radius: var(--tt-radius);
	padding: 1.5rem;
	display: flex;
	gap: 1.25rem;
	align-items: flex-start;
}

.tt-btn {
	display: inline-block;
	padding: 0.55rem 1.1rem;
	background: var(--tt-accent);
	color: #fff !important;
	border-radius: 6px;
	font-weight: 600;
	text-decoration: none !important;
}

.tt-btn:hover {
	filter: brightness(1.05);
}

/* ---- Back to top (single) ---- */
.tt-back-top {
	position: fixed;
	right: 1.25rem;
	bottom: 1.5rem;
	z-index: 90;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--tt-accent);
	color: #fff;
	font-size: 1.15rem;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(26, 31, 44, 0.18);
	opacity: 0;
	visibility: hidden;
	transform: translateY(0.5rem);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease, filter 0.15s ease;
}

.tt-back-top.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.tt-back-top:hover {
	filter: brightness(1.08);
}

.tt-back-top:focus-visible {
	outline: 2px solid var(--tt-accent);
	outline-offset: 3px;
}

@media (max-width: 900px) {
	.tt-portal__layout,
	.tt-tutorial__layout {
		grid-template-columns: 1fr;
	}

	.tt-portal-nav,
	.tt-tutorial-list {
		position: static;
		max-height: none;
	}

	.tt-tutorial-list {
		order: -1;
	}

	.tt-article {
		padding: 1.15rem;
	}

	.tt-back-top {
		right: 1rem;
		bottom: 1.15rem;
		width: 2.5rem;
		height: 2.5rem;
	}
}
