/* Capability Statement Builder — VetsLearn v1.1 (Bone/Ink/Rust), IBM Plex, "field manual" register.
   Local variable NAMES are unchanged from the original dark theme; VALUES now reference the
   shared tokens in sd-tools.css (linked before this file). --accent and --warn are intentionally
   omitted here (same names as the shared tokens) so they inherit the token's values directly. */

:root {
  --bg: var(--bone);
  --bg-panel: var(--panel);
  --bg-input: var(--bone-deep);
  --border: var(--bone-line);
  --text: var(--ink);
  --text-dim: var(--ink-mute);
  --accent-dim: var(--accent-deep);
  --error: var(--bad);
  --font-sans: "IBM Plex Sans", -apple-system, Segoe UI, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --max-width: 900px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--bone);
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
}

.site-header { border-bottom: 1px solid var(--border); padding: 1.5rem 0 1.25rem; }
.eyebrow { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.12em; color: var(--accent); margin: 0 0 0.35rem; }
h1 { margin: 0 0 0.4rem; font-size: 1.5rem; font-family: var(--font-display); font-weight: 700; }
.subtitle { margin: 0; color: var(--text-dim); font-size: 0.95rem; max-width: 68ch; }

main { padding: 1.25rem 0 2.5rem; }

.panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px; padding: 1.25rem; margin-bottom: 1.25rem; }
.panel h2 { margin-top: 0; font-size: 1.05rem; font-family: var(--font-display); font-weight: 600; }
.section-hint { color: var(--text-dim); font-size: 0.85rem; margin-top: -0.5rem; }
.subsection-heading { font-size: 0.95rem; color: var(--accent); margin: 1.5rem 0 0.4rem; border-top: 1px solid var(--border); padding-top: 1rem; font-family: var(--font-display); font-weight: 600; }

/* --- Toolbar --- */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.75rem; }
.file-label { display: inline-flex; align-items: center; cursor: pointer; }
.localstorage-notice { font-size: 0.82rem; color: var(--text-dim); margin: 0; }
.storage-warning, .import-error { color: var(--error); font-size: 0.85rem; margin: 0.5rem 0 0; }
.import-success { color: var(--accent); font-size: 0.85rem; margin: 0.5rem 0 0; }

/* --- Notices --- */
.opsec-notice { font-size: 0.85rem; color: var(--warn); border-left: 3px solid var(--warn); padding: 0.5rem 0.7rem; margin: 0; background: var(--panel); }
.placeholder-help { font-size: 0.82rem; color: var(--text-dim); border-left: 3px solid var(--accent-dim); padding: 0.4rem 0.6rem; margin: 0.5rem 0; background: var(--panel); }

/* --- Field editor grid --- */
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.9rem 1.2rem; margin-bottom: 0.5rem; }
.field-editor { margin-bottom: 0.9rem; }
.field-editor-wide { grid-column: 1 / -1; }
.field-label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 0.3rem; }
.prompt-text { font-size: 0.86rem; color: var(--text-dim); margin: 0 0 0.5rem; max-width: 68ch; }

.field-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.55rem 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}
textarea.field-input { resize: vertical; font-family: var(--font-mono); font-size: 0.88rem; }

.logo-status { font-size: 0.82rem; color: var(--text-dim); margin: 0.4rem 0 0; }
.logo-status.error-msg { color: var(--error); }

/* --- NAICS typeahead --- */
.naics-search-wrap { position: relative; margin-bottom: 0.4rem; }
.naics-suggestions {
  position: absolute;
  z-index: 10;
  left: 0; right: 0; top: calc(100% + 2px);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 260px;
  overflow-y: auto;
}
.naics-suggestion-item { padding: 0.5rem 0.65rem; cursor: pointer; font-size: 0.88rem; border-bottom: 1px solid var(--border); }
.naics-suggestion-item:last-child { border-bottom: none; }
.naics-suggestion-item:hover, .naics-suggestion-item.active { background: var(--accent-dim); color: var(--bone); }
.naics-suggestion-code { font-family: var(--font-mono); color: var(--accent); margin-right: 0.5rem; }
.naics-warning { color: var(--warn); font-size: 0.83rem; margin: 0.3rem 0; }
.naics-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.naics-row { display: flex; align-items: center; gap: 0.6rem; background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem 0.65rem; font-size: 0.88rem; flex-wrap: wrap; }
.naics-row-code { font-family: var(--font-mono); color: var(--accent); }
.naics-row-title { flex: 1; min-width: 0; }
.naics-row-primary-label { font-size: 0.78rem; color: var(--text-dim); display: flex; align-items: center; gap: 0.3rem; }

