/* เฉพาะ cavfirst/ธง/พระพุทธ */
.cavfirst-page {
	padding: 40px;
}

.cavfirst-wrapper {
	max-width: 900px;
	margin-inline: auto;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 40px;
	align-items: start;
}

/* ภาพทั่วไปใน cavFirst */
.cavfirst-img {
	width: auto;
	height: auto;
	max-width: 100%;
	margin-inline: auto;
	padding: 8px;
	background-color: #FFFFFF;
	border: 1px solid #b8c7d6;
	border-radius: 6px;
}

/* ขนาดภาพธงใหม่ 426×332 */
.cavfirst-flag {
	width: 426px;
	height: auto; /* คงสัดส่วน */
}
/* ปรับ caption เฉพาะของภาพธง */
.cavfirst-col:has(.cavfirst-flag) .cavfirst-caption {
	margin-top: 6px; /* ลดช่องว่าง */
}
/* คอลัมน์ซ้าย–ขวาให้เหมือนกัน */
/*.cavfirst-col {
	max-width: 380px;
	margin-inline: auto;
	min-height: 360px;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	text-align: center; 
}*/

.caption-flag {
    margin-top: 16px;   /* ปรับเฉพาะภาพธง */
    line-height: 1.8;
}

.cavfirst-col {
    max-width: 380px;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    text-align: center;
}

.cavfirst-caption {
	line-height: 1.8;
	margin-top: 12px;
	max-width: 260px; /* จำกัดความกว้าง */
	margin-inline: auto; /* จัดให้อยู่กลาง */
	word-break: keep-all; /* ไม่ตัดคำไทยผิดตำแหน่ง */
}

/* กรอบสีเทา (ถ้าต้องการใช้) */
.gray-frame-cavfirst {
	border: 2px solid #cfcfcf;
	padding: 4px;
	background: #ffffff;
	border-radius: 6px;
}
/* โครงสร้างหลัก */
.cavfirst-page {
	padding: 40px;
}

.cavfirst-wrapper {
	max-width: 900px;
	margin-inline: auto;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 40px;
	align-items: start;
}

/* ภาพทั่วไป */
.cavfirst-img {
	width: auto;
	height: auto;
	max-width: 100%;
	margin-inline: auto;
	padding: 8px;
	background-color: #d7e3f0;
	border: 1px solid #b8c7d6;
	border-radius: 6px;
}

/* ภาพธง (426×332) */
.cavfirst-flag {
	width: 426px;
	max-width: 100%;
	height: auto;
}

/* Caption */
.cavfirst-caption {
	margin-top: 12px;
	line-height: 1.8;
	white-space: normal;
}

/* ========== Responsive ========== */

/* จอเล็กกว่า 768px → ซ้อนเป็น 1 คอลัมน์ */
@media (max-width: 768px) {
    .cavfirst-wrapper {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .cavfirst-flag {
        width: 100%;
        height: auto;
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    .cavfirst-col:has(.cavfirst-flag) .cavfirst-caption {
        margin-top: -10px; /* ดึงขึ้นเล็กน้อย */
        transform: none;
    }
}

/* สำหรับมือถือแนวนอน */
@media (max-width: 768px) and (orientation: landscape) {
    .cavfirst-col:has(.cavfirst-flag) .cavfirst-caption {
        margin-top: 12px;
        transform: none; /* ยกเลิกการดันขึ้น */
    }
}

