/**
 * Homepage Tabs Styles
 * Modern, SEO-friendly design
 */

/* ============================================
   Variables - สีน้ำเงินสวยๆ
   ============================================ */
:root {
	--ftt-primary: #0066cc;
	--ftt-primary-dark: #0052a3;
	--ftt-primary-light: #1a7feb;
	--ftt-primary-hover: #0052a3;
	--ftt-text: #1f2937;
	--ftt-text-light: #6b7280;
	--ftt-border: #e5e7eb;
	--ftt-bg: #ffffff;
	--ftt-bg-light: #f0f7ff;
	--ftt-shadow: 0 1px 3px rgba(0, 102, 204, 0.1);
	--ftt-shadow-md: 0 4px 6px rgba(0, 102, 204, 0.15);
	--ftt-radius: 8px;
	--ftt-transition: all 0.3s ease;
}

/* ============================================
   Main Wrapper
   ============================================ */
.ftt-homepage-tabs-wrapper {
	max-width: 1200px;
	margin: 2rem auto;
	padding: 0 1rem;
	position: relative;
}

/* Decorative element */
.ftt-homepage-tabs-wrapper::before {
	content: '';
	position: absolute;
	top: -20px;
	left: 50%;
	transform: translateX(-50%);
	width: 60px;
	height: 4px;
	background: linear-gradient(90deg, #0a3e78 0%, #2298e0 100%);
	border-radius: 2px;
	opacity: 0.5;
}

/* ============================================
   Tab Navigation - Gradient Style
   ============================================ */
.ftt-tabs-nav {
	display: flex;
	gap: 0;
	margin-bottom: 2rem;
	border-bottom: none;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	-ms-overflow-style: none;
	background: linear-gradient(90deg, #0a3e78 0%, #2298e0 100%);
	border-radius: 8px 8px 0 0;
	padding: 0.5rem 0.5rem 0 0.5rem;
	box-shadow: 0 4px 12px rgba(10, 62, 120, 0.2);
	position: relative;
}

/* Shine effect on gradient */
.ftt-tabs-nav::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
	animation: shine 3s infinite;
}

@keyframes shine {
	0% {
		left: -100%;
	}
	100% {
		left: 100%;
	}
}

.ftt-tabs-nav::-webkit-scrollbar {
	display: none;
}

.ftt-tab-btn {
	flex: 0 0 auto;
	padding: 0.75rem 1.5rem;
	background: transparent;
	border: none;
	border-bottom: none;
	color: #ffffff;
	font-size: 1rem;
	font-weight: 500;
	cursor: pointer;
	transition: var(--ftt-transition);
	white-space: nowrap;
	position: relative;
	margin-bottom: 0;
	border-radius: 8px 8px 0 0;
}

.ftt-tab-btn:hover {
	color: #ffffff;
	background: rgba(255, 255, 255, 0.15);
	transform: translateY(-1px);
}

.ftt-tab-btn:active {
	transform: translateY(0);
}

.ftt-tab-btn.active {
	color: #ffffff;
	background: #0a3e78;
	font-weight: 600;
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
	position: relative;
}

/* เส้นขีดสีขาวใต้ tab ที่เลือก */
.ftt-tab-btn.active::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	width: 60%;
	height: 3px;
	background: linear-gradient(90deg, transparent 0%, #ffffff 50%, transparent 100%);
	border-radius: 2px 2px 0 0;
	animation: slideIn 0.3s ease-out;
	box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

@keyframes slideIn {
	from {
		width: 0;
		opacity: 0;
	}
	to {
		width: 60%;
		opacity: 1;
	}
}

.ftt-tab-btn:focus {
	outline: 2px solid var(--ftt-primary);
	outline-offset: 2px;
}

/* ============================================
   Tab Panels
   ============================================ */
.ftt-tabs-content {
	position: relative;
}

.ftt-tab-panel {
	display: none;
	animation: fadeInUp 0.4s ease-out;
}

.ftt-tab-panel.active {
	display: block;
}

@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ============================================
   Articles List
   ============================================ */
.ftt-articles-list {
	display: flex;
	flex-direction: column;
	gap: 1.2rem; /* Reduced gap */
	animation: fadeIn 0.5s ease-out;
}

/* Stagger Animation for Cards */
.ftt-articles-list .ftt-article-card {
	animation: slideInUp 0.5s ease-out backwards;
}

.ftt-articles-list .ftt-article-card:nth-child(1) {
	animation-delay: 0.1s;
}

.ftt-articles-list .ftt-article-card:nth-child(2) {
	animation-delay: 0.2s;
}

.ftt-articles-list .ftt-article-card:nth-child(3) {
	animation-delay: 0.3s;
}

.ftt-articles-list .ftt-article-card:nth-child(4) {
	animation-delay: 0.4s;
}

.ftt-articles-list .ftt-article-card:nth-child(5) {
	animation-delay: 0.5s;
}

@keyframes slideInUp {
	from {
		opacity: 0;
		transform: translateY(30px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ============================================
   Article Card (Compact & Wide Style)
   ============================================ */
.ftt-article-card {
	display: flex;
	gap: 1.2rem;
	padding: 1rem; /* Reduced padding */
	background: var(--ftt-bg);
	border: 1px solid var(--ftt-border);
	border-radius: var(--ftt-radius);
	transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
	position: relative;
	overflow: hidden;
	height: auto; /* Compact height */
	align-items: flex-start; /* Top align */
}

/* Subtle border gradient on hover */
.ftt-article-card::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	background: linear-gradient(90deg, #0a3e78 0%, #2298e0 100%);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.ftt-article-card:hover {
	box-shadow: 0 6px 16px rgba(0, 102, 204, 0.1);
	transform: translateY(-3px);
	border-color: var(--ftt-primary);
	background: var(--ftt-bg-light);
}

.ftt-article-card:hover::before {
	opacity: 1;
}

/* Thumbnail - Compact Size */
.ftt-article-thumbnail {
	flex: 0 0 160px; /* Reduced width */
	width: 160px;
	height: 120px; /* Fixed height for consistency */
	position: relative;
	overflow: hidden;
	border-radius: var(--ftt-radius);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
	transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ftt-article-thumbnail a {
	display: block;
	width: 100%;
	height: 100%;
	text-decoration: none;
	position: relative;
}

/* Gradient Overlay on Hover */
.ftt-article-thumbnail a::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(180deg, rgba(10, 62, 120, 0) 0%, rgba(10, 62, 120, 0.3) 100%);
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.ftt-article-card:hover .ftt-article-thumbnail a::after {
	opacity: 1;
}

.ftt-article-thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.ftt-article-card:hover .ftt-article-thumbnail {
	transform: scale(1.02);
	box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
}

.ftt-article-card:hover .ftt-article-thumbnail img {
	transform: scale(1.08);
}

/* Latest Badge - Smaller */
.ftt-latest-badge {
	position: absolute;
	top: 0.35rem;
	left: 0.35rem;
	background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
	color: white;
	padding: 0.25rem 0.6rem;
	border-radius: 15px;
	font-size: 0.65rem;
	font-weight: 700;
	z-index: 2;
	box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
	animation: pulse 2s ease-in-out infinite;
	letter-spacing: 0.5px;
}

@keyframes pulse {
	0%, 100% {
		transform: scale(1);
		box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
	}
	50% {
		transform: scale(1.05);
		box-shadow: 0 4px 12px rgba(239, 68, 68, 0.6);
	}
}

/* Article Content - Compact */
.ftt-article-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.25rem; /* Reduced gap significantly */
	justify-content: center;
}

.ftt-article-title {
	margin: 0 0 0.1rem 0; /* Reduced margin bottom */
	font-size: 1.1rem; /* Reduced font size */
	line-height: 1.3;
	font-weight: 600;
}

.ftt-article-title a {
	color: var(--ftt-text);
	text-decoration: none;
	transition: all 0.3s ease;
	display: inline-block;
	position: relative;
}

.ftt-article-title a::after {
	content: '';
	position: absolute;
	width: 0;
	height: 2px;
	bottom: -2px;
	left: 0;
	background: linear-gradient(90deg, #0a3e78 0%, #2298e0 100%);
	transition: width 0.3s ease;
}

.ftt-article-title a:hover {
	color: var(--ftt-primary);
	transform: translateX(4px);
}

.ftt-article-title a:hover::after {
	width: 100%;
}

.ftt-article-meta {
	color: var(--ftt-text-light);
	font-size: 0.8rem;
}

.ftt-article-meta time {
	display: inline-block;
	background: #f3f4f6;
	padding: 0.1rem 0.5rem;
	border-radius: 4px;
}

.ftt-article-excerpt {
	color: var(--ftt-text-light);
	font-size: 0.9rem;
	line-height: 1.5;
	margin-top: 0.1rem; /* Reduced margin top */
	display: -webkit-box;
	-webkit-line-clamp: 2; /* Limit to 2 lines */
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ============================================
   No Posts Message
   ============================================ */
.ftt-no-posts {
	text-align: center;
	padding: 3rem 1rem;
	color: var(--ftt-text-light);
	font-size: 1.125rem;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
	.ftt-homepage-tabs-wrapper {
		margin: 1rem auto;
		padding: 0 0.75rem;
	}
	
	.ftt-tabs-nav {
		gap: 0.25rem;
		margin-bottom: 1.5rem;
	}
	
	.ftt-tab-btn {
		padding: 0.625rem 1rem;
		font-size: 0.875rem;
	}
	
	.ftt-article-card {
		flex-direction: row; /* Keep horizontal on tablet */
		padding: 0.75rem;
		gap: 1rem;
	}
	
	.ftt-article-thumbnail {
		flex: 0 0 120px;
		width: 120px;
		height: 90px;
	}
	
	.ftt-article-title {
		font-size: 1rem;
	}
	
	.ftt-article-excerpt {
		font-size: 0.85rem;
		-webkit-line-clamp: 2;
	}
}

@media (max-width: 480px) {
	.ftt-tab-btn {
		padding: 0.5rem 0.75rem;
		font-size: 0.8125rem;
	}
	
	/* Mobile: Stack vertical or keep small horizontal? Let's keep small horizontal */
	.ftt-article-card {
		padding: 0.75rem;
		gap: 0.75rem;
	}

	.ftt-article-thumbnail {
		flex: 0 0 100px;
		width: 100px;
		height: 80px;
	}
	
	.ftt-article-title {
		font-size: 0.95rem;
		line-height: 1.3;
	}
	
	.ftt-article-excerpt {
		display: none; /* Hide excerpt on very small screens */
	}
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* Screen Reader Only */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

/* ============================================
   Loading State (Skeleton)
   ============================================ */
.ftt-loading-skeleton {
	display: flex;
	gap: 1.5rem;
	padding: 1.5rem;
	background: var(--ftt-bg);
	border-radius: var(--ftt-radius);
	animation: skeleton-loading 1.5s ease-in-out infinite;
}

.ftt-loading-skeleton .skeleton-thumbnail {
	width: 160px;
	height: 120px;
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	border-radius: var(--ftt-radius);
	animation: skeleton-shimmer 1.5s infinite;
}

.ftt-loading-skeleton .skeleton-content {
	flex: 1;
}

.ftt-loading-skeleton .skeleton-line {
	height: 16px;
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	border-radius: 4px;
	margin-bottom: 0.75rem;
	animation: skeleton-shimmer 1.5s infinite;
}

.ftt-loading-skeleton .skeleton-line:first-child {
	width: 80%;
}

.ftt-loading-skeleton .skeleton-line:nth-child(2) {
	width: 100%;
}

.ftt-loading-skeleton .skeleton-line:nth-child(3) {
	width: 90%;
}

@keyframes skeleton-shimmer {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}

/* ============================================
   Smooth Scroll Behavior
   ============================================ */
html {
	scroll-behavior: smooth;
}

/* ============================================
   Enhanced Focus States
   ============================================ */
.ftt-article-card:focus-within {
	outline: 2px solid var(--ftt-primary);
	outline-offset: 4px;
	border-radius: var(--ftt-radius);
}

.ftt-article-title a:focus {
	outline: 2px solid var(--ftt-primary);
	outline-offset: 4px;
	border-radius: 4px;
}
