@tailwind base;
@tailwind components;
@tailwind utilities;

/* Custom RTL utilities to mirror layout using logical properties and Tailwind utilities */
@layer utilities {

	/* Layout flipping for topbar and content row */
	html[dir="rtl"] .topbar {
		@apply flex-row-reverse;
	}

	html[dir="rtl"] .docs-content-row {
		flex-direction: row-reverse !important;
	}

	/* Sidebar ordering in flex layout */
	html[dir="rtl"] .aside-left {
		order: 3;
	}

	html[dir="rtl"] .aside-right {
		order: 1;
	}

	/* Mobile overlay sidebar anchoring */
	aside.mobile-sidebar {
		left: 0;
	}

	html[dir="rtl"] aside.mobile-sidebar {
		left: auto;
		right: 0;
	}

	/* Mobile article TOC mirroring */
	aside.mobile-page-toc {
		@apply ml-auto;
	}

	html[dir="rtl"] aside.mobile-page-toc {
		@apply mr-auto;
		margin-left: 0;
	}

	/* Mobile slide transform inversion for RTL */
	html[dir="rtl"] .mobile-page-toc.translate-x-full {
		transform: translateX(-100%) !important;
	}

	html[dir="rtl"] .mobile-page-toc.-translate-x-full {
		transform: translateX(100%) !important;
	}

	/* Grid placement for article and TOC on desktop (lg) */
	@media (min-width: 1024px) {
		html[dir="rtl"] .content-grid>.content-article {
			grid-column: 2 / 4 !important;
			grid-row: 1 !important;
			align-self: start !important;
		}

		html[dir="rtl"] .content-grid>.aside-right {
			grid-column: 1 / 2 !important;
			grid-row: 1 !important;
			align-self: start !important;
		}

		html[dir="rtl"] .content-grid>.aside-left {
			grid-column: 3 / 4 !important;
			grid-row: 1 !important;
			align-self: start !important;
		}
	}

	/* Text alignment for RTL */
	html[dir="rtl"] main,
	html[dir="rtl"] .article-content {
		text-align: right;
	}

	/* Logical border utility */
	.bd-inline-end {
		border-inline-end-width: 1px;
		border-inline-end-style: solid;
	}
}

:root {
	--docs-bg: #04050e;
	--docs-bg-glow: linear-gradient(135deg, #04050e 0%, #0c1224 42%, #131e34 100%);
	--docs-surface: #0f1526;
	--docs-panel: #151c31;
	--docs-panel-muted: #1b2338;
	--docs-border: #232b40;
	--docs-border-strong: #3c4866;
	--docs-accent: #6affce;
	--docs-accent-strong: #c1ff3e;
	--docs-text: #f5f6fb;
	--docs-text-muted: #9ba4c4;
	--docs-font-sans: 'Space Grotesk', 'Instrument Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	--docs-font-mono: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', ui-monospace, 'Segoe UI Mono', monospace;
	--docs-radius: 18px;
	--docs-radius-small: 12px;
	--docs-shadow: 0 25px 50px rgba(4, 5, 14, 0.6);
	--docs-grid-gap: 2rem;
}

* {
	box-sizing: border-box;
}

body,
html {
	height: 100%;
}

.docs-body {
	min-height: 100vh;
	margin: 0;
	font-family: var(--docs-font-sans);
	color: var(--docs-text);
	background: var(--docs-bg-glow);
	position: relative;
	padding: 2.5rem clamp(1rem, 4vw, 4rem) 3rem;
	overflow-x: hidden;
}

.docs-noise {
	position: fixed;
	inset: 0;
	pointer-events: none;
	background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 0);
	background-size: 180px 180px;
	opacity: 0.35;
	mix-blend-mode: screen;
	z-index: 0;
}

.docs-topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	gap: 1.5rem;
	padding: 1rem 1.5rem;
	margin-bottom: 2rem;
	border: 1px solid var(--docs-border);
	border-radius: var(--docs-radius);
	background: rgba(8, 11, 22, 0.9);
	box-shadow: 0 20px 60px rgba(3, 4, 10, 0.55);
	backdrop-filter: blur(24px);
}

.docs-brand {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.docs-brand-mark {
	width: 48px;
	height: 48px;
	border-radius: 14px;
	display: grid;
	place-items: center;
	background: radial-gradient(circle at 20% 20%, var(--docs-accent), var(--docs-panel) 70%);
	font-weight: 600;
	letter-spacing: 0.08em;
}

.docs-brand-title {
	font-size: 1.1rem;
	font-weight: 600;
}

.docs-brand-subtitle {
	margin: 0;
	color: var(--docs-text-muted);
	font-size: 0.85rem;
}

.docs-topnav {
	display: flex;
	align-items: center;
	gap: 1rem;
	color: var(--docs-text-muted);
	font-size: 0.95rem;
}

.docs-topnav a {
	padding: 0.35rem 0.6rem;
	border-radius: 999px;
	transition: background 0.3s ease, color 0.3s ease;
}

.docs-topnav a:hover {
	background: rgba(255, 255, 255, 0.05);
	color: var(--docs-text);
}

.docs-top-actions {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 1rem;
}

.docs-top-search {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.65rem 1rem;
	border-radius: 999px;
	border: 1px solid var(--docs-border);
	background: rgba(12, 16, 30, 0.7);
}

.docs-top-search svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: var(--docs-text-muted);
	stroke-width: 1.4px;
}

