/*
 * Theme T&B — Main Stylesheet
 *
 * Global reset, base styles, layout system, and typography.
 * Depends on design-tokens.css.
 *
 * @package ThemeTB
 * @version 2.0.0
 */

/* =========================================================
   Reset & Base
   ========================================================= */

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

html {
	font-size: 16px;
	scroll-behavior: smooth;
	-webkit-text-size-adjust: 100%;
}

body {
	font-family: var(--tb-font-sans);
	font-size: var(--tb-text-base);
	font-weight: var(--tb-font-normal);
	line-height: var(--tb-leading-normal);
	color: var(--tb-text-primary);
	background-color: var(--tb-bg);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

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

a {
	color: var(--tb-link);
	text-decoration: none;
	transition: color var(--tb-duration-fast) var(--tb-ease-default);
}

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

a:focus-visible {
	outline: 2px solid var(--tb-focus-ring);
	outline-offset: var(--tb-focus-ring-offset);
	border-radius: var(--tb-radius-sm);
}

ul,
ol {
	list-style: none;
}

button {
	cursor: pointer;
	border: none;
	background: none;
	font-family: inherit;
}

input,
textarea,
select {
	font-family: inherit;
	font-size: inherit;
}

/* =========================================================
   Skip Link
   ========================================================= */

.tb-skip-link {
	position: absolute;
	top: -100%;
	left: var(--tb-space-4);
	z-index: var(--tb-z-toast);
	padding: var(--tb-space-3) var(--tb-space-6);
	background: var(--tb-color-primary);
	color: var(--tb-text-inverse);
	border-radius: var(--tb-radius-md);
	font-weight: var(--tb-font-semibold);
	transition: top var(--tb-duration-fast);
}

.tb-skip-link:focus {
	top: var(--tb-space-4);
}

/* =========================================================
   Container
   ========================================================= */

.tb-container {
	width: 100%;
	max-width: var(--tb-container-max);
	margin-inline: auto;
	padding-inline: var(--tb-container-padding);
	overflow: visible !important;
}

/* =========================================================
   Page Layout
   ========================================================= */

.tb-page {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.tb-main {
	flex: 1;
	padding-block: var(--tb-space-12);
}

.tb-content-area {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--tb-space-8);
}

@media (min-width: 1024px) {
	.tb-content-area:has(.tb-sidebar) {
		grid-template-columns: 1fr var(--tb-sidebar-width);
	}
}

/* =========================================================
   Typography
   ========================================================= */

h1, h2, h3, h4, h5, h6 {
	font-family: var(--tb-font-heading);
	font-weight: var(--tb-font-bold);
	line-height: var(--tb-leading-tight);
	color: var(--tb-text-primary);
}

h1 { font-size: var(--tb-text-4xl); }
h2 { font-size: var(--tb-text-3xl); }
h3 { font-size: var(--tb-text-2xl); }
h4 { font-size: var(--tb-text-xl); }
h5 { font-size: var(--tb-text-lg); }
h6 { font-size: var(--tb-text-base); }

@media (max-width: 768px) {
	h1 { font-size: var(--tb-text-3xl); }
	h2 { font-size: var(--tb-text-2xl); }
	h3 { font-size: var(--tb-text-xl); }
}

p {
	margin-bottom: var(--tb-space-4);
	color: var(--tb-text-secondary);
}

/* =========================================================
   Header
   ========================================================= */

.tb-header {
	position: sticky;
	top: 0;
	z-index: 99999 !important;
	background: rgba(255, 255, 255, 0.85);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	border-bottom: 1px solid var(--tb-border);
	min-height: var(--tb-header-height);
	display: flex;
	align-items: center;
	overflow: visible !important;
}

[data-tb-theme='dark'] .tb-header {
	background: rgba(15, 23, 42, 0.85);
}

.tb-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--tb-space-4);
	width: 100%;
	flex-wrap: nowrap;
	overflow: visible !important;
	position: relative;
}

/* =========================================================
   Secondary Menu — Top Bar
   ========================================================= */

