/* =========================================================
   HuayuHub — Tra cứu & huy hiệu xác thực (signature element)
   ========================================================= */

/* ---------- Hero tra cứu ---------- */
.verify-hero {
  max-width: 640px;
  margin: 0 auto 48px;
  text-align: center;
}
.verify-hero .eyebrow { justify-content: center; }
.verify-hero h1 {
  font-size: clamp(30px, 4.4vw, 44px);
  line-height: 1.15;
}
.verify-hero p {
  color: var(--text-dim);
  font-size: 16px;
  max-width: 480px;
  margin: 12px auto 0;
}

.verify-form {
  max-width: 560px;
  margin: 0 auto 40px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.verify-form .field { flex: 1; margin-bottom: 0; }
.verify-form input {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.verify-form .btn { height: 50px; white-space: nowrap; }

/* ---------- Huy hiệu xác thực ---------- */
.badge-wrap { width: 108px; height: 108px; flex: none; }
.badge-wrap svg { width: 100%; height: 100%; display: block; }

.verify-badge {
  transform-origin: center;
  transform: scale(0.6);
  opacity: 0;
  transition: transform 0.55s cubic-bezier(.18,1.6,.4,1), opacity 0.35s ease;
}
.is-verified .verify-badge,
.result-card.is-verified .verify-badge {
  transform: scale(1);
  opacity: 1;
}

/* ---------- Kết quả tra cứu (khung gọn — không dùng nữa, giữ lại để
   không phá vỡ CSS cũ nếu có nơi khác còn tham chiếu) ---------- */
.result-card {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 30px;
  display: flex;
  gap: 22px;
  align-items: center;
}
.result-card.state--revoked { border-color: rgba(210,70,85,0.4); }
.result-card.state--expired { border-color: rgba(200,150,50,0.4); }
.result-card.state--unknown { border-color: rgba(165,140,115,0.4); }

.result-body { flex: 1; min-width: 0; }
.result-title { font-family: var(--font-display); font-size: 20px; margin-bottom: 4px; }
.result-meta { font-size: 14px; color: var(--text-dim); }
.result-meta strong { color: var(--text); }
.result-code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  margin-top: 8px;
}
.result-link { display: inline-block; margin-top: 12px; font-size: 14px; font-weight: 700; }

/* =========================================================
   Kết quả tra cứu — khung đầy đủ kiểu "verification receipt"
   (thay cho .result-card gọn ở trên). Dùng biến --state-* để đổi
   màu theo trạng thái (valid / revoked / expired / unknown) mà
   không phải lặp lại CSS cho từng trạng thái.
   ========================================================= */
.vresult {
  max-width: 640px;
  margin: 0 auto;
  padding: 30px 32px 0;
  overflow: hidden;
  --state-color: var(--valid);
  --state-tint: var(--valid-tint);
}
.vresult.state--valid { --state-color: var(--brand-valid); --state-tint: var(--brand-valid-tint); }
.vresult.state--revoked { --state-color: var(--revoked); --state-tint: var(--revoked-tint); }
.vresult.state--expired { --state-color: var(--expired); --state-tint: var(--expired-tint); }
.vresult.state--unknown { --state-color: var(--unknown); --state-tint: var(--unknown-tint); }

.vresult-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 22px;
}
.vresult-badge { display: flex; align-items: center; gap: 20px; flex: 1; min-width: 260px; }

.vbadge-wrap { width: 92px; height: 92px; flex: none; }
.vbadge-wrap svg { width: 100%; height: 100%; display: block; }
.vbadge-halo { fill: var(--state-tint); }
.vbadge-ring { fill: none; stroke: var(--state-color); stroke-opacity: 0.3; stroke-width: 2; stroke-dasharray: 4 5; }
.vbadge-core { fill: var(--state-color); }
.vbadge-icon { fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
/* Trạng thái hợp lệ: viền đỏ triện + lõi vàng ánh kim — phối màu 2 lớp
   giống đúng vòng ngoài của logo (đỏ) và vòng trong (vàng). */
.vbadge--valid .vbadge-ring { stroke: var(--red); stroke-opacity: 0.55; stroke-dasharray: none; }

.vresult-heading { font-family: var(--font-display); font-size: 24px; font-weight: 800; color: var(--state-color); margin-bottom: 4px; line-height: 1.2; }
.vresult-subheading { font-size: 14px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.vresult-desc { font-size: 13px; color: var(--text-dim); }

.vresult-vdivider { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }

.vresult-stamp {
  text-align: right;
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  flex: none;
}
.vresult-stamp .stamp-line {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  font-weight: 700;
  color: var(--state-color);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 11px;
}
.vresult-stamp .stamp-line svg { width: 15px; height: 15px; }
.vresult-stamp .stamp-time { margin-top: 3px; }

.vresult-hr { height: 1px; background: var(--border); margin: 4px 0 0; }

.vresult-people {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 22px 0;
}
.vresult-person, .vresult-program { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 180px; }
.vresult-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--state-tint); color: var(--state-color);
  display: flex; align-items: center; justify-content: center;
}
.vresult-avatar svg { width: 22px; height: 22px; }
.vresult-label { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 2px; }
.vresult-value { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--text); }
.vresult-divider { width: 1px; align-self: stretch; background: var(--border); }

