/* Field certificate overlay + operator name prompt + print rules.
   Measured spec: docs/monolith-parity-spec.md — "Certificate + name prompt". */

/* ---- certificate overlay (z 9998; closes via button only) ---- */

.cert-scrim {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(5, 10, 20, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow: auto;
}

.cert-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

#cert-print {
  width: 720px;
  max-width: 100%;
  background: var(--navy);
  border: 2px solid var(--primary);
  box-shadow: 0 0 50px rgba(0, 240, 255, 0.2);
}

.cert-titlebar {
  background: var(--primary);
  color: var(--navy);
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
  font-family: var(--font-identity);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.06em;

  .cert-titlebar-org {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .cert-titlebar-terminal {
    opacity: 0.7;
    flex: none;
  }
}

.cert-body {
  padding: 44px 48px 40px;
  text-align: center;
  position: relative;
}

.cert-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}

.cert-content {
  position: relative;

  > img {
    display: block;
    margin: 0 auto 20px;
    opacity: 0.92;
  }
}

.cert-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--gray);
  margin-bottom: 18px;
}

.cert-course-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: 0.08em;
  color: var(--white);
  margin-bottom: 6px;
}

.cert-course-sub {
  color: var(--gray);
  font-size: 15px;
  margin-bottom: 26px;
}

.cert-awarded-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--gray);
  margin-bottom: 8px;
}

.cert-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 27px;
  letter-spacing: 0.06em;
  color: var(--success);
  text-shadow: 0 0 18px rgba(0, 255, 157, 0.35);
  margin-bottom: 6px;
}

.cert-rule {
  width: 160px;
  height: 1px;
  background: rgba(0, 240, 255, 0.35);
  margin: 0 auto 26px;
}

.cert-attained-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--gray);
  margin-bottom: 6px;
}

.cert-clearance {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 30px;
}

.cert-stamp {
  display: inline-block;
  border: 3px solid var(--success);
  color: var(--success);
  padding: 14px 26px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: 0.2em;
  transform: rotate(-4deg);
  background: rgba(0, 255, 157, 0.08);
  box-shadow: 0 0 24px rgba(0, 255, 157, 0.25);
  margin-bottom: 32px;
}

.cert-footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgba(0, 240, 255, 0.2);
  padding-top: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--gray);

  .cert-issued { color: var(--white); }
  .cert-auth { color: var(--primary); }
}

#cert-controls {
  display: flex;
  gap: 12px;
}

.cert-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 12px 22px;
  cursor: pointer;

  &.solid {
    background: var(--primary);
    border: 1px solid var(--primary);
    color: var(--navy);
  }
  &.outline-cyan {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
  }
  &.outline-gray {
    background: transparent;
    border: 1px solid var(--gray);
    color: var(--gray);
  }
}

/* ---- operator name prompt (z 9999, cyan; click-outside cancels) ---- */

.nameprompt-scrim {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(5, 10, 20, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.nameprompt-box {
  width: 440px;
  max-width: 100%;
  background: var(--navy);
  border: 1px solid var(--primary);
  box-shadow: 0 0 44px rgba(0, 240, 255, 0.22);
}

.nameprompt-titlebar {
  background: var(--primary);
  color: var(--navy);
  padding: 11px 20px;
  font-family: var(--font-identity);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0.1em;
}

.nameprompt-body { padding: 26px 28px 28px; }

.nameprompt-lead {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--gray);
  line-height: 1.6;
  margin-bottom: 18px;
}

.nameprompt-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--primary);
  margin-bottom: 7px;
}

.nameprompt-input {
  width: 100%;
  box-sizing: border-box;
  background: #050a14;
  border: 1px solid rgba(0, 240, 255, 0.4);
  color: var(--white);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.08em;
  padding: 12px 14px;
  outline: none;
  margin-bottom: 22px;
}

.nameprompt-actions {
  display: flex;
  gap: 12px;
}

.nameprompt-issue {
  flex: 1;
  background: var(--primary);
  border: 1px solid var(--primary);
  color: var(--navy);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  padding: 12px;
  cursor: pointer;

  &:disabled {
    background: rgba(0, 240, 255, 0.25);
    border-color: rgba(0, 240, 255, 0.3);
    cursor: not-allowed;
  }
}

.nameprompt-cancel {
  background: transparent;
  border: 1px solid var(--gray);
  color: var(--gray);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  padding: 12px 18px;
  cursor: pointer;
}

/* ---- print: the certificate is the page ----
   Fix over the monolith (which only flipped visibility): browsers strip
   background colours by default when printing, so the navy card and cyan
   titlebar vanished and left neon text on white paper. This variant is
   ink-on-paper by design — dark navy/teal/green text and borders, no
   reliance on backgrounds printing at all. */

@media print {
  body * { visibility: hidden !important; }
  #cert-print, #cert-print * { visibility: visible !important; }
  #cert-print {
    position: absolute !important;
    left: 0;
    top: 0;
    width: 100% !important;
    box-shadow: none !important;
    background: #fff !important;
    border-color: #0a192f !important;
  }
  /* rebuild ids: #vignette here (monolith had #vign) */
  #scanlines, #vignette, #cert-controls { display: none !important; }

  /* Night Corp palette on paper (user call, 2026-07-09): NC Navy takes the
     cyan roles, gold takes the green roles, black takes the grey roles,
     black logo. The titlebar stays a solid navy band: print-color-adjust
     exact makes the background print AND stops Chrome darkening the light
     text; the inset box-shadow is a band fallback for browsers that ignore
     the hint (shadows print as content ink either way). */
  #cert-print {
    .cert-titlebar {
      background: #0a192f !important;
      box-shadow: inset 0 0 0 200px #0a192f;
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
      color: #e6f1ff;
    }
    .cert-grid { display: none; }
    .cert-content > img { filter: brightness(0); } /* white monogram → black ink */
    .cert-kicker,
    .cert-awarded-label,
    .cert-attained-label,
    .cert-course-sub,
    .cert-footer { color: #000; }
    .cert-course-title { color: #0a192f; }
    .cert-name {
      color: #ffd400;
      text-shadow: none;
    }
    .cert-rule { background: #0a192f; }
    .cert-clearance { color: #0a192f; }
    .cert-stamp {
      color: #ffd400;
      border-color: #ffd400;
      background: transparent !important;
      box-shadow: none;
    }
    .cert-footer {
      border-top-color: #0a192f;
      .cert-issued { color: #0a192f; }
      .cert-auth { color: #0a192f; }
    }
  }
}
