/*
 * 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;
	}
}