.docs-top-search input {
	background: transparent;
	border: 0;
	outline: none;
	color: var(--docs-text);
	font-size: 0.95rem;
	width: 160px;
}

.docs-key,
.docs-top-search kbd {
	font-family: var(--docs-font-mono);
	font-size: 0.7rem;
	padding: 0.2rem 0.5rem;
	border-radius: 6px;
	border: 1px solid var(--docs-border);
	color: var(--docs-text-muted);
}

.docs-auth {
	display: flex;
	align-items: center;
	gap: 0.85rem;
}

.docs-shell {
	position: relative;
	z-index: 1;
	display: grid;
	grid-template-columns: 260px minmax(0, 1fr);
	gap: clamp(1.5rem, 3vw, 2.5rem);
}

.docs-sidebar {
	border-radius: var(--docs-radius);
	border: 1px solid var(--docs-border);
	background: var(--docs-panel);
	padding: 1.5rem;
	height: fit-content;
	position: sticky;
	top: 6.5rem;
	box-shadow: var(--docs-shadow);
}

.docs-sidebar-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1.5rem;
	font-size: 0.95rem;
	color: var(--docs-text-muted);
}

.docs-sidebar-group+.docs-sidebar-group {
	margin-top: 1.75rem;
}

.docs-sidebar-label {
	font-size: 0.8rem;
	color: var(--docs-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	margin-bottom: 0.75rem;
}

.docs-sidebar-link {
	display: block;
	padding: 0.45rem 0.65rem;
	border-radius: var(--docs-radius-small);
	color: var(--docs-text-muted);
	text-decoration: none;
	transition: background 0.3s ease, color 0.3s ease;
}

.docs-sidebar-link:hover,
.docs-sidebar-link.is-active {
	background: rgba(255, 255, 255, 0.06);
	color: var(--docs-text);
}

.docs-main {
	display: flex;
	flex-direction: column;
	gap: clamp(1.5rem, 2.5vw, 2.75rem);
}

.docs-hero {
	border-radius: var(--docs-radius);
	border: 1px solid var(--docs-border);
	padding: clamp(1.8rem, 3vw, 3rem);
	background: radial-gradient(circle at top left, rgba(106, 255, 206, 0.18), transparent 55%), var(--docs-panel);
	box-shadow: var(--docs-shadow);
	animation: docs-fade-in 0.8s ease;
}

.docs-pill-row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.docs-pill {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	border-radius: 999px;
	padding: 0.3rem 0.9rem;
	font-size: 0.8rem;
	color: var(--docs-text-muted);
	border: 1px solid var(--docs-border);
}

.docs-pill--accent {
	color: #041407;
	background: var(--docs-accent);
	border-color: transparent;
}

.docs-hero h1 {
	margin: 0 0 1rem;
	font-size: clamp(2rem, 4vw, 3.5rem);
	line-height: 1.1;
}

.docs-hero p {
	margin: 0 0 1.5rem;
	color: var(--docs-text-muted);
	max-width: 60ch;
}

.docs-hero-actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 2rem;
}

.docs-btn {
	border-radius: 999px;
	border: 1px solid transparent;
	padding: 0.75rem 1.4rem;
	font-size: 0.95rem;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	cursor: pointer;
	text-decoration: none;
	transition: transform 0.2s ease, background 0.3s ease, color 0.3s ease;
}

.docs-btn--primary {
	background: linear-gradient(120deg, #6affce, #1affb4 60%, #54ffd7);
	color: #021c0e;
}

.docs-btn--ghost {
	border-color: var(--docs-border-strong);
	background: transparent;
	color: var(--docs-text);
}

.docs-btn--icon {
	border-color: var(--docs-border);
	padding: 0.6rem;
	width: 44px;
	height: 44px;
	justify-content: center;
}

.docs-btn--icon svg {
	width: 18px;
	height: 18px;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.6px;
}

.docs-btn:hover {
	transform: translateY(-2px);
}

.docs-link {
	color: var(--docs-accent);
	text-decoration: none;
	font-size: 0.95rem;
}

.docs-hero-metrics {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 1rem;
}

.docs-hero-metrics article {
	padding: 1rem 1.2rem;
	border-radius: var(--docs-radius-small);
	border: 1px solid var(--docs-border);
	background: rgba(255, 255, 255, 0.02);
}

.docs-hero-metrics .label {
	margin: 0;
	font-size: 0.8rem;
	color: var(--docs-text-muted);
}

.docs-hero-metrics .value {
	margin: 0.2rem 0;
	font-size: 1.8rem;
	font-weight: 600;
}

.docs-hero-metrics .hint {
	margin: 0;
	color: var(--docs-text-muted);
	font-size: 0.85rem;
}

.docs-search-panel {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
	gap: 1.5rem;
}

.docs-search-box,
.docs-release-card {
	border-radius: var(--docs-radius);
	border: 1px solid var(--docs-border);
	padding: 1.75rem;
	background: var(--docs-panel);
	box-shadow: var(--docs-shadow);
}

.docs-search-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 1rem;
}