/* --- Certifications --- */
.cert-list { display: flex; flex-direction: column; gap: 0.6rem; }
.cert-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px; padding: 0.6rem; }
.cert-row-label { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; min-width: 140px; }
.cert-row-fullname { font-size: 0.78rem; color: var(--text-dim); flex-basis: 100%; }
.cert-certifier-input { flex: 1 1 220px; min-width: 0; }
.cert-nudge { font-size: 0.78rem; color: var(--warn); flex-basis: 100%; }
.cert-nudge a { color: var(--warn); }

/* --- Past performance --- */
.pp-entry { border: 1px solid var(--border); border-radius: 4px; padding: 0.75rem; margin-bottom: 0.75rem; background: var(--bg-input); }
.pp-entry-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-bottom: 0.5rem; }
.pp-entry textarea.field-input { min-height: 4rem; }
.pp-remove-btn { margin-top: 0.4rem; }

/* --- Buttons --- */
button {
  background: var(--accent);
  color: var(--bone);
  border: none;
  border-radius: 4px;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
button:disabled { background: var(--accent-dim); color: var(--bone); opacity: 0.6; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent-dim); padding: 0.5rem 1rem; font-size: 0.85rem; }
button.secondary.danger { color: var(--error); border-color: var(--error); }

/* --- AI polish --- */
.polish-block { margin: 0.5rem 0 1rem; }
.status-note { font-size: 0.85rem; padding: 0.5rem 0.65rem; border-radius: 4px; background: var(--panel); color: var(--warn); margin: 0.5rem 0 0; }
.polish-result { margin-top: 0.6rem; }
.critique-block, .rewrite-block { background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px; padding: 0.65rem 0.75rem; margin-bottom: 0.6rem; font-size: 0.88rem; }
.critique-block h4, .rewrite-block h4 { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--accent); }
.rewrite-text { white-space: pre-wrap; }

/* --- Preview tabs / mode toggle --- */
.tabs, .mode-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.tab-btn, .mode-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px 4px 0 0;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
}
.tab-btn.active, .mode-btn.active { color: var(--accent); border-color: var(--accent-dim); background: var(--bg-input); }
.print-btn { margin-left: auto; }
.final-blocked { border: 1px solid var(--error); background: var(--panel); border-radius: 4px; padding: 0.75rem 1rem; margin-bottom: 1rem; }
.blocked-heading { color: var(--error); font-weight: 600; margin: 0 0 0.5rem; }
.final-blocked ul { margin: 0; padding-left: 1.25rem; }
.final-blocked li { color: var(--error); font-size: 0.9rem; }

