/* ==========================================================================
   Certificate verification page
   Loaded only on Certificate/ValidateCertificate. Brand tokens come from front.css.
   ========================================================================== */
.cert-page {
  --cert-ink: #211D36;
  --cert-gold: #B8721A;
  --cert-gold-light: #FFB955;
  --cert-valid: #2F6B3A;
  --cert-invalid: #B3261E;
}

/* ==========================================================================
   Breadcrumb
   ========================================================================== */
.cert-breadcrumb {
  background-color: var(--brand-surface);
  border-bottom: 1px solid var(--brand-border);
  padding: 0.85rem 0;
}

.cert-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.83rem;
  color: var(--brand-muted);
}

.cert-breadcrumb li + li::before {
  content: "/";
  margin-right: 0.5rem;
  color: var(--brand-border);
}

.cert-breadcrumb a {
  color: var(--brand-primary);
  text-decoration: none;
}

.cert-breadcrumb a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Hero + verification console
   ========================================================================== */
.cert-hero {
  position: relative;
  overflow: hidden;
  padding: 3.25rem 0 3.75rem;
  background: linear-gradient(135deg, #2A1B4A 0%, var(--brand-primary-dark) 45%, var(--brand-primary) 100%);
  color: #fff;
}

/* Slow drifting highlight so the band reads as a surface rather than a flat fill. */
.cert-hero-glow {
  position: absolute;
  top: -45%;
  left: 50%;
  width: 120vw;
  height: 200%;
  transform: translateX(-50%);
  background:
    radial-gradient(closest-side, rgba(255, 185, 85, 0.22), transparent 70%) 22% 38% / 46% 62% no-repeat,
    radial-gradient(closest-side, rgba(255, 255, 255, 0.16), transparent 70%) 76% 58% / 40% 56% no-repeat;
  animation: cert-drift 18s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes cert-drift {
  from { transform: translateX(-52%) translateY(-2%); }
  to { transform: translateX(-48%) translateY(3%); }
}

.cert-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.cert-hero-crest {
  width: 62px;
  height: 62px;
  margin: 0 auto 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--cert-gold-light);
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.05);
}

.cert-hero-crest svg {
  width: 30px;
  height: 30px;
}

.cert-hero-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cert-gold-light);
  margin-bottom: 0.4rem;
}

.cert-hero-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: #fff;
  margin-bottom: 0.65rem;
}

.cert-hero-lead {
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 1.75rem;
}

.cert-console {
  margin-bottom: 1rem;
}

.cert-console-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.35rem 0.35rem 0.9rem;
  border-radius: var(--brand-radius-pill);
  background-color: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 16px 34px rgba(20, 12, 40, 0.28);
  transition: box-shadow var(--brand-transition), transform var(--brand-transition);
}

.cert-console-field:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(20, 12, 40, 0.36), 0 0 0 3px rgba(255, 185, 85, 0.45);
}

.cert-console-icon {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--brand-muted);
}

.cert-console-icon svg {
  width: 19px;
  height: 19px;
}

.cert-console-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.7rem 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--cert-ink);
  text-transform: uppercase;
}

.cert-console-input::placeholder {
  color: #A79FBB;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: none;
}

.cert-console-input:focus {
  outline: 0;
}

.cert-console-clear {
  flex: 0 0 auto;
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  border-radius: 999px;
  background-color: var(--brand-bg);
  color: var(--brand-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--brand-transition), color var(--brand-transition);
}

.cert-console-clear:hover {
  background-color: var(--brand-border);
  color: var(--cert-ink);
}

.cert-console-clear[hidden] {
  display: none;
}

.cert-console-submit {
  position: relative;
  flex: 0 0 auto;
  min-width: 7rem;
  min-height: 2.9rem;
  padding: 0 1.5rem;
  border: 0;
  border-radius: var(--brand-radius-pill);
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(120deg, var(--cert-gold), var(--cert-gold-light));
  box-shadow: 0 8px 18px rgba(184, 114, 26, 0.4);
  transition: transform var(--brand-transition), box-shadow var(--brand-transition), filter var(--brand-transition);
}

.cert-console-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(184, 114, 26, 0.52);
}

.cert-console-submit:disabled {
  cursor: progress;
  filter: saturate(0.75);
}

.cert-console-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.05rem;
  height: 1.05rem;
  margin: -0.525rem 0 0 -0.525rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  opacity: 0;
  animation: cert-spin 640ms linear infinite;
}

@keyframes cert-spin {
  to { transform: rotate(360deg); }
}

.cert-console.is-busy .cert-console-submit-label { opacity: 0; }
.cert-console.is-busy .cert-console-spinner { opacity: 1; }

.cert-console-error {
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cert-gold-light);
}

/* The validation tag helpers still emit their elements when the field is valid
   (marked *-valid), which would otherwise leave a gap under the input. */
