/**
 * LELAM · Tối ưu Mobile — TKT-008
 *
 * Mọi luật ở đây đều đứng sau một class của <body> (`lelam-mo--…`) do PHP gắn
 * theo công tắc trong trang cài đặt. Tắt công tắc là class biến mất và luật tự
 * vô hiệu — không cần sinh CSS động.
 *
 * Về !important: bộ block lelam-header và tệp lelam-custom.css của theme đang
 * dùng !important ở gần như mọi luật liên quan tới header. Muốn đè lên chúng thì
 * buộc phải dùng !important; bù lại mỗi selector đều có thêm một class ở <body>
 * nên độ ưu tiên luôn cao hơn bản gốc, không phụ thuộc thứ tự nạp tệp.
 *
 * Mốc mobile 781px trùng với mốc theme và bộ block đang dùng (xem hằng số
 * LELAM_MO_BREAKPOINT).
 */

/* ══════════════════════════════════════════════════════════════════════════
   1. ẨN KHU VỰC NGÔN NGỮ & QUỐC GIA (mọi màn hình)
   "Ẩn khu vực ngôn ngữ và quốc gia nhé, cái này ở giai đoạn này chưa làm
    (ở tất cả màn hình)"

   Khối này là ô đầu tiên trong lưới footer của khối lelam/footer.
   ══════════════════════════════════════════════════════════════════════════ */

body.lelam-mo--hide-locale .lelam-footer__locale {
	display: none !important;
}

/* Lưới footer khai báo cứng 5 cột: ngôn ngữ · liên hệ · menu 1 · menu 2 ·
   newsletter. Bỏ ô đầu mà không sửa lưới thì 4 ô còn lại dồn sang trái và cột
   thứ 5 bỏ trống — nhìn như footer bị lệch. Khai báo lại đúng 4 cột, giữ nguyên
   tỉ lệ gốc của từng ô còn lại. */
body.lelam-mo--hide-locale .wp-block-lelam-footer.lelam-footer .lelam-footer__main {
	grid-template-columns:
		minmax(220px, 1.75fr)
		minmax(120px, 1fr)
		minmax(120px, 1fr)
		minmax(260px, 2fr) !important;
}

/* Hai mốc dưới đây bản thân footer đã có; lặp lại vì luật 4 cột ở trên nằm ngoài
   media query nên nếu không chặn, nó sẽ đè cả hai. */
@media (max-width: 1024px) {
	body.lelam-mo--hide-locale .wp-block-lelam-footer.lelam-footer .lelam-footer__main {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}

@media (max-width: 640px) {
	body.lelam-mo--hide-locale .wp-block-lelam-footer.lelam-footer .lelam-footer__main {
		grid-template-columns: 1fr !important;
	}
}

/* ══════════════════════════════════════════════════════════════════════════
   2. THANH HEADER Ở ĐIỆN THOẠI — HẾT CHỒNG CHỮ
   Ảnh khách gửi: logo "LELAM" đè lên chữ "SEARCH".

   Nguyên nhân: ở mobile theme chuyển header sang flex rồi căn giữa logo bằng
   position:absolute + left:50%. Logo không còn chiếm chỗ trong hàng, nên trình
   duyệt không biết là nó đang đè lên cụm SEARCH · ACCOUNT bên phải.

   Cách sửa: trả logo về đúng một ô của lưới 3 cột `1fr auto 1fr`. Hai cột hai
   bên rộng bằng nhau nên logo vẫn nằm chính giữa thanh, nhưng lần này nó có chỗ
   thật — chồng chữ trở thành chuyện không thể xảy ra, ở mọi bề rộng máy.
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 781px) {
	body.lelam-mo--header .wp-block-lelam-header.lelam-header {
		display: grid !important;
		grid-template-columns: 1fr auto 1fr !important;
		align-items: center !important;
		column-gap: 8px !important;
	}

	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__logo {
		position: static !important;
		top: auto !important;
		left: auto !important;
		transform: none !important;
		justify-self: center !important;
		pointer-events: auto !important;
		min-width: 0 !important;
	}

	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__nav {
		justify-self: start !important;
		min-width: 0 !important;
	}

	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__actions {
		justify-self: end !important;
		flex-wrap: nowrap !important;
		gap: 0.75rem !important;
		min-width: 0 !important;
	}

	/* "Chữ search ở góc nhé" — cụm bên phải giờ chỉ còn SEARCH (và giỏ hàng nếu
	   bật), nên hạ một nấc cỡ chữ cho gọn góc. Theme đang ép 15px !important ở
	   `body .wp-block-lelam-header…`; selector này thêm một class ở <body> nên
	   thắng về độ ưu tiên. */
	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__actions,
	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__actions a,
	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__actions button {
		font-size: 13px !important;
		white-space: nowrap !important;
	}

	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__logo img {
		width: 92px !important;
		max-width: 100% !important;
		height: auto !important;
	}
}

