/*
Theme Name: VidHub
Theme URI: https://example.com/vidhub
Author: VidHub
Description: A YouTube-style video hub for self-hosted videos. Adds a "Videos" section with topics, a thumbnail grid, a watch page with an "Up next" list, view counts, durations, and a player with keyboard shortcuts, theater mode, resume and autoplay-next. Includes a Dark style.
Version: 1.0.0
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: vidhub
Tags: block-patterns, full-site-editing, grid-layout, wide-blocks, entertainment, dark
*/

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

.vh-main {
	max-width: var(--wp--style--global--wide-size);
	margin-inline: auto;
	padding-block: var(--wp--preset--spacing--40) var(--wp--preset--spacing--50);
}

.vh-article,
.vh-404 {
	max-width: var(--wp--style--global--content-size);
	margin-inline: auto;
}

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

.vh-site-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background: var(--wp--preset--color--base);
}

.admin-bar .vh-site-header {
	top: var(--wp-admin--admin-bar--height, 32px);
}

.vh-header {
	gap: 1rem;
	padding-block: 0.5rem;
	min-height: 56px;
}

.vh-brand {
	gap: 0.5rem;
	flex-shrink: 0;
}

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

.vh-site-title a {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	text-decoration: none;
}

/* A play-button mark when no logo is set. */
.vh-site-title a {
	position: relative;
}

.vh-brand:not(:has(.wp-block-site-logo img)) .vh-site-title a::before {
	content: "";
	flex-shrink: 0;
	width: 30px;
	height: 21px;
	border-radius: 6px;
	background: var(--wp--preset--color--accent);
}

.vh-brand:not(:has(.wp-block-site-logo img)) .vh-site-title a::after {
	content: "";
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	border-style: solid;
	border-width: 5px 0 5px 8px;
	border-color: transparent transparent transparent var(--wp--preset--color--accent-contrast);
}

.vh-search {
	flex: 0 1 600px;
	margin: 0;
}

.vh-search .wp-block-search__inside-wrapper {
	border: 1px solid var(--wp--preset--color--surface-hover);
	border-radius: 999px;
	padding: 0;
	overflow: hidden;
	background: var(--wp--preset--color--base);
}

.vh-search .wp-block-search__input {
	border: 0;
	padding: 0.55rem 1rem;
	background: transparent;
	color: inherit;
	min-width: 0;
}

.vh-search .wp-block-search__button {
	margin: 0;
	border: 0;
	border-left: 1px solid var(--wp--preset--color--surface-hover);
	border-radius: 0;
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
	padding: 0 1.1rem;
}

.vh-nav {
	flex-shrink: 0;
	font-weight: 500;
}

@media (max-width: 600px) {
	.vh-site-title a > :not(img) { font-size: 1rem; }
	.vh-search { flex-basis: 100%; }
}

/* ---------- Topic chips ---------- */

.vh-chips {
	display: flex;
	flex-wrap: nowrap;
	gap: 0.6rem;
	overflow-x: auto;
	scrollbar-width: none;
	margin-bottom: var(--wp--preset--spacing--40);
	padding-bottom: 2px;
}

.vh-chips a {
	flex-shrink: 0;
	padding: 0.35rem 0.8rem;
	border-radius: 8px;
	background: var(--wp--preset--color--surface);
	font-weight: 500;
	white-space: nowrap;
	text-decoration: none !important;
	margin: 0 !important;
}

.vh-chips a:hover {
	background: var(--wp--preset--color--surface-hover);
}

/* ---------- Video grid & cards ---------- */

.vh-grid {
	column-gap: 1rem !important;
	row-gap: 2.5rem !important;
}

.vh-grid > li,
.vh-related > li {
	margin: 0;
}

.vh-thumb {
	position: relative;
	margin: 0 0 0.75rem;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	background: var(--wp--preset--color--surface);
	border-radius: 12px;
}

.vh-thumb a {
	display: block;
	height: 100%;
}

.vh-thumb img,
.vh-thumb video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.25s ease;
	pointer-events: none;
}

.vh-thumb a:hover img,
.vh-thumb a:hover video {
	transform: scale(1.03);
}

.vh-thumb-empty {
	display: block;
	height: 100%;
	background:
		linear-gradient(135deg, var(--wp--preset--color--surface), var(--wp--preset--color--surface-hover));
}

.vh-duration {
	position: absolute;
	right: 8px;
	bottom: 8px;
	padding: 1px 4px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.8);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0.02em;
	pointer-events: none;
}

.vh-card-body > * {
	margin-block: 0;
}

.vh-card-body > * + * {
	margin-block-start: 0.15rem;
}

.vh-card-title {
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-bottom: 0.3rem !important;
}

.vh-card-title a:hover {
	text-decoration: none;
}

.vh-card-channel,
.vh-meta {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
}

