/*
 * Kininusa News — widget system styles (Phase 10).
 *
 * Covers the widget-area wrappers and the five custom widgets. Loaded after
 * components.css; consumes only the design tokens (tokens.css) so the dark
 * theme keeps working without per-widget overrides.
 */

/* ------------------------------------------------------------------ *
 * Areas
 * ------------------------------------------------------------------ */
.kn-home-widgets {
	margin-bottom: var(--kn-space-6);
}

.kn-home-widgets .kn-widget:last-child,
.kn-archive-widgets .kn-widget:last-child {
	margin-bottom: var(--kn-space-5);
}

.kn-archive-widgets {
	margin-top: var(--kn-space-6);
}

/* ------------------------------------------------------------------ *
 * Shared widget chrome
 * ------------------------------------------------------------------ */
.kn-widget__title {
	padding-left: var(--kn-space-3);
	border-left: 3px solid var(--kn-widget-accent, var(--kn-color-accent));
	color: var(--kn-widget-head, inherit);
	font-weight: var(--kn-widget-weight, var(--kn-font-weight-bold));
	line-height: var(--kn-line-height-tight);
}

/* Sidebar widget headings use the widget-title scale (Phase 17 visual pass:
   reference widget headings are 21px — one step below the 25px section scale). */
.kn-sidebar .kn-widget__title,
.kn-sidebar .wp-block-heading {
	font-size: var(--kn-font-size-xl);
}

.kn-sidebar {
	color: var(--kn-widget-text, inherit);
}

/* Core block search button inside the sidebar follows the palette. */
.kn-sidebar .wp-block-search__button {
	background-color: var(--kn-color-primary);
	border-color: var(--kn-color-primary);
	color: var(--kn-color-on-accent, #fff);
}

.kn-sidebar .wp-block-search__button:hover {
	filter: brightness(0.92);
}

/* Core block search INPUT follows the palette in both themes. */
.kn-sidebar .wp-block-search__input {
	background: var(--kn-color-surface);
	border: 1px solid var(--kn-color-border);
	color: var(--kn-color-text);
}

.kn-sidebar .wp-block-search__input::placeholder {
	color: var(--kn-color-text-muted);
	opacity: 1;
}

.kn-sidebar a {
	color: var(--kn-widget-link, var(--kn-color-link));
}

.kn-widget__index {
	float: right;
	font-size: var(--kn-font-size-xs);
	font-weight: var(--kn-font-weight-normal);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--kn-color-text-muted);
}

.kn-widget__index:hover {
	color: var(--kn-color-link-hover);
}

.kn-widget-thumb-placeholder {
	display: block;
	width: 100%;
	height: 100%;
	min-height: 90px;
	background: var(--kn-color-surface-2);
}

/* ------------------------------------------------------------------ *
 * Trending (numbered list)
 * ------------------------------------------------------------------ */
.kn-widget-trending__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.kn-widget-trending__item {
	display: flex;
	gap: var(--kn-space-3);
	padding: var(--kn-space-3) 0;
	border-bottom: 1px solid var(--kn-color-border);
}

.kn-widget-trending__item:last-child {
	border-bottom: 0;
}

.kn-widget-trending__num {
	flex: 0 0 auto;
	font-size: var(--kn-font-size-xl);
	font-weight: var(--kn-font-weight-bold);
	line-height: 1.1;
	color: var(--kn-color-accent);
}

.kn-widget-trending__body {
	min-width: 0;
}

.kn-widget-trending__title {
	margin: 0;
	font-size: var(--kn-font-size-base);
	font-weight: var(--kn-font-weight-medium);
	line-height: var(--kn-line-height-tight);
}

.kn-widget-trending__time {
	display: inline-block;
	margin-top: var(--kn-space-1);
	font-size: var(--kn-font-size-xs);
	color: var(--kn-color-text-muted);
}

/* ------------------------------------------------------------------ *
 * Category list
 * ------------------------------------------------------------------ */
.kn-widget-category__item {
	padding: var(--kn-space-3) 0;
	border-bottom: 1px solid var(--kn-color-border);
}

.kn-widget-category__item:last-child {
	border-bottom: 0;
}

.kn-widget-category__title {
	margin: 0;
	font-size: var(--kn-font-size-base);
	font-weight: var(--kn-font-weight-medium);
	line-height: var(--kn-line-height-tight);
}

.kn-widget-category__time {
	display: inline-flex;
	align-items: center;
	gap: var(--kn-space-2);
	margin-top: var(--kn-space-1);
	font-size: var(--kn-font-size-xs);
	color: var(--kn-color-text-muted);
}

.kn-widget-category__time::before {
	content: "";
	width: 7px;
	height: 7px;
	border: 1px solid var(--kn-color-accent);
	border-radius: var(--kn-radius-circle);
}

