/* ============================================================
   AsiaAI.FYI — Videos
   ------------------------------------------------------------
   Additions only, same approach as guides.css. Everything below is
   built from the --asiaai-* tokens already defined in style.css — no
   new colors, no new fonts, no new radii. The tab control deliberately
   borrows the geometry of .asiaai-guide-filters__chip so the Videos
   page reads as a sibling of the Guides hub rather than a new idea.
   ============================================================ */

/* ---------- Tabs ---------- */

.asiaai-videos__tabs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 0 0 32px;
	padding-bottom: 24px;
	border-bottom: 1px solid var(--asiaai-border);
}

.asiaai-videos__tab {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 5px 14px;
	background: none;
	border: 1px solid var(--asiaai-border);
	border-radius: 999px;
	font-family: var(--font-sans);
	font-size: 13px;
	line-height: 1.4;
	color: var(--asiaai-muted);
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.asiaai-videos__tab:hover {
	border-color: var(--asiaai-red);
	color: var(--asiaai-red);
}

.asiaai-videos__tab.is-active {
	background: var(--asiaai-ink);
	border-color: var(--asiaai-ink);
	color: #fff;
}

.asiaai-videos__tab:focus-visible {
	outline: 2px solid var(--asiaai-red);
	outline-offset: 2px;
}

/* The count is supporting information, so it never competes with the label. */
.asiaai-videos__count {
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	color: var(--asiaai-hint);
}

.asiaai-videos__tab.is-active .asiaai-videos__count {
	color: rgba(255, 255, 255, 0.65);
}

/* With JavaScript off the tabs stay hidden and these headings do the work. */
.asiaai-videos__label {
	margin-top: 40px;
}

.asiaai-videos__label:first-of-type {
	margin-top: 0;
}

/* ---------- Grids ---------- */

.asiaai-video-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 1.75rem 1.25rem;
	margin-bottom: 1.75rem;
}

/* Shorts are portrait, so more of them fit across the same column. */
.asiaai-video-grid--shorts {
	grid-template-columns: repeat(4, 1fr);
	gap: 1.5rem 1rem;
}

@media (max-width: 900px) {
	.asiaai-video-grid--shorts {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 680px) {
	.asiaai-video-grid {
		grid-template-columns: 1fr;
	}

	.asiaai-video-grid--shorts {
		grid-template-columns: 1fr 1fr;
	}
}

@media (min-width: 481px) and (max-width: 680px) {
	.asiaai-video-grid {
		grid-template-columns: 1fr 1fr;
	}
}

/* ---------- Card ---------- */

.asiaai-video-card__link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.asiaai-video-card__link:focus-visible {
	outline: 2px solid var(--asiaai-red);
	outline-offset: 4px;
}

.asiaai-video-card__thumb {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	margin-bottom: 12px;
	border-radius: var(--radius-md);
	overflow: hidden;
	background: var(--asiaai-tinted);
}

.asiaai-video-card--short .asiaai-video-card__thumb {
	aspect-ratio: 9 / 16;
}

.asiaai-video-card__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	object-fit: cover;
	transition: transform 0.2s ease;
}

/* ---------- Player modal ---------- */

/*
 * The dialog fills the viewport and centres the frame inside it, rather
 * than shrink-wrapping the frame and leaning on the UA stylesheet's
 * margin:auto. That default centring only holds while width stays
 * fit-content, so any author width rule silently pushes the box to the
 * left edge — which is exactly what happened here.
 *
 * display must be scoped to [open]: an unscoped author display value
 * beats the UA's dialog:not([open]) { display: none } and leaves the
 * closed dialog sitting on the page.
 */
.asiaai-video-modal {
	position: fixed;
	inset: 0;
	width: 100vw;
	max-width: 100vw;
	height: 100vh;
	height: 100dvh; /* keeps clear of mobile browser chrome */
	max-height: 100dvh;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	overflow: visible;
}

.asiaai-video-modal[open] {
	display: grid;
	place-items: center;
}

.asiaai-video-modal::backdrop {
	background: rgba(26, 26, 24, 0.9);
}

.asiaai-video-modal__stage {
	border-radius: var(--radius-md);
	overflow: hidden;
	background: #000;
}

.asiaai-video-modal__stage iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}

/*
 * Sized off the viewport's smaller constraint so the player always fits
 * without scrolling, whichever way the window is shaped. Setting width and
 * letting aspect-ratio derive the height keeps the frame exact — capping
 * both dimensions instead would let the box drift off ratio and letterbox.
 */
.asiaai-video-modal--wide .asiaai-video-modal__stage {
	width: min(1040px, 94vw, calc(86vh * 16 / 9));
	aspect-ratio: 16 / 9;
}

