/*
 * Press & Influencer Ledger - "Warm Ranch" look.
 *
 * What this file is: the one stylesheet on top of Bootstrap 5 (loaded from the CDN).
 * Bootstrap keeps the grid and the form controls; this file re-colours, re-fonts and
 * re-shapes them to the Warm Ranch design (ivory ground, copper accents, Fraunces
 * headings, Inter body) and adds the page components: nav bar, profile cards, metric
 * tiles, the "story so far" timeline and the outlined estimate tag.
 *
 * Design rules it protects: text contrast of at least 4.5:1, touch targets of at
 * least 44px, a visible copper focus outline, and a layout that stacks at phone width.
 */

/* ---------- Design tokens ---------- */
:root {
  --ground: #F7F3EC;        /* page background (ivory) */
  --surface: #FFFDF9;       /* card background */
  --line: #E5DCCD;          /* card and rule borders */
  --divider: #EFE7DA;       /* hairlines inside cards */
  --ink: #23201C;           /* main text (charcoal) */
  --ink-2: #4D463E;         /* secondary text */
  --ink-muted: #6E655A;     /* labels and captions */
  --copper: #8A4E22;        /* links and primary buttons */
  --copper-dark: #6B3B17;   /* hover */
  --nav-text: #E8E1D6;
  --nav-active: #F2C79B;
  --green: #2F6B3F;         /* current / positive */
  --amber: #7A4A12;         /* estimate / unverified text */
  --amber-line: #E2C9A6;    /* estimate tag border */
  --red: #8E2A1F;           /* errors and destructive actions */
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: Fraunces, Georgia, serif;

  /* Bootstrap variables, re-pointed at the tokens above */
  --bs-body-bg: var(--ground);
  --bs-body-color: var(--ink);
  --bs-body-font-family: var(--font-body);
  --bs-secondary-color: var(--ink-muted);
  --bs-link-color: var(--copper);
  --bs-link-color-rgb: 138, 78, 34;
  --bs-link-hover-color: var(--copper-dark);
  --bs-link-hover-color-rgb: 107, 59, 23;
  --bs-border-color: var(--line);
  --bs-border-radius: 4px;
  --bs-border-radius-sm: 4px;
  --bs-border-radius-lg: 4px;
}

/* ---------- Base ---------- */
body { background: var(--ground); color: var(--ink); font-family: var(--font-body); }
h1, h2, h3, .h1, .h2, .h3, .h4, .h5 { font-family: var(--font-display); font-weight: 700; color: var(--ink); }
h1, .h3 { font-size: 2rem; line-height: 1.1; }
h2, .h5 { font-size: 1.25rem; }
.text-muted { color: var(--ink-muted) !important; }
.text-danger { color: var(--red) !important; }
a { text-underline-offset: 2px; }

/* Visible keyboard focus everywhere */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible, .form-check-input:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
  box-shadow: none;
}

