/* =====================================================================
   FANlines — tool styles
   EvidenceToolbox design system (CLAUDE.md): navy/teal/gold/cream,
   Inter/Lora, teal-left-border cards, 900px max width, mobile-first.
   ===================================================================== */

:root {
  --navy: #1F3B57;
  --teal: #1C8C8C;
  --teal-hover: #166f6f;
  --nav-bg: #17304a;
  --gold: #D9A441;
  --cream: #F7F3EC;
  --white: #FFFFFF;
  --body-text: #111111;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--body-text);
  background: var(--cream);
}

/* ---------- site header (linen texture sits in an inline SVG) ---------- */
header.site-header {
  background: var(--navy);
  color: var(--white);
  text-align: center;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
}
header.site-header .linen {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  pointer-events: none;
}
header.site-header h1 {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 2.4rem;
  letter-spacing: 1px;
  margin: 0;
  position: relative;
}
header.site-header .tagline {
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 1.2rem;
  color: var(--gold);
  margin: 6px 0 0;
  position: relative;
}

/* ---------- nav ---------- */
nav.site-nav {
  background: var(--nav-bg);
  border-bottom: 2px solid var(--teal);
  padding: 10px 20px;
}
nav.site-nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
nav.site-nav a {
  color: var(--white);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding-bottom: 2px;
}
nav.site-nav a:hover,
nav.site-nav a.active {
  color: var(--gold);
  border-bottom: 2px solid var(--gold);
}

/* ---------- layout ---------- */
main {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
}
h2 {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 1.9rem;
  color: var(--navy);
}
h3 {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--navy);
  margin-top: 0;
}

