/* ATC Tube CMS — base styles (theme-agnostic).
 * Layout, typography, components. Theme variables — отдельные файлы dark.css / light.css.
 * Spec 6.2 (layouts) + 6.3 (themes) + 6.5 (index page) + 6.6 (video page).
 */

/* ─── Reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -moz-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.4;
	color: var(--fg);
	background: var(--bg);
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 600; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
button, input { font: inherit; color: inherit; }

/* ─── Layout containers ────────────────────────────────────────────────── */
.site-header,
.site-main,
.site-footer {
	max-width: 1600px;
	margin: 0 auto;
	padding: 0 16px;
}
.site-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding-top: 12px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--border);
	background: var(--bg-elev);
}
.site-logo {
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--fg);
	text-decoration: none;
}
.site-nav { display: flex; gap: 16px; }
.site-main { padding-top: 16px; padding-bottom: 32px; }
.site-footer {
	margin-top: 32px;
	padding-top: 16px;
	padding-bottom: 24px;
	border-top: 1px solid var(--border);
	color: var(--fg-muted);
	font-size: 12px;
}
.footer-links { display: flex; gap: 16px; margin-top: 8px; }

/* ─── Categories nav ───────────────────────────────────────────────────── */
.categories-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 16px;
}
.category-link {
	padding: 6px 12px;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: var(--bg-elev);
	color: var(--fg);
	font-size: 13px;
	transition: background 0.1s ease;
}
.category-link:hover { background: var(--bg-hover); text-decoration: none; }

/* ─── Video grid ───────────────────────────────────────────────────────── */
.video-grid {
	display: grid;
	gap: 16px;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.video-card {
	display: block;
	color: var(--fg);
	background: var(--bg-elev);
	border-radius: 6px;
	overflow: hidden;
	transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.video-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 2px 8px var(--shadow);
	text-decoration: none;
}
.video-card__thumb {
	position: relative;
	aspect-ratio: 16 / 9;
	/* Shimmer placeholder via CSS gradient animation. Image loads on top,
	 * перекрывает shimmer. No JS needed (P1-12 simplification — spec 6.12
	 * mentions optional :has() / onload JS as future enhancement). */
	background: linear-gradient(
		90deg,
		var(--bg) 25%,
		var(--bg-hover) 50%,
		var(--bg) 75%
	);
	background-size: 200% 100%;
	animation: video-card-shimmer 1.4s linear infinite;
}
@keyframes video-card-shimmer {
	0%   { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
	.video-card__thumb { animation: none; }
}
.video-card__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.video-card__duration {
	position: absolute;
	right: 6px;
	bottom: 6px;
	padding: 2px 6px;
	background: rgba(0, 0, 0, 0.75);
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	border-radius: 3px;
}
.video-card__meta { padding: 8px 10px 10px; }
.video-card__title {
	margin: 0 0 4px;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.video-card__stats {
	display: flex;
	gap: 8px;
	font-size: 11px;
	color: var(--fg-muted);
}

/* ─── Video page ───────────────────────────────────────────────────────── */
.video-page__title { margin-bottom: 16px; }
.video-page__player {
	background: #000;
	aspect-ratio: 16 / 9;
	margin-bottom: 16px;
}
.video-page__player video { width: 100%; height: 100%; }
.video-page__description {
	color: var(--fg-muted);
	margin-bottom: 16px;
}
.video-page__stats {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 4px 12px;
	margin: 0 0 24px;
	font-size: 13px;
}
.video-page__stats dt { color: var(--fg-muted); }
.video-page__related { margin-top: 24px; }
.video-page__related h2 {
	padding-bottom: 8px;
	border-bottom: 1px solid var(--border);
}

/* ─── Category / Search pages ──────────────────────────────────────────── */
.category-page__header,
.search-page__header {
	margin-bottom: 16px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--border);
}
.category-page__description { color: var(--fg-muted); }
.search-form {
	display: flex;
	gap: 8px;
	margin-bottom: 16px;
}
.search-form input[type="search"] {
	flex: 1;
	padding: 8px 12px;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: var(--bg-elev);
	color: var(--fg);
}
.search-form button {
	padding: 8px 16px;
	border: 1px solid var(--accent);
	border-radius: 4px;
	background: var(--accent);
	color: var(--accent-fg);
	cursor: pointer;
}
.search-form button:hover { opacity: 0.9; }

/* ─── Static pages ─────────────────────────────────────────────────────── */
.static-page {
	max-width: 800px;
	margin: 0 auto;
}
.static-page__content { line-height: 1.6; }
.static-page__content h1,
.static-page__content h2 { margin-top: 1.5em; }
.static-page__content p { margin: 0 0 1em; }

/* ─── Ad slots ─────────────────────────────────────────────────────────── */
.atc-slot {
	display: block;
	overflow: hidden;
	position: relative;
}
.atc-slot--header { margin: 16px 0; }
.atc-slot--footer { margin: 16px 0; }
.atc-slot--inContent {
	background: var(--bg-elev);
	border: 1px dashed var(--border);
	min-height: 100px;
	border-radius: 6px;
}
.atc-slot--full-row { grid-column: 1 / -1; }

/* P2-19 substrate (подложка) layering — substrate behind, live ad on top.
   When .atc-slot--live-ready toggled by inline JS load handler, substrate
   collapses. Pool-empty slots don't emit either layer (inheritance, см.
   render/slots.go). */
.atc-slot__substrate {
	position: absolute;
	inset: 0;
	z-index: 1;
}
.atc-slot__live {
	position: relative;
	z-index: 2;
}
.atc-slot--live-ready .atc-slot__substrate { display: none; }

/* ─── Mobile layouts ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
	.site-header,
	.site-main,
	.site-footer { padding: 0 12px; }
	.video-grid { gap: 12px; }
	.video-card__title { font-size: 12px; }
}

/* Mobile 2col (default — больше viewport coverage / ad density) */
body.layout-mobile.layout-mobile-2col .video-grid {
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}
body.layout-mobile.layout-mobile-2col .video-card__title { font-size: 12px; }
body.layout-mobile.layout-mobile-2col .atc-slot--full-row {
	grid-column: 1 / -1;
}

/* Mobile 1col (YouTube-style full-width) */
body.layout-mobile.layout-mobile-1col .video-grid {
	grid-template-columns: 1fr;
	gap: 12px;
}
body.layout-mobile.layout-mobile-1col .video-card { display: flex; flex-direction: column; }

/* ─── Desktop wide screens ─────────────────────────────────────────────── */
@media (min-width: 1200px) {
	body.layout-desktop .video-grid {
		grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	}
}
@media (min-width: 1600px) {
	body.layout-desktop .video-grid {
		grid-template-columns: repeat(6, 1fr);
	}
}