.cert-console-error:empty,
.cert-console-error[hidden],
.cert-console .field-validation-valid,
.cert-console .validation-summary-valid {
  display: none;
}

.cert-hero-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0;
}

.cert-hero-hint svg {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   Scanner (in-flight state)
   ========================================================================== */
.cert-stage {
  padding: 2.5rem 0 0;
}

.cert-stage:has(.cert-result-slot:empty) {
  padding-bottom: 0;
}

.cert-scanner {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.cert-scanner[hidden] {
  display: none;
}

.cert-scanner-card {
  position: relative;
  height: 132px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--brand-border);
  background-color: var(--brand-surface);
  box-shadow: var(--brand-shadow-soft);
}

.cert-scanner-beam {
  position: absolute;
  inset: 0 auto 0 -35%;
  width: 35%;
  background: linear-gradient(90deg, transparent, rgba(184, 114, 26, 0.28), transparent);
  animation: cert-sweep 1.15s ease-in-out infinite;
}

@keyframes cert-sweep {
  to { left: 100%; }
}

.cert-scanner-lines {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.85rem;
  padding: 0 2rem;
}

.cert-scanner-lines span {
  height: 11px;
  border-radius: 999px;
  background-color: var(--brand-border);
}

.cert-scanner-lines span:nth-child(1) { width: 42%; }
.cert-scanner-lines span:nth-child(2) { width: 78%; }
.cert-scanner-lines span:nth-child(3) { width: 60%; }

.cert-scanner-text {
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-muted);
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Result
   ========================================================================== */
.cert-result-slot:empty {
  display: none;
}

.cert-result {
  max-width: 860px;
  margin: 0 auto;
  outline: 0;
  animation: cert-rise 420ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes cert-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* The document itself — a gold-edged card meant to read like the printed
   certificate that ships in the box. */
.cert-doc {
  position: relative;
  border-radius: 18px;
  padding: 3px;
  background: linear-gradient(135deg, var(--cert-gold), var(--cert-gold-light) 30%, var(--brand-primary) 70%, var(--brand-primary-dark));
  box-shadow: 0 18px 42px rgba(33, 29, 54, 0.16);
}

.cert-doc > * {
  position: relative;
  background-color: var(--brand-surface);
}

.cert-doc > *:first-child {
  border-radius: 15px 15px 0 0;
}

.cert-doc > *:last-child {
  border-radius: 0 0 15px 15px;
}

.cert-doc-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 1.75rem 1.25rem;
}

.cert-seal {
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--cert-valid), #4E9A5F);
  box-shadow: 0 0 0 6px rgba(47, 107, 58, 0.12);
  animation: cert-stamp 520ms cubic-bezier(0.2, 1.5, 0.4, 1) both;
  animation-delay: 160ms;
}

.cert-seal svg {
  width: 28px;
  height: 28px;
}

@keyframes cert-stamp {
  from { opacity: 0; transform: scale(1.7) rotate(-14deg); }
  to { opacity: 1; transform: none; }
}

.cert-doc-status {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cert-valid);
  margin-bottom: 0.2rem;
}

.cert-doc-title {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 2.6vw, 1.55rem);
  margin-bottom: 0.15rem;
}

.cert-doc-sub {
  font-size: 0.8rem;
  color: var(--brand-muted);
  margin-bottom: 0;
}

.cert-number-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.75rem;
  border-top: 1px dashed var(--brand-border);
  border-bottom: 1px dashed var(--brand-border);
  background-image: linear-gradient(90deg, rgba(184, 114, 26, 0.07), transparent 60%);
}

.cert-number-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-muted);
}

.cert-number-value {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cert-ink);
}

.cert-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--brand-border);
  background-color: var(--brand-surface);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--brand-muted);
  cursor: pointer;
  transition: color var(--brand-transition), border-color var(--brand-transition);
}

.cert-copy svg {
  width: 13px;
  height: 13px;
}

.cert-copy:hover {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.cert-copy.is-done {
  color: var(--cert-valid);
  border-color: var(--cert-valid);
}

.cert-doc-body {
  display: grid;
  gap: 1.5rem;
  padding: 1.6rem 1.75rem;
}

@media (min-width: 768px) {
  .cert-doc-body {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    gap: 2rem;
  }
}

.cert-photo {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--brand-border);
  background-color: var(--brand-bg);
}

.cert-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cert-photo-badge {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  color: #fff;
  background-color: var(--cert-gold);
}

.cert-photo-thumbs {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.65rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.cert-photo-thumb {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 9px;
  overflow: hidden;
  border: 2px solid var(--brand-border);
  background: none;
  cursor: pointer;
  transition: border-color var(--brand-transition);
}

.cert-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cert-photo-thumb:hover,
.cert-photo-thumb.is-active {
  border-color: var(--cert-gold);
}

.cert-product-name {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.cert-attrs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.15rem 1.25rem;
  margin: 0 0 1.1rem;
}

.cert-attr {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--brand-border);
}