/* Máy nhỏ (iPhone SE, 320–375px): bóp thêm một nấc nữa. */
@media (max-width: 380px) {
	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__actions,
	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__actions a,
	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__actions button {
		font-size: 12px !important;
		letter-spacing: 0.04em !important;
	}

	body.lelam-mo--header .wp-block-lelam-header.lelam-header .lelam-header__logo img {
		width: 78px !important;
	}
}

/* ── ACCOUNT nằm dưới đáy panel menu ────────────────────────────────────────
   "Chắc account cho vào trong menu ở mobile."

   JS di chuyển chính thẻ ACCOUNT (không nhân bản) xuống đáy panel, nên nếu JS
   không chạy được thì link vẫn còn nguyên trên thanh header — hỏng nhẹ chứ
   không mất chức năng. Vì thế ở đây KHÔNG có luật display:none cho ACCOUNT. */
.lelam-mo-panel-foot {
	display: none;
}

@media (max-width: 781px) {
	body.lelam-mo--header .lelam-mega__panel .lelam-mo-panel-foot {
		display: flex;
		align-items: center;
		gap: 1rem;
		/* Panel là flex column: margin-top:auto đẩy cụm này xuống đáy, dù nội
		   dung menu ngắn hay dài. */
		margin-top: auto;
		padding: 1.1rem clamp(1.25rem, 5vw, 2rem) 1.5rem;
		border-top: 1px solid rgba(0, 0, 0, 0.08);
		flex: 0 0 auto;
	}

	body.lelam-mo--header .lelam-mo-panel-foot .lelam-header__account {
		display: block !important;
		margin: 0 !important;
	}

	body.lelam-mo--header .lelam-mo-panel-foot a {
		color: inherit;
		font-size: 14px;
		text-decoration: none;
		text-transform: uppercase;
		letter-spacing: 0.08em;
	}
}