/* ------------------------------------------------------------------ *
 * Latest (featured-first)
 * ------------------------------------------------------------------ */
.kn-widget-latest__featured {
	margin-bottom: var(--kn-space-4);
}

.kn-widget-latest__thumb {
	display: block;
	overflow: hidden;
	border-radius: var(--kn-radius-md);
}

.kn-widget-latest__thumb img {
	display: block;
	width: 100%;
	height: auto;
}

.kn-widget-latest__featured .kn-widget-latest__title {
	margin: var(--kn-space-3) 0 var(--kn-space-1);
	font-size: var(--kn-font-size-lg);
	line-height: var(--kn-line-height-tight);
}

.kn-widget-latest__item {
	display: flex;
	gap: var(--kn-space-3);
	padding: var(--kn-space-3) 0;
	border-top: 1px solid var(--kn-color-border);
}

.kn-widget-latest__thumb--sm {
	flex: 0 0 76px;
}

.kn-widget-latest__thumb--sm img {
	width: 76px;
	height: 57px;
	object-fit: cover;
	border-radius: var(--kn-radius-sm);
}

.kn-widget-latest__body {
	min-width: 0;
}

.kn-widget-latest__item .kn-widget-latest__title {
	margin: 0;
	font-size: var(--kn-font-size-base);
	font-weight: var(--kn-font-weight-medium);
	line-height: var(--kn-line-height-tight);
}

.kn-widget-latest__meta {
	margin: var(--kn-space-1) 0 0;
	font-size: var(--kn-font-size-xs);
	color: var(--kn-color-text-muted);
}

.kn-widget-latest__cat {
	color: var(--kn-color-link);
}

/* ------------------------------------------------------------------ *
 * Category slider (Splide; JS loaded conditionally)
 * ------------------------------------------------------------------ */
.kn-widget-slider {
	padding: var(--kn-space-4);
	border-radius: var(--kn-radius-lg);
	background: var(--kn-color-surface);
}

.kn-widget-slider--bold .kn-widget-slide__title {
	font-weight: var(--kn-font-weight-bold);
}

.kn-widget-slide {
	position: relative;
	overflow: hidden;
	border-radius: var(--kn-radius-md);
}

.kn-widget-slide__image {
	display: block;
}

.kn-widget-slide__image img {
	display: block;
	width: 100%;
	height: 150px;
	object-fit: cover;
}

.kn-widget-slide__meta {
	position: absolute;
	inset: auto 0 0 0;
	padding: var(--kn-space-5) var(--kn-space-3) var(--kn-space-3);
	background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 30%, transparent);
}

.kn-widget-slide__date {
	display: inline-block;
	margin-bottom: var(--kn-space-1);
	padding: 1px var(--kn-space-2);
	border-radius: var(--kn-radius-sm);
	background: var(--kn-color-secondary);
	color: var(--kn-color-text);
	font-size: var(--kn-font-size-xs);
	line-height: 1.5;
}

.kn-widget-slide__title {
	margin: 0;
	font-size: var(--kn-font-size-sm);
	line-height: var(--kn-line-height-tight);
}

.kn-widget-slide__title a,
.kn-widget-slide__meta a {
	color: #ffffff;
}

.kn-widget-slide__title a:hover,
.kn-widget-slide__meta a:hover {
	color: var(--kn-color-secondary);
}

/* No-JS fallback: keep slides readable as a horizontal strip until Splide
   mounts (it adds .is-active). Progressive enhancement, no dead content. */
.kn-widget-slider__splide:not(.is-active) .splide__track {
	overflow-x: auto;
}

.kn-widget-slider__splide:not(.is-active) .splide__list {
	display: flex;
	gap: var(--kn-space-3);
	margin: 0;
	padding: 0;
	list-style: none;
}

.kn-widget-slider__splide:not(.is-active) .splide__slide {
	flex: 0 0 31%;
}

/* ------------------------------------------------------------------ *
 * Static block (featured + rows)
 * ------------------------------------------------------------------ */
.kn-widget-block--bold .kn-widget-block__title {
	font-weight: var(--kn-font-weight-bold);
}

.kn-widget-block__image {
	display: block;
	overflow: hidden;
	border-radius: var(--kn-radius-md);
}

.kn-widget-block__image img {
	display: block;
	width: 100%;
	height: auto;
}

.kn-widget-block__featured .kn-widget-block__date {
	display: inline-block;
	margin-top: var(--kn-space-3);
	font-size: var(--kn-font-size-xs);
	color: var(--kn-color-text-muted);
}