.cert-attr dt {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--brand-muted);
}

.cert-attr dd {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--cert-ink);
  text-align: right;
}

.cert-lab-note {
  font-size: 0.8rem;
  color: var(--brand-muted);
  line-height: 1.6;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background-color: var(--brand-bg);
  margin-bottom: 1.1rem;
}

.cert-lab-note strong {
  display: block;
  color: var(--cert-ink);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.cert-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cert-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.6rem;
  padding: 0.5rem 1.2rem;
  border-radius: var(--brand-radius-pill);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--brand-transition), box-shadow var(--brand-transition),
              background-color var(--brand-transition), color var(--brand-transition);
}

.cert-btn svg {
  width: 15px;
  height: 15px;
}

.cert-btn-primary {
  border: 0;
  color: #fff;
  background: linear-gradient(120deg, var(--brand-primary), var(--brand-primary-dark));
  box-shadow: 0 8px 18px rgba(138, 38, 164, 0.28);
}

.cert-btn-primary:hover,
.cert-btn-primary:focus {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(138, 38, 164, 0.38);
}

.cert-btn-ghost {
  border: 1px solid var(--brand-border);
  background-color: var(--brand-surface);
  color: var(--brand-muted);
}

.cert-btn-ghost:hover,
.cert-btn-ghost:focus {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.cert-btn-ghost.is-done {
  border-color: var(--cert-valid);
  color: var(--cert-valid);
}

.cert-doc-foot {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.85rem 1.75rem;
  border-top: 1px solid var(--brand-border);
  font-size: 0.76rem;
  color: var(--brand-muted);
}

.cert-doc-foot svg {
  width: 15px;
  height: 15px;
  color: var(--cert-valid);
}

/* Not-found state */
.cert-result-invalid .cert-empty {
  border: 1px solid rgba(179, 38, 30, 0.28);
  border-radius: 18px;
  padding: 2.5rem 1.75rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(179, 38, 30, 0.06), var(--brand-surface) 60%);
}

.cert-empty-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--cert-invalid);
  background-color: rgba(179, 38, 30, 0.1);
  animation: cert-shake 480ms ease both;
}

.cert-empty-mark svg {
  width: 28px;
  height: 28px;
}

@keyframes cert-shake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

.cert-empty-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: 0.55rem;
}

.cert-empty-text {
  max-width: 520px;
  margin: 0 auto 1.5rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--brand-muted);
}

.cert-empty-code {
  font-weight: 700;
  color: var(--cert-invalid);
  background-color: rgba(179, 38, 30, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
}

.cert-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

/* ==========================================================================
   Help section
   ========================================================================== */
.cert-help {
  padding: 3.25rem 0;
}

.cert-help-title {
  font-family: var(--font-heading);
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
  text-align: center;
  margin-bottom: 1.75rem;
}

.cert-help-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  counter-reset: cert-step;
}

.cert-help-step {
  position: relative;
  padding: 1.4rem 1.25rem 1.25rem;
  border: 1px solid var(--brand-border);
  border-radius: 14px;
  background-color: var(--brand-surface);
  transition: transform var(--brand-transition), box-shadow var(--brand-transition), border-color var(--brand-transition);
}

.cert-help-step:hover {
  transform: translateY(-4px);
  border-color: var(--cert-gold);
  box-shadow: var(--brand-shadow-soft);
}

.cert-help-step-no {
  position: absolute;
  top: -0.85rem;
  left: 1.25rem;
  width: 1.7rem;
  height: 1.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--cert-gold), var(--cert-gold-light));
}

.cert-help-step h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.cert-help-step p {
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--brand-muted);
  margin-bottom: 0;
}

.cert-help-step code {
  font-size: 0.8rem;
  color: var(--brand-primary);
}

.cert-help-foot {
  text-align: center;
  font-size: 0.86rem;
  color: var(--brand-muted);
  margin-bottom: 0;
}

/* ==========================================================================
   Print — everything except the certificate itself is chrome.
   ========================================================================== */
@media print {
  .brand-header,
  .brand-footer,
  .cert-breadcrumb,
  .cert-hero,
  .cert-scanner,
  .cert-help,
  .cert-doc-actions {
    display: none !important;
  }

  .cert-stage {
    padding: 0;
  }

  .cert-result {
    animation: none;
    max-width: none;
  }

  .cert-doc {
    box-shadow: none;
  }

  .cert-seal {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cert-hero-glow,
  .cert-seal,
  .cert-result,
  .cert-empty-mark,
  .cert-scanner-beam {
    animation: none;
  }

  .cert-console-field:focus-within,
  .cert-help-step:hover,
  .cert-btn:hover {
    transform: none;
  }
}