.tb-header__topbar {
	background: var(--tb-color-primary, #2563eb);
	padding: var(--tb-space-1) 0;
	font-size: var(--tb-text-xs);
}

.tb-header__topbar .tb-container {
	display: flex;
	justify-content: flex-end;
}

.tb-nav--secondary .tb-nav__list--secondary {
	display: flex;
	flex-direction: row;
	gap: var(--tb-space-4);
	list-style: none;
	margin: 0;
	padding: 0;
}

.tb-nav--secondary .tb-nav__list--secondary li a {
	color: rgba(255, 255, 255, 0.9);
	text-decoration: none;
	padding: var(--tb-space-1) var(--tb-space-2);
	border-radius: var(--tb-radius-sm);
	transition: color var(--tb-duration-fast);
}

.tb-nav--secondary .tb-nav__list--secondary li a:hover {
	color: #fff;
	background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 767px) {
	.tb-header__topbar {
		display: none;
	}
}

.tb-header__logo {
	flex-shrink: 0;
}

.tb-header__logo a {
	display: flex;
	align-items: center;
	gap: var(--tb-space-2);
	text-decoration: none;
}

.tb-header__logo img {
	height: 36px;
	width: auto;
}

.tb-logo--text {
	font-family: var(--tb-font-heading);
	font-size: var(--tb-text-xl);
	font-weight: var(--tb-font-extrabold);
	background: linear-gradient(135deg, var(--tb-color-primary), var(--tb-color-accent));
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	white-space: nowrap;
}

/* =========================================================
   Navigation — Modern Colorful
   ========================================================= */

.tb-nav--primary {
	display: block !important;
	overflow: visible !important;
	position: relative;
}

.tb-nav__list {
	display: flex !important;
	flex-direction: row !important;
	align-items: center;
	gap: var(--tb-space-1);
	list-style: none;
	margin: 0;
	padding: 0;
	flex-wrap: nowrap;
	overflow: visible !important;
	position: relative;
}

.tb-nav__list li {
	position: relative;
	display: inline-block !important;
	flex-shrink: 0;
	overflow: visible !important;
}

.tb-nav__list li a {
	display: inline-flex;
	align-items: center;
	gap: var(--tb-space-2);
	padding: var(--tb-space-2) var(--tb-space-4);
	color: var(--tb-text-secondary);
	font-size: var(--tb-text-sm);
	font-weight: var(--tb-font-medium);
	border-radius: var(--tb-radius-lg);
	text-decoration: none;
	transition: all var(--tb-duration-fast) var(--tb-ease-default);
	position: relative;
	white-space: nowrap;
}

.tb-nav__list li a::after {
	content: '';
	position: absolute;
	bottom: -2px;
	left: 50%;
	width: 0;
	height: 2px;
	background: linear-gradient(90deg, var(--tb-color-primary), var(--tb-color-accent));
	border-radius: 2px;
	transition: all var(--tb-duration-normal) var(--tb-ease-default);
	transform: translateX(-50%);
}

.tb-nav__list li a:hover {
	color: var(--tb-color-primary);
	background: var(--tb-color-primary-50);
}

.tb-nav__list li a:hover::after {
	width: 60%;
}

.tb-nav__list li.current-menu-item > a {
	color: var(--tb-color-primary);
	background: var(--tb-color-primary-50);
	font-weight: var(--tb-font-semibold);
}

.tb-nav__list li.current-menu-item > a::after {
	width: 60%;
}

/* Active state glow */
.tb-nav__list li.current-menu-item > a {
	box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
}

/* =========================================================
   Sub-menu — Vertical Dropdown
   ========================================================= */

.tb-nav__list li .sub-menu {
	display: none !important;
	position: absolute !important;
	top: 100% !important;
	left: 0 !important;
	min-width: 200px !important;
	padding: 8px 0 !important;
	margin: 0 !important;
	background: #fff !important;
	border: 1px solid #e5e7eb !important;
	border-radius: 12px !important;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04) !important;
	z-index: 9999 !important;
	flex-direction: column !important;
	list-style: none !important;
	overflow: visible !important;
}

.tb-nav__list li:hover > .sub-menu {
	display: flex !important;
}

.tb-nav__list li .sub-menu li {
	display: block !important;
	flex-shrink: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
}

.tb-nav__list li .sub-menu li a {
	display: block !important;
	padding: 10px 18px !important;
	font-size: 14px !important;
	font-weight: 500 !important;
	color: #374151 !important;
	white-space: nowrap !important;
	border-radius: 0 !important;
	transition: all 0.15s ease !important;
}

