/* ==========================================================================
   the-xuat-xu.css — Khối bổ sung · Thẻ nguồn gốc cuộn hiện dần (ngành thực phẩm, đặc sản, nông sản)
   the-xuat-xu.js tự chèn file này nếu trang chưa có. Muốn trang không nháy bố cục lúc tải thì đặt sẵn trong <head>,
   ngay sau khoi.css:   <link rel="stylesheet" href="/ai-web-kit/demo/_loi/khoi/the-xuat-xu.css">
   Tấm tem luôn là "giấy in sáng" (như nhãn thật dán trên bao bì) nên đọc tốt trên cả trang nền sáng lẫn nền tối.
   Mẫu đổi màu tem bằng cách ghi đè các biến --xx-* trên .the-xuat-xu, không sửa file này.
   Tương phản mặc định (đo 22/9/2026): chữ 15,6:1 · nhãn dòng 7,1:1 · màu tem 5,9:1 trên giấy #FBF7EE.
   Trạng thái (JS đặt): --chay = đang cho hiện dần · .dang-hien = dòng đã in · --dong-dau = con dấu đã đóng.
   Không JS / giảm chuyển động / ?cap=tinh → mọi dòng hiện đủ, đường chỉ vẽ trọn, con dấu nằm sẵn.
   ========================================================================== */

.the-xuat-xu {
  --xx-giay: #FBF7EE;                  /* nền tem */
  --xx-muc: #1F1D19;                   /* chữ giá trị */
  --xx-muc-phu: #595347;               /* nhãn dòng (Vùng nguyên liệu, Ngày sản xuất…) */
  --xx-nhan: #8C5A1C;                  /* màu tem: chấm, đường chỉ, con dấu */
  --xx-tren-nhan: #FBF7EE;             /* biểu tượng trên chấm đã tô */
  --xx-vien: rgba(31, 29, 25, .18);
  --xx-font: var(--font-tieu-de);
  --xx-dam: 600;
  --xx-bo-goc: 18px;
  --xx-dem: clamp(1.25rem, 1rem + 1.2vw, 2rem);
  --xx-bong: drop-shadow(0 26px 34px rgba(6, 10, 16, .42));
  --xx-cham: 30px;                     /* cỡ chấm trên đường chỉ */
  --xx-cham-tam: 29px;                 /* từ đỉnh dòng tới tâm chấm = đệm trên + nửa chấm */
  --xx-khac: 5.75rem;                  /* vị trí hai khấc vé (JS đo lại theo phần đầu thẻ) */
  position: relative;
  max-width: 36rem;
  filter: var(--xx-bong);
}