.kn-widget-block__featured .kn-widget-block__title {
	margin: var(--kn-space-1) 0 var(--kn-space-4);
	font-size: var(--kn-font-size-lg);
	line-height: var(--kn-line-height-tight);
}

.kn-widget-block__row {
	display: flex;
	gap: var(--kn-space-3);
	padding: var(--kn-space-3) 0;
	border-top: 1px solid var(--kn-color-border);
}

.kn-widget-block__thumb {
	flex: 0 0 76px;
}

.kn-widget-block__thumb img {
	width: 76px;
	height: 57px;
	object-fit: cover;
	border-radius: var(--kn-radius-sm);
}

.kn-widget-block__body {
	min-width: 0;
}

.kn-widget-block__row .kn-widget-block__title {
	margin: 0;
	font-size: var(--kn-font-size-base);
	font-weight: var(--kn-font-weight-medium);
	line-height: var(--kn-line-height-tight);
}

.kn-widget-block__row .kn-widget-block__date {
	display: inline-block;
	margin-top: var(--kn-space-1);
	font-size: var(--kn-font-size-xs);
	color: var(--kn-color-text-muted);
}

/* ------------------------------------------------------------------ *
 * Responsive (theme breakpoints: 980 / 640 / 533 / 420)
 * ------------------------------------------------------------------ */
@media (max-width: 640px) {
	.kn-widget-slide__image img {
		height: 130px;
	}

	.kn-widget-slider {
		padding: var(--kn-space-3);
	}
}

@media (max-width: 533px) {
	.kn-widget-trending__num {
		font-size: var(--kn-font-size-lg);
	}

	.kn-widget-latest__thumb--sm,
	.kn-widget-block__thumb {
		flex-basis: 64px;
	}

	.kn-widget-latest__thumb--sm img,
	.kn-widget-block__thumb img {
		width: 64px;
		height: 48px;
	}
}

@media (max-width: 420px) {
	.kn-widget-slider__splide:not(.is-active) .splide__slide {
		flex-basis: 46%;
	}

	.kn-widget__index {
		float: none;
		display: block;
		margin-top: var(--kn-space-1);
	}
}

/* ------------------------------------------------------------------ *
 * Kini News Iklan — ad posts (v1.4.0)
 * Image + title cards: the featured image is the ad image; the whole
 * card links to the post. No date/meta — a clean image + title.
 * ------------------------------------------------------------------ */
.kn-widget-ad__item {
	margin-bottom: var(--kn-space-4);
}

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

.kn-widget-ad__thumb {
	display: block;
	overflow: hidden;
	border-radius: var(--kn-radius-md);
}

.kn-widget-ad__thumb img {
	display: block;
	width: 100%;
	height: auto;
	transition: transform 0.25s ease;
}

.kn-widget-ad__item:hover .kn-widget-ad__thumb img {
	transform: scale(1.03);
}

.kn-widget-ad__title {
	margin: var(--kn-space-2) 0 0;
	font-size: var(--kn-font-size-sm);
	font-weight: var(--kn-font-weight-medium);
	line-height: var(--kn-line-height-tight);
}

.kn-widget-ad__title a {
	color: var(--kn-color-text);
	text-decoration: none;
}

.kn-widget-ad__title a:hover,
.kn-widget-ad__title a:focus-visible {
	color: var(--kn-color-primary);
}

@media (prefers-reduced-motion: reduce) {
	.kn-widget-ad__thumb img {
		transition: none;
	}

	.kn-widget-ad__item:hover .kn-widget-ad__thumb img {
		transform: none;
	}
}

/* ------------------------------------------------------------------
 * Stats widget (Total Tayangan)
 * ------------------------------------------------------------------ */

.kn-widget-stats {
	text-align: center;
}

.kn-widget-stats__value {
	margin: 0;
	font-size: var(--kn-font-size-3xl);
	font-weight: var(--kn-font-weight-bold);
	line-height: 1.1;
	color: var(--kn-color-primary);
	font-variant-numeric: tabular-nums;
}

.kn-widget-stats__mini {
	display: flex;
	justify-content: center;
	gap: var(--kn-space-5);
	margin: var(--kn-space-4) 0 0;
	padding: var(--kn-space-3) 0 0;
	list-style: none;
	border-top: 1px solid var(--kn-color-border);
}

.kn-widget-stats__mini li {
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: var(--kn-font-size-xs);
	color: var(--kn-color-text-muted);
}