/* --- Capability statement document (three templates, one content model) --- */
.cap-view {}
.cap-doc {
  background: #ffffff;
  color: #141815;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  font-size: 0.92rem;
}
.cap-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 2px solid #141815; }
.cap-logo { max-width: 90px; max-height: 90px; object-fit: contain; }
.cap-company-name { font-size: 1.35rem; font-weight: 700; margin: 0; }
.cap-tagline { margin: 0.15rem 0 0; color: #444; font-size: 0.9rem; }
.cap-contact-line { margin: 0.3rem 0 0; font-size: 0.82rem; color: #444; }

.cap-section { margin-bottom: 1rem; }
.cap-section-heading { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 0.4rem; color: #141815; }
.cap-bullets { margin: 0; padding-left: 1.1rem; }
.cap-bullets li { margin-bottom: 0.2rem; }
.cap-text { margin: 0; white-space: pre-wrap; }
.cap-empty { color: #777; font-style: italic; }
.cap-add-marker { color: var(--bad); font-weight: 600; }

.cap-identifiers { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-size: 0.85rem; }
.cap-identifiers dt { font-weight: 700; display: inline; }
.cap-identifiers dd { display: inline; margin: 0 0 0 0.3rem; }
.cap-naics-row { display: block; }

.cap-certs { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.85rem; margin: 0; padding: 0; list-style: none; }
.cap-cert-claim { font-weight: 600; }

.cap-pp-entry { margin-bottom: 0.6rem; padding-bottom: 0.5rem; border-bottom: 1px dashed #ccc; }
.cap-pp-entry:last-child { border-bottom: none; }
.cap-pp-meta { font-size: 0.8rem; color: #555; }

/* Classic: traditional two-column layout via named grid areas. */
.template-classic .cap-doc-body {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 0 1.5rem;
}
.template-classic .cap-section[data-section="coreCompetencies"],
.template-classic .cap-section[data-section="differentiators"],
.template-classic .cap-section[data-section="pastPerformance"] { grid-column: 1; }
.template-classic .cap-section[data-section="naics"],
.template-classic .cap-section[data-section="poc"],
.template-classic .cap-section[data-section="certifications"] { grid-column: 2; }

/* Modern: single column, rule-lines between sections. */
.template-modern .cap-doc-body { display: block; }
.template-modern .cap-section { border-top: 1px solid #ccc; padding-top: 0.6rem; }
.template-modern .cap-section:first-child { border-top: none; padding-top: 0; }

/* Compact: dense single column, smaller type, for pasting into an email body.
   (.cap-doc and .template-compact are the SAME element — see app.js's
   buildCapView — so this must be a single compound selector, not a
   descendant selector.) */
.cap-doc.template-compact { padding: 0.9rem; font-size: 0.82rem; }
.template-compact .cap-doc-body { display: block; }
.template-compact .cap-section { margin-bottom: 0.55rem; }
.template-compact .cap-section-heading { font-size: 0.75rem; margin-bottom: 0.2rem; }
.template-compact .cap-header { gap: 0.6rem; margin-bottom: 0.6rem; padding-bottom: 0.4rem; }
.template-compact .cap-logo { max-width: 60px; max-height: 60px; }

/* --- Footer --- */
.site-footer { border-top: 1px solid var(--border); padding: 1.25rem 0 2rem; }
.site-footer p { font-size: 0.75rem; color: var(--text-dim); margin: 0 0 0.6rem; }

.loading-note, .error-msg { color: var(--text-dim); font-size: 0.9rem; }
.error-msg { color: var(--error); }

/* --- Mobile: usable at 375px, no horizontal scroll --- */
@media (max-width: 480px) {
  h1 { font-size: 1.25rem; }
  .panel { padding: 0.9rem; }
  .field-grid, .pp-entry-grid { grid-template-columns: 1fr; }
  .tabs, .mode-toggle { flex-direction: column; align-items: stretch; }
  .print-btn { margin-left: 0; }
  .template-classic .cap-doc-body { grid-template-columns: 1fr; }
  .template-classic .cap-section[data-section="naics"],
  .template-classic .cap-section[data-section="poc"],
  .template-classic .cap-section[data-section="certifications"] { grid-column: 1; }
}

/* --- Print (spec 15 templates: Letter print CSS, page-break rules) --- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  #form-section, #opsec-panel, #toolbar-panel { display: none !important; }
  #preview-section { margin: 0; padding: 0; }
  .panel { background: #fff; border: none; padding: 0; }
  .cap-doc { border: none; padding: 0; }
  .cap-section { break-inside: avoid; page-break-inside: avoid; }
  .cap-section-heading { break-after: avoid; page-break-after: avoid; }
  a { color: #000; text-decoration: underline; }
  @page { size: letter; margin: 0.6in; }
}
