/* 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 {
  /* A printed document, not a screen: the ladder is compressed at the top
     because the course title and the operator's name compete deliberately. */
  --fs-title:     30px; /* course title */
  --fs-heading:   27px; /* operator name, CERTIFIED stamp */
  --fs-secondary: 20px; /* clearance level */
  --fs-body:      15px; /* course subtitle */
  --fs-ui:        12px; /* titlebar, buttons, attained label */
  --fs-label:     11px; /* kicker, awarded label, fine print */

  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  background: rgb(from var(--field-bg) r g b / 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--scrim-pad);
  overflow: auto;
}

.cert-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3xl);
}

#cert-print {
  width: 720px;
  max-width: 100%;
  background: var(--bg);
  border: 2px solid var(--primary);
  box-shadow: 0 0 50px rgb(from var(--primary) r g b / 0.2);
}

.cert-titlebar {
  background: var(--primary);
  color: var(--bg);
  padding: var(--space-lg) var(--space-5xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-xl);
  white-space: nowrap;
  font-family: var(--font-identity);
  font-weight: 400;
  font-size: var(--fs-ui);
  letter-spacing: var(--tracking-label);

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

.cert-body {
  padding: 44px 48px var(--frame-gutter);
  text-align: center;
  position: relative;
}

.cert-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgb(from var(--primary) r g b / 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgb(from var(--primary) r g b / 0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}

.cert-content {
  position: relative;

  > img {
    display: block;
    margin: 0 auto var(--space-4xl);
    opacity: 0.92;
  }
}

.cert-kicker {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-wide);
  color: var(--muted);
  margin-bottom: var(--space-3xl);
}

.cert-course-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-title);
  letter-spacing: var(--tracking-label);
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.cert-course-sub {
  color: var(--muted);
  font-size: var(--fs-body);
  margin-bottom: 26px;
}

.cert-awarded-label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-caps);
  color: var(--muted);
  margin-bottom: var(--space-sm);
}

.cert-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-heading);
  letter-spacing: var(--tracking-label);
  color: var(--success);
  text-shadow: 0 0 18px rgb(from var(--success) r g b / 0.35);
  margin-bottom: var(--space-xs);
}

.cert-rule {
  width: 160px;
  height: 1px;
  background: rgb(from var(--primary) r g b / 0.35);
  margin: 0 auto 26px;
}

.cert-attained-label {
  font-family: var(--font-mono);
  font-size: var(--fs-ui);
  letter-spacing: var(--tracking-mid);
  color: var(--muted);
  margin-bottom: var(--space-xs);
}

.cert-clearance {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-secondary);
  letter-spacing: var(--tracking-mid);
  color: var(--primary);
  margin-bottom: 30px;
}

.cert-stamp {
  display: inline-block;
  border: 3px solid var(--success);
  color: var(--success);
  padding: var(--space-xl) 26px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-heading);
  letter-spacing: var(--tracking-wide);
  transform: rotate(-4deg);
  background: rgb(from var(--success) r g b / 0.08);
  box-shadow: 0 0 24px rgb(from var(--success) r g b / 0.25);
  margin-bottom: var(--scrim-pad);
}

.cert-footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgb(from var(--primary) r g b / 0.2);
  padding-top: var(--space-3xl);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-label);
  color: var(--muted);

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

#cert-controls {
  display: flex;
  gap: var(--space-lg);
}

.cert-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-ui);
  letter-spacing: var(--tracking-mid);
  padding: var(--space-lg) var(--space-5xl);
  cursor: pointer;

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

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

/* Its own root: a fixed scrim at App level, so it inherits :root, not .cert-scrim. */
.nameprompt-scrim {
  --fs-secondary: 16px; /* the name field */
  --fs-ui:        14px; /* titlebar */
  --fs-label:     12px; /* lead, validation issue, buttons */
  --fs-micro:     10px; /* field label */

  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  background: rgb(from var(--field-bg) r g b / 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--scrim-pad);
}

.nameprompt-box {
  width: 440px;
  max-width: 100%;
  background: var(--bg);
  border: 1px solid var(--primary);
  box-shadow: 0 0 44px rgb(from var(--primary) r g b / 0.22);
}

.nameprompt-titlebar {
  background: var(--primary);
  color: var(--bg);
  padding: var(--space-md) var(--space-4xl);
  font-family: var(--font-identity);
  font-weight: 400;
  font-size: var(--fs-ui);
  letter-spacing: var(--tracking-mid);
}

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

.nameprompt-lead {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-label);
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: var(--space-3xl);
}

.nameprompt-label {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-mid);
  color: var(--primary);
  margin-bottom: var(--space-xs);
}

.nameprompt-input {
  width: 100%;
  box-sizing: border-box;
  background: #050a14;
  border: 1px solid rgb(from var(--primary) r g b / 0.4);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-secondary);
  letter-spacing: var(--tracking-label);
  padding: var(--space-lg) var(--space-xl);
  outline: none;
  margin-bottom: var(--space-5xl);
}

.nameprompt-actions {
  display: flex;
  gap: var(--space-lg);
}

.nameprompt-issue {
  flex: 1;
  background: var(--primary);
  border: 1px solid var(--primary);
  color: var(--bg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-mid);
  padding: var(--space-lg);
  cursor: pointer;

  &:disabled {
    background: rgb(from var(--primary) r g b / 0.25);
    border-color: rgb(from var(--primary) r g b / 0.3);
    cursor: not-allowed;
  }
}

.nameprompt-cancel {
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-mid);
  padding: var(--space-lg) var(--space-3xl);
  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; }
    }
  }
}