/* ---------------------------------------------------------------- tấm tem */
.the-xuat-xu__the {
  position: relative;
  padding: var(--xx-dem);
  border-radius: var(--xx-bo-goc);
  background: var(--xx-giay);
  color: var(--xx-muc);
}
/* Hai khấc kiểu vé ở ngang đường răng cưa — chỉ khi thẻ có phần đầu */
.the-xuat-xu__the:has(> .the-xuat-xu__dau), .the-xuat-xu__the.the-xuat-xu__the--co-dau {
  -webkit-mask:
    radial-gradient(circle 11px at 0 var(--xx-khac), #0000 97%, #000 100%) left / 51% 100% no-repeat,
    radial-gradient(circle 11px at 100% var(--xx-khac), #0000 97%, #000 100%) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle 11px at 0 var(--xx-khac), #0000 97%, #000 100%) left / 51% 100% no-repeat,
    radial-gradient(circle 11px at 100% var(--xx-khac), #0000 97%, #000 100%) right / 51% 100% no-repeat;
}
.the-xuat-xu__dau {
  display: grid; gap: .35rem;
  padding: 0 5.5rem 1.1rem 0;          /* chừa góc phải cho con dấu */
  margin-bottom: .35rem;
  border-bottom: 2px dashed var(--xx-vien);
}
.the-xuat-xu__nhan {
  font-size: .72rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--xx-nhan);
}
.the-xuat-xu__ten {
  font-family: var(--xx-font); font-weight: var(--xx-dam);
  font-size: clamp(1.2rem, 1.05rem + .6vw, 1.5rem); line-height: 1.25; letter-spacing: -.01em;
  text-wrap: balance;
}

/* ---------------------------------------------------------------- các dòng + đường chỉ */
.the-xuat-xu__ds { position: relative; margin: 0; }
.the-xuat-xu__ds::before, .the-xuat-xu__ds::after {
  content: ""; position: absolute; left: calc(var(--xx-cham) / 2 - 1px); width: 2px;
  top: var(--xx-duong-dau, var(--xx-cham-tam));
  height: var(--xx-duong-dai, calc(100% - 2 * var(--xx-cham-tam)));
  pointer-events: none;
}
.the-xuat-xu__ds::before {             /* đường chỉ mờ (nét đứt) */
  background: repeating-linear-gradient(to bottom, var(--xx-vien) 0 5px, transparent 5px 9px);
}
.the-xuat-xu__ds::after {              /* phần chỉ đã "in" */
  background: var(--xx-nhan);
  transform-origin: 50% 0; transform: scaleY(var(--xx-tien, 1));
}
.the-xuat-xu__dong {
  position: relative;
  padding: 14px 0 14px calc(var(--xx-cham) + .95rem);
}
.the-xuat-xu__dong:not([hidden]) ~ .the-xuat-xu__dong { border-top: 1px solid var(--xx-vien); }
.the-xuat-xu__dong::before, .the-xuat-xu__dong::after {    /* chấm + biểu tượng loại dòng */
  content: ""; position: absolute; left: 0; top: calc(var(--xx-cham-tam) - var(--xx-cham) / 2);
  width: var(--xx-cham); height: var(--xx-cham); border-radius: 50%;
}
.the-xuat-xu__dong::before { z-index: 1; background: var(--xx-nhan); box-shadow: 0 0 0 1.5px var(--xx-nhan); }
.the-xuat-xu__dong::after {
  z-index: 2; background: var(--xx-tren-nhan);
  -webkit-mask: var(--xx-bieu-tuong) center / 17px 17px no-repeat;
  mask: var(--xx-bieu-tuong) center / 17px 17px no-repeat;
}
.the-xuat-xu__dong > dt {
  font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; line-height: 1.5;
  color: var(--xx-muc-phu);
}
.the-xuat-xu__dong > dd {
  margin: .2rem 0 0;
  font-family: var(--xx-font); font-weight: var(--xx-dam);
  font-size: clamp(1rem, .96rem + .25vw, 1.14rem); line-height: 1.42;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.the-xuat-xu__dong > dd > .the-xuat-xu__gia-tri { display: block; }
.the-xuat-xu__chu-thich {
  margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--xx-vien);
  font-size: .8rem; line-height: 1.55; color: var(--xx-muc-phu); text-wrap: pretty;
}

/* Biểu tượng theo loại dòng (vẽ bằng mặt nạ nên tự theo màu tem) */
.the-xuat-xu__dong { --xx-bieu-tuong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4' fill='black'/%3E%3C/svg%3E"); }
.the-xuat-xu__dong[data-loai="vung"] { --xx-bieu-tuong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s-6.5-6-6.5-11a6.5 6.5 0 0 1 13 0c0 5-6.5 11-6.5 11Z'/%3E%3Ccircle cx='12' cy='10' r='2.3'/%3E%3C/svg%3E"); }
.the-xuat-xu__dong[data-loai="nguoi"] { --xx-bieu-tuong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='7.5' r='3.3'/%3E%3Cpath d='M5.5 20.5c.5-4 3.2-6.4 6.5-6.4s6 2.4 6.5 6.4'/%3E%3C/svg%3E"); }
.the-xuat-xu__dong[data-loai="ngay"] { --xx-bieu-tuong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5.5' width='16' height='15' rx='2.2'/%3E%3Cpath d='M4 10.5h16M8.5 3.5v4M15.5 3.5v4'/%3E%3C/svg%3E"); }
.the-xuat-xu__dong[data-loai="han"] { --xx-bieu-tuong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 3.5h11M6.5 20.5h11M8 3.5c0 4.2 4 5 4 8.5s-4 4.3-4 8.5M16 3.5c0 4.2-4 5-4 8.5s4 4.3 4 8.5'/%3E%3C/svg%3E"); }
.the-xuat-xu__dong[data-loai="chung-nhan"] { --xx-bieu-tuong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='9.5' r='5.8'/%3E%3Cpath d='m9.4 9.6 1.8 1.8 3.4-3.4M8.6 14.6 7.4 21l4.6-2.4 4.6 2.4-1.2-6.4'/%3E%3C/svg%3E"); }
.the-xuat-xu__dong[data-loai="mua"] { --xx-bieu-tuong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 19.5C5 11 10.5 5 19.5 5c0 9-6 14.5-14.5 14.5Z'/%3E%3Cpath d='M5 19.5 13.5 11'/%3E%3C/svg%3E"); }
.the-xuat-xu__dong[data-loai="thanh-phan"] { --xx-bieu-tuong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 3.5h6M10 3.5v5.2L5.3 17.4A2.2 2.2 0 0 0 7.2 20.5h9.6a2.2 2.2 0 0 0 1.9-3.1L14 8.7V3.5'/%3E%3Cpath d='M7.5 14h9'/%3E%3C/svg%3E"); }

/* ---------------------------------------------------------------- ảnh giấy tờ (chỉ hiện khi có ảnh thật) */
.the-xuat-xu__giay { display: flex; flex-wrap: wrap; gap: 8px; }
.the-xuat-xu__giay:not(:has(img)) { display: none; }
.the-xuat-xu__gia-tri + .the-xuat-xu__giay { margin-top: 10px; }
.the-xuat-xu__giay a { display: block; min-width: 44px; min-height: 44px; border-radius: 6px; }
.the-xuat-xu__giay img {
  display: block; width: 62px; height: 82px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--xx-vien); background: #fff;
}
.the-xuat-xu__giay a:hover img { outline: 2px solid var(--xx-nhan); outline-offset: 2px; }

/* Dòng trống (JS đặt hidden; tắt JS thì luật này lo): không giá trị chữ, không ảnh giấy tờ → ẩn */
.the-xuat-xu__dong:not(:has(.the-xuat-xu__gia-tri:not(:empty))):not(:has(img)) { display: none; }

/* ---------------------------------------------------------------- con dấu (JS vẽ từ data-dau-moc) */
.the-xuat-xu__dau-moc {
  position: absolute; z-index: 3; top: -26px; right: -18px;
  width: clamp(92px, 7.5vw, 116px); aspect-ratio: 1; pointer-events: none;
  color: var(--xx-dau, var(--xx-nhan));
  transform: rotate(-12deg);
}
.the-xuat-xu__dau-moc svg { width: 100%; height: 100%; overflow: visible; }
.the-xuat-xu__dau-moc text { font-family: var(--xx-font); font-weight: 700; fill: currentColor; }

/* ================================================================ hiện dần — chỉ khi JS đã nhận khối */
.the-xuat-xu--khoi-tao *, .the-xuat-xu--khoi-tao *::before, .the-xuat-xu--khoi-tao *::after { transition: none !important; }

.the-xuat-xu--chay .the-xuat-xu__dong::before { background: var(--xx-giay); transition: background-color .35s var(--duong-cong) .12s; }
.the-xuat-xu--chay .the-xuat-xu__dong::after { background: var(--xx-nhan); transition: background-color .35s var(--duong-cong) .12s; }
.the-xuat-xu--chay .the-xuat-xu__dong.dang-hien::before { background: var(--xx-nhan); }
.the-xuat-xu--chay .the-xuat-xu__dong.dang-hien::after { background: var(--xx-tren-nhan); }
.the-xuat-xu--chay .the-xuat-xu__ds { --xx-tien: 0; }
.the-xuat-xu--buoc .the-xuat-xu__ds::after { transition: transform .5s var(--duong-cong); }

/* L1: mờ + trượt nhẹ */
.the-xuat-xu--chay .the-xuat-xu__dong > * { transition: opacity .5s var(--duong-cong), transform .5s var(--duong-cong); }
.the-xuat-xu--chay .the-xuat-xu__dong:not(.dang-hien) > * { opacity: 0; transform: translate3d(0, 10px, 0); }
/* L2/L3: in ra từ trái sang như máy in tem */
.the-xuat-xu--chay:is([data-cap-chay="L2"], [data-cap-chay="L3"]) .the-xuat-xu__dong > * {
  clip-path: inset(-.2em -1% -.2em 0); transform: none;
  transition: clip-path .75s cubic-bezier(.3, .55, .2, 1), opacity .3s linear;
}
.the-xuat-xu--chay:is([data-cap-chay="L2"], [data-cap-chay="L3"]) .the-xuat-xu__dong:not(.dang-hien) > * {
  opacity: 0; transform: none; clip-path: inset(-.2em 101% -.2em 0);
}
.the-xuat-xu--chay:is([data-cap-chay="L2"], [data-cap-chay="L3"]) .the-xuat-xu__dong.dang-hien > dd { transition-delay: .12s; }

/* Con dấu: ẩn tới khi dòng cuối in xong, rồi "đóng" xuống */
.the-xuat-xu--chay .the-xuat-xu__dau-moc { opacity: 0; transform: rotate(-4deg) scale(1.45); transition: opacity .2s linear, transform .2s linear; }
.the-xuat-xu--chay.the-xuat-xu--dong-dau .the-xuat-xu__dau-moc {
  opacity: 1; transform: rotate(-12deg) scale(1);
  transition: opacity .12s linear, transform .5s cubic-bezier(.22, 1.35, .36, 1);
}

/* ---------------------------------------------------------------- điện thoại */
@media (max-width: 760px) {
  .the-xuat-xu { --xx-bong: drop-shadow(0 16px 20px rgba(6, 10, 16, .36)); --xx-cham: 28px; --xx-cham-tam: 27px; }
  .the-xuat-xu__dau { padding-right: 4.25rem; }
  .the-xuat-xu__dau-moc { width: 84px; top: -18px; right: -6px; }
  .the-xuat-xu__dong { padding-left: calc(var(--xx-cham) + .8rem); }
}
@media print {
  .the-xuat-xu { filter: none; }
  .the-xuat-xu__dong, .the-xuat-xu__dong > * { opacity: 1 !important; clip-path: none !important; transform: none !important; }
}
