/*
 * 2.320.0: lớp giao diện thích ứng mọi thiết bị (điện thoại nhỏ, điện thoại ngang, gập, máy tính bảng, laptop, màn hình rộng).
 * Nạp SAU frontend.css / home-redesign.css / home-v3.css. Chỉ bổ sung, không đổi thiết kế: các quy tắc nền dùng :where() (độ ưu tiên 0)
 * nên không ghi đè bất kỳ quy tắc có sẵn nào; chỉ các mốc màn hình mới (<=340px, >=1280px, >=1600px, >=2000px, ngang thấp) có độ ưu tiên thường.
 */

/* ---- 1. Nền chung: không tràn ngang, media co theo khung, chữ dài tự xuống dòng ---- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: clip; }                                   /* clip (không phải hidden) để header sticky vẫn hoạt động */
:where(.bods-main, .bods-footer, .bods-header) :where(img, video, canvas, iframe, embed, object) { max-width: 100%; }
:where(.bods-main) :where(img, video) { height: auto; }
:where(.bods-main, .bods-footer) :where(h1, h2, h3, h4, p, li, a, span, td, th) { overflow-wrap: break-word; }
:where(.bods-main) :where(pre, code) { max-width: 100%; overflow-x: auto; }

/* Bảng trong nội dung dài (mô tả, bài viết, SEO): cuộn ngang bên trong bảng, không đẩy rộng cả trang */
:where(.bods-description-content, .bods-seo-body, .bods-editorial, .bods-post-content, .entry-content) table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* ---- 2. Thiết bị cảm ứng: vùng chạm đủ lớn, bỏ trễ chạm, cuộn mượt ---- */
@media (pointer: coarse) {
	:where(.bods-main, .bods-header, .bods-footer) :where(button, [role="button"], select, input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="range"])) {
		min-height: 44px;
	}
	:where(.bods-main, .bods-header, .bods-footer) :where(a, button, [role="button"], label, summary) { touch-action: manipulation; }
	:where(.bods-main) :where(input, select, textarea) { font-size: max(16px, 1em); } /* iOS không tự phóng to khi chạm vào ô nhập */
}

/* ---- 3. Tai thỏ / viền cong / thanh điều hướng: chừa vùng an toàn (cần viewport-fit=cover, đã thêm ở meta) ---- */
@supports (padding: max(0px)) {
	body {
		padding-left: env(safe-area-inset-left, 0px);
		padding-right: env(safe-area-inset-right, 0px);
	}
	.bods-header { padding-top: env(safe-area-inset-top, 0px); }
	.bods-footer { padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px)); }
	.bods-vip2-float { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}

/* ---- 4. Điện thoại rất nhỏ (<= 340px: Galaxy Fold gập, iPhone SE đời đầu) ---- */
@media (max-width: 340px) {
	.bods-product-grid { gap: 6px; }
}

/* ---- 5. Điện thoại nằm ngang / màn hình thấp: header không chiếm chỗ khi cuộn ---- */
@media (max-height: 480px) and (orientation: landscape) {
	.bods-header { position: static; }
	html { scroll-padding-top: 12px; }
}

/* ---- 6. Màn hình rộng: tận dụng chiều ngang thay vì để trống hai bên ---- */
@media (min-width: 1600px) {
	.bods-container { width: min(1480px, calc(100% - 96px)); }
	.bods-product-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px; }
}
@media (min-width: 2000px) {
	.bods-container { width: min(1680px, calc(100% - 160px)); }
	.bods-product-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ---- 7. Người dùng chọn giảm chuyển động ---- */
@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto !important; }
}