.vh-card-channel a:hover {
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.vh-dot {
	margin: 0 0.1rem;
}

.vh-pagination {
	margin-top: var(--wp--preset--spacing--50);
}

.vh-empty {
	color: var(--wp--preset--color--muted);
}

/* ---------- Watch page ---------- */

.vh-watch {
	gap: 1.5rem;
	align-items: flex-start;
}

.vh-player {
	margin: 0;
	background: #000;
	border-radius: 12px;
	overflow: hidden;
}

.vh-player .wp-block-video {
	margin: 0;
}

.vh-player video {
	display: block;
	width: 100%;
	max-height: calc(100vh - 170px);
	aspect-ratio: 16 / 9;
	background: #000;
}

.vh-player-placeholder {
	aspect-ratio: 16 / 9;
	display: grid;
	place-items: center;
	color: #fff;
	font-size: 1.25rem;
}

.vh-player-tools {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 0.5rem;
	margin-top: 0.6rem;
}

.vh-player-tools button,
.vh-player-tools label {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.35rem 0.9rem;
	border: 0;
	border-radius: 999px;
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
	font: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	cursor: pointer;
}

.vh-player-tools button:hover,
.vh-player-tools label:hover {
	background: var(--wp--preset--color--surface-hover);
}

.vh-player-tools button[aria-pressed="true"] {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

.vh-watch-title {
	font-size: 1.25rem;
	margin: 0.75rem 0 0.5rem;
}

.vh-channel {
	gap: 0.75rem;
	margin-bottom: 0.75rem;
}

.vh-channel-name {
	font-weight: 600;
	font-size: 1rem;
	color: var(--wp--preset--color--contrast);
}

.vh-description {
	background: var(--wp--preset--color--surface);
	border-radius: 12px;
	padding: 0.75rem 1rem;
}

.vh-description-meta {
	gap: 0.5rem 1rem;
	font-weight: 600;
}

.vh-description-meta .vh-meta {
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--medium);
}

.vh-topics {
	font-size: var(--wp--preset--font-size--medium);
}

.vh-topics a {
	color: var(--wp--preset--color--accent);
}

.vh-description-body {
	margin-top: 0.5rem;
}

.vh-description-body > :first-child {
	margin-top: 0;
}

.vh-section-title {
	font-size: 1rem;
	margin: 0 0 0.75rem;
}

/* "Up next": thumbnail on the left, text on the right */
.vh-related {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	padding: 0;
	list-style: none;
}

.vh-related > li {
	display: grid;
	grid-template-columns: minmax(140px, 42%) 1fr;
	gap: 0.6rem;
	align-items: start;
}

.vh-related .vh-thumb {
	margin: 0;
	border-radius: 8px;
}

.vh-related .vh-card-title {
	font-size: 0.875rem;
}

.vh-related .vh-card-channel,
.vh-related .vh-meta {
	font-size: 0.75rem;
}

.vh-related .vh-duration {
	right: 4px;
	bottom: 4px;
}

/* Theater mode: player takes the full width, "Up next" moves below it */
@media (min-width: 782px) {
	.vh-theater .vh-watch {
		flex-wrap: wrap !important;
	}
	.vh-theater .vh-watch-main {
		flex-basis: 100% !important;
	}
	.vh-theater .vh-watch-side {
		flex-basis: 100% !important;
	}
	.vh-theater .vh-related {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
	}
}

/* ---------- Comments ---------- */

.vh-comments {
	margin-top: 1.5rem;
}

.vh-comment {
	gap: 0.75rem;
	margin-bottom: 1rem;
}

.vh-comment-head {
	gap: 0.5rem;
	font-size: var(--wp--preset--font-size--small);
}

.vh-comment-head .wp-block-comment-author-name {
	font-weight: 600;
}

.vh-comment-head .wp-block-comment-date {
	color: var(--wp--preset--color--muted);
}

.vh-comment-body > * {
	margin-block: 0.2rem;
}

/* ---------- Archive, channel, footer ---------- */

.vh-archive-title {
	margin: 0 0 1.5rem;
}

.vh-channel-header {
	gap: 1.25rem;
	margin-bottom: 2rem;
	padding-bottom: 1.5rem;
	border-bottom: 1px solid var(--wp--preset--color--surface-hover);
}

.vh-channel-info .vh-archive-title {
	margin: 0;
}

.vh-site-footer {
	border-top: 1px solid var(--wp--preset--color--surface-hover);
	margin-top: var(--wp--preset--spacing--50);
}

.vh-footer {
	max-width: var(--wp--style--global--wide-size);
	margin-inline: auto;
	padding-block: 1.5rem;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
}

.vh-footer .wp-block-site-title {
	font-size: inherit;
	font-weight: 600;
}

.vh-footer-credit {
	margin: 0;
}
