/* Khối «Thẻ chi nhánh» (0483, mẫu B bỏ QR) — dựng từ phần tử sẵn có: khối from=the-chi-nhanh gồm 3 phần tử card,
   mỗi card = ảnh + tcn-diem + tcn-sao + tcn-dg + tcn-nhan (chữ có đường dẫn = bấm cả thẻ) + tcn-dc.
   Hiệu ứng do public/js/the-chi-nhanh.js (thêm lớp tcn--js / tcn--vao lên section); giảm chuyển động / tắt JS → hiện đủ.
   Màu bộ XMG: xanh #33421f/#485c2b, vàng #debd7c. */
section[data-from="the-chi-nhanh"], section.xb--tcn-nguon { --tcn-xanh: #33421f; --tcn-xanh2: #485c2b; --tcn-vang: #debd7c; --tcn-muc: #232b18; --tcn-sao: #f2b01e; }
section[data-from="the-chi-nhanh"] .xb__inner { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; align-items: stretch; }
section[data-from="the-chi-nhanh"] .xb__inner > .el { margin: 0; min-width: 0; }

/* thẻ */
.tcn-the { position: relative; min-height: 336px; padding: 16px 14px 0 16px !important; border-radius: 14px; overflow: hidden; background: var(--tcn-xanh2); border: 1.5px solid rgba(222, 189, 124, .75);
  color: #fff; display: flex; flex-direction: column; align-items: flex-start; gap: 0; box-shadow: 0 18px 34px -16px rgba(30,41,16,.55), 0 2px 6px rgba(30,41,16,.12); text-align: left; }
.tcn-the > .el { margin: 0; width: auto; max-width: 100%; position: relative; z-index: 2; }
/* ảnh nền phủ cả thẻ, chừa dải địa chỉ 38px */
.tcn-the > .el--image * { height: 100%; }
.tcn-the > .el--image { position: absolute; inset: 0 0 38px 0; z-index: 0; width: auto; max-width: none; }
.tcn-the > .el--image .el__image, .tcn-the > .el--image .el__imagelink { height: 100%; width: 100%; border-radius: 0; aspect-ratio: auto; }
.tcn-the > .el--image img { width: 100%; height: 100%; object-fit: cover; object-position: 70% 50%; display: block; border-radius: 0; aspect-ratio: auto; }
.tcn-the > .el--image::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(30,41,16,.94) 0%, rgba(30,41,16,.82) 40%, rgba(30,41,16,.1) 62%, transparent 100%); }
.tcn-the > .el--image .el__caption { display: none; }