/* ---------- cards ---------- */
.card {
  background: var(--white);
  border-left: 6px solid var(--teal);
  border-radius: 0 6px 6px 0;
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  background: var(--teal);
  color: var(--white);
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--teal-hover); }
.btn.secondary {
  background: var(--white);
  color: var(--teal);
  border: 1px solid var(--teal);
}
.btn.secondary:hover { background: var(--cream); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- screen stepper ---------- */
.stepper {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-size: 0.9rem;
}
.stepper span {
  padding: 4px 12px;
  border-radius: 14px;
  background: #e7e0d2;
  color: #555;
}
.stepper span.active {
  background: var(--teal);
  color: var(--white);
  font-weight: 600;
}
.stepper span.future { opacity: 0.55; }

/* ---------- screen 1 ---------- */
.privacy-note {
  font-size: 0.95rem;
  color: #333;
  border-left: 4px solid var(--gold);
  padding-left: 12px;
  margin: 20px 0;
}
.coming-soon { color: #777; font-size: 0.95rem; }
.resume-banner {
  background: #fff8e8;
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

/* ---------- header strip (screen 2) ---------- */
.tool-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--white);
  border-left: 6px solid var(--navy);
  border-radius: 0 6px 6px 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 0.95rem;
}
.tool-strip label { font-weight: 600; color: var(--navy); }
.tool-strip input[type="text"] {
  flex: 1 1 180px;
  min-width: 140px;
}
.autosave-status { color: #555; font-size: 0.85rem; }

/* ---------- screen 2 layout: lanes + entry ---------- */
.entry-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: start;
}
/* Grid children default to min-width:auto, which lets a wide table (the
   1950 preview has 71 columns) stretch the column past its track and blow
   out the whole page. min-width:0 lets the column shrink to its track so
   the scrollable containers below actually scroll instead. */
.entry-layout > * { min-width: 0; }
@media (max-width: 700px) {
  .entry-layout { grid-template-columns: 1fr; }
}

/* decade lane sidebar */
.decade-lanes { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 700px) {
  .decade-lanes { flex-direction: row; flex-wrap: wrap; }
}
.decade-chip {
  background: var(--white);
  border: 1px solid #d8d2c4;
  border-left: 4px solid #d8d2c4;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  font-family: 'Inter', sans-serif;
  line-height: 1.35;
}
.decade-chip .year { font-weight: 600; color: var(--navy); font-size: 1rem; }
.decade-chip .loc { color: #555; display: block; }
/* FL-4: structure-number coverage span — slightly darker than loc/counts so the
   "what's covered" line reads as the substantive detail on the chip. */
.decade-chip .coverage { color: #3a3a3a; display: block; }
.decade-chip .counts { color: #555; display: block; }
.decade-chip.has-data { border-left-color: var(--teal); }
.decade-chip.active {
  border-color: var(--teal);
  border-left-color: var(--teal);
  background: #eef6f6;
}
.decade-chip .subject-dot { color: var(--gold); font-weight: 700; }
/* FL-9: legend tying the gold dot to its meaning, sitting under the lanes. */
.lane-legend { color: #555; font-size: 0.78rem; margin: 8px 2px 0; line-height: 1.4; }
.lane-legend .subject-dot { color: var(--gold); font-weight: 700; }

/* ---------- metadata form ---------- */
.meta-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
@media (max-width: 700px) { .meta-form { grid-template-columns: 1fr; } }
.meta-form .field { display: flex; flex-direction: column; }
.meta-form label { font-size: 0.85rem; font-weight: 600; color: var(--navy); margin-bottom: 2px; }
.meta-form .hint { font-size: 0.78rem; color: #777; font-weight: 400; }
input[type="text"], select {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  padding: 8px 10px;
  border: 1px solid #c9c2b2;
  border-radius: 4px;
  background: var(--white);
}
input[type="text"]:focus, select:focus, .paste-zone:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}
.citation-completeness { font-size: 0.85rem; color: #8a6d1d; margin-top: 8px; }

/* ---------- paste zone ---------- */
.paste-zone {
  min-height: 110px;
  border: 2px dashed var(--teal);
  border-radius: 6px;
  background: #fbfaf6;
  padding: 14px;
  font-size: 0.9rem;
  color: #555;
}
.paste-zone.has-content { border-style: solid; }

/* ---------- validation panel ---------- */
.validation-panel { margin-top: 16px; }
.vline { display: flex; gap: 8px; align-items: baseline; font-size: 0.92rem; margin: 4px 0; }
.vline .icon { width: 1.2em; text-align: center; flex: none; }
.vline.pass .icon { color: #0a6e4f; }
.vline.warn { color: #8a5a1d; }
.vline.warn .icon { color: #c08a2d; }
.vline.block { color: #a3331f; font-weight: 600; }
.vline.block .icon { color: #a3331f; }
.vline.info { color: #0e5a5a; }

/* ---------- preview table ---------- */
/* The ONLY thing that scrolls horizontally is this container — the page
   itself never exceeds the design system's width, whatever the decade. */
.preview-wrap { overflow-x: auto; max-width: 100%; margin-top: 12px; }
table.preview {
  border-collapse: collapse;
  background: var(--white);
  font-size: 0.82rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
table.preview th {
  background: var(--navy);
  color: var(--white);
  padding: 5px 8px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
table.preview td {
  padding: 4px 8px;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}
table.preview th.core, table.preview td.core { background-color: #eef6f6; }
table.preview th.core { background: var(--teal); }
table.preview td.editable {
  outline: 1px dashed var(--gold);
  cursor: text;
  background: #fff8e8;
}
/* A corrected cell: solid teal underline marker; recorded value on hover. */
table.preview td.corrected {
  background: #e6f3f0;
  border-bottom: 2px solid var(--teal);
  font-weight: 600;
}
table.preview tr.realigned-row td.core { box-shadow: inset 0 0 0 9999px rgba(217, 164, 65, 0.06); }
.preview-note { font-size: 0.82rem; color: #555; margin-top: 6px; }

/* ---------- correction notes (optional rationale, FL-5) ---------- */
.correction-notes {
  background: #fbfaf6;
  border-left: 4px solid var(--teal);
  border-radius: 0 4px 4px 0;
  padding: 10px 14px;
  margin-top: 12px;
}
.correction-notes h3 { font-size: 1rem; margin: 0 0 4px; }
.correction-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.correction-row .correction-what { font-size: 0.85rem; color: #333; flex: 1 1 240px; }
.correction-row input[type="text"] { flex: 2 1 280px; font-size: 0.85rem; }

/* ---------- FL-1 confirmation + stale indicator ---------- */
.commit-confirmation {
  color: #0a6e4f;
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 10px;
}
.stale-indicator {
  color: #8a5a1d;
  background: #fdf2e3;
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 0.82rem;
}
/* ---------- decade panel: segments, households, designation ---------- */
.segment-note {
  background: #eef6f6;
  border-left: 4px solid var(--teal);
  border-radius: 0 4px 4px 0;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #0e5a5a;
  margin: 12px 0;
}
.warn-note {
  background: #fdf2e3;
  border-left: 4px solid #c08a2d;
  border-radius: 0 4px 4px 0;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #8a5a1d;
  margin: 12px 0;
}
.household-list { list-style: none; margin: 12px 0 0; padding: 0; }
.household-list li {
  display: flex;
  flex-wrap: wrap; /* long flag chips wrap instead of widening the page */
  gap: 10px;
  align-items: baseline;
  padding: 7px 8px;
  border-bottom: 1px solid #eee;
  font-size: 0.92rem;
}
.household-list .hh-label { min-width: 0; }
.household-list li.selected { background: #eef6f6; }
.household-list .hh-label { flex: 1; }
.household-list .hh-meta { color: #555; font-size: 0.85rem; }
.flag-chip {
  display: inline-block;
  background: #eef6f6;
  color: #0e5a5a;
  border-radius: 4px;
  font-size: 0.74rem;
  padding: 1px 7px;
  margin-left: 6px;
  white-space: nowrap;
}
.flag-chip.seg { background: #f3efe6; color: #7a5c12; }
.pages-list { font-size: 0.88rem; color: #555; margin: 8px 0 0; }

/* watchlist */
.watch-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.watch-chips span {
  background: var(--navy);
  color: var(--white);
  border-radius: 14px;
  padding: 3px 12px;
  font-size: 0.85rem;
}
.watch-chips button {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 0 0 6px;
}

/* misc */
.muted { color: #777; font-size: 0.9rem; }
.hidden { display: none !important; }

/* ---------- footer ---------- */
footer.site-footer {
  background: var(--navy);
  color: var(--white);
  text-align: center;
  padding: 20px;
  font-size: 0.9rem;
  margin-top: 40px;
}
footer.site-footer a { color: var(--white); }

/* ===================================================================
   Build 3b — page-list management
   =================================================================== */
.pages-list h3 { margin: 4px 0 8px; }
ul.page-list { list-style: none; margin: 0 0 16px; padding: 0; }
.page-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid #e3ddcf;
  border-radius: 4px;
  margin-bottom: 6px;
  background: var(--white);
  flex-wrap: wrap;
}
.page-open {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--navy);
  cursor: pointer;
  padding: 2px 0;
  min-width: 0;
}
.page-open:hover { text-decoration: underline; }
.review-marker {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.review-marker.rs-unreviewed { background: #ece6d8; color: #6b6450; }
.review-marker.rs-reviewed { background: #e3f0ea; color: #0a6e4f; }
.review-marker.rs-corrected { background: #fdf2e3; color: #8a5a1d; }
.page-controls { display: flex; gap: 4px; }
.page-move, .page-delete {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  border: 1px solid #c9c2b2;
  background: var(--white);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}
.page-move:disabled { opacity: 0.35; cursor: not-allowed; }
.page-delete { color: #a3331f; border-color: #e0b3aa; }
.page-delete:hover { background: #fbe9e7; }

/* FL-6 boundary override control between two pages */
.page-boundary {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 6px 12px;
  padding: 8px 12px;
  border-left: 3px solid var(--gold);
  background: #fbf6ea;
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  color: #6b5a2a;
}
.page-boundary.asserted { border-left-color: var(--teal); background: #eef6f6; color: #0e5a5a; }
.page-boundary input { margin-top: 3px; }

/* Tier-4 metadata edit form (shown when re-opening a committed page) */
.metadata-edit {
  background: #f5f1e8;
  border-left: 4px solid var(--navy);
  border-radius: 0 4px 4px 0;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.metadata-edit h3 { margin: 0 0 10px; }
.metadata-edit .field { display: flex; flex-direction: column; margin-bottom: 8px; }
.metadata-edit label { font-size: 0.8rem; font-weight: 600; color: var(--navy); margin-bottom: 2px; }

/* ================================================================== *
 * Session 3 — Screen 3 (Link) + Screen 4 (Analysis) styles
 * ================================================================== */

.strip-subject { color: var(--navy); font-family: 'Lora', serif; font-size: 1.1rem; margin-right: auto; }
.panel-h { font-family: 'Lora', serif; color: var(--navy); font-size: 1.3rem; margin: 22px 0 6px; }

/* Linkage candidate cards */
.cand-card {
  background: #fff; border-left: 6px solid var(--teal); border-radius: 0 6px 6px 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08); padding: 16px 18px; margin-bottom: 14px;
}
.cand-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; }
.cand-decades { font-weight: 600; color: var(--teal); font-variant-numeric: tabular-nums; }
.cand-names { font-family: 'Lora', serif; color: var(--navy); font-size: 1.05rem; }
.cand-card .evidence { margin: 10px 0; padding-left: 0; list-style: none; }
.cand-card .evidence li { position: relative; padding-left: 22px; margin: 4px 0; font-size: 0.95rem; }
.cand-card .evidence li::before {
  content: ""; position: absolute; left: 4px; top: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--teal);
}
.cand-actions { display: flex; gap: 10px; margin-top: 8px; }
.badge {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  background: #eef6f6; color: #0e5a5a; padding: 2px 8px; border-radius: 10px;
}
.badge.subject { background: #fbf2da; color: #8a6a16; }

.group-card { margin-bottom: 12px; }
.group-card h3 { margin: 0 0 4px; }
.manage-links { margin-top: 14px; }
.link-pair { display: flex; align-items: center; gap: 12px; padding: 5px 0; font-size: 0.92rem; }
.link-pair span { margin-right: auto; }
.btn.tiny { padding: 4px 10px; font-size: 0.82rem; }

/* Analysis screen */
.stale-banner {
  background: #fbf0d8; border-left: 6px solid var(--gold); border-radius: 0 4px 4px 0;
  padding: 12px 16px; color: #6b5212; font-weight: 500; margin-bottom: 10px;
}
.recurrence-toggle label { margin-right: 14px; font-size: 0.92rem; }
.analysis-panel { margin-bottom: 18px; }
.analysis-panel h3 { font-family: 'Lora', serif; color: var(--navy); border-bottom: 2px solid var(--teal); padding-bottom: 6px; }
.small { font-size: 0.85rem; }
.muted.small, .footnote { color: #555; }
.footnote { font-size: 0.85rem; margin: 8px 0 0; }

.assess { display: inline-block; margin-left: 8px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.4px; padding: 1px 8px; border-radius: 10px; }
.assess.strong { background: #e3f1e6; color: #1d6b33; }
.assess.moderate { background: #fdf0d8; color: #8a6a16; }
.assess.single { background: #eee; color: #666; }

.stab-row, .rec-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; padding: 8px 0; border-bottom: 1px solid #eee; }
.rec-row.watch { background: #fbf6e8; }
.tierstrip { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.85rem; color: var(--navy); }

.event { padding: 8px 0; border-left: 3px solid #e4ddcf; padding-left: 12px; margin: 6px 0; }
.event .yr { font-weight: 700; color: var(--teal); margin-right: 8px; }
.evo-item { margin: 4px 0; font-size: 0.95rem; }
.flag { display: inline-block; font-size: 0.72rem; font-weight: 600; background: #eef6f6; color: #0e5a5a; padding: 1px 7px; border-radius: 9px; margin-left: 6px; }
.flag.migr { background: #f3e6d2; color: #8a5a12; }
.flag.ageconf { background: #fbe9e9; color: #9a3030; }
.prompt-actions { display: inline-flex; gap: 6px; margin-left: 8px; }

.lead { background: #faf7f0; border-left: 4px solid var(--teal); border-radius: 0 4px 4px 0; padding: 10px 14px; margin: 8px 0; font-size: 0.95rem; }
.lead.deemph { opacity: 0.6; border-left-color: #bbb; }
.vlabel { font-weight: 700; color: var(--navy); margin-right: 4px; }

table.grid { border-collapse: collapse; width: 100%; font-size: 0.9rem; margin: 8px 0; }
table.grid th, table.grid td { border: 1px solid #ddd; padding: 5px 8px; text-align: left; vertical-align: top; }
table.grid th { background: var(--navy); color: #fff; font-weight: 600; }
table.grid td.attr { font-weight: 600; color: var(--navy); background: #f5f1e8; white-space: nowrap; }
.grid .change { font-weight: 600; }
.grid .conflict { color: #9a3030; font-weight: 700; text-decoration: underline wavy #9a3030; }
.grid .absent { color: #999; font-style: italic; }

.neg ul { margin: 0; padding-left: 18px; }
.neg li { margin: 4px 0; font-size: 0.92rem; }
.rep-section { display: block; margin: 4px 0; font-size: 0.95rem; }

/* Session 4 — report preview iframe (Screen 4). The generated report is a
   full standalone document, so it renders inside a sandboxed iframe. */
#report-preview-wrap { margin-top: 16px; }
#report-preview-wrap h3 { margin-bottom: 8px; }
#report-preview { width: 100%; height: 70vh; min-height: 420px; border: 1px solid #ddd; border-radius: 4px; background: #fff; }

/* ---------- intro (above the stepper) & FAQ (below the tool) ----------
   Both sit outside the #screen-* sections that showScreen() toggles, so
   they render unchanged no matter which of the four steps is active. */
.tool-intro h3 { margin-top: 26px; }
.delivers-list { list-style: none; margin: 10px 0 0; padding: 0; }
.delivers-list li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 12px;
  line-height: 1.6;
}
.delivers-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
}
.delivers-list li:last-child { margin-bottom: 0; }

.faq-section { margin-top: 40px; }
.faq-item { margin-bottom: 22px; }
.faq-item:last-child { margin-bottom: 0; }
.faq-q { font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.faq-a { margin: 0; }

/* Content links (intro paragraphs, FAQ answers) — nav/footer links have
   their own rules above, so this is scoped to prose links only. */
.tool-intro a, .faq-a a {
  color: var(--teal);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.tool-intro a:hover, .faq-a a:hover {
  color: var(--teal-hover);
  border-bottom-color: var(--teal-hover);
}
