/* ══════════════════════════════════════════
   CERTIFICATE — NINTENDO-STYLED
   Red/gold Nintendo Switch UI chrome, question blocks,
   pixel-font headers, Super Mario iconography.
   ══════════════════════════════════════════ */

/* ── Overlay ── */
.cert-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(6, 4, 8, 0.92);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top, 0px)) max(1.25rem, env(safe-area-inset-right, 0px)) max(1.25rem, env(safe-area-inset-bottom, 0px)) max(1.25rem, env(safe-area-inset-left, 0px));
  opacity: 0;
  transition: opacity 0.4s ease;
}
.cert-overlay.visible { display: flex; opacity: 1; }
.cert-overlay-inner {
  max-width: 880px;
  width: 100%;
  animation: certReveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ── The Certificate ── */
.certificate {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 4px,
      rgba(230, 0, 18, 0.012) 4px,
      rgba(230, 0, 18, 0.012) 5px
    ),
    linear-gradient(175deg, #fffcf5 0%, #faf7f0 30%, #f5eed8 70%, #efe5cc 100%);
  color: #1a1610;
  box-shadow:
    0 0 0 3px var(--nintendo-red),
    0 0 0 5px rgba(230, 0, 18, 0.3),
    0 0 0 8px rgba(230, 0, 18, 0.1),
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(230, 0, 18, 0.08);
}

/* ── Top Red Banner — Switch UI chrome ── */
.cert-top-bar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  background:
    linear-gradient(180deg, #ff1a2c 0%, var(--nintendo-red) 40%, var(--nintendo-primary-hover) 100%);
  border-bottom: 3px solid #8a0009;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 4px 16px rgba(0, 0, 0, 0.25);
}
.cert-top-bar-logo {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.cert-top-bar-text {
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
  line-height: 1.6;
}

/* ── Holographic security shimmer ── */
.cert-holo-veil {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.12;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(230, 0, 18, 0.08) 42%,
    rgba(255, 214, 10, 0.14) 50%,
    rgba(57, 70, 160, 0.1) 58%,
    transparent 70%
  );
  background-size: 220% 220%;
  animation: certHoloDrift 8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .cert-holo-veil {
    animation: none;
    opacity: 0.08;
  }
}

/* ── Decorative Borders — Red outer + Gold inner ── */
.cert-border-outer {
  position: absolute;
  inset: 8px;
  border: 3px solid var(--nintendo-red);
  border-radius: 8px;
  pointer-events: none;
  z-index: 1;
}
.cert-border-inner {
  position: absolute;
  inset: 16px;
  border: 2px solid var(--coin-gold, #ffd60a);
  border-radius: 6px;
  pointer-events: none;
  z-index: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 214, 10, 0.15);
}

/* ── Question Block Corner Ornaments ── */
.q-block {
  position: absolute;
  width: 28px;
  height: 28px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: #6a4a00;
  background:
    linear-gradient(145deg, #ffe066 0%, var(--block-gold, #ffc400) 40%, var(--block-gold-mid, #e8a200) 100%);
  border: 2px solid var(--stage-coin-rim, #b86a08);
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.15);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.q-block.tl { top: 20px; left: 20px; }
.q-block.tr { top: 20px; right: 20px; }
.q-block.bl { bottom: 20px; left: 20px; }
.q-block.br { bottom: 20px; right: 20px; }

/* ── Diagonal Issue Ribbon ── */
.cert-issue-ribbon {
  position: absolute;
  top: 28px;
  right: -44px;
  z-index: 6;
  transform: rotate(38deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.06rem;
  min-width: 200px;
  padding: 0.3rem 2.5rem;
  background:
    linear-gradient(90deg, var(--nintendo-red) 0%, var(--nintendo-primary-hover) 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.cert-ribbon-label {
  font-family: var(--font-mono);
  font-size: 0.35rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.88);
}
.cert-ribbon-value {
  font-family: var(--font-mono);
  font-size: 0.48rem;
  letter-spacing: 0.1em;
  color: #fff;
  font-weight: 600;
}

/* ── Brand Lockup ── */
.cert-nintendo-lockup {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.6rem;
  padding: 0.45rem 1.4rem;
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(230, 0, 18, 0.06) 0%, rgba(255, 214, 10, 0.06) 50%, rgba(57, 70, 160, 0.05) 100%);
  border: 2px solid var(--nintendo-red);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 2px 8px rgba(230, 0, 18, 0.08);
}
.cert-lockup-logo {
  flex-shrink: 0;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.cert-lockup-text {
  font-family: var(--font-pixel);
  font-size: 0.32rem;
  color: var(--nintendo-red);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.6;
}

/* ── Seal Row — Stars flanking org name ── */
.cert-seal-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
}
.cert-seal-top .seal-icon {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: #6a4a00;
  line-height: 1;
  background:
    radial-gradient(circle at 38% 30%, #fff8e0 0%, var(--coin-gold, #ffd60a) 50%, #c9a000 100%);
  box-shadow:
    0 0 0 2px #b89848,
    0 0 0 3px rgba(255, 214, 10, 0.2),
    inset 0 2px 4px rgba(255, 255, 255, 0.7),
    inset 0 -3px 6px rgba(0, 0, 0, 0.08),
    0 4px 12px rgba(0, 0, 0, 0.12);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: certStarGlow 3s ease-in-out infinite;
}

.cert-seal-approval-caption {
  font-family: var(--font-mono);
  font-size: 0.38rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #9a8a64;
  margin: 0 0 0.5rem;
}

.cert-org-name {
  font-family: var(--font-pixel);
  font-size: 0.42rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--nintendo-red);
  line-height: 1.5;
}

/* ── Title ── */
.cert-doc-type {
  font-family: var(--font-pixel);
  font-size: clamp(0.6rem, 2vw, 0.78rem);
  color: var(--nintendo-red);
  margin: 0.2rem 0 0.1rem;
  line-height: 1.7;
  text-shadow:
    2px 2px 0 rgba(172, 0, 13, 0.12),
    0 0 20px rgba(230, 0, 18, 0.08);
  letter-spacing: 0.04em;
}
.cert-doc-sub {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8a7a5a;
  margin-bottom: 1rem;
}
.cert-rule {
  width: 140px;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--coin-gold, #ffd60a) 20%, var(--coin-gold, #ffd60a) 80%, transparent 100%);
  margin: 0 auto 0.7rem;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(255, 214, 10, 0.2);
}

/* ── Recipient ── */
.cert-preamble {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: #5a5040;
  margin-bottom: 0.25rem;
}
.cert-recipient-name {
  font-family: var(--font-sans);
  font-size: clamp(1.35rem, 2.8vw, 1.85rem);
  font-weight: 700;
  color: var(--nintendo-red);
  margin-bottom: 0.08rem;
  word-break: break-word;
  text-shadow: 0 1px 0 rgba(230, 0, 18, 0.08);
}
.cert-recipient-dept {
  font-family: var(--font-pixel);
  font-size: 0.38rem;
  color: var(--nintendo-secondary, #3946a0);
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
  line-height: 1.7;
}
.cert-body-text {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: #5a5040;
  line-height: 1.55;
  max-width: 480px;
  margin-bottom: 0.8rem;
}

/* ── Rank Block — Nintendo "item acquired" style ── */
.cert-rank-block {
  max-width: 440px;
  margin-bottom: 0.6rem;
  padding: 0.4rem 0.85rem;
  background:
    linear-gradient(135deg, rgba(230, 0, 18, 0.04) 0%, rgba(255, 214, 10, 0.06) 50%, rgba(57, 70, 160, 0.04) 100%);
  border: 2px solid var(--nintendo-red);
  border-radius: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.06);
}
.cert-rank-title {
  font-family: var(--font-pixel);
  font-size: 0.42rem;
  line-height: 1.8;
  color: var(--nintendo-red);
  margin-bottom: 0.3rem;
}
.cert-rank-blurb {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: #4a4034;
  line-height: 1.5;
  margin: 0;
}

/* ── Certificate Body ── */
.cert-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 2.5rem 1.6rem;
  padding-left: 4.8rem;
  padding-right: 4rem;
  text-align: center;
  position: relative;
  z-index: 3;
}

/* ── Stars row ── */
.cert-stars {
  display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 0.7rem;
}
.cert-star {
  width: 24px; height: 24px; color: #c9a84c;
}
.cert-star.earned {
  color: var(--coin-gold, #ffd60a);
  filter: drop-shadow(0 0 4px rgba(255, 214, 10, 0.4));
}

/* ── Signatures ── */
.cert-sig-row {
  display: flex; gap: 2.2rem; justify-content: center; align-items: flex-end;
  margin-top: auto;
}
.cert-sig {
  text-align: center;
  min-width: 130px;
}
.cert-sig-line {
  font-family: var(--font-sans);
  font-style: italic;
  font-size: 1rem;
  color: #3a3020;
  border-bottom: 2px solid var(--nintendo-red);
  padding-bottom: 2px;
  margin-bottom: 4px;
  line-height: 1.3;
}
.cert-sig-title {
  font-family: var(--font-pixel);
  font-size: 0.28rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a7a5a;
  line-height: 1.6;
}

/* ── Wax Seal (Nintendo red, mushroom/star) ── */
.cert-wax-seal {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 55% 40% at 38% 28%, rgba(255, 255, 255, 0.5) 0%, transparent 55%),
    radial-gradient(circle at 35% 32%, #ff5a5a 0%, var(--nintendo-red) 40%, var(--nintendo-primary-hover) 70%, #6a0008 100%);
  box-shadow:
    inset 0 3px 6px rgba(255, 255, 255, 0.4),
    inset 0 -6px 14px rgba(0, 0, 0, 0.35),
    0 8px 24px rgba(0, 0, 0, 0.3);
  border: 3px solid rgba(20, 0, 4, 0.4);
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .cert-wax-seal {
    animation: certWaxFloat 5s ease-in-out infinite;
  }
}
@media (prefers-reduced-motion: reduce) {
  .cert-wax-seal {
    animation: none;
  }
}

.cert-wax-seal::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  z-index: -1;
  background: repeating-conic-gradient(
    from -4deg,
    rgba(172, 0, 13, 0.5) 0deg 7deg,
    rgba(255, 255, 255, 0.08) 7deg 14deg
  );
  opacity: 0.5;
  mask: radial-gradient(circle closest-side, transparent calc(100% - 5px), #000 calc(100% - 4px) 100%);
  -webkit-mask: radial-gradient(circle closest-side, transparent calc(100% - 5px), #000 calc(100% - 4px) 100%);
}

.cert-wax-seal::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.cert-wax-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  position: relative;
  z-index: 1;
}
.cert-wax-star {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.98);
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
.cert-wax-slop {
  font-family: var(--font-pixel);
  font-size: 0.28rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ── Bottom Gold Seal ── */
.cert-bottom-seal {
  position: absolute;
  bottom: 24px;
  right: 32px;
  z-index: 7;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0.92;
  background:
    radial-gradient(circle at 42% 32%, rgba(255, 255, 255, 0.7) 0%, transparent 45%),
    linear-gradient(165deg, #fff8d6 0%, var(--coin-gold, #ffd60a) 50%, #c99a00 100%);
  border: 2px solid #a87800;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.7),
    inset 0 -4px 10px rgba(80, 60, 0, 0.15),
    0 0 0 1px rgba(255, 252, 200, 0.8),
    0 6px 18px rgba(0, 0, 0, 0.2);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.12));
  animation: certSealSpin 12s linear infinite;
}

.cert-bottom-seal::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px dashed rgba(138, 100, 0, 0.5);
  pointer-events: none;
}
.cert-bottom-seal::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 1px solid #c9a000;
  box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.cert-seal-micro {
  font-family: var(--font-mono);
  font-size: 0.24rem;
  color: #8a6a00;
  position: relative;
  z-index: 1;
}
.cert-bottom-seal .seal-slop {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  color: #6a4a00;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.cert-bottom-seal .seal-ring {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(184, 152, 72, 0.55);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.cert-seal-verified {
  font-family: var(--font-pixel);
  font-size: 0.22rem;
  font-weight: 600;
  color: #6a4a00;
  letter-spacing: 0.08em;
  position: relative;
  z-index: 1;
  line-height: 1.5;
}

/* ── Floating Pixel Decorations ── */
.pixel-deco {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  font-size: 1.2rem;
  opacity: 0.08;
}
.pixel-deco.d1 { top: 36%; left: 18%; transform: rotate(-12deg); }
.pixel-deco.d2 { top: 65%; right: 15%; transform: rotate(8deg); }
.pixel-deco.d3 { bottom: 18%; left: 25%; transform: rotate(15deg); }

/* ── Footer Bar — Switch HUD style ── */
.cert-footer-bar {
  position: relative;
  z-index: 5;
  padding: 0.55rem 1.25rem 0.6rem;
  background:
    linear-gradient(180deg, #2d2d2d 0%, #1a1a1a 100%);
  border-top: 3px solid var(--nintendo-red);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.cert-footer-credentials {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-align: center;
}
.cert-footer-registry {
  font-family: var(--font-mono);
  font-size: 0.42rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--nintendo-red);
}
.cert-footer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}
.cert-footer-bar .cert-footer-meta span {
  font-family: var(--font-pixel);
  font-size: 0.32rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #969696;
  line-height: 1.5;
}
.cert-footer-bar #cert-disp-cred {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c8c8c8;
  word-break: break-word;
}
.cert-footer-bar #cert-disp-lives {
  color: var(--pipe-green, #3ddc84);
}
.cert-footer-bar #cert-disp-coins {
  color: var(--coin-gold, #ffd60a);
}

/* ── Overlay action buttons ── */
.cert-actions {
  display: flex; gap: 0.8rem; justify-content: center; margin-top: 1.4rem; flex-wrap: wrap;
}
.cert-action-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  font-family: var(--font-pixel);
  font-size: 0.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  line-height: 1.5;
}
.cert-action-btn.primary {
  background: var(--nintendo-red); color: #fff;
  border-color: var(--nintendo-primary-hover);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 4px 12px rgba(230, 0, 18, 0.3);
}
.cert-action-btn.primary:hover {
  background: var(--nintendo-primary-hover);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 6px 20px rgba(230, 0, 18, 0.4);
}
.cert-action-btn.secondary {
  background: rgba(255, 255, 255, 0.06); color: #dadada; border-color: rgba(255, 255, 255, 0.15);
}
.cert-action-btn.secondary:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); }
.cert-action-btn.ghost {
  background: transparent; color: var(--text-muted);
}
.cert-action-btn.ghost:hover { color: var(--text-primary); }

.cert-action-btn:focus-visible {
  outline: 3px solid var(--nintendo-secondary, #3946a0);
  outline-offset: 3px;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .cert-body {
    padding: 2rem 2.5rem;
    padding-left: 4.2rem;
  }
  .cert-sig-row { gap: 1.2rem; flex-wrap: wrap; }
  .cert-sig { min-width: 100px; }
  .cert-wax-seal { width: 54px; height: 54px; left: 10px; }
  .cert-bottom-seal { width: 60px; height: 60px; bottom: 18px; right: 22px; }
}

/* ── Animations ── */
@keyframes certStarGlow {
  0%, 100% {
    box-shadow: 0 0 0 2px #b89848, 0 0 0 3px rgba(255, 214, 10, 0.2), inset 0 2px 4px rgba(255, 255, 255, 0.7), inset 0 -3px 6px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.12);
  }
  50% {
    box-shadow: 0 0 0 2px #b89848, 0 0 0 3px rgba(255, 214, 10, 0.4), 0 0 12px rgba(255, 214, 10, 0.2), inset 0 2px 4px rgba(255, 255, 255, 0.7), inset 0 -3px 6px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.12);
  }
}

@keyframes certSealSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