/* ══════════════════════════════════════════════════════════════════════════
   3. PANEL MENU Ở ĐIỆN THOẠI — HẾT TRÀN HAI CỘT VÀO NHAU
   "Kiểm tra lại style ở mobile với menu panel hiện đang hiển thị tràn vào
    với nhau."

   Panel gốc dựng theo kiểu hai cột: nhãn tab xếp dọc thành một dải bên trái,
   còn danh sách link của tab đang mở thì position:absolute, lùi vào đúng bề
   rộng dải ấy (--lelam-rail). Ở điện thoại dải chỉ còn 120–150px trong khi nhãn
   "NEW COLLECTION" đã dài hơn thế, nên chữ của hai cột nằm đè lên nhau.

   Ở bề ngang một chiếc điện thoại thì hai cột vốn không đủ chỗ. Nên thay vì
   cưỡng ép, panel chuyển hẳn sang accordion dọc: bấm nhãn nào thì danh sách của
   nhãn ấy mở ra ngay bên dưới. Không còn cột thứ hai thì cũng không còn gì để
   tràn vào nhau, và thao tác trùng với cái người dùng vẫn quen ở menu điện thoại.
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 781px) {
	body.lelam-mo--panel .lelam-mega__panel {
		width: 100% !important;
	}

	/* Hàng SHOP · ABOUT · BRANDS · GALLERY ở đầu panel: cho xuống dòng gọn gàng
	   và giữ nút đóng luôn dính mép phải. */
	body.lelam-mo--panel .lelam-mega__panel-head {
		align-items: flex-start;
		gap: 0.75rem;
		padding: 1rem clamp(1.25rem, 5vw, 2rem) !important;
	}

	body.lelam-mo--panel .lelam-mega__panel-nav {
		flex: 1 1 auto;
		min-width: 0;
		gap: 0.4rem 1.1rem !important;
	}

	body.lelam-mo--panel .lelam-mega__panel-nav-item {
		font-size: 0.95rem !important;
	}

	body.lelam-mo--panel .lelam-mega__close {
		flex: 0 0 auto;
	}

	/* Thân panel: bỏ dải cột trái, các tab xếp dọc thành accordion. */
	body.lelam-mo--panel .lelam-mega__tabs {
		display: block !important;
		padding: 0.25rem clamp(1.25rem, 5vw, 2rem) 1.5rem !important;
	}

	body.lelam-mo--panel .lelam-mega-tab {
		display: block;
		border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	}

	body.lelam-mo--panel .lelam-mega-tab__label {
		display: flex !important;
		width: 100% !important;
		align-items: center;
		justify-content: space-between;
		margin: 0 !important;
		padding: 0.95rem 0 !important;
		border-bottom: 0 !important;
		opacity: 1 !important;
		text-align: left;
	}

	/* Mũi chevron báo đóng/mở. Vẽ bằng hai cạnh viền nên không phải nạp icon. */
	body.lelam-mo--panel .lelam-mega-tab__label::after {
		content: "";
		flex: 0 0 auto;
		width: 7px;
		height: 7px;
		margin-left: 1rem;
		border-right: 1px solid currentColor;
		border-bottom: 1px solid currentColor;
		opacity: 0.5;
		transform: translateY(-2px) rotate(45deg);
		transition: transform 0.25s ease, opacity 0.25s ease;
	}

	body.lelam-mo--panel .lelam-mega-tab.is-active .lelam-mega-tab__label::after {
		opacity: 1;
		transform: translateY(2px) rotate(-135deg);
	}

	/* Danh sách link: trả về dòng chảy bình thường (bỏ position:absolute) rồi
	   đóng/mở bằng max-height.

	   Bản gốc để tab không mở ở opacity:0 + visibility:hidden; giữ nguyên hai
	   thuộc tính ấy là đủ để nó tàng hình, còn max-height:0 lo phần "không chiếm
	   chỗ". Chỉ cần khai báo lại transition cho có cả hai. */
	body.lelam-mo--panel .lelam-mega-tab__content {
		position: static !important;
		top: auto !important;
		left: auto !important;
		right: auto !important;
		max-height: 0 !important;
		overflow: hidden !important;
		flex-wrap: nowrap !important;
		gap: 0 !important;
		transition: max-height 0.3s ease, opacity 0.25s ease !important;
	}

	body.lelam-mo--panel .lelam-mega-tab.is-active .lelam-mega-tab__content {
		max-height: 60vh !important;
		overflow-y: auto !important;
		padding-bottom: 0.8rem !important;
	}

	/* Vùng chạm tối thiểu ~40px cho từng link. */
	body.lelam-mo--panel .lelam-mega-tab__content .lelam-mega-tab__link {
		padding: 0.55rem 0 !important;
		white-space: normal !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	body.lelam-mo--panel .lelam-mega-tab__content,
	body.lelam-mo--panel .lelam-mega-tab__label::after {
		transition: none !important;
	}
}

/* ══════════════════════════════════════════════════════════════════════════
   4. DROPDOWN BRANDS ĐỒNG BỘ VỚI LUỒNG MENU SHOP (chỉ mobile)
   "Đoạn này về lý khi ấn Brands phải dropdown nhưng vì có menu shop đã toggle
    nên không thấy gì cả? hãy chỉnh lại cho đồng bộ với luồng Menu shop
    (dành cho bản mobile thôi nhé)."

   BRANDS là submenu của core/navigation, mở ra bằng hover ở desktop. Ở mobile
   theme ẩn mọi nav item ngoài SHOP, nên cái dropdown ấy không còn chỗ nào để
   hiện — bấm vào thì "không thấy gì cả".

   JS dựng lại danh sách link của nó thành một khối ngay trong panel. Bấm BRANDS
   trên hàng đầu panel thì thân panel đổi từ các tab của SHOP sang danh sách
   BRANDS; bấm SHOP thì quay lại. Cùng một panel, cùng một luồng — đúng như
   khách mô tả. Ở desktop khối này không bao giờ hiện, BRANDS vẫn hover như cũ.
   ══════════════════════════════════════════════════════════════════════════ */

