/* ============================================================================
   JPI Backplane — Design & Data Portal — styles
   Accessibility-first: high base contrast, scalable type (rem), visible focus,
   reduced-motion + prefers-contrast honored, optional High Contrast mode.
   ============================================================================ */

:root {
  --fs: 100%;                       /* driven by the a11y text-size control */
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #11212e;
  --ink-soft: #43586a;
  --line: #c4d0dc;
  --line-strong: #8aa0b4;
  --accent: #0b5cad;
  --accent-ink: #ffffff;
  --focus: #b8400a;                 /* warm, high-contrast focus ring */
  --ok: #1b7a3d;
  --warn: #9a6700;
  --bad: #b3261e;
  --block: #6a3ea0;
  --radius: 8px;
  --maxw: 980px;
}

html { font-size: var(--fs); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

/* High-contrast mode */
body.contrast-high {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --ink: #000000;
  --ink-soft: #1a1a1a;
  --line: #000000;
  --line-strong: #000000;
  --accent: #00407a;
  --focus: #b3001b;
}
body.contrast-high .card,
body.contrast-high .sidebar,
body.contrast-high .app-header { border-width: 2px; }

/* Focus + skip link ----------------------------------------------------------*/
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem;
  border-radius: 0 0 var(--radius) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Header ---------------------------------------------------------------------*/
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.1rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.brand-mark { color: var(--accent); font-size: 1.2rem; }
.brand-name { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 1rem; font-size: .92rem; color: var(--ink-soft); }
.role-chip { font-size: .78rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; border: 1px solid var(--line-strong); }
.role-chip.iaxov { background: #0b5cad; color: #fff; border-color: #0b5cad; }
.role-chip.jpi   { background: #e7f0fa; color: #0b3a6b; }
.signed-in { white-space: nowrap; }

/* Layout ---------------------------------------------------------------------*/
.layout { display: grid; grid-template-columns: 290px 1fr; min-height: calc(100vh - 56px); }
.sidebar {
  border-right: 1px solid var(--line); background: var(--surface);
  padding: .8rem .6rem; overflow-y: auto; max-height: calc(100vh - 56px);
  position: sticky; top: 56px;
}
.content { padding: 1.4rem 1.6rem 5rem; min-width: 0; }
.view { max-width: var(--maxw); margin: 0 auto; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--line); }
}

/* Nav ------------------------------------------------------------------------*/
.nav-section { margin-bottom: .6rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
.nav-group-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-soft); font-weight: 700; margin: .9rem .4rem .25rem;
}
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  color: var(--ink); padding: .42rem .55rem; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: .9rem; line-height: 1.3;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: #e7f0fa; border-color: var(--accent); font-weight: 600; }
.nav-top { font-weight: 600; }
.badge {
  min-width: 1.4em; text-align: center; font-size: .72rem; font-weight: 700;
  background: var(--accent); color: #fff; border-radius: 999px; padding: .05rem .4rem;
}
.badge:empty { display: none; }
.nav-comment-count { font-size: .72rem; color: var(--ink-soft); }

