/* ============================================================
   SecureBuilder — design system
   Tokens first (light + dark), then components.
   ============================================================ */

/* ---------- self-hosted Google Sans fonts ---------- */
@font-face {
  font-family: "GoogleSansText";
  src: url("/static/fonts/GoogleSansText-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "GoogleSansText";
  src: url("/static/fonts/GoogleSansText-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "GoogleSansText";
  src: url("/static/fonts/GoogleSans-MediumItalic.ttf") format("truetype");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "GoogleSansMono";
  src: url("/static/fonts/GoogleSansMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "GoogleSansMono";
  src: url("/static/fonts/GoogleSansMono-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "GoogleSansMono";
  src: url("/static/fonts/GoogleSansMono-MediumItalic.ttf") format("truetype");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

:root {
  /* type */
  --font-display: "GoogleSansText", system-ui, sans-serif;   /* weight 500 — titles, headings */
  --font-body:    "GoogleSansText", system-ui, sans-serif;   /* weight 400 — all default text  */
  --font-accent:  "GoogleSansText", system-ui, sans-serif;   /* weight 500 italic — callouts   */
  --font-mono:    "GoogleSansMono", ui-monospace, monospace;  /* weight 400 — code, scores, IDs */

  /* light theme */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --inset: #eef1f7;
  --border: #e3e8f0;
  --text: #0d1326;
  --muted: #5b657a;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --on-primary: #ffffff;
  --ring: rgba(79, 70, 229, .35);
  --shadow: 0 1px 2px rgba(13, 19, 38, .04), 0 10px 28px rgba(13, 19, 38, .06);

  /* semantic grade scale (used inline by the scorecard too) */
  --grade-a: #16a34a;
  --grade-b: #65a30d;
  --grade-c: #d97706;
  --grade-d: #ea580c;
  --grade-f: #dc2626;

  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1040px;
}

[data-theme="dark"] {
  --bg: #0a0e1a;
  --surface: #121829;
  --inset: #0e1322;
  --border: #1e2740;
  --text: #e6e9f2;
  --muted: #8a93a8;
  --primary: #7c83ff;
  --primary-hover: #6d72f0;
  --on-primary: #ffffff;
  --ring: rgba(124, 131, 255, .40);
  --shadow: 0 1px 2px rgba(0, 0, 0, .30), 0 12px 32px rgba(0, 0, 0, .38);

  --grade-a: #22c55e;
  --grade-b: #84cc16;
  --grade-c: #f59e0b;
  --grade-d: #fb923c;
  --grade-f: #ef4444;
}

/* No-JS safety net: honor the OS setting if the script never set a theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0a0e1a; --surface: #121829; --inset: #0e1322; --border: #1e2740;
    --text: #e6e9f2; --muted: #8a93a8; --primary: #7c83ff; --primary-hover: #6d72f0;
    --ring: rgba(124, 131, 255, .40);
    --shadow: 0 1px 2px rgba(0, 0, 0, .30), 0 12px 32px rgba(0, 0, 0, .38);
    --grade-a: #22c55e; --grade-b: #84cc16; --grade-c: #f59e0b; --grade-d: #fb923c; --grade-f: #ef4444;
  }
}

/* ---------- reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; }

/* headings — Medium (500) */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

.mono  { font-family: var(--font-mono); }
.muted { color: var(--muted); }

/* ---------- layout ---------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }
.main { flex: 1 0 auto; padding-block: 36px 56px; }
.stack > * + * { margin-top: 16px; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; gap: 18px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 500; }
.brand:hover { text-decoration: none; }
.brand .mark { color: var(--primary); display: inline-flex; }

/* wordmark — Medium (500), no longer needs font-weight:700 override */
.wordmark { font-family: var(--font-display); font-size: 1.12rem; letter-spacing: -0.02em; font-weight: 500; }
.wordmark strong { font-weight: 500; } /* GoogleSansText has no Bold; Medium is the heaviest */

.nav-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-links a {
  color: var(--muted); font-size: .92rem; font-weight: 400;
  padding: 7px 11px; border-radius: 8px;
}
.nav-links a:hover { color: var(--text); background: var(--inset); text-decoration: none; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--primary); }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display);
  font-weight: 500; font-size: .95rem; line-height: 1;
  padding: 12px 20px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn--block { width: 100%; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }

/* ---------- forms ---------- */
.field { display: block; }
.field > label {
  display: block; font-size: .85rem; font-weight: 500;
  color: var(--muted); margin-bottom: 7px;
}
.input {
  width: 100%; padding: 12px 14px; font-size: .95rem; font-family: var(--font-mono);
  font-weight: 400;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--muted); opacity: .7; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.scan-form { display: flex; gap: 10px; flex-wrap: wrap; }
.scan-form .input { flex: 1; min-width: 240px; }

/* ---------- hero (landing) ---------- */
.hero { padding-block: 40px 28px; }
.eyebrow {
  font-family: var(--font-mono); font-size: .74rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--primary); font-weight: 500;
}

/* lead — accent: Medium Italic, draws user attention to the subtitle */
.lead {
  font-family: var(--font-accent);
  font-weight: 500;
  font-style: italic;
  color: var(--muted); font-size: 1.06rem; max-width: 60ch; margin-top: 14px;
}
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

/* ---------- scorecard ---------- */
.scorecard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.scorecard + .scorecard { margin-top: 16px; }
.scorecard-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.repo-name { font-family: var(--font-display); font-weight: 500; font-size: 1.1rem; word-break: break-all; }
.repo-meta { font-family: var(--font-mono); font-weight: 400; font-size: .8rem; color: var(--muted); margin-top: 4px; }

.status { display: inline-block; margin-top: 8px; padding: 3px 11px; border-radius: 999px; font-size: .72rem; font-weight: 500; font-family: var(--font-mono); letter-spacing: .03em; }
.status--ok      { background: color-mix(in srgb, var(--grade-a) 16%, transparent); color: var(--grade-a); }
.status--blocked { background: color-mix(in srgb, var(--grade-f) 16%, transparent); color: var(--grade-f); }

.grade {
  width: 56px; height: 56px; flex-shrink: 0; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 500; font-size: 1.9rem; color: #fff;
}

.meter { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.meter-label { font-family: var(--font-mono); font-weight: 400; font-size: .8rem; color: var(--muted); min-width: 96px; }
.meter-track { flex: 1; height: 10px; background: var(--inset); border-radius: 6px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 6px; }

.scanners { margin-top: 20px; display: grid; gap: 11px; }
.scanner-row { display: flex; align-items: center; gap: 12px; }
.scanner-name { min-width: 184px; font-size: .86rem; font-weight: 400; color: var(--text); }
.scanner-track { flex: 1; height: 7px; background: var(--inset); border-radius: 5px; overflow: hidden; }
.scanner-fill { height: 100%; border-radius: 5px; }
.scanner-value { min-width: 104px; text-align: right; font-family: var(--font-mono); font-weight: 400; font-size: .78rem; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 44px 0; }

/* ---------- banners ---------- */
/* accent font (Medium Italic) — these are the "pay attention" moments */
.banner {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: .92rem;
  font-family: var(--font-accent); font-weight: 500; font-style: italic;
  border: 1px solid transparent;
}
.banner + * { margin-top: 16px; }
.banner--ok  { background: color-mix(in srgb, var(--grade-a) 12%, transparent); color: var(--grade-a); border-color: color-mix(in srgb, var(--grade-a) 30%, transparent); }
.banner--err { background: color-mix(in srgb, var(--grade-f) 12%, transparent); color: var(--grade-f); border-color: color-mix(in srgb, var(--grade-f) 30%, transparent); }

/* ---------- scanning state ---------- */
.scanning { text-align: center; padding: 48px 20px; }
.scanning .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* ---------- AI review prose ---------- */
.prose { font-size: .95rem; font-weight: 400; color: var(--text); }
.prose h2 { font-size: 1.05rem; font-weight: 500; margin: 20px 0 8px; }
.prose p { margin: 8px 0; color: var(--text); }
.prose ul, .prose ol { margin: 8px 0 8px 20px; }
.prose li { margin: 4px 0; }
.prose pre { background: var(--inset); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 10px 0; }
.prose code { font-family: var(--font-mono); font-size: .85em; }
.prose :not(pre) > code { color: var(--primary); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: auto; }
.footer-inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-block: 22px; }
.footer-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.footer-brand .mark { color: var(--primary); display: inline-flex; }
.footer-note { color: var(--muted); font-size: .85rem; flex: 1; min-width: 200px; }
.footer-links { display: flex; gap: 14px; }
.footer-links a { color: var(--muted); font-size: .85rem; }
.footer-links a:hover { color: var(--text); text-decoration: none; }

/* ---------- accessibility / motion / responsive ---------- */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (max-width: 640px) {
  .nav { gap: 10px; }
  .nav-links { gap: 0; }
  .nav-links a { padding: 6px 8px; font-size: .85rem; }
  .wordmark { font-size: 1rem; }
  .scanner-name { min-width: 130px; }
  .meter-label { min-width: 78px; }
}

/* ---------- auth, cta, user list (migrated pages) ---------- */
.auth { max-width: 400px; margin: 40px auto; }
.cta { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.user-list { margin-top: 10px; }
.user-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.user-row:last-child { border-bottom: none; }