/* ---------- Nav bar ---------- */
.site-header { background: var(--ink); color: var(--nav-text); }
.site-nav {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 28px; min-height: 64px;
}
.site-brand { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.3px; color: #FFFDF9; text-decoration: none; padding: 8px 0; }
.site-brand:hover { color: #FFFDF9; }
.site-links { display: flex; flex-wrap: wrap; column-gap: 6px; list-style: none; margin: 0; padding: 0; }
.site-links a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px;
  color: var(--nav-text); text-decoration: none; font-size: 0.875rem;
}
.site-links a:hover { color: #FFFDF9; text-decoration: underline; }
.site-links a[aria-current="page"] { color: var(--nav-active); font-weight: 600; }
.site-header a:focus-visible, .site-header button:focus-visible { outline-color: var(--nav-active); }
.nav-count { background: var(--nav-active); color: var(--ink); font-size: 0.75rem; font-weight: 600; border-radius: 10px; padding: 1px 8px; margin-left: 6px; }
.site-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 0.8125rem; color: #D9D0C2; }
.site-user .btn { color: var(--nav-text); border-color: #8B8072; }
.site-user .btn:hover { background: var(--nav-text); color: var(--ink); }

/* Second row under the nav on admin pages: Overview, Backfill, Competitors */
.admin-subnav { max-width: 1200px; margin: 0 auto; padding: 0 24px; display: flex; flex-wrap: wrap; column-gap: 6px; border-top: 1px solid #3A342D; }
.admin-subnav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--nav-text); text-decoration: none; font-size: 0.8125rem; }
.admin-subnav a:hover { color: #FFFDF9; text-decoration: underline; }
.admin-subnav a[aria-current="page"] { color: var(--nav-active); font-weight: 600; }
@media (max-width: 575.98px) { .admin-subnav { padding-left: 16px; padding-right: 16px; } }

/* ---------- Page shell ---------- */
.page-shell { max-width: 1200px; margin: 0 auto; padding: 36px 24px 48px; }
@media (max-width: 575.98px) {
  .site-nav, .page-shell { padding-left: 16px; padding-right: 16px; }
  .page-shell { padding-top: 24px; }
  h1, .h3 { font-size: 1.6rem; }
}

/* ---------- Buttons and form controls (44px touch targets) ---------- */
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.875rem; border-radius: 4px; }
.btn-sm { min-height: 44px; padding-left: 14px; padding-right: 14px; font-size: 0.8125rem; }
.btn-primary, .btn-dark { --bs-btn-bg: var(--copper); --bs-btn-border-color: var(--copper); --bs-btn-color: #FFFDF9;
  --bs-btn-hover-bg: var(--copper-dark); --bs-btn-hover-border-color: var(--copper-dark); --bs-btn-hover-color: #FFFDF9;
  --bs-btn-active-bg: var(--copper-dark); --bs-btn-active-border-color: var(--copper-dark); --bs-btn-active-color: #FFFDF9;
  --bs-btn-disabled-bg: var(--copper); --bs-btn-disabled-border-color: var(--copper); }
.btn-success { --bs-btn-bg: var(--green); --bs-btn-border-color: var(--green); --bs-btn-color: #FFFDF9;
  --bs-btn-hover-bg: #245230; --bs-btn-hover-border-color: #245230; --bs-btn-hover-color: #FFFDF9;
  --bs-btn-active-bg: #245230; --bs-btn-active-border-color: #245230; }
.btn-warning { --bs-btn-bg: var(--nav-active); --bs-btn-border-color: var(--nav-active); --bs-btn-color: var(--ink);
  --bs-btn-hover-bg: #E8B67F; --bs-btn-hover-border-color: #E8B67F; --bs-btn-hover-color: var(--ink); }
.btn-outline-dark, .btn-outline-secondary, .btn-outline-primary { --bs-btn-color: var(--ink-2); --bs-btn-border-color: #D5C9B6;
  --bs-btn-hover-bg: var(--ink); --bs-btn-hover-border-color: var(--ink); --bs-btn-hover-color: #FFFDF9;
  --bs-btn-active-bg: var(--ink); --bs-btn-active-border-color: var(--ink); --bs-btn-active-color: #FFFDF9; }
.btn-outline-danger { --bs-btn-color: var(--red); --bs-btn-border-color: #D9B3AD;
  --bs-btn-hover-bg: var(--red); --bs-btn-hover-border-color: var(--red); --bs-btn-hover-color: #FFFDF9;
  --bs-btn-active-bg: var(--red); --bs-btn-active-border-color: var(--red); }
.btn-outline-success { --bs-btn-color: var(--green); --bs-btn-border-color: #A9C4B0;
  --bs-btn-hover-bg: var(--green); --bs-btn-hover-border-color: var(--green); --bs-btn-hover-color: #FFFDF9; }
.form-control, .form-select, .form-control-sm, .form-select-sm {
  background-color: var(--surface); border-color: #D5C9B6; border-radius: 4px; color: var(--ink);
  min-height: 44px; font-size: 0.875rem;
}
.form-control::placeholder { color: var(--ink-muted); opacity: 1; }
.form-control:focus, .form-select:focus { border-color: var(--copper); box-shadow: none; outline: 2px solid var(--copper); outline-offset: 0; }
.form-check-input { width: 1.25em; height: 1.25em; border-color: #8B8072; }
.form-check-input:checked { background-color: var(--copper); border-color: var(--copper); }
.form-check-label { min-height: 44px; display: inline-flex; align-items: center; }
.form-label { font-weight: 600; color: var(--ink-2); }
.filter-bar .form-label { font-size: 0.75rem; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 0.2rem; }
.page-link { min-height: 44px; display: inline-flex; align-items: center; color: var(--copper); border-color: var(--line); background: var(--surface); }
.page-item.disabled .page-link { color: var(--ink-muted); background: var(--surface); }

/* ---------- Alerts ---------- */
.alert { border-radius: 4px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left-width: 4px; }
.alert-info { border-left-color: var(--copper); }
.alert-danger { border-left-color: var(--red); }
.alert-warning { border-left-color: var(--amber); }

/* ---------- Tables (wrapped in .table-scroll so phones scroll sideways) ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; margin-bottom: 1rem; }
.table-scroll > .table { margin-bottom: 0; }
.table { --bs-table-bg: var(--surface); --bs-table-hover-bg: #F7F0E3; --bs-table-color: var(--ink); --bs-table-border-color: var(--divider); }
.table > thead th { font-size: 0.75rem; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; border-bottom-color: var(--line); white-space: nowrap; }
.table td, .table th { vertical-align: middle; padding: 0.6rem 0.75rem; }

/* ---------- Badges ---------- */
.badge { border-radius: 3px; font-weight: 600; letter-spacing: 0.3px; }
.text-bg-success { background-color: var(--green) !important; color: #FFFDF9 !important; }
.text-bg-secondary { background-color: var(--ink-muted) !important; color: #FFFDF9 !important; }
.text-bg-primary { background-color: var(--copper) !important; color: #FFFDF9 !important; }
.text-bg-warning { background-color: var(--nav-active) !important; color: var(--ink) !important; }
.text-bg-danger { background-color: var(--red) !important; color: #FFFDF9 !important; }
.text-bg-light { background-color: var(--surface) !important; color: var(--ink-2) !important; border-color: var(--line) !important; }

/* Estimate / unverified: an outlined uppercase amber tag (never a fill, so it reads as "unsure") */
.estimate-badge {
  background: transparent; color: var(--amber); border: 1px solid var(--amber-line); border-radius: 3px;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; padding: 2px 6px;
}

/* ---------- Cards (Bootstrap .card plus the profile cards) ---------- */
.card, .profile-card, .review-item { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.card-header { background: transparent; border-bottom: 1px solid var(--divider); font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; padding: 16px 24px; }
.card-body { padding: 16px 24px; }
.list-group-item { background: transparent; border-color: var(--divider); padding: 12px 24px; }
.profile-card { padding: 28px; display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.profile-card.compact { padding: 24px; }
.profile-card h2 { margin: 0; font-size: 1.25rem; }
.eyebrow { font-size: 0.75rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; }
.profile-name { margin: 0; font-size: 2.6rem; line-height: 1.05; overflow-wrap: anywhere; }
.profile-place { font-size: 0.9375rem; color: var(--ink-2); margin: 0; }
.profile-rule { height: 1px; background: var(--line); border: 0; margin: 0; opacity: 1; }
.fact-list { display: flex; flex-direction: column; gap: 10px; font-size: 0.875rem; margin: 0; }
.fact-list > div { display: flex; justify-content: space-between; gap: 12px; }
.fact-list dt { color: var(--ink-muted); font-weight: 400; }
.fact-list dd { margin: 0; font-weight: 600; text-align: right; }
.role-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 0.875rem; }
.role-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.role-list a { font-weight: 600; }
.status-current, .status-former { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; }
.status-current { color: var(--green); }
.status-former { color: var(--ink-muted); }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 0.875rem; }
.plain-list li { border-bottom: 1px solid var(--divider); padding-bottom: 10px; }
.plain-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-actions form { display: contents; }
.form-card { padding: 24px; margin-bottom: 20px; }

/* ---------- Profile layout: left column cards, right column story ---------- */
.profile-layout { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.profile-side { flex: 1 1 320px; min-width: 0; }
.profile-main { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }

/* ---------- Metric tiles: no box, a 3px top rule, copper for the headline number ---------- */
.metric-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 767.98px) { .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.metric-tile { border-top: 3px solid var(--ink); padding-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.metric-tile.headline { border-top-color: var(--copper); }
.metric-label { font-size: 0.75rem; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; }
.metric-value { font-family: var(--font-display); font-size: 2.75rem; font-weight: 700; line-height: 1.1; }
.metric-caption { font-size: 0.75rem; color: var(--ink-muted); }
.metric-caption.is-estimate { color: var(--amber); }

/* ---------- "The story so far" timeline ---------- */
.story-card { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 28px; }
.story-card h2 { margin: 0 0 12px; font-size: 1.5rem; }
.timeline-row { display: flex; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--divider); }
.timeline-row:last-child { border-bottom: 0; }
.timeline-row.is-removed { opacity: 0.7; }
.timeline-when { flex: 0 0 84px; font-size: 0.8125rem; color: var(--ink-muted); font-weight: 600; text-transform: uppercase; }
.timeline-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.timeline-headline { font-weight: 600; }
.timeline-detail { font-size: 0.875rem; color: var(--ink-2); }
.timeline-hit { color: var(--green); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; margin-left: 6px; }
@media (max-width: 479.98px) { .timeline-row { flex-direction: column; gap: 4px; } .timeline-when { flex-basis: auto; } }

/* ---------- Existing component names kept for the other pages ---------- */
.payload-list { font-size: 0.9rem; margin-bottom: 0.5rem; }
.payload-list dt { color: var(--ink-muted); font-weight: 600; }
.review-item { padding: 1rem 1.25rem; margin-bottom: 1rem; }
.payload-list dd { margin-bottom: 0.25rem; }
.stack-sm > * + * { margin-top: 0.5rem; }

/* Report page: square article thumbnails */
.report-thumb { object-fit: cover; border-radius: 3px; border: 1px solid var(--divider); }
.site-user-link { color: var(--nav-text); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.site-user-link:hover { color: #FFFDF9; text-decoration: underline; }

/* Dashboards: view tabs and fixed-height chart boxes (Chart.js fills them) */
.dash-tabs { display: flex; flex-wrap: wrap; gap: 4px 18px; border-bottom: 1px solid var(--line); }
.dash-tabs a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-2); text-decoration: none; border-bottom: 3px solid transparent; }
.dash-tabs a:hover { color: var(--copper); }
.dash-tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--copper); }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 520px; }
.series-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
/* Sortable table headers: the whole label is a link; the active column shows its direction */
th.sortable a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; min-height: 32px; }
th.sortable a:hover { color: var(--copper); text-decoration: underline; }
th.sortable[aria-sort] a { color: var(--ink); }
.sort-mark { font-size: 0.7em; margin-left: 2px; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; min-height: 32px; cursor: pointer; }
.th-sort:hover { color: var(--copper); text-decoration: underline; }
.th-sort:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }
.metric-value-long { font-size: clamp(1.5rem, 2.6vw, 2.25rem); overflow-wrap: anywhere; }