.tb-nav__list li .sub-menu li a::after {
	display: none !important;
}

.tb-nav__list li .sub-menu li a:hover {
	background: #f3f4f6 !important;
	color: #111827 !important;
	box-shadow: none !important;
}

.tb-nav__list li .sub-menu li:first-child a {
	border-radius: 10px 10px 0 0 !important;
}

.tb-nav__list li .sub-menu li:last-child a {
	border-radius: 0 0 10px 10px !important;
}

.tb-header__actions {
	display: flex;
	align-items: center;
	gap: var(--tb-space-2);
}

.tb-header__search-toggle,
.tb-header__dark-toggle,
.tb-header__mobile-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: var(--tb-radius-lg);
	color: var(--tb-text-secondary);
	background: transparent;
	border: none;
	cursor: pointer;
	transition: all var(--tb-duration-fast) var(--tb-ease-default);
}

.tb-header__search-toggle:hover,
.tb-header__dark-toggle:hover,
.tb-header__mobile-toggle:hover {
	color: var(--tb-color-primary);
	background: var(--tb-color-primary-50);
}

.tb-header__mobile-toggle {
	display: none;
}

@media (max-width: 1023px) {
	.tb-nav--primary {
		display: none !important;
	}
	.tb-header__mobile-toggle {
		display: flex;
	}
	.tb-nav__list {
		flex-direction: column !important;
	}
	.tb-nav--secondary .tb-nav__list--secondary,
	.tb-footer__menu {
		flex-direction: row !important;
	}
}

/* Hamburger icon */
.tb-hamburger {
	display: flex;
	flex-direction: column;
	gap: 5px;
	width: 22px;
	height: 22px;
	justify-content: center;
}
.tb-hamburger span {
	display: block;
	width: 20px;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
	transition: transform var(--tb-duration-fast);
}

/* Mobile drawer — hidden on desktop, slide-in on mobile/tablet */
.tb-nav--mobile {
	display: none !important;
}

@media (max-width: 1023px) {
	.tb-nav--mobile[hidden] {
		display: none !important;
	}
	.tb-nav--mobile:not([hidden]) {
		display: block !important;
		position: fixed;
		top: 0;
		right: 0;
		width: 280px;
		height: 100vh;
		background: var(--tb-surface, #fff);
		box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
		z-index: 100000;
		overflow-y: auto;
		padding: 80px var(--tb-space-4) var(--tb-space-4);
		animation: tb-slide-in 0.25s ease-out;
	}
	.tb-nav--mobile .tb-nav__list {
		flex-direction: column !important;
		gap: var(--tb-space-1);
	}
	.tb-nav--mobile .tb-nav__list li {
		display: block !important;
	}
	.tb-nav--mobile .tb-nav__list li a {
		display: block;
		padding: var(--tb-space-3) var(--tb-space-4);
		font-size: var(--tb-text-base);
		border-radius: var(--tb-radius-lg);
	}
	/* Backdrop */
	body.tb-mobile-menu-open::after {
		content: '';
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0.4);
		z-index: 99999;
	}
}

@keyframes tb-slide-in {
	from { transform: translateX(100%); }
	to   { transform: translateX(0); }
}
}

/* =========================================================
   Search Bar
   ========================================================= */

.tb-search-bar {
	background: var(--tb-surface);
	border-top: 1px solid var(--tb-border);
	padding-block: var(--tb-space-4);
}

.tb-search-bar__form {
	display: flex;
	gap: var(--tb-space-2);
}

.tb-search-bar__input {
	flex: 1;
	padding: var(--tb-space-3) var(--tb-space-4);
	border: 1px solid var(--tb-border);
	border-radius: var(--tb-radius-lg);
	background: var(--tb-bg-secondary);
	color: var(--tb-text-primary);
	font-size: var(--tb-text-base);
	transition: border-color var(--tb-duration-fast), box-shadow var(--tb-duration-fast);
}