.tcn-the .el__text { color: inherit; max-width: none; white-space: normal; margin: 0; }
.tcn-diem { padding-left: 38px; min-height: 44px; display: flex; align-items: center;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23EA4335' d='M12 2a7 7 0 0 0-7 7c0 5.2 7 13 7 13s7-7.8 7-13a7 7 0 0 0-7-7z'/%3E%3Ccircle cx='12' cy='9' r='2.6' fill='%23fff'/%3E%3C/svg%3E") no-repeat left center / 30px 30px; }
.tcn-diem .el__text { font-family: var(--font-serif-brand, "Lora", Georgia, serif); font-size: 2.6rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
/* «chờ số» (nội dung không có chữ số — lớp tcn-cho do the-chi-nhanh.js gắn tự động) → chữ nhỏ */
.tcn-diem.tcn-cho .el__text { font-size: 1.05rem; font-weight: 600; letter-spacing: .02em; opacity: .85; font-family: inherit; }
.tcn-sao .el__text { font-size: 1.15rem; letter-spacing: 2px; line-height: 1.4; min-height: 1.4em; white-space: nowrap; margin-top: 4px;
  background: linear-gradient(90deg, var(--tcn-sao) 0 50%, rgba(128,128,110,.35) 50% 100%) 0 0 / 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; background-position: 0 0; }
.tcn-dg .el__text { font-size: .82rem; font-weight: 600; margin: 2px 0 10px; color: #f3efe1; line-height: 1.4; }
/* danh hiệu (0505): ô chữ riêng giữa dòng đánh giá và nút tên — nền vàng ấm, viền #A8792C, chữ nâu đậm (≥ 4,5:1), to hơn dòng đánh giá.
   Rỗng ở tiếng đang hiện → JS gắn tcn-trong → ẩn cả khung (đang sửa thì vẫn hiện khung nét đứt để còn gõ vào). */
.tcn-the { --tcn-dh-chu: #3b2a08; --tcn-dh-nen: #f6e7b8; }
/* 0523: khối NHỎ bên trái, HAI DÒNG trong MỘT phần tử chữ (dữ liệu «dòng 1⏎dòng 2», Sếp sửa cả hai trong trình sửa; xuống dòng do `white-space: pre-line`
   của `.el__text [data-locale]` trong xmg.css). Dòng 1 = ::first-line (to, đậm); dòng 2 = chữ nhỏ. Rộng vừa chữ, tối đa ~⅓–½ thẻ để lộ ảnh quán bên phải. */
/* Trần bề ngang đặt ở `.tcn-the > .tcn-dh` (mạnh bằng `.tcn-the > .el` mà nằm sau → thắng max-width:100%). KHÔNG dựa vào `fit-content`: trình duyệt đo bề ngang
   «vừa chữ» theo cỡ chữ ::first-line cho CẢ khối (đo 0523: 230px dù chữ dòng 2 chỉ 135px) → để `auto` + trần 52% của phần ruột thẻ (≈ 0,48 bề ngang thẻ; điện thoại 64%), khối ra cùng một cỡ ở cả 3 thẻ / 4 tiếng. */
/* Khối ôm sát BA dòng «TOP #n» / «Tripadvisor» / «tháng/năm», chữ canh giữa. Bề ngang cố định 7,4rem đo từ chữ dài nhất 4 tiếng
   (đổi chữ hay thêm tiếng thì đo lại); không dùng fit-content — bẫy 0523. */
.tcn-the > .tcn-dh { width: 7.4rem; max-width: 100%; box-sizing: border-box; display: flex; align-items: center; justify-content: center; text-align: center; }
.tcn-dh { margin: 2px 0 12px !important; padding: 5px 10px; border-radius: 10px; border: 2px solid #A8792C; background: linear-gradient(135deg, #fbf0cc, var(--tcn-dh-nen)); box-shadow: 0 4px 12px rgba(0,0,0,.35); }
.tcn-dh .el__text { font-size: .78rem; font-weight: 600; line-height: 1.3; color: var(--tcn-dh-chu); word-break: keep-all; text-align: center; width: 100%; }
.tcn-dh .el__text::first-line { font-size: 1.1rem; font-weight: 800; line-height: 1.3; }
.tcn-dh.tcn-trong { display: none; }
body.xmg-edit-on .tcn-dh.tcn-trong { display: block; min-height: 40px; border-style: dashed; opacity: .75; }
/* 0679 (tờ 0075): người đăng nhập KHÔNG bật sửa cũng thấy ô trống (khách không có data-can-edit nên vẫn không thấy) — lớp phủ
   public/js/lop-tu-an.js làm mờ + ghi «Đang ẩn với khách · Ô danh hiệu chưa điền tiếng …». */
body[data-can-edit]:not(.xmg-edit-on) .tcn-dh.tcn-trong { display: block; min-height: 40px; border-style: dashed; }
.tcn-nhan { margin-top: auto !important; margin-bottom: 52px !important; padding: 7px 18px; border-radius: 8px; align-self: flex-start;
  background: linear-gradient(110deg, transparent 38%, rgba(255,255,255,.8) 50%, transparent 62%) -160% 0 / 250% 100% no-repeat, linear-gradient(135deg, #f0d9a0, #debd7c 45%, #c79d4d);
  color: var(--tcn-muc); box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.tcn-nhan .el__text { font-family: var(--f-heading, "Lora", Georgia, serif); font-weight: 800; font-size: 1.15rem; letter-spacing: .05em; color: var(--tcn-muc); line-height: 1.3; }
.tcn-nhan .el__textlink { color: inherit; text-decoration: none; }
/* bấm chỗ nào trên thẻ cũng đi: public/js/the-chi-nhanh.js chuyển cú bấm sang đường dẫn của tên (không dùng lớp phủ ::after — nó chặn rê chuột lên ảnh) */
.tcn-the { cursor: pointer; }
.xmg-edit-on .tcn-the { cursor: auto; }
.tcn-nhan .el__textlink:focus-visible { outline: none; }
.tcn-the:has(.tcn-nhan .el__textlink:focus-visible) { outline: 3px solid var(--tcn-vang); outline-offset: -3px; }
.tcn-dc { position: absolute !important; left: 0; right: 0; bottom: 0; height: 38px; padding: 0 14px; display: flex; align-items: center; background: var(--tcn-xanh2); overflow: hidden; }
.tcn-dc .el__text { font-size: .85rem; font-weight: 600; color: #f7f3e6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; line-height: 1.2; }

/* ---------- hiệu ứng (chỉ khi JS thêm tcn--js; giảm chuyển động thì JS không thêm) ---------- */
.tcn--js:not(.tcn--vao) .tcn-the { opacity: 0; transform: translateY(34px); }
.tcn--js .tcn-the { transition: opacity .7s ease, transform .7s cubic-bezier(.2,.8,.2,1), box-shadow .3s ease; }
.tcn--js .tcn-the:nth-child(2) { transition-delay: .16s; }
.tcn--js .tcn-the:nth-child(3) { transition-delay: .32s; }
.tcn--js.tcn--vao .tcn-the { opacity: 1; transform: none; }
/* 5 sao sáng lần lượt từ trái qua phải (quét nền chữ) */
.tcn--js:not(.tcn--vao) .tcn-sao .el__text { background-position: 100% 0; }
.tcn--js.tcn--vao .tcn-sao .el__text { animation: tcn-sao-sang 1s steps(5, end) both; }
.tcn--js.tcn--vao .tcn-the:nth-child(1) .tcn-sao .el__text { animation-delay: .5s; }
.tcn--js.tcn--vao .tcn-the:nth-child(2) .tcn-sao .el__text { animation-delay: .66s; }
.tcn--js.tcn--vao .tcn-the:nth-child(3) .tcn-sao .el__text { animation-delay: .82s; }
@keyframes tcn-sao-sang { from { background-position: 100% 0; } to { background-position: 0 0; } }
/* ánh sáng lướt qua nhãn tên một lần */
.tcn--js.tcn--vao .tcn-nhan { animation: tcn-luot 1.3s ease 1.1s 1 both; }
.tcn--js.tcn--vao .tcn-the:nth-child(2) .tcn-nhan { animation-delay: 1.26s; }
.tcn--js.tcn--vao .tcn-the:nth-child(3) .tcn-nhan { animation-delay: 1.42s; }
@keyframes tcn-luot { from { background-position: -160% 0, 0 0; } to { background-position: 260% 0, 0 0; } }

@media (hover: hover) {
  .tcn--js .tcn-the:hover, .tcn-the:hover { transform: translateY(-8px) !important; transition-delay: 0s !important; }
  .tcn-the > .el--image img { transition: transform .6s cubic-bezier(.2,.8,.2,1); }
  .tcn-the:hover > .el--image img { transform: scale(1.07); }
}
/* đang sửa: khỏi nổi / trồi (đừng để thẻ nhảy khi bấm chọn) */
.xmg-edit-on .tcn-the, .xmg-edit-on .tcn--js .tcn-the { transform: none !important; opacity: 1 !important; transition: none; }
/* trình sửa đặt `body.xmg-edit-on .el{position:relative}` (editor-ui.css, mạnh hơn) → ảnh mặt tiền rơi vào dòng chảy, thẻ cao thêm 57px khi ảnh về. Giữ ảnh nền tuyệt đối như trang thường. */
body.xmg-edit-on .tcn-the > .el--image { position: absolute; }
body.xmg-edit-on .tcn-the > .tcn-dc { position: absolute; }
@media (prefers-reduced-motion: reduce) {
  .tcn-the, .tcn-sao .el__text, .tcn-nhan { animation: none !important; transition: none !important; opacity: 1 !important; transform: none !important; }
  .tcn-sao .el__text { background-position: 0 0 !important; }
}

/* ---------- điện thoại: 3 thẻ vuốt ngang ---------- */
@media (max-width: 760px) {
  section[data-from="the-chi-nhanh"] .xb__inner { display: flex; width: 100%; overflow-x: auto; scroll-snap-type: x mandatory; gap: 14px; padding: 6px 20px 22px; scroll-padding-inline: 20px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  section[data-from="the-chi-nhanh"] .xb__inner::-webkit-scrollbar { display: none; }
  section[data-from="the-chi-nhanh"] .xb__inner > .tcn-the { flex: 0 0 82%; scroll-snap-align: center; }
}

/* ---------- 0572: khúc «Chi nhánh khác» ở trang chi nhánh = CÙNG kiểu thẻ, 2 thẻ còn lại, lấy từ khối thẻ của Trang chủ (app/Support/TheChiNhanhNguon.php) ----------
   Hai cột cùng cỡ với cột thẻ trang chủ (≈ 385px), canh giữa; điện thoại vuốt ngang như trang chủ. */
.tcn-nguon { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: stretch; margin: 32px auto 0; width: min(100% - (2 * var(--w-gutter, 20px)), 50rem); }
.xb--w-full .tcn-nguon { width: min(100% - (2 * var(--w-gutter, 20px)), 50rem); }
.tcn-nguon > .el { margin: 0; min-width: 0; }
/* phần tử đánh dấu: khách không thấy; đang sửa thì hiện dòng nhắc (xoá phần tử này = khối quay về khối thường) */
.tcn-nguon-dau { display: none; }
body.xmg-edit-on .tcn-nguon-dau { display: block; min-height: 0; margin: 4px 0 0; padding: 8px 12px; border: 1.5px dashed #6b8442; border-radius: 8px; background: #f3f6ec; color: #33421f; font-size: .85rem; line-height: 1.4; text-align: center; }
body.xmg-edit-on .tcn-nguon-dau::before { content: "Hai thẻ chi nhánh bên dưới lấy từ khối «Thẻ chi nhánh» ở Trang chủ — muốn đổi số sao, TOP, ảnh, địa chỉ thì sửa ở Trang chủ."; }
body.xmg-edit-on .tcn-nguon-dau > * { display: none; }
body.xmg-edit-on .tcn-nguon { pointer-events: none; }
@media (max-width: 760px) {
  .tcn-nguon { display: flex; width: 100%; overflow-x: auto; scroll-snap-type: x mandatory; gap: 14px; padding: 6px 20px 22px; scroll-padding-inline: 20px; -webkit-overflow-scrolling: touch; scrollbar-width: none; box-sizing: border-box; }
  .tcn-nguon::-webkit-scrollbar { display: none; }
  .tcn-nguon > .tcn-the { flex: 0 0 82%; scroll-snap-align: center; }
}
