/* ==========================================================================
   KreditChain — the access gate.

   Standalone on purpose. This is loaded by pages with three different
   stylesheets between them (styles.css, demo.css, the cheatsheet's own print
   CSS), so it must not depend on anyone else's custom properties. Every value
   here is literal, and every value is from the brand specification.

   WHAT THIS IS AND IS NOT

   This hides the page until Firebase Auth confirms a signed-in account that
   also holds a members/{uid} record. It is a real check against real rules,
   and it is the right control for the DATA — Firestore refuses the read.

   It is NOT a control over these static files. Firebase Hosting serves the
   HTML, the CSS and the JavaScript to anyone who asks for the URL, signed in
   or not. Anyone who opens the network tab has the markup. Gating a static
   page in the browser keeps out visitors, not adversaries. If a page must be
   genuinely unreadable without credentials, its content has to move behind a
   function that checks the ID token before it returns anything.
   ========================================================================== */

/* Written into the markup as class="kove-gated" on <html> — NOT added by
   script. A page that adds it with JavaScript shows its whole content to a
   browser with JavaScript switched off, which is the one visitor the gate
   most obviously has to stop. gate.js removes it once access is granted, so
   no gated content is painted even for a frame.

   <noscript> is the single exception that stays visible: it renders only when
   scripting is off, which is exactly when there is nothing else to say. */
html.kove-gated body > *:not(.auth-gate):not(noscript) { display: none !important; }
html.kove-gated body { background: #F7F9FB; }

/* Shown by gate-boot.js when the SDK never arrives, and by <noscript> when
   scripting is off. Same card, so both failures look like the gate and not
   like a broken page. */
.gate-fallback {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: #F7F9FB;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5; color: #0C2040;
}
.gate-fallback .auth-card {
  width: 100%; max-width: 420px; background: #FFFFFF;
  border: 1px solid #DCE5ED; border-radius: 12px; padding: 34px 32px;
  box-shadow: 0 1px 2px rgba(12, 32, 64, .05), 0 18px 44px -18px rgba(12, 32, 64, .22);
}
.gate-fallback h2 {
  font-family: Montserrat, Inter, sans-serif; font-weight: 600;
  font-size: 21px; letter-spacing: -.01em; margin: 0 0 6px;
}
.gate-fallback p { color: #4A6180; font-size: 14px; margin: 0 0 14px; }
.gate-fallback p:last-child { margin-bottom: 0; }
.gate-fallback .gate-brand {
  display: flex; align-items: center; gap: 11px; margin-bottom: 22px;
  font-family: Montserrat, Inter, sans-serif; font-weight: 700;
  font-size: 17px; letter-spacing: .12em; text-transform: uppercase; color: #0C2040;
}
.gate-fallback .brand-mark {
  width: 30px; height: 34px; flex: none;
  background: url("../img/kove-mark.png") center/contain no-repeat;
}

.auth-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: #F7F9FB;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5; color: #0C2040;
  overflow-y: auto;
}

.auth-gate .auth-card {
  width: 100%; max-width: 420px; background: #FFFFFF;
  border: 1px solid #DCE5ED; border-radius: 12px; padding: 34px 32px;
  box-shadow: 0 1px 2px rgba(12, 32, 64, .05), 0 18px 44px -18px rgba(12, 32, 64, .22);
}

/* The wordmark: Montserrat Bold, tracked, as the specification requires. */
.auth-gate .auth-brand {
  display: flex; align-items: center; gap: 11px; margin-bottom: 22px;
  font-family: Montserrat, Inter, sans-serif; font-weight: 700;
  font-size: 17px; letter-spacing: .12em; text-transform: uppercase; color: #0C2040;
}
.auth-gate .brand-mark {
  width: 30px; height: 34px; flex: none;
  background: url("../img/kove-mark.png") center/contain no-repeat;
}

.auth-gate h2 {
  font-family: Montserrat, Inter, sans-serif; font-weight: 600;
  font-size: 21px; letter-spacing: -.01em; margin: 0 0 6px;
}
.auth-gate .auth-sub { color: #5E7189; font-size: 14px; margin: 0 0 20px; }

.auth-gate .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.auth-gate .field label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: #5C728E; font-weight: 500;
}
.auth-gate input {
  font: inherit; font-size: 14.5px; padding: 10px 12px; color: #0C2040;
  border: 1px solid #C3D1DE; border-radius: 6px; background: #FFFFFF;
}
.auth-gate input:focus-visible { outline: 2px solid #0070C0; outline-offset: 1px; border-color: #0070C0; }

.auth-gate .auth-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.auth-gate .btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  padding: 10px 16px; border-radius: 6px; border: 1px solid transparent; flex: 1 1 auto;
}
.auth-gate .btn-primary { background: #0070C0; color: #FFFFFF; }
.auth-gate .btn-primary:hover:not(:disabled) { background: #005A9A; }
.auth-gate .btn-primary:disabled { opacity: .55; cursor: default; }
.auth-gate .btn-ghost { background: #FFFFFF; color: #2A3E5C; border-color: #C3D1DE; }
.auth-gate .btn-ghost:hover { border-color: #0070C0; color: #0070C0; }

.auth-gate .auth-link {
  display: block; margin-top: 14px; background: none; border: 0; padding: 0;
  cursor: pointer; font: inherit; font-size: 13px; color: #5E7189; text-align: left;
}
.auth-gate .auth-link:hover { color: #0C2040; }

.auth-gate .auth-fine {
  font-size: 12.5px; color: #5E7189; margin: 20px 0 0;
  padding-top: 16px; border-top: 1px solid #DCE5ED;
}
.auth-gate .auth-fine code { font-size: 11.5px; word-break: break-all; }
.auth-gate .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.auth-gate .msg { padding: 11px 14px; border-radius: 6px; font-size: 13.5px; margin-bottom: 14px; }
.auth-gate .msg-err  { background: #FBECE8; color: #A8452C; }
.auth-gate .msg-ok   { background: #E1F7F2; color: #00806B; }
.auth-gate .msg-warn { background: #FBF3E2; color: #8A6A1F; }

@media (max-width: 480px) {
  .auth-gate .auth-card { padding: 26px 22px; }
}