.tb-search-bar__input:focus {
	outline: none;
	border-color: var(--tb-color-primary);
	box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.tb-search-bar__submit {
	padding: var(--tb-space-3) var(--tb-space-5);
	background: var(--tb-color-primary);
	color: var(--tb-text-inverse);
	border-radius: var(--tb-radius-lg);
	font-weight: var(--tb-font-medium);
	transition: background var(--tb-duration-fast);
}

.tb-search-bar__submit:hover {
	background: var(--tb-color-primary-dark);
}

/* =========================================================
   Footer
   ========================================================= */

.tb-footer {
	background: var(--tb-bg-secondary);
	border-top: 1px solid var(--tb-border);
}

.tb-footer__widgets {
	padding-block: var(--tb-space-16);
}

.tb-footer__widgets-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: var(--tb-space-8);
}

.tb-footer__bottom {
	border-top: 1px solid var(--tb-border);
	padding-block: var(--tb-space-6);
}

.tb-footer__bottom-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--tb-space-4);
	flex-wrap: wrap;
}

@media (min-width: 768px) {
	.tb-footer__bottom-inner {
		display: grid;
		grid-template-columns: 1fr auto 1fr;
		align-items: center;
	}
	.tb-footer__copyright {
		text-align: left;
	}
	.tb-social-links--footer {
		justify-content: center;
	}
	.tb-footer__nav {
		justify-content: flex-end;
	}
}

.tb-footer__copyright {
	color: var(--tb-text-muted);
	font-size: var(--tb-text-sm);
}

.tb-footer__nav {
	display: flex;
}

.tb-footer__menu,
.tb-footer__nav .tb-footer__menu {
	display: flex !important;
	flex-direction: row !important;
	flex-wrap: wrap;
	gap: var(--tb-space-4);
	list-style: none !important;
	margin: 0;
	padding: 0;
}

.tb-footer__menu li a {
	color: var(--tb-text-muted);
	font-size: var(--tb-text-sm);
	text-decoration: none;
	transition: color var(--tb-duration-fast);
}

.tb-footer__menu li a:hover {
	color: var(--tb-color-primary);
}

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

.tb-sidebar {
	padding: var(--tb-space-6);
	background: var(--tb-bg-secondary);
	border-radius: var(--tb-radius-xl);
	border: 1px solid var(--tb-border);
}

.tb-widget {
	margin-bottom: var(--tb-space-8);
}

.tb-widget:last-child {
	margin-bottom: 0;
}

.tb-widget__title {
	font-size: var(--tb-text-base);
	font-weight: var(--tb-font-semibold);
	margin-bottom: var(--tb-space-4);
	padding-bottom: var(--tb-space-3);
	border-bottom: 2px solid var(--tb-color-primary);
}

/* =========================================================
   Archive Header
   ========================================================= */

.tb-archive-header {
	margin-bottom: var(--tb-space-8);
}

.tb-archive-header__title {
	font-size: var(--tb-text-3xl);
	margin-bottom: var(--tb-space-3);
}

.tb-archive-header__description {
	color: var(--tb-text-secondary);
}

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

.tb-pagination {
	margin-top: var(--tb-space-12);
}

.tb-pagination__list {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--tb-space-2);
	flex-wrap: wrap;
}

.tb-pagination__item a,
.tb-pagination__item span {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding-inline: var(--tb-space-3);
	border: 1px solid var(--tb-border);
	border-radius: var(--tb-radius-md);
	color: var(--tb-text-secondary);
	font-size: var(--tb-text-sm);
	font-weight: var(--tb-font-medium);
	transition: all var(--tb-duration-fast);
}

.tb-pagination__item a:hover {
	border-color: var(--tb-color-primary);
	color: var(--tb-color-primary);
	background: var(--tb-color-primary-50);
}

.tb-pagination__item .current {
	background: var(--tb-color-primary);
	border-color: var(--tb-color-primary);
	color: var(--tb-text-inverse);
}

/* =========================================================
   404 Page
   ========================================================= */

.tb-error-404 {
	text-align: center;
	padding-block: var(--tb-space-24);
}

.tb-error-404__title {
	font-size: 8rem;
	font-weight: var(--tb-font-extrabold);
	color: var(--tb-color-primary);
	line-height: 1;
	margin-bottom: var(--tb-space-4);
}

.tb-error-404__subtitle {
	font-size: var(--tb-text-3xl);
	margin-bottom: var(--tb-space-4);
}

.tb-error-404__description {
	color: var(--tb-text-secondary);
	max-width: 500px;
	margin-inline: auto;
	margin-bottom: var(--tb-space-8);
}