/* Cards + generic ------------------------------------------------------------*/
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.muted { color: var(--ink-soft); }
.loading { color: var(--ink-soft); padding: 2rem 0; }
.page-title { margin: 0 0 .2rem; font-size: 1.5rem; }
.page-sub { margin: 0 0 1.2rem; color: var(--ink-soft); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

button.btn, .btn {
  font: inherit; font-size: .88rem; cursor: pointer; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: .4rem .8rem;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-sm { padding: .25rem .55rem; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: .82rem; font-weight: 600; margin: .6rem 0 .2rem; }
input[type=text], input[type=url], input[type=date], select, textarea {
  width: 100%; font: inherit; font-size: .9rem; padding: .45rem .55rem;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink);
}
textarea { min-height: 5rem; resize: vertical; }

/* Status + priority pills ----------------------------------------------------*/
.pill { font-size: .74rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.pill.requested  { color: var(--ink-soft); border-color: var(--line-strong); background: var(--surface-2); }
.pill.in_progress{ color: var(--accent); border-color: var(--accent); background: #e7f0fa; }
.pill.blocked    { color: var(--block); border-color: var(--block); background: #f1ebfa; }
.pill.delivered  { color: var(--ok); border-color: var(--ok); background: #e6f4ec; }
.pill.accepted   { color: #fff; border-color: var(--ok); background: var(--ok); }
.pill.na         { color: var(--ink-soft); border-color: var(--line); background: transparent; text-decoration: line-through; }
.pill.p0 { color: #fff; background: var(--bad); border-color: var(--bad); }
.pill.p1 { color: var(--warn); border-color: var(--warn); background: #fbf3e0; }
.pill.p2 { color: var(--ink-soft); border-color: var(--line-strong); background: var(--surface-2); }
.kind-pill { font-size: .72rem; font-weight: 700; text-transform: capitalize; padding: .1rem .45rem; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.kind-pill.concern, .kind-pill.correction { background: #fbece9; border-color: var(--bad); color: var(--bad); }
.kind-pill.question { background: #fbf3e0; border-color: var(--warn); color: var(--warn); }
.kind-pill.approval { background: #e6f4ec; border-color: var(--ok); color: var(--ok); }

/* Data-request tracker -------------------------------------------------------*/
.req-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.req-filter { display: flex; gap: .3rem; flex-wrap: wrap; }
.stat-grid { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .8rem; min-width: 5.5rem; }
.stat .n { font-size: 1.4rem; font-weight: 700; }
.stat .l { font-size: .74rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }

.req { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .8rem; overflow: hidden; }
.req-head { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; cursor: pointer; }
.req-head:hover { background: var(--surface-2); }
.req-pills { display: flex; gap: .35rem; flex-shrink: 0; flex-wrap: wrap; }
.req-main { min-width: 0; flex: 1; }
.req-title { font-weight: 600; }
.req-system { font-size: .8rem; color: var(--ink-soft); }
.req-meta { font-size: .76rem; color: var(--ink-soft); margin-top: .15rem; }
.req-body { padding: 0 1rem 1rem; border-top: 1px solid var(--line); }
.req-body[hidden] { display: none; }
.req-desc { margin: .8rem 0; }
.asset-tag { font-size: .74rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; }

.timeline { list-style: none; padding: 0; margin: .6rem 0 0; border-left: 2px solid var(--line); }
.timeline li { padding: .35rem 0 .35rem .8rem; position: relative; font-size: .85rem; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .7rem; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline .ev-meta { font-size: .74rem; color: var(--ink-soft); }
.timeline a { color: var(--accent); }

/* Comments -------------------------------------------------------------------*/
.comment { border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: .7rem; background: var(--surface); }
.comment.reply { margin-left: 1.4rem; border-left: 3px solid var(--accent); }
.comment.resolved { opacity: .7; }
.comment.deleted { opacity: .6; border-style: dashed; }
.comment-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-size: .8rem; color: var(--ink-soft); margin-bottom: .35rem; }
.comment-author { font-weight: 700; color: var(--ink); }
.comment-body { white-space: pre-wrap; word-wrap: break-word; }
.comment-actions { margin-top: .5rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.comment-subject { font-weight: 700; }
.comments-panel { margin-top: 2.4rem; border-top: 2px solid var(--line); padding-top: 1.2rem; }
.comments-panel h2 { font-size: 1.15rem; }

/* Bubble button beside a heading + inline thread attached to its section */
.section-comment { margin-left: .5rem; vertical-align: middle; padding: .08rem .45rem; font-size: .8rem; line-height: 1.2; }
.section-thread {
  margin: .3rem 0 1.3rem; padding: .5rem .2rem .2rem .85rem;
  border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 6px 6px 0;
}
.section-thread .comment { background: var(--surface); }

/* Rendered markdown ----------------------------------------------------------*/
.md { overflow-wrap: break-word; }
.md h1 { font-size: 1.8rem; line-height: 1.2; margin: 1.4rem 0 .6rem; }
.md h2 { font-size: 1.4rem; margin: 1.6rem 0 .5rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 1.15rem; margin: 1.3rem 0 .4rem; }
.md h4 { font-size: 1rem; margin: 1.1rem 0 .3rem; }
.md p, .md li { font-size: 1rem; }
.md a { color: var(--accent); }
.md code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }
.md pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .8rem 1rem; overflow-x: auto; }
.md pre code { background: transparent; padding: 0; }
.md blockquote { margin: .8rem 0; padding: .4rem 1rem; border-left: 4px solid var(--accent); background: var(--surface-2); color: var(--ink-soft); }
.md table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: .9rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: .4rem .6rem; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md img { max-width: 100%; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 1.5rem 0; }
/* Exploded "(1)…(n)" run-on enumerations rendered as a readable numbered list */
.md ol.exploded-enum { margin: .6rem 0 1rem; padding-left: 1.6rem; }
.md ol.exploded-enum > li { margin: .45rem 0; padding-left: .2rem; line-height: 1.6; }
/* A source link to a document/asset not hosted in this portal (neutralized) */
.md-deadlink { color: var(--ink-soft); border-bottom: 1px dotted var(--line-strong); cursor: help; }
.doc-toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line); }

/* Toast ----------------------------------------------------------------------*/
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .6rem 1.1rem; border-radius: 8px;
  font-size: .9rem; z-index: 60; box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.bad { background: var(--bad); }
.toast.ok  { background: var(--ok); }

/* Accessibility tray ---------------------------------------------------------*/
.a11y-tray { position: fixed; bottom: 1.1rem; right: 1.1rem; z-index: 50; }
.a11y-toggle {
  width: 3rem; height: 3rem; border-radius: 50%; border: 2px solid var(--accent);
  background: var(--surface); color: var(--accent); font-size: 1.3rem; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.a11y-panel {
  position: absolute; bottom: 3.6rem; right: 0; width: 15rem;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: .6rem .9rem 1rem; box-shadow: 0 6px 24px rgba(0,0,0,.2);
}
.a11y-panel fieldset { border: none; padding: 0; margin: .6rem 0 0; }
.a11y-panel legend { font-weight: 700; font-size: .8rem; padding: 0; }
.seg { display: flex; gap: .25rem; margin-top: .3rem; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 3rem; font: inherit; font-size: .8rem; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 5px; padding: .3rem 0;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Cursor sizing — applied to <html> by app.js */
html.cursor-2, html.cursor-2 * { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'><path d='M6 2 L6 34 L14 26 L20 40 L26 37 L20 23 L32 23 Z' fill='black' stroke='white' stroke-width='2'/></svg>") 4 2, auto; }
html.cursor-3, html.cursor-3 * { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'><path d='M8 3 L8 50 L20 38 L29 58 L38 54 L29 34 L46 34 Z' fill='black' stroke='white' stroke-width='3'/></svg>") 6 3, auto; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (prefers-contrast: more) { :root { --line: #000; --line-strong: #000; --ink-soft: #222; } }

/* Confidentiality notice pinned to the bottom of the nav */
.sidebar-confidential {
  margin-top: 1.2rem; padding: .7rem .6rem; border-top: 2px solid #7f1d1d;
  color: #7f1d1d; font-size: .72rem; line-height: 1.45;
  display: flex; flex-direction: column; gap: .35rem;
}
body.contrast-high .sidebar-confidential { color: #6b0000; border-top-color: #6b0000; }
.confidential-chip { font-size: .68rem; font-weight: 800; letter-spacing: .08em; color: #7f1d1d; border: 1px solid #7f1d1d; border-radius: 4px; padding: .1rem .45rem; }
.sidebar-confidential strong { font-size: .74rem; letter-spacing: .04em; color: #7f1d1d; }
.sidebar-confidential a { color: #7f1d1d; text-decoration: underline; }

/* Printing is disabled: suppress all content and show only the confidentiality
   notice. (A deterrent — request formal, security-watermarked copies instead.) */
@media print {
  body * { visibility: hidden !important; }
  body::before {
    content: "CONFIDENTIAL · TRADE SECRET · PROPRIETARY — © IAXOV Inc.\A\A Printing is disabled. This portal is provided to JPI Solutions for review only. Request formal, security-watermarked copies from systems@iaxov.com.";
    white-space: pre-wrap;
    visibility: visible !important;
    position: fixed; inset: 0; padding: 2cm;
    font: 16px/1.6 -apple-system, Helvetica, Arial, sans-serif; color: #7f1d1d;
  }
}

/* ── sign-in page (owner 2026-10-27: the e-mailed-code gate in place of Cloudflare Zero Trust) ── */
.signin-main { max-width: 34rem; margin: 2.5rem auto; padding: 0 1rem; display: grid; gap: 1.5rem; }
.signin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.signin-card h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
.signin-form { display: grid; gap: .5rem; margin: 1rem 0; }
.signin-form label { font-weight: 600; }
.signin-form input[type=email], .signin-form input[type=text] { font-size: 1.1rem; padding: .55rem .65rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.signin-form input:focus-visible, .signin-form button:focus-visible, .signin-main a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.signin-form button { justify-self: start; margin-top: .5rem; }
.signin-error { color: var(--bad); font-weight: 600; border-left: 4px solid var(--bad); padding: .35rem .65rem; }
.signin-notice { border-left: 4px solid var(--ok); padding: .35rem .65rem; }
.signin-confidential { position: static; }
.header-signout { margin-left: .75rem; }
.people-table { width: 100%; border-collapse: collapse; }
.people-table th, .people-table td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.signin-form button.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* Briefs and API keys (2026-10-27) */
.brief-card { margin: 0 0 1rem; }
.brief-fields dt { font-weight: 600; margin-top: .5rem; }
.brief-fields dd { margin: .15rem 0 0 0; white-space: pre-wrap; }
.key-add textarea, .key-add input[type=text] { width: 100%; max-width: 36rem; }
.key-once { border: 2px solid var(--warn); margin-bottom: 1.5rem; }
