/* VaultScan — shared design tokens
   Technical / terminal aesthetic, with a tasteful, modern twist. */

:root {
  /* Type */
  --font-display: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-sans: "Söhne", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Colors — dark by default */
  --bg: #0A0E12;
  --bg-elev: #11161B;
  --bg-elev-2: #161C22;
  --line: rgba(255,255,255,0.08);
  --line-2: rgba(255,255,255,0.14);
  --ink: #E6EDF3;
  --ink-mute: #8B96A3;
  --ink-faint: #5A6573;

  --accent: #5EE6A8;        /* terminal green */
  --accent-dim: #2EBE7F;
  --accent-glow: rgba(94, 230, 168, 0.18);

  --crit: #FF5C7A;
  --high: #FFB86B;
  --med:  #FFE066;
  --low:  #7BD8FF;
  --ok:   #5EE6A8;

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  --radius: 6px;
  --radius-lg: 10px;
}

[data-theme="light"] {
  --bg: #F5F2EC;
  --bg-elev: #FFFFFF;
  --bg-elev-2: #FAF7F1;
  --line: rgba(20,18,15,0.10);
  --line-2: rgba(20,18,15,0.18);
  --ink: #14120F;
  --ink-mute: #5A554C;
  --ink-faint: #8B8478;

  --accent: #1F7D4D;
  --accent-dim: #156237;
  --accent-glow: rgba(31, 125, 77, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.mono { font-family: var(--font-mono); font-feature-settings: "ss02", "cv11"; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #061712;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.btn-ghost:hover { background: var(--bg-elev); border-color: var(--ink-mute); }

/* Generic cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

/* Caret blink */
@keyframes caret { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
.caret { display: inline-block; width: 0.6ch; background: var(--accent); height: 1em; vertical-align: -0.12em; animation: caret 1s steps(2) infinite; }

/* Severity dot */
.sev { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.sev::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.sev-crit { color: var(--crit); }
.sev-high { color: var(--high); }
.sev-med  { color: var(--med); }
.sev-low  { color: var(--low); }
.sev-ok   { color: var(--ok); }

/* Tabular nums helper */
.num { font-variant-numeric: tabular-nums; }

/* Subtle scanline */
@keyframes scan {
  0%   { transform: translateY(0); }
  100% { transform: translateY(100%); }
}

/* hairline divider */
.hr { height: 1px; background: var(--line); }

/* ─── Chrome: modals, toasts, inputs ───────────────────────── */
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Modal */
.vs-modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2,5,8,0.72);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: vsFade .14s ease-out;
}
.vs-modal {
  background: var(--bg-elev);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px var(--line);
  animation: vsRise .18s ease-out;
}
.vs-modal--wide { width: min(720px, 100%); }
.vs-modal-head {
  padding: 22px 28px 14px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--line);
}
.vs-modal-eyebrow {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 6px;
}
.vs-modal-title {
  font-size: 22px; font-weight: 500; letter-spacing: -0.015em; margin: 0;
}
.vs-modal-close {
  background: transparent; border: 1px solid var(--line-2); border-radius: 4px;
  width: 28px; height: 28px; padding: 0; color: var(--ink-mute);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 14px; line-height: 1;
}
.vs-modal-close:hover { color: var(--ink); border-color: var(--ink-mute); }
.vs-modal-body { padding: 20px 28px 24px; }
.vs-modal-foot {
  padding: 16px 28px;
  border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end; align-items: center;
  background: color-mix(in srgb, var(--bg) 30%, transparent);
}

/* Inputs */
.vs-label {
  display: block; font-family: var(--font-mono);
  font-size: 11px; color: var(--ink-faint);
  letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 8px;
}
.vs-input, .vs-textarea {
  width: 100%; padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-mono); font-size: 14px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.vs-input:focus, .vs-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.vs-input::placeholder, .vs-textarea::placeholder { color: var(--ink-faint); }

.vs-radio-group { display: grid; gap: 8px; }
.vs-radio {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .12s ease, background .12s ease;
}
.vs-radio:hover { border-color: var(--line-2); }
.vs-radio.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-glow) 70%, var(--bg));
}
.vs-radio-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--ink-faint); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.vs-radio.is-active .vs-radio-dot { border-color: var(--accent); }
.vs-radio.is-active .vs-radio-dot::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

/* Scan progress */
.vs-progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.vs-progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); transition: width .35s ease; }

/* Toasts */
.vs-toasts {
  position: fixed; right: 24px; bottom: 24px; z-index: 200;
  display: flex; flex-direction: column-reverse; gap: 10px;
  pointer-events: none;
}
.vs-toast {
  pointer-events: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px 12px 14px;
  min-width: 280px; max-width: 380px;
  display: flex; gap: 12px; align-items: flex-start;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  animation: vsToastIn .22s cubic-bezier(.2,.8,.2,1);
  font-size: 13px;
}
.vs-toast--crit { border-left-color: var(--crit); }
.vs-toast--ok   { border-left-color: var(--ok); }
.vs-toast-icon {
  font-family: var(--font-mono); font-size: 12px; flex-shrink: 0;
  color: var(--accent); margin-top: 1px;
}
.vs-toast--crit .vs-toast-icon { color: var(--crit); }
.vs-toast-text { line-height: 1.5; color: var(--ink); }
.vs-toast-text small { display: block; color: var(--ink-mute); font-size: 12px; margin-top: 2px; }