.asiaai-video-modal--tall .asiaai-video-modal__stage {
	width: min(94vw, calc(84vh * 9 / 16));
	aspect-ratio: 9 / 16;
}

/* Fixed to the viewport, not the frame: a portrait Short is tall enough
   that a button above it would sit off the top of the screen. */
.asiaai-video-modal__close {
	position: fixed;
	top: 14px;
	right: 16px;
	width: 40px;
	height: 40px;
	padding: 0;
	background: none;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 50%;
	font-family: var(--font-sans);
	font-size: 24px;
	line-height: 1;
	color: #fff;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.asiaai-video-modal__close:hover {
	background: var(--asiaai-red);
	border-color: var(--asiaai-red);
}

.asiaai-video-modal__close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.asiaai-video-card__link:hover .asiaai-video-card__thumb img {
	transform: scale(1.03);
}

/* The one piece of colour on the card. A filled red disc with a white
   triangle cut from it — drawn rather than shipped as an asset. */
.asiaai-video-card__play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 46px;
	height: 46px;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: var(--asiaai-red);
	opacity: 0.92;
	transition: background-color 0.15s ease, transform 0.15s ease;
}

.asiaai-video-card__play::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 52%;
	transform: translate(-50%, -50%);
	border-style: solid;
	border-width: 8px 0 8px 13px;
	border-color: transparent transparent transparent #fff;
}

.asiaai-video-card__link:hover .asiaai-video-card__play {
	background: var(--asiaai-red-dark);
	transform: translate(-50%, -50%) scale(1.06);
}

.asiaai-video-card__duration {
	position: absolute;
	right: 8px;
	bottom: 8px;
	padding: 2px 6px;
	border-radius: var(--radius-sm);
	background: rgba(26, 26, 24, 0.82);
	font-family: var(--font-sans);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	color: #fff;
}

.asiaai-video-card__title {
	font-family: var(--font-display);
	font-size: 15px;
	font-weight: 400;
	line-height: 1.35;
	color: var(--asiaai-ink);
	margin: 0 0 0.35rem;
	text-wrap: balance;
	transition: color 0.15s;
}

.asiaai-video-card__link:hover .asiaai-video-card__title {
	color: var(--asiaai-red);
}

.asiaai-video-card--short .asiaai-video-card__title {
	font-size: 14px;
}

.asiaai-video-card__meta {
	font-family: var(--font-sans);
	font-size: 10px;
	color: var(--asiaai-hint);
	margin: 0;
}

.asiaai-video-card__meta time {
	font-variant-numeric: tabular-nums;
}

/* ---------- Load more ---------- */

.asiaai-videos__more {
	text-align: center;
	margin: 8px 0 0;
}

.asiaai-videos__more-btn {
	padding: 9px 24px;
	background: none;
	border: 1px solid var(--asiaai-border);
	border-radius: var(--radius-sm);
	font-family: var(--font-sans);
	font-size: 13px;
	color: var(--asiaai-muted);
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.asiaai-videos__more-btn:hover {
	border-color: var(--asiaai-red);
	color: var(--asiaai-red);
}

.asiaai-videos__more-btn:focus-visible {
	outline: 2px solid var(--asiaai-red);
	outline-offset: 2px;
}

/* ---------- Empty, error, channel link ---------- */

.asiaai-videos__empty {
	font-family: var(--font-serif);
	font-size: 16px;
	color: var(--asiaai-muted);
	margin: 0 0 24px;
}

/* Administrators only — visitors get the empty state instead. */
.asiaai-videos__notice {
	padding: 12px 16px;
	margin: 0 0 24px;
	border: 1px solid var(--asiaai-red);
	border-radius: var(--radius-sm);
	background: var(--asiaai-red-light);
	font-family: var(--font-sans);
	font-size: 13px;
	color: var(--asiaai-red-dark);
}

.asiaai-videos__channel {
	margin: 32px 0 0;
	padding-top: 24px;
	border-top: 1px solid var(--asiaai-border);
	font-family: var(--font-sans);
	font-size: 14px;
}

.asiaai-videos__channel a {
	color: var(--asiaai-muted);
	text-decoration: none;
}

.asiaai-videos__channel a:hover {
	color: var(--asiaai-red);
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.asiaai-video-card__thumb img,
	.asiaai-video-card__play,
	.asiaai-video-card__title,
	.asiaai-videos__tab,
	.asiaai-videos__more-btn,
	.asiaai-video-modal__close {
		transition: none;
	}

	.asiaai-video-card__link:hover .asiaai-video-card__thumb img,
	.asiaai-video-card__link:hover .asiaai-video-card__play {
		transform: translate(-50%, -50%);
	}

	.asiaai-video-card__link:hover .asiaai-video-card__thumb img {
		transform: none;
	}
}
