/* ADA DOCX Remediator - accessible, high-contrast, keyboard-friendly UI.
   Color choices target WCAG AA contrast (>=4.5:1 for text). */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #14202b;
  --ink-soft: #445562;
  --brand: #0000ff;       /* pure blue */
  --brand-dark: #0000cc;
  --gold: #eeb412;
  --header-grad: linear-gradient(90deg, #000000 0%, #eeb412 100%);
  --border: #c9d2da;
  --focus: #0b5fff;
  --viewer-bg: #4b4f52;

  --error-bg: #fdecec;  --error-ink: #8a1420;  --error-bd: #e3a3a8;
  --warn-bg:  #fff4e0;  --warn-ink:  #7a4b00;  --warn-bd:  #e6c68a;
  --info-bg:  #e8f1fb;  --info-ink:  #0f4c81;  --info-bd:  #a9c9e8;
  --ok-bg:    #e6f4ea;  --ok-ink:    #1c6b34;  --ok-bd:    #a6d5b5;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

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

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--brand); color: #fff; padding: 10px 16px; z-index: 100; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

/* Gradient nav header (Manchester black -> gold), matching the lab's other apps. */
.site-header { background: var(--header-grad); color: #fff; }
.site-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-logo-link { display: block; line-height: 0; }
.brand-logo {
  height: 46px; width: auto; display: block;
  background: #fff; border-radius: 8px; padding: 3px;
}
.brand-name {
  font-size: 1.4rem; font-weight: 700; color: #fff; text-decoration: none;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5); transition: color 0.2s;
}
.brand-name:hover { color: var(--gold); }
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-link {
  color: #fff; text-decoration: none; font-weight: 600; font-size: 0.98rem;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5); transition: color 0.2s;
}
.nav-link:hover { color: var(--gold); }

/* Hero (title + tagline) now lives in the page body below the nav. */
.hero { text-align: center; padding: 34px 10px 12px; }
.hero h1 { margin: 0 0 8px; font-size: 2rem; color: var(--ink); }
.tagline { margin: 0 auto; max-width: 720px; color: var(--ink-soft); font-size: 1.08rem; }

.site-footer { margin: 40px 0 0; padding: 24px 0; border-top: 1px solid var(--border); color: var(--ink-soft); font-size: 0.9rem; }
.site-footer .version { margin: 8px 0 0; font-size: 0.82rem; opacity: 0.75; }
main { padding-top: 22px; }

.banner {
  background: var(--info-bg); border: 1px solid var(--info-bd); color: var(--info-ink);
  padding: 14px 16px; border-radius: 8px; margin: 0 0 22px;
}
.banner code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 22px; margin-bottom: 22px;
}
.card h2 { margin-top: 0; font-size: 1.3rem; }

/* About page: numbered sections (matches Osborne Lab timetable About tab). */
.about-page h1 { text-align: left; font-size: 1.75rem; margin-bottom: 1.25rem; }
.about-page .step {
  margin-bottom: 2rem; padding: 1.5rem;
  border: 2px solid #e9ecef; border-radius: 8px; background: #f8f9fa;
}
.about-page .step h3 {
  color: var(--brand); margin: 0 0 1rem; font-size: 1.15rem;
  display: flex; align-items: center;
}
.about-page .step-number {
  background: var(--brand); color: #fff; width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: 1rem; font-weight: 700; flex-shrink: 0;
}
.about-page .step p { margin: 0 0 0.65rem; }
.about-page .step p:last-child { margin-bottom: 0; }
.about-page .step a { color: var(--brand); }
.about-page .step a:hover { color: var(--brand-dark); }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="file"] {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 1rem;
}

/* Scan options (step 1) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.scan-options { margin: 0 0 16px; border: 1px solid var(--border); border-radius: 8px; background: #fbfcfd; }
.scan-options > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; }
.scan-options[open] > summary { border-bottom: 1px solid var(--border); }
.opt-hint { margin: 10px 14px 6px; color: var(--ink-soft); font-size: 0.9rem; }
.opt-group { border: 0; margin: 0; padding: 0 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; align-items: baseline; gap: 8px; font-size: 0.95rem; }
.opt input { margin: 0; }
.opt-sub { margin-left: 26px; font-size: 0.9rem; }
.opt-sub input:disabled { opacity: 0.5; }
.opt-note { color: var(--ink-soft); font-size: 0.85rem; }

.btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: #fff; color: var(--ink); padding: 9px 16px; border-radius: 6px;
}
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--brand); border-color: var(--brand-dark); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 0.9rem; }

a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}

.status { margin: 10px 0 0; min-height: 1.3em; font-weight: 600; }
.status.error { color: var(--error-ink); }
.status.ok { color: var(--ok-ink); }

.review-title { margin-bottom: 4px; }
.review-summary { color: var(--ink-soft); margin-top: 0; }

/* Sticky toolbar */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.toolbar-inner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.counts { display: flex; gap: 14px; font-size: 0.92rem; }
.count-approved { color: var(--ok-ink); }
.count-rejected { color: var(--error-ink); }
.count-pending { color: var(--ink-soft); }
#apply-btn { margin-left: auto; }