.vresult-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 22px;
}
.vresult-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  padding: 22px 24px;
}
.vresult-grid-item .vresult-icon {
  width: 30px; height: 30px; border-radius: 8px; margin-bottom: 10px;
  background: var(--state-tint); color: var(--state-color);
  display: flex; align-items: center; justify-content: center;
}
.vresult-grid-item .vresult-icon svg { width: 16px; height: 16px; }
.vresult-grid-item .vresult-value { font-size: 14px; }
.vresult-grid-item .vresult-value.mono { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.02em; word-break: break-all; }
.vresult-copy {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--link);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.vresult-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  margin: 0 0 22px;
  border-radius: var(--radius-sm);
  background: var(--grad-brand);
  color: var(--btn-seal-text);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  box-shadow: var(--shadow-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.vresult-cta:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 16px 40px -10px rgba(179,34,46,0.5); }
.vresult-cta svg { width: 16px; height: 16px; }

.vresult-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 22px -32px 0;
  padding: 16px 32px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.vresult-footer-note { display: flex; align-items: flex-start; gap: 10px; max-width: 380px; }
.vresult-footer-note svg { width: 18px; height: 18px; color: var(--state-color); flex: none; margin-top: 1px; }
.vresult-footer-note strong { display: block; font-size: 13px; color: var(--text); }
.vresult-footer-note p { font-size: 12px; color: var(--text-faint); margin: 2px 0 0; }
.vresult-footer-brand { display: flex; align-items: center; gap: 8px; }
.vresult-footer-brand img { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.vresult-footer-brand .fb-name { font-family: var(--font-display); font-weight: 800; font-size: 13px; color: var(--text); line-height: 1.25; }
.vresult-footer-brand .fb-sub { display: block; font-family: var(--font-body); font-weight: 500; font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.02em; }

.result-empty, .result-loading {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  padding: 20px;
}

/* =========================================================
   certificate.html — vẽ đè lên ẢNH MẪU THẬT (canvas) của bạn
   ========================================================= */
.certificate-page { max-width: 900px; margin: 0 auto; }

.cert-cover {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.cert-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

.status-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 900px;
  margin: 0 auto 20px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}
.status-banner .verify-badge { transform: scale(1); opacity: 1; }
.status-banner svg { width: 40px; height: 40px; }
.status-banner--revoked { background: var(--revoked-tint); color: var(--revoked); border: 1px solid rgba(210,70,85,0.35); }
.status-banner--expired { background: var(--expired-tint); color: var(--expired); border: 1px solid rgba(200,150,50,0.35); }

.certificate-actions {
  max-width: 900px;
  margin: 22px auto 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* =========================================================
   Hộp quà bất ngờ — mở trước khi lộ chứng chỉ đầy đủ
   ========================================================= */
.giftbox-stage {
  max-width: 520px;
  margin: 10px auto 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 20px 36px;
}

.giftbox-copy .eyebrow { justify-content: center; margin-bottom: 10px; }
.giftbox-copy h2 {
  font-family: var(--font-display);
  font-size: clamp(22px, 3.4vw, 30px);
  line-height: 1.25;
  margin: 0 0 34px;
}

.giftbox {
  position: relative;
  width: 168px;
  height: 168px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.giftbox:focus-visible { outline: 2px solid var(--gold); outline-offset: 6px; border-radius: 20px; }

.giftbox-glow {
  position: absolute;
  inset: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(225,187,107,0.55) 0%, rgba(225,187,107,0.0) 70%);
  opacity: 0.55;
  animation: giftbox-breathe 2.6s ease-in-out infinite;
  pointer-events: none;
}

.giftbox-base {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 8px;
  height: 92px;
  border-radius: 10px;
  background: linear-gradient(155deg, var(--red) 0%, var(--maroon) 100%);
  box-shadow: var(--shadow-card);
  transition: transform 0.5s cubic-bezier(.3,1.6,.4,1), opacity 0.5s ease;
}
.giftbox-ribbon-v {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 22px;
  margin-left: -11px;
  background: linear-gradient(90deg, rgba(0,0,0,0.08), var(--gold) 35%, #F6E3AE 50%, var(--gold) 65%, rgba(0,0,0,0.08));
}

.giftbox-lid {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 46px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(155deg, var(--gold) 0%, #B5872E 100%);
  box-shadow: 0 6px 16px -6px rgba(0,0,0,0.45);
  transform-origin: 50% 100%;
  transition: transform 0.55s cubic-bezier(.4,1.8,.4,1), opacity 0.45s ease 0.35s;
  z-index: 2;
}
.giftbox-bow {
  position: absolute;
  left: 50%;
  top: -22px;
  width: 46px;
  height: 30px;
  margin-left: -23px;
}
.giftbox-bow::before,
.giftbox-bow::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 60% 60% 60% 5%;
  background: linear-gradient(155deg, var(--gold) 0%, #B5872E 100%);
  box-shadow: 0 3px 8px -3px rgba(0,0,0,0.4);
}
.giftbox-bow::before { left: -2px; transform: rotate(-18deg); }
.giftbox-bow::after { right: -2px; transform: scaleX(-1) rotate(-18deg); }

.giftbox-sparkle {
  position: absolute;
  color: var(--gold);
  font-size: 16px;
  opacity: 0;
  animation: giftbox-sparkle 2.4s ease-in-out infinite;
  pointer-events: none;
}
.giftbox-sparkle.s1 { left: -18px; top: 10px; animation-delay: 0s; }
.giftbox-sparkle.s2 { right: -22px; top: 42px; animation-delay: 0.7s; font-size: 12px; }
.giftbox-sparkle.s3 { left: 6px; bottom: -6px; animation-delay: 1.4s; font-size: 13px; }

.giftbox-hint {
  margin-top: 26px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  animation: giftbox-hint-pulse 1.8s ease-in-out infinite;
}

.giftbox:hover .giftbox-lid { transform: translateY(-4px) rotate(-2deg); }
.giftbox:hover .giftbox-base { transform: translateY(-2px); }

/* --- Trạng thái đang mở --- */
.giftbox-stage.is-opening .giftbox-hint { opacity: 0; }
.giftbox-stage.is-opening .giftbox-glow {
  animation: none;
  transform: scale(2.6);
  opacity: 0;
  transition: transform 0.9s cubic-bezier(.2,.7,.3,1), opacity 0.9s ease;
}
.giftbox-stage.is-opening .giftbox-lid {
  transform: translateY(-150px) translateX(-16px) rotate(-70deg);
  opacity: 0;
}
.giftbox-stage.is-opening .giftbox-base {
  transform: scale(0.9) translateY(6px);
  opacity: 0;
  transition: transform 0.5s ease 0.15s, opacity 0.5s ease 0.15s;
}
.giftbox-stage.is-opening .giftbox-sparkle { animation: none; opacity: 0; transition: opacity 0.3s ease; }

.giftbox-stage.is-closing {
  animation: giftbox-stage-fade-out 0.5s ease forwards;
}

.giftbox-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.giftbox-confetti span {
  position: absolute;
  left: 50%;
  top: 55%;
  width: 8px;
  height: 12px;
  background: var(--gold);
  border-radius: 2px;
  opacity: 0;
}
.giftbox-stage.is-opening .giftbox-confetti span {
  animation: giftbox-confetti-fly 1.05s cubic-bezier(.15,.7,.3,1) forwards;
  animation-delay: var(--d, 0s);
}

@keyframes giftbox-breathe {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 0.75; }
}
@keyframes giftbox-sparkle {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0.7); }
  50% { opacity: 1; transform: translateY(-6px) scale(1); }
}
@keyframes giftbox-hint-pulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}
@keyframes giftbox-stage-fade-out {
  to { opacity: 0; transform: scale(0.96); }
}
@keyframes giftbox-confetti-fly {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, -160px))) rotate(var(--rot, 260deg)) scale(0.6); }
}