.kn-widget-stats__mini-value {
	font-size: var(--kn-font-size-lg);
	font-weight: var(--kn-font-weight-bold);
	color: var(--kn-color-text);
	font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------
 * Hot topics widget (Topik Hangat)
 * ------------------------------------------------------------------ */

.kn-widget-topics {
	display: flex;
	flex-wrap: wrap;
	gap: var(--kn-space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.kn-widget-topics__pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	border-radius: var(--kn-radius-pill);
	background: var(--kn-color-surface-2);
	color: var(--kn-color-text);
	font-size: var(--kn-font-size-sm);
	font-weight: var(--kn-font-weight-medium);
	text-decoration: none;
	transition: background var(--kn-t-fast), color var(--kn-t-fast);
}

.kn-widget-topics__pill:hover,
.kn-widget-topics__pill:focus-visible {
	background: var(--kn-color-primary);
	color: var(--kn-color-on-accent);
}

.kn-widget-topics__count {
	font-size: var(--kn-font-size-xs);
	opacity: 0.7;
}

/* ------------------------------------------------------------------
 * Video widget
 * ------------------------------------------------------------------ */

.kn-widget-video {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--kn-space-4);
}

.kn-widget-video__item {
	margin: 0;
}

.kn-widget-video__thumb {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--kn-radius-md);
}

.kn-widget-video__thumb img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 10;
	object-fit: cover;
	transition: transform 0.25s ease;
}

.kn-widget-video__item:hover .kn-widget-video__thumb img {
	transform: scale(1.04);
}

.kn-widget-video__play {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	background: rgba(2, 18, 63, 0.28);
	transition: background var(--kn-t-fast);
}

.kn-widget-video__play svg {
	width: 38px;
	height: 38px;
	padding: 8px;
	border-radius: var(--kn-radius-circle);
	background: var(--kn-color-primary);
	box-shadow: 0 6px 18px rgba(2, 18, 63, 0.4);
}

.kn-widget-video__item:hover .kn-widget-video__play {
	background: rgba(2, 18, 63, 0.14);
}

.kn-widget-video__title {
	margin: var(--kn-space-2) 0 0;
	font-size: var(--kn-font-size-sm);
	font-weight: var(--kn-font-weight-medium);
	line-height: var(--kn-line-height-tight);
}

.kn-widget-video__title a {
	color: var(--kn-color-text);
	text-decoration: none;
}

.kn-widget-video__title a:hover,
.kn-widget-video__title a:focus-visible {
	color: var(--kn-color-primary);
}

.kn-widget-video__meta {
	margin: 4px 0 0;
	font-size: var(--kn-font-size-xs);
	color: var(--kn-color-text-muted);
}

@media (max-width: 420px) {
	.kn-widget-video {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	.kn-widget-video__thumb img,
	.kn-widget-video__play {
		transition: none;
	}

	.kn-widget-video__item:hover .kn-widget-video__thumb img {
		transform: none;
	}
}

/* ------------------------------------------------------------------
 * Video widget — social source (Repliz)
 * ------------------------------------------------------------------ */

.kn-widget-video__badge {
	position: absolute;
	top: 8px;
	left: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: var(--kn-radius-circle);
	background: rgba(2, 18, 63, 0.72);
	color: #fff;
}

.kn-widget-video__badge svg {
	width: 14px;
	height: 14px;
}

.kn-widget-video__account {
	color: var(--kn-color-text-muted);
}

.kn-widget-video__sep {
	margin: 0 4px;
}

/* ------------------------------------------------------------------
 * Video lightbox — inline social playback
 * ------------------------------------------------------------------ */

body.kn-vlight-open {
	overflow: hidden;
}

.kn-vlight {
	position: fixed;
	inset: 0;
	z-index: var(--kn-z-overlay);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--kn-space-4);
	padding: var(--kn-space-5);
	background: rgba(2, 10, 30, 0.86);
}

.kn-vlight__frame {
	overflow: hidden;
	border-radius: var(--kn-radius-lg);
	background: #000;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.kn-vlight__frame--vertical {
	width: min(92vw, 420px, calc(78vh * 9 / 16));
	aspect-ratio: 9 / 16;
}

.kn-vlight__frame--wide {
	width: min(92vw, 960px, calc(78vh * 16 / 9));
	aspect-ratio: 16 / 9;
}

.kn-vlight__frame iframe,
.kn-vlight__frame video {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: #000;
}

.kn-vlight__bar {
	display: flex;
	align-items: center;
	gap: var(--kn-space-4);
}

.kn-vlight__out {
	color: #fff;
	font-size: var(--kn-font-size-sm);
	text-decoration: none;
	opacity: 0.85;
}

.kn-vlight__out:hover,
.kn-vlight__out:focus-visible {
	opacity: 1;
	text-decoration: underline;
}

.kn-vlight__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: var(--kn-radius-circle);
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	font-size: 16px;
	cursor: pointer;
}

.kn-vlight__close:hover,
.kn-vlight__close:focus-visible {
	background: rgba(255, 255, 255, 0.26);
}