/* ===================== Two-pane workspace ===================== */
.workspace {
  position: relative;
  height: 78vh; min-height: 480px;
  overflow: auto;
  background: var(--viewer-bg);
  border-top: 1px solid var(--border);
}
.scroll-content { position: relative; margin: 0 auto; }

.doc-column { position: absolute; top: 0; left: 0; }
.pdf-page { position: relative; margin: 16px auto; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.4); }
.pdf-page canvas { display: block; }
.pdf-page .textLayer { z-index: 2; }

/* Line-number rail down the left of the document pane (aligned mode). */
.linenum-layer { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 1; }
.linenum {
  position: absolute; right: 7px; transform: translateY(-50%);
  color: rgba(255,255,255,0.6); font-size: 0.7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.linenum.slide-num {
  right: 6px; font-size: 0.85rem; font-weight: 700; color: rgba(255,255,255,0.85);
}
body.mode-list .linenum-layer { display: none; }

.marker-layer { position: absolute; top: 0; left: 0; pointer-events: none; }
.marker {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff; border: 2px solid #fff;
  font-size: 0.8rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5); pointer-events: auto; cursor: pointer;
}
.marker.sev-error { background: var(--error-ink); }
.marker.sev-warning { background: var(--warn-ink); }
.marker.sev-info { background: var(--info-ink); }
.marker.active { outline: 3px solid #ffd84d; outline-offset: 1px; }

.connectors { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 1; }
.connectors line { stroke: rgba(255,255,255,0.55); stroke-width: 1.5; }
.connectors line.active { stroke: #ffd84d; stroke-width: 2.5; }

.gutter { position: absolute; top: 0; }

/* Issue card */
.issue {
  background: var(--surface);
  border: 1px solid var(--border); border-left-width: 6px; border-radius: 8px;
  margin: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.25); overflow: hidden;
}
.gutter .issue { position: absolute; left: 0; width: 100%; }
.issue[data-state="approve"] { border-color: var(--ok-bd); border-left-color: var(--ok-ink); background: var(--ok-bg); }
.issue[data-state="reject"]  { opacity: 0.7; }
.issue.sev-error   { border-left-color: var(--error-ink); }
.issue.sev-warning { border-left-color: var(--warn-ink); }
.issue.sev-info    { border-left-color: var(--info-ink); }
.issue.active { outline: 3px solid #ffd84d; }

/* Compact header / toggle */
.issue-header {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; border: 0; background: transparent; cursor: pointer;
  font: inherit; text-align: left; color: inherit;
}
.issue-num {
  background: var(--brand); color: #fff; border-radius: 50%; width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 700; flex: none;
}
.chip { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 2px 7px; border-radius: 4px; border: 1px solid; flex: none; }
.chip.sev-error   { background: var(--error-bg); color: var(--error-ink); border-color: var(--error-bd); }
.chip.sev-warning { background: var(--warn-bg);  color: var(--warn-ink);  border-color: var(--warn-bd); }
.chip.sev-info    { background: var(--info-bg);  color: var(--info-ink);  border-color: var(--info-bd); }
.issue-kind { font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.issue-loc { color: var(--ink-soft); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state-dot { margin-left: auto; width: 12px; height: 12px; border-radius: 50%; background: var(--border); flex: none; }
.issue[data-state="approve"] .state-dot { background: var(--ok-ink); }
.issue[data-state="reject"]  .state-dot { background: var(--error-ink); }
.issue[data-state="ack"]     .state-dot { background: var(--warn-ink); }
.flag-only-tag { font-size: 0.72rem; font-weight: 700; color: var(--warn-ink); flex: none; }

/* Collapsible body */
.issue-body { display: none; padding: 0 14px 12px; }
.issue.expanded .issue-body { display: block; }
body.mode-list .issue-body { display: block; }

.rationale { margin: 4px 0 8px; font-size: 0.92rem; }
.diff { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 8px; }
.diff .cell { border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; background: #fafbfc; font-size: 0.88rem; }
.diff .cell .lbl { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); margin-bottom: 2px; }
.diff .current .val { color: var(--error-ink); }
.diff .proposed .val { color: var(--ok-ink); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.controls textarea, .controls select { font: inherit; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; width: 100%; }
.controls textarea { min-height: 54px; resize: vertical; }
.edit-field { flex: 1 1 100%; }
.edit-field label { display: block; font-size: 0.78rem; font-weight: 600; margin-bottom: 3px; }
.decorative-opt {
  flex: 1 1 100%; display: flex; align-items: center; gap: 6px;
  margin-top: 6px; font-size: 0.82rem; color: var(--muted, #555);
}
.decorative-opt input { margin: 0; }
.opt-preview {
  display: inline-block; margin-top: 6px; padding: 2px 10px; border: 1px dashed var(--border);
  border-radius: 6px; background: #fff; font-size: 0.95rem;
}
.opt-preview.heading-preview {
  display: block; width: 100%; padding: 6px 10px; line-height: 1.25;
  font-family: "Calibri Light", "Segoe UI Light", "Segoe UI", system-ui, sans-serif;
}
.opt-preview.color-preview { display: block; width: 100%; padding: 6px 10px; }

/* COLOR_ONLY multi-select controls */
.color-fix { display: flex; flex-direction: column; gap: 10px; }
.cf-block { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.cf-label { flex: 1 1 100%; font-size: 0.78rem; font-weight: 600; }
.eff, .color-choice {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 0.9rem; padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff;
}
.eff input, .color-choice input { margin: 0; }
.eff-bold span { font-weight: 700; }
.eff-underline span { text-decoration: underline; }
.eff-italic span { font-style: italic; }
.swatch {
  width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.25);
  display: inline-block; flex: 0 0 auto;
}
.swatch-keep {
  background: repeating-linear-gradient(45deg, #eee, #eee 3px, #fff 3px, #fff 6px);
}
.tbl-alt-title { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.decision-btns { display: flex; gap: 8px; }
.btn-approve[aria-pressed="true"] { background: var(--ok-ink); border-color: var(--ok-ink); color: #fff; }
.btn-reject[aria-pressed="true"]  { background: var(--error-ink); border-color: var(--error-ink); color: #fff; }

.empty { color: var(--ink-soft); font-style: italic; }
.pdf-status { color: var(--ink-soft); font-size: 0.88rem; padding-top: 8px; }

/* Legend */
.legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 20px; margin: 10px auto 0; font-size: 0.88rem; color: var(--ink-soft);
}
.legend-title { font-weight: 700; color: var(--ink); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.legend .dot.sev-error { background: var(--error-ink); }
.legend .dot.sev-warning { background: var(--warn-ink); }
.legend .dot.sev-info { background: var(--info-ink); }
.legend-note { flex: 1 1 300px; min-width: 240px; }

/* ===================== List / stacked mode (narrow screens) =====================
   Split the workspace into an independently-scrolling document (top) and issue
   list (bottom) so scroll-spy can keep the two in sync side-by-side vertically. */
body.mode-list .workspace { height: 82vh; overflow: hidden; background: var(--bg); border: none; }
body.mode-list .scroll-content { width: auto !important; height: 100%; display: flex; flex-direction: column; }
body.mode-list .doc-column {
  position: static; width: auto !important; overflow: auto; flex: 1 1 55%;
  background: var(--viewer-bg); border-radius: 8px; padding: 4px 0;
}
body.mode-list .marker-layer, body.mode-list .connectors { display: none; }
body.mode-list .gutter {
  position: static; width: auto !important; overflow: auto; flex: 1 1 45%;
  margin-top: 10px; padding-top: 10px; border-top: 2px solid var(--border);
}
body.mode-list .gutter .issue { position: static; width: auto; margin-bottom: 10px; }
body.mode-list .pdf-page { max-width: 100%; }
/* When there is no preview at all, let the list use the full height. */
body.mode-list.no-preview .doc-column { display: none; }
body.mode-list.no-preview .gutter { flex: 1 1 100%; border-top: none; }

@media (prefers-reduced-motion: no-preference) {
  .issue, .marker { transition: outline-color 0.15s ease, background-color 0.15s ease, opacity 0.15s ease; }
}