.lelam-mo-subnav {
	display: none;
}

@media (max-width: 781px) {
	body.lelam-mo--subnav .lelam-mo-subnav.is-active {
		display: flex;
		flex-direction: column;
		flex: 1 1 auto;
		padding: 0.25rem clamp(1.25rem, 5vw, 2rem) 1.5rem;
	}

	/* Đang xem một nhánh submenu thì giấu các tab của SHOP đi — hai thứ dùng
	   chung một chỗ trong panel, đúng nghĩa "đồng bộ luồng". */
	body.lelam-mo--subnav .lelam-mega__panel.lelam-mo-panel--subnav .lelam-mega__tabs {
		display: none !important;
	}

	body.lelam-mo--subnav .lelam-mo-subnav__link {
		display: block;
		padding: 0.85rem 0;
		border-bottom: 1px solid rgba(0, 0, 0, 0.08);
		color: inherit;
		font-size: 14px;
		font-weight: 400;
		letter-spacing: 0.02em;
		text-decoration: none;
		text-transform: uppercase;
		opacity: 0.85;
	}

	body.lelam-mo--subnav .lelam-mo-subnav__link:hover,
	body.lelam-mo--subnav .lelam-mo-subnav__link:focus-visible {
		opacity: 1;
	}

	/* Link tới chính trang cha (ví dụ trang BRANDS) đứng đầu danh sách, đậm hơn
	   một chút để phân biệt với các mục con. */
	body.lelam-mo--subnav .lelam-mo-subnav__link--all {
		opacity: 1;
	}
}

/* ══════════════════════════════════════════════════════════════════════════
   5. HIỆU ỨNG REVEAL LÀM TRANG TRƯỢT NGANG Ở ĐIỆN THOẠI
   Không nằm trong 4 ý khách note, mà thuộc phần "ngoài những chỗ em note anh
   cứ thấy cái gì đang chưa ổn anh tinh chỉnh thêm nha".

   Trang /about/ ở khổ 390px kéo ngang được 27px. Thủ phạm là trạng thái CHỜ của
   hiệu ứng reveal trong theme:

       .lelam-reveal--drift-right { transform: translate3d(58px, 20px, 0); }

   Ở desktop khối chữ có lề hai bên nên 58px ấy nằm gọn trong lề. Ở điện thoại
   khối chữ gần như tràn hết bề ngang, nên 58px đẩy nó vượt mép phải và trình
   duyệt sinh thanh cuộn ngang. Khối nào chưa lọt vào tầm nhìn thì còn nằm
   nguyên ở trạng thái ấy, nên thanh cuộn tồn tại suốt.

   Cách sửa: ở điện thoại bỏ thành phần ngang của quãng trôi, giữ nguyên thành
   phần dọc. Hiệu ứng vẫn "trôi vào" đúng tinh thần, chỉ là trôi từ dưới lên
   thay vì từ bên cạnh — hướng mà màn hình dọc thừa chỗ.

   `:not(.is-inview)` là bắt buộc: lớp `.is-inview` (theme gắn khi khối lọt vào
   tầm nhìn) đặt `transform: none` ở độ ưu tiên thấp hơn luật này, không loại trừ
   thì khối sẽ kẹt lại cách chỗ đúng 28px và không bao giờ về vị trí.

   Selector bắt đầu bằng `.lelam-motion` vì class ấy nằm trên <html> — tổ tiên
   của <body>, không phải con cháu.
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 781px) {
	.lelam-motion body.lelam-mo--reveal .lelam-reveal--drift-left:not(.is-inview),
	.lelam-motion body.lelam-mo--reveal .lelam-reveal--drift-right:not(.is-inview) {
		transform: translate3d(0, 28px, 0);
	}
}