.tb-error-404__actions {
	display: flex;
	gap: var(--tb-space-4);
	justify-content: center;
	margin-bottom: var(--tb-space-8);
}

/* =========================================================
   Screen Reader Utilities
   ========================================================= */

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* =========================================================
   Entry Content (WordPress content area)
   ========================================================= */

.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
	margin-top: var(--tb-space-8);
	margin-bottom: var(--tb-space-4);
}

.entry-content p {
	margin-bottom: var(--tb-space-4);
}

.entry-content ul,
.entry-content ol {
	list-style: revert;
	padding-left: var(--tb-space-6);
	margin-bottom: var(--tb-space-4);
}

.entry-content a {
	text-decoration: underline;
}

.entry-content img {
	border-radius: var(--tb-radius-lg);
	margin-block: var(--tb-space-6);
}

.entry-content blockquote {
	border-left: 4px solid var(--tb-color-primary);
	padding-left: var(--tb-space-6);
	margin-block: var(--tb-space-6);
	color: var(--tb-text-secondary);
	font-style: italic;
}

.entry-content code {
	font-family: var(--tb-font-mono);
	font-size: 0.875em;
	background: var(--tb-bg-tertiary);
	padding: 0.125em 0.375em;
	border-radius: var(--tb-radius-sm);
}

.entry-content pre {
	background: var(--tb-bg-tertiary);
	padding: var(--tb-space-6);
	border-radius: var(--tb-radius-lg);
	overflow-x: auto;
	margin-block: var(--tb-space-6);
}

.entry-content pre code {
	background: none;
	padding: 0;
}

/* =========================================================
   Snake Glow Border — Global (Tools, Books, Blog cards)
   ========================================================= */

@keyframes tb-snake-spin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}

/* Base: all snake cards — transparent bg, overflow hidden, relative */
.tb-tool-card,
.tb-ebook-card,
.tb-blog-card {
	background: transparent;
	border-radius: var(--tb-radius-xl);
	position: relative;
	transition: transform var(--tb-duration-normal) var(--tb-ease-default),
	            box-shadow var(--tb-duration-normal) var(--tb-ease-default);
	overflow: hidden;
}

/* Rotating conic-gradient element — shared for all card types */
.tb-tool-card::before,
.tb-ebook-card::before,
.tb-blog-card::before {
	content: '';
	position: absolute;
	top: -50%;
	left: -50%;
	width: 200%;
	height: 200%;
	border-radius: inherit;
	animation: tb-snake-spin 3s linear infinite;
}

/* Inner elements sit above the rotating border */
.tb-tool-card .tb-tool-card__image-link,
.tb-tool-card .tb-tool-card__body,
.tb-ebook-card .tb-ebook-card__cover-link,
.tb-ebook-card .tb-ebook-card__cover,
.tb-ebook-card .tb-ebook-card__body,
.tb-blog-card .tb-blog-card__image-link,
.tb-blog-card .tb-blog-card__body {
	background: var(--tb-card-bg, #fff);
	position: relative;
	z-index: 1;
	margin: 2px;
}

/* =========================================================
   Social Media Links
   ========================================================= */

.tb-social-links {
	display: flex;
	align-items: center;
	gap: var(--tb-space-3);
	flex-wrap: wrap;
}

.tb-social-links--footer {
	justify-content: center;
	padding-block: var(--tb-space-2);
}

.tb-social-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--tb-text-muted, #94a3b8);
	transition: color var(--tb-duration-fast), transform var(--tb-duration-fast);
	text-decoration: none;
	border-radius: var(--tb-radius-full);
	padding: var(--tb-space-1);
}

.tb-social-link:hover {
	color: var(--tb-color-primary, #2563eb);
	transform: translateY(-2px);
}

.tb-social-link svg {
	width: 1em;
	height: 1em;
	flex-shrink: 0;
}

/* Platform-specific hover colors */
.tb-social-link--facebook:hover { color: #1877F2; }
.tb-social-link--twitter:hover { color: #000000; }
.tb-social-link--instagram:hover { color: #E4405F; }
.tb-social-link--youtube:hover { color: #FF0000; }
.tb-social-link--linkedin:hover { color: #0A66C2; }
.tb-social-link--pinterest:hover { color: #BD081C; }
.tb-social-link--telegram:hover { color: #0088CC; }
.tb-social-link--whatsapp:hover { color: #25D366; }