.docs-search-head h2 {
	margin: 0.35rem 0 0.4rem;
}

.docs-chip {
	border-radius: 999px;
	border: 1px solid var(--docs-border);
	background: rgba(255, 255, 255, 0.04);
	color: var(--docs-text);
	font-size: 0.8rem;
	padding: 0.35rem 0.9rem;
}

.docs-chip--accent {
	background: rgba(97, 255, 154, 0.2);
	border-color: rgba(97, 255, 154, 0.55);
	color: #84f896;
}

.docs-search-field {
	margin-top: 1.5rem;
	border-radius: 16px;
	border: 1px solid var(--docs-border-strong);
	background: rgba(5, 8, 18, 0.8);
	padding: 0.85rem 1rem;
	display: grid;
	grid-template-columns: auto 1fr auto auto;
	align-items: center;
	gap: 0.6rem;
}

.docs-search-field svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: var(--docs-text-muted);
	stroke-width: 1.5px;
}

.docs-search-field input {
	border: 0;
	outline: none;
	background: transparent;
	color: var(--docs-text);
	font-family: var(--docs-font-mono);
	font-size: 0.95rem;
}

.docs-search-field kbd {
	padding: 0.2rem 0.4rem;
	border-radius: 6px;
	border: 1px solid var(--docs-border);
	font-size: 0.75rem;
	color: var(--docs-text-muted);
	min-width: 24px;
	text-align: center;
}

.docs-search-tags {
	margin-top: 1.25rem;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.docs-search-tags span {
	padding: 0.25rem 0.7rem;
	border-radius: 999px;
	border: 1px dashed var(--docs-border-strong);
	font-size: 0.8rem;
	color: var(--docs-text-muted);
}

.docs-release-card ul {
	margin: 1rem 0 1.2rem;
	padding-left: 1.05rem;
	color: var(--docs-text-muted);
}

.docs-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: var(--docs-grid-gap);
}

.docs-card {
	border-radius: var(--docs-radius);
	border: 1px solid var(--docs-border);
	padding: 1.8rem;
	background: var(--docs-panel-muted);
	position: relative;
	overflow: hidden;
}

.docs-card::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(125deg, rgba(255, 255, 255, 0.05), transparent 40%);
	opacity: 0;
	transition: opacity 0.35s ease;
}

.docs-card:hover::after {
	opacity: 1;
}

.docs-card-label {
	margin: 0 0 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.15em;
	font-size: 0.75rem;
	color: var(--docs-text-muted);
}

.docs-card h3 {
	margin: 0 0 0.75rem;
	font-size: 1.35rem;
}

.docs-card p {
	margin: 0 0 1rem;
	color: var(--docs-text-muted);
}

.docs-card-meta {
	font-size: 0.85rem;
	color: var(--docs-accent);
}

.docs-timeline {
	border-radius: var(--docs-radius);
	border: 1px solid var(--docs-border);
	padding: 2rem;
	background: var(--docs-panel);
	display: grid;
	grid-template-columns: 220px 1fr;
	gap: 2rem;
}

.docs-timeline ul {
	list-style: none;
	margin: 0;
	padding: 0;
	border-left: 1px solid var(--docs-border-strong);
}

.docs-timeline li {
	position: relative;
	padding-left: 1.5rem;
	margin-bottom: 1.5rem;
}

.docs-timeline li::before {
	content: '';
	width: 12px;
	height: 12px;
	border-radius: 999px;
	border: 2px solid var(--docs-accent);
	position: absolute;
	left: -6px;
	top: 4px;
	background: var(--docs-panel);
}

.docs-timeline span {
	font-size: 0.8rem;
	letter-spacing: 0.1em;
	color: var(--docs-text-muted);
}

.docs-footer {
	margin-top: 3rem;
	padding: 1.5rem 0;
	border-top: 1px solid var(--docs-border);
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 1rem;
	color: var(--docs-text-muted);
}

.docs-footer a {
	color: var(--docs-text);
	text-decoration: none;
	margin-right: 1rem;
}

.docs-footer-links {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
}

@media (max-width: 1000px) {
	.docs-shell {
		grid-template-columns: 1fr;
	}

	.docs-sidebar {
		position: static;
		order: 2;
	}

	.docs-topbar {
		flex-direction: column;
		align-items: flex-start;
	}

	.docs-top-actions {
		width: 100%;
		flex-wrap: wrap;
	}

	.docs-top-search {
		flex: 1;
	}
}

@media (max-width: 768px) {
	.docs-body {
		padding: 1.5rem;
	}

	.docs-search-panel,
	.docs-timeline {
		grid-template-columns: 1fr;
	}

	.docs-top-search input {
		width: 100px;
	}
}

@keyframes docs-fade-in {
	from {
		opacity: 0;
		transform: translateY(12px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}