@keyframes vsFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes vsRise { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes vsToastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ─── Mobile responsive utilities ─────────────────────────── */
.row-stack { display: flex; gap: 16px; }
.cols-2, .cols-3, .cols-4 { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Hide on mobile / desktop — preserve the element's own display value on desktop */
.mobile-only { display: none !important; }

@media (max-width: 900px) {
  body { font-size: 15px; }
  .btn { padding: 10px 14px; font-size: 12px; }
  .vs-modal-head { padding: 18px 20px 12px; }
  .vs-modal-body { padding: 16px 20px 20px; }
  .vs-modal-foot { padding: 14px 20px; flex-wrap: wrap; }
  .vs-modal-title { font-size: 19px; }
  .vs-toasts { right: 12px; left: 12px; bottom: 12px; }
  .vs-toast { min-width: 0; max-width: none; }

  .mobile-only { display: flex !important; }
  .desktop-only { display: none !important; }

  /* generic responsive grid collapses */
  [data-mq="cols-stack"] { grid-template-columns: 1fr !important; }
  [data-mq="cols-2-stack"] { grid-template-columns: 1fr !important; }
  [data-mq="row-stack"] { flex-direction: column !important; align-items: stretch !important; }
  [data-mq="hide-sm"] { display: none !important; }

  /* Tap targets */
  button, a.btn { min-height: 40px; }
}

@media (max-width: 600px) {
  h1 { font-size: 32px !important; line-height: 1.08 !important; }
  h2 { font-size: 20px !important; }
  .vs-cols-mobile-2 { grid-template-columns: repeat(2, 1fr) !important; }
  .vs-toasts { right: 8px; left: 8px; bottom: 8px; }

  /* Sample-report finding header: collapse 5-col grid into 2 rows */
  .finding-head {
    grid-template-columns: 1fr auto !important;
    grid-template-areas:
      "title  toggle"
      "meta   meta" !important;
    row-gap: 8px !important;
    padding: 16px 16px !important;
  }
  .finding-head > :nth-child(1) { grid-area: meta; justify-self: start; } /* sev */
  .finding-head > :nth-child(2) { grid-area: meta; justify-self: start; margin-left: 80px; opacity: 0.6; } /* id */
  .finding-head > :nth-child(3) { grid-area: title; font-size: 15px !important; } /* title */
  .finding-head > :nth-child(4) { grid-area: meta; justify-self: end; } /* age */
  .finding-head > :nth-child(5) { grid-area: toggle; align-self: start; } /* + */

  /* Dashboard / panel data rows: linearize multi-column grids */
  .row-collapse {
    grid-template-columns: 1fr !important;
    row-gap: 6px !important;
    padding: 14px 16px !important;
  }

  /* Landing-page section padding + section-level grid collapse */
  section { padding: 48px 20px !important; }
  footer > div { padding-left: 20px !important; padding-right: 20px !important; }
  .vs-collapse-2 { grid-template-columns: 1fr !important; gap: 32px !important; }
  .vs-collapse-3 { grid-template-columns: 1fr !important; }
  .vs-collapse-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .vs-pricing-row { grid-template-columns: 1fr !important; }
  /* On mobile, pricing cells stack — convert side borders into top borders so the layout reads as a clean column */
  .vs-pricing-row > * { border-left: none !important; }
  .vs-pricing-row > * + * { border-top: 1px solid var(--line) !important; }
  /* The matrix-axis label "cadence ↓ / depth →" makes no sense in a stacked layout — hide it on mobile */
  .vs-pricing-row.vs-pricing-row--header > :first-child { display: none; }
  .vs-nav { padding: 14px 16px !important; gap: 8px !important; }
  .vs-picker-summary { position: static !important; padding: 22px !important; }
}

/* Mobile drawer for dashboard */
.vs-drawer-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(2,5,8,0.6); backdrop-filter: blur(4px);
  animation: vsFade .14s ease-out;
}
.vs-drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 95;
  width: min(280px, 84vw);
  background: var(--bg);
  border-right: 1px solid var(--line);
  animation: vsSlideIn .18s ease-out;
  overflow-y: auto;
}
@keyframes vsSlideIn { from { transform: translateX(-100%); } to { transform: none; } }

/* Print: clean up the report */
@media print {
  body { background: white !important; color: #111 !important; }
  nav, .vs-modal-backdrop, .vs-toasts, button { display: none !important; }
  a { color: inherit !important; text-decoration: none !important; }
  .card { break-inside: avoid; }
}