/* Chứng chỉ hiện ra sau khi mở hộp quà */
.cert-reveal {
  animation: cert-reveal-in 0.7s cubic-bezier(.2,.8,.3,1) both;
}
@keyframes cert-reveal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .giftbox-glow, .giftbox-sparkle, .giftbox-hint { animation: none; }
  .cert-reveal { animation: none; }
}

@media (max-width: 640px) {
  .giftbox-stage { padding: 32px 16px 24px; }
  .giftbox { width: 140px; height: 140px; }
}

@media print {
  .hyh-topbar, .hyh-footer, .certificate-actions, .status-banner, .theme-toggle { display: none; }
  body { background: #fff; }
  .cert-cover, .cert-canvas { box-shadow: none; border: none; width: 100%; }
  .cert-cover { page-break-after: always; break-after: page; margin-bottom: 0; }
}

@media (max-width: 640px) {
  .verify-form {
    flex-direction: column;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
  }
  .verify-form .field { width: 100%; }
  .verify-form .btn { width: 100%; }
  .result-card { flex-direction: column; text-align: center; padding: 22px 20px; }
  .status-banner { flex-direction: column; text-align: center; }
  .badge-wrap { width: 84px; height: 84px; }
  .certificate-actions .btn { width: 100%; }

  .vresult { padding: 24px 20px 0; }
  .vresult-top { text-align: center; justify-content: center; }
  .vresult-badge { flex-direction: column; min-width: 0; }
  .vresult-vdivider { display: none; }
  .vresult-stamp { text-align: center; width: 100%; }
  .vresult-stamp .stamp-line { justify-content: center; }
  .vresult-people { flex-direction: column; text-align: center; }
  .vresult-person, .vresult-program { flex-direction: column; }
  .vresult-divider { display: none; }
  .vresult-grid { grid-template-columns: repeat(2, 1fr); text-align: center; padding: 20px; }
  .vresult-grid-item .vresult-icon { margin-left: auto; margin-right: auto; }
  .vresult-footer { flex-direction: column; margin: 22px -20px 0; padding: 16px 20px; text-align: center; }
  .vresult-footer-note { flex-direction: column; align-items: center; text-align: center; }
}