/* ==========================================================================
   GIFTCODE — "Hoa Đăng Dạ Yến" (đêm hội đèn lồng, bao lì xì, vé quà)
   Nền mận chín + vàng đèn lồng. Form nằm trong một phong bao đỏ, mỗi mã là
   một tấm vé xé. Chỉ đổi giao diện — ID, API và hàm trong index.html giữ nguyên.
   ========================================================================== */
@font-face {
  font-family: "NL Cadena";
  src: url("/assets/fonts/iCielCadena.otf") format("opentype");
  font-weight: 800; font-display: swap;
}

.hd-gift { --hd-display: "NL Cadena", "Be Vietnam Pro", system-ui, sans-serif; }
.hd-gift, .hd-gift .hd-wrap {
  --bg: #170a14;
  --bg2: #1f0e1b;
  --card: #26121f;
  --card-2: #321829;
  --ink: #fff0e4;
  --body-c: #ecd3cf;
  --muted: #bd9ba6;
  --faint: #8c6b78;
  --line: #4a2740;
  --line-soft: #3a1d32;
  --gold: #f6c26b;
  --gold-strong: #ffd98f;
  --gold-ink: #3a1608;
  --gold-soft: rgba(246, 194, 107, 0.12);
  --gold-grad: linear-gradient(135deg, #ffdc94, #f0a94a);
  --input-bg: #1c0d18;
  --input-border: #55304a;
  --input-focus: #f6c26b;
  --hd-rose: #ff6f88;
  --hd-red-a: #d4324f;
  --hd-red-b: #8b1232;
  --hd-hero-fade: #170a14;
}
[data-theme="light"] .hd-gift, [data-theme="light"] .hd-gift .hd-wrap {
  --bg: #fff1e6;
  --bg2: #ffe7d9;
  --card: #fffaf4;
  --card-2: #ffefe2;
  --ink: #3b1224;
  --body-c: #5c3141;
  --muted: #8d6170;
  --faint: #b9929b;
  --line: #f1cfc6;
  --line-soft: #f7ded6;
  --gold: #b56a1c;
  --gold-strong: #8f4f0f;
  --gold-ink: #fff7ea;
  --gold-soft: rgba(181, 106, 28, 0.1);
  --gold-grad: linear-gradient(135deg, #e0a04a, #b56a1c);
  --input-bg: #ffffff;
  --input-border: #ecc4ba;
  --input-focus: #c42b47;
  --hd-rose: #c42b47;
  --hd-hero-fade: #fff1e6;
}
body.hd-gift { background: var(--bg); color: var(--body-c); }

/* ---------- Hero: đêm hội ---------- */
.hd-hero {
  position: relative; isolation: isolate; overflow: hidden;
  margin-top: -92px; padding: 150px 20px 150px;
  text-align: center; color: #fff3e6;
}
.hd-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background: url("/assets/img/bg_chon_may_chu.jpg") 50% 34% / cover no-repeat;
}
.hd-hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(23, 10, 20, 0.55) 0%, transparent 30%, transparent 48%, var(--hd-hero-fade) 92%),
    radial-gradient(60% 70% at 50% 42%, rgba(23, 10, 20, 0.2), rgba(23, 10, 20, 0.72));
}
.hd-hero .gc-eyebrow {
  display: inline-block; margin: 0 0 14px; padding: 6px 16px;
  border: 1px solid rgba(255, 220, 150, 0.55); border-radius: 999px;
  background: rgba(40, 12, 28, 0.5); color: #ffdc94;
  font-size: 11px; letter-spacing: 0.22em;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.hd-hero h1 {
  margin: 0; font-family: var(--hd-display); font-weight: 800;
  font-size: clamp(38px, 7vw, 84px); line-height: 1; letter-spacing: 0.01em;
  color: #fff3e6;
  text-shadow: 0 3px 0 #a3213f, 0 6px 0 #6d1029, 0 18px 40px rgba(0, 0, 0, 0.6);
}
.hd-hero h1 span { color: #ffd277; }
.hd-hero .hd-lead { margin: 20px auto 0; max-width: 52ch; font-size: 15.5px; line-height: 1.7; color: rgba(255, 243, 230, 0.9); text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7); }

.hd-steps {
  list-style: none; margin: 28px auto 0; padding: 0;
  display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 10px;
}
.hd-steps li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 16px 7px 7px; border-radius: 999px;
  background: rgba(40, 12, 28, 0.62); border: 1px solid rgba(255, 220, 150, 0.3);
  font-size: 13px; font-weight: 600; color: #fff3e6;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.hd-steps b {
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  background: linear-gradient(135deg, #ffdc94, #f0a94a); color: #5a1c0c;
  font: 800 14px/1 var(--hd-display);
}

/* đèn trời bay lên */
.hd-sky { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hd-sky i {
  position: absolute; bottom: -40px; left: var(--x);
  width: var(--s, 16px); height: calc(var(--s, 16px) * 1.25);
  border-radius: 45% 45% 30% 30%;
  background: radial-gradient(circle at 50% 70%, #fff2b8, #ffb24a 55%, #d4572a);
  box-shadow: 0 0 22px 6px rgba(255, 170, 70, 0.45);
  opacity: 0; animation: hdFly var(--d, 16s) linear infinite; animation-delay: var(--w, 0s);
}
@keyframes hdFly {
  0% { transform: translate(0, 0) rotate(-4deg); opacity: 0; }
  12% { opacity: 0.95; }
  80% { opacity: 0.6; }
  100% { transform: translate(var(--drift, 30px), -560px) rotate(5deg); opacity: 0; }
}

/* ---------- Khung nội dung ---------- */
.hd-wrap.gc-wrap { width: min(1120px, 100%); padding: 0 20px 56px; margin-top: -96px; position: relative; z-index: 2; }
.hd-gift .giftcode-grid { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 28px; }
.hd-gift [data-tce-promo="inline"] { margin-bottom: 18px; }

/* ---------- Phong bao đỏ (đổi mã) ---------- */
.hd-envelope.nl-card {
  /* token riêng trong phong bao: luôn đỏ ở cả hai giao diện */
  --ink: #fff3e2; --body-c: #ffe2d2; --muted: #f3b9b6; --faint: #e79aa0;
  --line: rgba(255, 220, 150, 0.35); --line-soft: rgba(255, 220, 150, 0.22);
  --gold: #ffd277; --gold-strong: #ffe4a6; --gold-ink: #5a1c0c;
  --gold-soft: rgba(255, 210, 119, 0.16);
  --input-bg: #fff6ea; --input-border: #f0c68b; --input-focus: #ffd277;
  --card: rgba(90, 10, 34, 0.5); --card-2: rgba(90, 10, 34, 0.5);
  --amber-soft: rgba(60, 6, 22, 0.45); --amber-line: rgba(255, 220, 150, 0.4); --amber-ink: #ffd277;
  --green: #b9f5c8; --green-soft: rgba(20, 70, 40, 0.5); --red: #ffe0a8; --red-soft: rgba(60, 6, 22, 0.55);
  position: sticky; top: 104px;
  padding: 92px 26px 26px; border: 0; border-radius: 22px;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 255, 255, 0.14), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 220, 150, 0.05) 0 2px, transparent 2px 14px),
    linear-gradient(170deg, var(--hd-red-a), var(--hd-red-b));
  color: var(--body-c);
  box-shadow: 0 30px 60px rgba(90, 10, 34, 0.5), inset 0 0 0 1.5px rgba(255, 220, 150, 0.55), inset 0 0 0 6px rgba(120, 14, 42, 0.5);
}
/* nắp phong bao */
.hd-envelope::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 74px;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, #e84463, #b41f40);
  clip-path: polygon(0 0, 100% 0, 100% 34%, 50% 100%, 0 34%);
  filter: drop-shadow(0 6px 8px rgba(60, 6, 22, 0.5));
}
.hd-clasp {
  position: absolute; left: 50%; top: 44px; width: 58px; height: 58px; margin-left: -29px;
  display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1c2, #f3b24e 55%, #b8721d);
  color: #7a1a12; font-size: 28px;
  box-shadow: 0 8px 18px rgba(60, 6, 22, 0.55), inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.hd-envelope .card-head { border-bottom: 1px dashed var(--line); margin-top: 18px; }
.hd-envelope .card-title { font: 800 24px/1.1 var(--hd-display); color: var(--ink); }
.hd-envelope .card-title .ti { display: none; }
.hd-envelope .card-badge { color: var(--gold); border-color: var(--line); }
.hd-envelope .form-label { color: var(--ink); font-size: 12.5px; }
.hd-envelope .form-label .req { color: var(--gold); }
.hd-envelope .form-control { height: 50px; border-radius: 12px; color: #4a1420; font-weight: 600; border-width: 1.5px; }
.hd-envelope .form-control:focus { box-shadow: 0 0 0 4px rgba(255, 210, 119, 0.3); }
.hd-envelope .form-control:disabled { opacity: 0.7; }
.hd-envelope .input-code-wrap .form-control {
  height: 58px; font-size: 19px; text-align: center; letter-spacing: 0.2em;
  border-style: dashed; border-width: 2px; border-color: #d99a3c;
}
.hd-envelope .input-code-wrap .form-control::placeholder { color: #c9a58d; letter-spacing: 0.1em; font-weight: 500; }
.hd-envelope .input-paste-btn {
  min-height: 58px; border-radius: 12px; padding: 0 14px;
  background: rgba(60, 6, 22, 0.4); color: var(--ink); border: 1.5px solid var(--line);
}
.hd-envelope .input-paste-btn:hover { border-color: var(--gold); color: var(--gold); }
.hd-envelope .btn-submit-code {
  min-height: 56px; border-radius: 999px; margin-top: 8px;
  background: linear-gradient(180deg, #ffe4a6, #f0a94a); color: #5a1c0c;
  font: 800 17px/1 var(--hd-display); letter-spacing: 0.03em; text-transform: none;
  box-shadow: 0 6px 0 #8a4a12, 0 16px 28px rgba(60, 6, 22, 0.5);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.15s;
}
.hd-envelope .btn-submit-code:hover:not(:disabled) { background: linear-gradient(180deg, #fff0c8, #f5b65c); filter: brightness(1.03); }
.hd-envelope .btn-submit-code:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 #8a4a12, 0 6px 12px rgba(60, 6, 22, 0.5); }
.hd-envelope .code-help { color: var(--muted); text-align: center; }
.hd-envelope .auth-notice { border-radius: 12px; }
.hd-envelope .auth-notice-btn { background: var(--gold); color: var(--gold-ink); border-radius: 999px; }
.hd-envelope #user-info-badge { color: var(--muted) !important; }
.hd-envelope .result-card { border-radius: 14px; background: rgba(60, 6, 22, 0.5); }
.hd-envelope .result-title { color: var(--gold) !important; }
.hd-envelope .reward-pill { background: #fff6ea; color: #4a1420; border-color: #f0c68b; }
.hd-envelope .reward-pill .ti { color: #b8721d; }
.hd-envelope :focus-visible { outline-color: #ffe4a6; }

/* ---------- Cột vé quà ---------- */
.hd-col { min-width: 0; display: grid; gap: 22px; align-content: start; }
.hd-gift .hd-col > .nl-card { margin: 0 !important; }
.hd-tickets.nl-card { background: transparent; border: 0; padding: 0; }
.hd-tickets .card-head { border: 0; padding: 0; margin-bottom: 12px; align-items: flex-end; }
.hd-tickets .card-title { font: 800 28px/1.1 var(--hd-display); color: var(--ink); }
.hd-tickets .card-title .ti { color: var(--hd-rose); font-size: 26px; }
.hd-gift .card-badge { border-radius: 6px; }

.hd-gift .claimed-toggle {
  display: inline-flex; padding: 7px 14px 7px 10px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--body-c);
}
.hd-gift .claimed-toggle input { accent-color: var(--hd-rose); }

.hd-gift #active-codes-container { gap: 14px; }
.hd-gift .code-item-card {
  position: relative; overflow: hidden;
  padding: 16px 18px 16px 96px;
  background: linear-gradient(120deg, var(--card), var(--card-2));
  border: 1px solid var(--line); border-radius: 18px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.hd-gift .code-item-card:hover { transform: translateY(-3px) rotate(-0.25deg); border-color: var(--gold); box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28); }
/* cuống vé + răng cưa */
.hd-gift .code-item-card::before {
  content: "🎁"; position: absolute; left: 0; top: 0; bottom: 0; width: 78px;
  display: grid; place-items: center; font-size: 30px;
  background: linear-gradient(170deg, var(--hd-red-a), var(--hd-red-b));
}
.hd-gift .code-item-card::after {
  content: ""; position: absolute; left: 69px; top: 0; bottom: 0; width: 18px;
  background:
    radial-gradient(circle at 50% 0, var(--bg) 8.5px, transparent 9px),
    radial-gradient(circle at 50% 100%, var(--bg) 8.5px, transparent 9px),
    repeating-linear-gradient(180deg, var(--bg) 0 5px, transparent 5px 11px) 50% 50% / 2px calc(100% - 30px) no-repeat;
}
.hd-gift .code-item-card.is-private { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 14px 30px var(--gold-soft); }
.hd-gift .code-item-card.is-private::before { content: "🧧"; background: linear-gradient(170deg, #f6c26b, #b8721d); }
.hd-gift .code-item-card.is-claimed { opacity: 1; filter: saturate(0.25); }
.hd-gift .code-item-card.is-claimed::before { content: "✔"; color: #fff; font-size: 26px; background: linear-gradient(170deg, #6b5560, #45333d); }
.hd-gift .code-head { margin-bottom: 8px; }
.hd-gift .code-badge-lbl { padding: 3px 9px; border-radius: 6px; background: var(--gold-soft); }
.hd-gift .code-string-box { padding: 0; background: transparent; border: 0; }
.hd-gift .code-text { font-size: 22px; font-weight: 800; letter-spacing: 0.12em; color: var(--ink); }
.hd-gift .btn-mini { min-height: 36px; border-radius: 999px; padding: 6px 14px; }
.hd-gift .btn-mini-use { background: var(--hd-red-a); border-color: var(--hd-red-a); color: #fff3e6; }
.hd-gift .btn-mini-use:hover { background: var(--hd-red-b); border-color: var(--hd-red-b); color: #fff3e6; }
.hd-gift .code-perks-list {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.hd-gift .code-perks-list li {
  padding: 3px 10px; border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 60%, transparent); border: 1px solid var(--line-soft);
  font-size: 12px; line-height: 1.6;
}

/* ---------- Nạp Ví Nhận Code ---------- */
#tce-card[hidden] { display: none; }
.hd-gift #tce-card { border-radius: 18px; border-color: var(--gold); background: linear-gradient(160deg, var(--gold-soft), transparent 45%), var(--card); }
.hd-gift #tce-card .card-title { font: 800 22px/1.1 var(--hd-display); }
.tce-sub { font-size: 13px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.tce-total { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.tce-total strong { color: var(--gold); font: 800 22px/1 var(--hd-display); }
.tce-bar { height: 10px; border-radius: 999px; background: var(--line-soft); overflow: hidden; margin-bottom: 14px; }
.tce-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--hd-red-a), #f6c26b); width: 0; transition: width 0.5s; }
.tce-tier { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; background: color-mix(in srgb, var(--bg) 45%, transparent); }
.tce-tier.is-reached { border-color: var(--gold); }
.tce-tier h3 { margin: 0; font-size: 14px; color: var(--ink); }
.tce-tier p { margin: 0; font-size: 12px; color: var(--muted); grid-column: 1 / -1; line-height: 1.45; }
.tce-tier .card-badge { justify-self: start; }
.tce-btn { border: 0; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer; background: var(--gold-grad); color: var(--gold-ink); white-space: nowrap; text-decoration: none; }
.tce-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.tce-btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--line); }
.tce-code { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tce-code code { font-size: 15px; letter-spacing: 1px; padding: 4px 8px; border: 1px dashed var(--gold); border-radius: 6px; color: var(--gold); user-select: all; }
.tce-msg { font-size: 12px; color: var(--muted); margin-top: 4px; min-height: 1em; }

/* ---------- Hướng dẫn: hai dải lụa ---------- */
.hd-gift .guide-card { margin-top: 44px; padding: 0; background: transparent; border: 0; }
.hd-gift .guide-title { justify-content: center; font: 800 30px/1.1 var(--hd-display); margin-bottom: 22px; text-align: center; }
.hd-gift .guide-title .ti { color: var(--hd-rose) !important; }
.hd-gift .guide-grid { gap: 22px; }
.hd-gift .guide-method {
  padding: 22px 22px 16px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line);
  border-top: 4px solid var(--hd-red-a);
}
.hd-gift .guide-method + .guide-method { border-top-color: var(--gold); }
.hd-gift .guide-method-head { font-size: 13px; color: var(--ink); margin-bottom: 14px; }
.hd-gift .guide-method-head .ti { font-size: 22px; color: var(--hd-rose); }
.hd-gift .guide-steps { list-style: none; padding: 0; counter-reset: hd; }
.hd-gift .guide-steps li { position: relative; padding: 0 0 12px 40px; margin: 0; counter-increment: hd; }
.hd-gift .guide-steps li::before {
  content: counter(hd); position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold);
  font: 800 13px/1 var(--hd-display);
}
.hd-gift .guide-steps li:not(:last-child)::after { content: ""; position: absolute; left: 12.5px; top: 28px; bottom: 2px; border-left: 1px dashed var(--line); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hd-gift .giftcode-grid { grid-template-columns: minmax(0, 1fr); }
  .hd-envelope.nl-card { position: relative; top: auto; max-width: 520px; width: 100%; margin: 0 auto; }
  .hd-hero { padding: 132px 16px 132px; }
}
@media (max-width: 560px) {
  .hd-wrap.gc-wrap { padding: 0 14px 40px; margin-top: -84px; }
  .hd-hero { padding: 118px 14px 116px; }
  .hd-hero .hd-lead { font-size: 14px; }
  .hd-steps li { font-size: 12px; padding-right: 12px; }
  .hd-envelope.nl-card { padding: 88px 18px 22px; }
  .hd-envelope .input-code-wrap { flex-direction: row; }
  .hd-envelope .input-code-wrap .form-control { font-size: 17px; letter-spacing: 0.12em; min-width: 0; }
  .hd-gift .code-item-card { padding: 14px 14px 14px 72px; }
  .hd-gift .code-item-card::before { width: 56px; font-size: 24px; }
  .hd-gift .code-item-card::after { left: 47px; }
  .hd-gift .code-string-box { flex-direction: column; align-items: flex-start; }
  .hd-gift .code-text { font-size: 19px; }
  .hd-tickets .card-title { font-size: 23px; }
  .hd-gift .guide-title { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .hd-sky i { animation: none; }
  .hd-gift .code-item-card:hover { transform: none; }
}
