/*
Theme Name: CaHouseMarket
Theme URI: https://cahousingmarketnews.com
Author: Eric Dolan
Author URI: https://psypost.org
Description: Editorial WordPress theme for California housing market news. Renders structured market data (KPIs, neighborhood tables, trend charts) from custom post meta written by the Real Estate News Bot. Cities auto-integrate via parent/child categories (region → city).
Version: 1.0.50
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: cahousemarket
Tags: news, editorial, real-estate, data-journalism, custom-colors, custom-menu
*/

/* ============================================================================
   Design tokens
   ============================================================================ */
:root {
  --paper:        #f6f1e7;
  --paper-2:      #efe8d8;
  --ink:          #14202e;
  --ink-2:        #2a3a4f;
  --ink-3:        #5a6a7e;
  --rule:         rgba(20,32,46,0.14);
  --rule-strong:  rgba(20,32,46,0.30);
  --gold:         #b07c1e;
  --gold-soft:    #e2c98c;
  --pos:          #2f5d3a;
  --neg:          #8a2a22;
  --serif:        'Source Serif 4', 'Charter', 'Iowan Old Style', Georgia, serif;
  --display:      'Fraunces', 'Times New Roman', serif;
  --mono:         'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

/* ============================================================================
   Reset / base
   ============================================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(176,124,30,0.04), transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(20,32,46,0.04), transparent 60%);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; }

.screen-reader-text {
  border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%);
  height: 1px; width: 1px; margin: -1px; overflow: hidden; padding: 0;
  position: absolute; word-wrap: normal !important;
}

/* ============================================================================
   Top utility bar
   ============================================================================ */
.topbar {
  background: var(--ink); color: var(--paper);
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 8px 24px;
  display: flex; justify-content: flex-end; align-items: center;
  gap: 16px; flex-wrap: wrap;
}
.topbar-inner span { opacity: 0.7; }
.topbar-inner a { color: var(--gold-soft); }
.topbar-inner a:hover { color: var(--paper); }

/* ============================================================================
   Site header
   ============================================================================ */
header.site {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.site-inner {
  max-width: 1280px; margin: 0 auto; padding: 22px 24px;
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 32px; align-items: center;
}
.brand {
  display: flex; align-items: center; gap: 14px;
  border-right: 1px solid var(--rule); padding-right: 24px;
}
.brand-mark {
  /* Gold tile + navy house — matches the favicon and OG image, so the
     brand recognition pattern is consistent everywhere it appears. */
  width: 44px; height: 44px;
  background: var(--gold); color: var(--ink);
  display: grid; place-items: center;
  border-radius: 2px;
  flex-shrink: 0;
}
.brand-mark svg { width: 28px; height: 28px; }
.brand-text {
  font-family: var(--display); font-weight: 600;
  font-variation-settings: 'opsz' 144, 'SOFT' 0;
  line-height: 1;
}
.brand-text .name { font-size: 22px; letter-spacing: -0.01em; }
.brand-text .tag {
  display: block; margin-top: 4px;
  font-family: var(--mono); font-size: 10px; font-weight: 400;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3);
}

nav.primary ul {
  display: flex; gap: 28px; list-style: none;
  font-family: var(--display); font-size: 15px;
  font-variation-settings: 'opsz' 14;
  flex-wrap: wrap;
}
nav.primary a {
  padding: 6px 0;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.15s, color 0.15s;
}
nav.primary a:hover { border-bottom-color: var(--gold); }
nav.primary li.current-menu-item a,
nav.primary li.current-page-ancestor a,
nav.primary li.current-cat a { border-bottom-color: var(--ink); }

.header-tools { display: flex; gap: 12px; align-items: center; }
.search-form { display: contents; }
.search-field {
  background: transparent; border: 1px solid var(--rule-strong);
  padding: 8px 14px 8px 34px;
  font-family: var(--serif); font-size: 14px; color: var(--ink);
  border-radius: 999px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314202e' stroke-width='1.6'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center; background-size: 16px;
  width: 220px;
}
.search-field:focus { outline: none; border-color: var(--ink); }
.search-submit {
  position: absolute; left: -9999px;
}
.btn-subscribe {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; border: none; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-subscribe:hover { background: var(--gold); color: var(--ink); }

.menu-toggle {
  display: none;
  background: none; border: 1px solid var(--rule-strong);
  padding: 8px 12px; cursor: pointer;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
}

/* Mobile header */
@media (max-width: 900px) {
  .site-inner {
    /* Switch to flex on mobile so menu-toggle and header-tools can sit
       inline in the right cluster without grid placement gymnastics.
       Brand takes available space on the left, controls cluster on the
       right. The nav drops below as a full-width row when opened. */
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
  }
  .brand {
    border-right: none;
    padding-right: 0;
    flex: 1 1 auto;
    min-width: 0;
  }
  .brand-text .tag { display: none; }
  .header-tools {
    /* Sits inline with menu-toggle in the right cluster */
    order: 2;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .header-tools .search-field { display: none; }
  .menu-toggle {
    display: inline-block;
    order: 3;
  }
  nav.primary {
    /* Full-width row below the brand+controls */
    display: none;
    order: 4;
    flex: 1 0 100%;
  }
  nav.primary.is-open { display: block; }
  nav.primary ul {
    flex-direction: column;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--rule);
  }
}

/* ============================================================================
   Section nav / breadcrumb
   ============================================================================ */
.section-nav {
  border-bottom: 1px solid var(--rule);
  background: var(--paper-2);
}
.section-nav-inner {
  max-width: 1280px; margin: 0 auto; padding: 12px 24px;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
}
.section-nav .crumb { color: var(--ink-3); }
.section-nav .crumb a:hover { color: var(--ink); }
.section-nav .sep { color: var(--rule-strong); }
.section-nav .here { color: var(--ink); }

/* ============================================================================
   Article wrapper
   ============================================================================ */
main.site-main { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.article-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 64px;
  padding: 56px 0 80px;
}
@media (max-width: 960px) {
  .article-grid { grid-template-columns: 1fr; gap: 48px; padding: 32px 0 48px; }
}

/* ============================================================================
   Eyebrow + headline + deck + byline
   ============================================================================ */
.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 20px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.eyebrow .dot { width: 6px; height: 6px; background: var(--gold); border-radius: 50%; }
.eyebrow a { color: var(--gold); }
.eyebrow a:hover { color: var(--ink); }
.eyebrow .sep { color: var(--rule-strong); }
.eyebrow .label { color: var(--ink-3); }

h1.headline,
.archive-title {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 144, 'SOFT' 30;
  font-size: clamp(34px, 5.5vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 20px;
  max-width: 18ch;
}
h1.headline em,
.archive-title em {
  font-style: italic;
  font-variation-settings: 'opsz' 144, 'SOFT' 100;
  color: var(--ink-2);
}

.deck {
  font-family: var(--display); font-weight: 300;
  font-variation-settings: 'opsz' 24;
  font-size: clamp(19px, 2.2vw, 24px);
  line-height: 1.4;
  color: var(--ink-2);
  max-width: 38ch;
  margin-bottom: 32px;
}

.byline {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}
.author-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 600; color: var(--ink);
  font-size: 16px; flex-shrink: 0;
  overflow: hidden;
}
.author-avatar img { border-radius: 50%; }
.byline-text { flex: 1; min-width: 0; }
.byline-name {
  font-family: var(--display); font-weight: 600; font-size: 15px;
  font-variation-settings: 'opsz' 14;
}
.byline-name a { border-bottom: 1px solid var(--rule); }
.byline-name a:hover { border-bottom-color: var(--ink); }
.byline-meta {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.05em; margin-top: 2px;
}
.byline-meta time { color: var(--ink-2); }

.byline-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px;
  background: transparent; border: 1px solid var(--rule-strong);
  display: grid; place-items: center; cursor: pointer;
  border-radius: 50%; color: var(--ink);
  transition: all 0.15s;
  list-style: none;  /* hides the default <summary> disclosure triangle */
}
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.icon-btn svg { width: 16px; height: 16px; }

/* Share menu — popover that opens from the share icon */
.share-menu { position: relative; }
.share-menu[open] .icon-btn {
  border-color: var(--ink); background: var(--ink); color: var(--paper);
}
.share-menu-list {
  position: absolute; right: 0; top: calc(100% + 6px);
  z-index: 30;
  min-width: 200px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(20, 32, 46, 0.12);
  display: flex; flex-direction: column;
  padding: 4px 0;
  font-family: var(--mono);
  font-size: 12px;
}
.share-menu-list a,
.share-menu-list button {
  display: block; width: 100%; text-align: left;
  padding: 10px 16px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--ink);
  text-decoration: none;
  font: inherit;
}
.share-menu-list a:hover,
.share-menu-list button:hover { background: var(--paper-2, rgba(20, 32, 46, 0.04)); }
.share-menu-list .share-copy.is-done { color: var(--pos); }

/* ============================================================================
   KPI metric strip
   ============================================================================ */
.kpi-strip {
  margin-top: 36px;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--paper);
}
@media (max-width: 880px) {
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .kpi-cell:nth-child(3n) { border-right: none; }
  .kpi-cell:nth-child(n+4) { border-top: 1px solid var(--rule); }
}
@media (max-width: 480px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi-cell { border-right: 1px solid var(--rule); }
  .kpi-cell:nth-child(2n) { border-right: none; }
  .kpi-cell:nth-child(n+3) { border-top: 1px solid var(--rule); }
}
.kpi-cell {
  padding: 18px 16px;
  border-right: 1px solid var(--rule);
  position: relative;
}
.kpi-cell:last-child { border-right: none; }
.kpi-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 36;
  font-size: 26px; line-height: 1; letter-spacing: -0.02em;
  color: var(--ink);
  font-feature-settings: 'tnum' 1;
}
.kpi-delta {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  margin-top: 6px; display: flex; align-items: center; gap: 4px;
}
/* Sentiment → color */
.kpi-delta.sent-good { color: var(--pos); }
.kpi-delta.sent-bad  { color: var(--neg); }
.kpi-delta.sent-warn { color: var(--gold); }
.kpi-delta.sent-flat { color: var(--ink-3); }
/* Legacy single-class fallback (sidebar uses cahm_delta_class). */
.kpi-delta.up    { color: var(--pos); }
.kpi-delta.down  { color: var(--neg); }
.kpi-delta.warn  { color: var(--gold); }
.kpi-delta.flat  { color: var(--ink-3); }
/* Direction → glyph. Pseudo-element so it inherits color from sentiment. */
.kpi-delta::before {
  font-family: var(--display); font-weight: 700;
  font-size: 9px; line-height: 1;
}
.kpi-delta.dir-up::before   { content: '▲'; }
.kpi-delta.dir-down::before { content: '▼'; }
.kpi-delta.dir-flat::before { content: '–'; }
/* Legacy single-class glyph fallback. */
.kpi-delta.up:not([class*="dir-"])::before   { content: '▲'; }
.kpi-delta.down:not([class*="dir-"])::before { content: '▼'; }
.kpi-delta.warn:not([class*="dir-"])::before { content: '◆'; }
.kpi-delta.flat:not([class*="dir-"])::before { content: '–'; }

/* ============================================================================
   Hero chart card
   ============================================================================ */
.hero-chart {
  margin-top: 40px;
  border: 1px solid var(--rule);
  background: linear-gradient(180deg, #fdfaf2 0%, var(--paper) 100%);
  padding: 32px;
  position: relative;
}
.hero-chart::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, transparent 60%);
}
.hero-chart figure { margin: 0; }
.hero-chart img { width: 100%; height: auto; }
.chart-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px; flex-wrap: wrap; gap: 16px;
}
.chart-title {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 24;
  font-size: 22px; line-height: 1.2;
}
.chart-sub {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.05em;
  color: var(--ink-3); text-transform: uppercase; margin-top: 4px;
}
.chart-legend {
  display: flex; align-items: center;
  font-family: var(--serif); font-size: 14px; color: var(--ink-2);
}
.chart-legend > span {
  display: inline-flex; align-items: center;
  white-space: nowrap;
  margin-left: 16px;
}
.chart-legend > span:first-child { margin-left: 0; }
.chart-legend .swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 2px;
  margin-right: 6px;
}

/* ============================================================================
   Article body prose
   ============================================================================ */
.article-body {
  margin-top: 56px;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  color: var(--ink);
  max-width: 64ch;
}
.article-body p { margin-bottom: 1.4em; }
.article-body > p:first-child::first-letter,
.article-body > .first-letter::first-letter {
  font-family: var(--display); font-weight: 600;
  font-variation-settings: 'opsz' 144;
  float: left; font-size: 4.6em; line-height: 0.85;
  margin: 0.08em 0.08em 0 -0.04em;
  color: var(--ink);
}
.article-body h2 {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 36;
  font-size: 28px; line-height: 1.15; letter-spacing: -0.015em;
  margin: 2em 0 0.6em;
  padding-top: 0.6em;
  border-top: 1px solid var(--rule);
}
.article-body h3 {
  font-family: var(--display); font-weight: 600;
  font-variation-settings: 'opsz' 24;
  font-size: 21px; line-height: 1.2; letter-spacing: -0.01em;
  margin: 1.6em 0 0.5em;
}
.article-body strong { font-weight: 600; }
.article-body a {
  color: var(--ink); border-bottom: 1px solid var(--gold);
  transition: background 0.15s;
}
.article-body a:hover { background: var(--gold-soft); }
.article-body figure { margin: 2em 0; }
.article-body figure img { width: 100%; height: auto; }
.article-body figcaption {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.05em; margin-top: 8px;
}

/* Pull quote */
.article-body blockquote,
.article-body .pullquote {
  margin: 2em 0;
  padding: 24px 0 24px 28px;
  border-left: 3px solid var(--gold);
  font-family: var(--display);
  font-weight: 400;
  font-variation-settings: 'opsz' 36, 'SOFT' 100;
  font-style: italic;
  font-size: 26px; line-height: 1.3; color: var(--ink);
  max-width: 28ch;
}
.article-body blockquote cite,
.article-body .pullquote cite {
  display: block; margin-top: 12px;
  font-family: var(--mono); font-size: 11px; font-style: normal;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3);
}

/* Data callout */
.data-callout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin: 2em 0;
  padding: 28px;
  background: var(--ink); color: var(--paper);
  position: relative;
}
.data-callout::before {
  content: 'BY THE NUMBERS';
  position: absolute; top: -10px; left: 24px;
  background: var(--gold); color: var(--ink);
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.12em; padding: 4px 10px;
}
.data-callout .stat {
  border-left: 2px solid var(--gold-soft); padding-left: 16px;
}
.data-callout .stat-num {
  font-family: var(--display); font-weight: 600;
  font-variation-settings: 'opsz' 96;
  font-size: 44px; line-height: 1; color: var(--paper);
  font-feature-settings: 'tnum' 1;
  margin-bottom: 8px;
}
.data-callout .stat-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.05em;
  color: var(--gold-soft); text-transform: uppercase;
}

/* ZIP / neighborhood table */
.zip-table {
  width: 100%; margin: 2em 0;
  border: 1px solid var(--rule); border-collapse: collapse;
  font-family: var(--mono); font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.zip-table caption {
  caption-side: top; text-align: left;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 8px; padding: 0 0 8px 0;
}
.zip-table thead { background: var(--ink); color: var(--paper); }
.zip-table th {
  padding: 12px 16px; text-align: left;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 500;
}
.zip-table th.num,
.zip-table td.num { text-align: right; }
.zip-table td {
  padding: 12px 16px; border-top: 1px solid var(--rule);
}
.zip-table .delta-up { color: var(--pos); }
.zip-table .delta-down { color: var(--neg); }

/* Methodology box */
.methodology {
  margin: 3em 0 2em;
  padding: 28px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
}
.methodology h3 {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.methodology h3::before {
  content: ''; width: 24px; height: 1px; background: var(--gold);
}
.methodology p {
  font-family: var(--serif); font-size: 15px; line-height: 1.55;
  color: var(--ink-2); margin-bottom: 12px;
}
.methodology ul {
  list-style: none; padding: 0; display: grid; gap: 10px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
}
.methodology li {
  padding-left: 18px; position: relative;
}
.methodology li::before {
  content: '→'; position: absolute; left: 0; color: var(--gold);
}
.methodology a {
  color: var(--ink);
  border-bottom: 1px dotted var(--rule-strong);
}
.methodology a:hover { border-bottom-color: var(--ink); border-bottom-style: solid; }

/* ============================================================================
   About / Methodology page
   ============================================================================ */
/* The default article headline is capped at 18ch for editorial impact;
   About-page titles need different rules. We reduce the font size so a
   longer title like "About CaHousingMarketNews.com" still fits on one
   line at typical column widths, but recommend using a short title
   ("About") and letting the eyebrow + brand carry the rest. */
.about-page h1.headline {
  font-size: clamp(36px, 5vw, 56px);
  max-width: none;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
  word-break: normal;
  overflow-wrap: break-word;
}
.about-page .article-body {
  font-family: var(--serif); font-size: 18px; line-height: 1.6;
  color: var(--ink-2);
}
.about-page .article-body h2 {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 24;
  font-size: 24px; line-height: 1.2;
  color: var(--ink); letter-spacing: -0.01em;
  margin: 48px 0 16px; padding-top: 24px;
  border-top: 2px solid var(--ink);
}
.about-page .article-body h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.about-page .article-body p { margin: 0 0 18px; }
.about-page .article-body strong { color: var(--ink); font-weight: 600; }

/* Source cards — used on About / Methodology pages.
   Selector intentionally NOT scoped to .about-page so cards can be embedded
   anywhere via the [cahm_sources] shortcode. */
.source-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--rule);
  margin: 8px 0 28px;
  border: 1px solid var(--rule);
  /* Defensive against parent's wpautop or block-editor styles trying to
     change layout inside the grid */
  list-style: none;
}
@media (max-width: 720px) {
  .source-grid { grid-template-columns: 1fr; }
}
.source-card {
  background: var(--paper);
  padding: 20px;
  margin: 0; /* override any default block margins */
}
.source-card .source-eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--gold); text-transform: uppercase; margin-bottom: 8px;
}
.source-card .source-name {
  font-family: var(--display); font-weight: 600;
  font-variation-settings: 'opsz' 14;
  font-size: 17px; color: var(--ink);
  letter-spacing: -0.01em; margin-bottom: 4px;
}
.source-card .source-meta {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.04em; margin-bottom: 10px;
}
.source-card p {
  font-size: 14px; line-height: 1.5; color: var(--ink-2);
  margin: 0;
}

/* Methodology callout — used on About / Methodology pages.
   Same de-scoping rationale as .source-grid above. */
.methodology-callout {
  background: var(--ink); color: var(--paper);
  padding: 28px; margin: 32px 0;
}
.methodology-callout h2,
.about-page .article-body .methodology-callout h2 {
  /* Specificity boost via the second selector — when this callout is
     embedded inside .about-page .article-body (the normal case), the
     ancestor h2 rule sets ink color + ink border-top, which makes the
     heading vanish against the navy callout background. We override
     all three (color, border, padding/margin) here. */
  color: var(--paper);
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
  margin-bottom: 14px;
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 24;
  font-size: 24px; line-height: 1.2;
  letter-spacing: -0.01em;
}
.methodology-callout p {
  color: rgba(246,241,231,0.85); font-size: 16px;
  margin-bottom: 12px;
}
.methodology-callout p:last-child { margin-bottom: 0; }
.methodology-callout strong { color: var(--paper); }
.methodology-callout a {
  color: var(--gold); text-decoration: underline; text-underline-offset: 2px;
}

/* Byline-style meta line on About page */
.about-page .byline { margin-top: 24px; }
.about-page .byline-meta {
  font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.04em; color: var(--ink-3);
}

/* ============================================================================
   Partner cards (inline ads) — Option C: full-bleed magazine ad
   ============================================================================
   Solid gold background, big editorial headline, dark CTA button. Designed
   to function as a strong call-to-action that drives clicks; visually
   distinct from article body so it reads unambiguously as an ad. The
   "PARTNER" disclosure is small and dim by design — fulfills the legal
   requirement without competing with the headline.
*/
.partner-card {
  position: relative;
  margin: 36px 0 40px;
  padding: 26px 32px 26px;
  background: var(--gold);
  color: var(--ink);
  border-radius: 0;
  overflow: hidden;
  display: block;
}
.partner-card-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.55;
  margin-bottom: 10px;
  font-weight: 700;
}
.partner-card-headline {
  font-family: var(--display);
  font-weight: 700;
  font-variation-settings: 'opsz' 30, 'SOFT' 30;
  font-size: 26px;
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.022em;
  margin: 0 0 10px;
  max-width: 22ch;
}
.partner-card-subhead {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  margin: 0 0 16px;
  max-width: 56ch;
}
.partner-card-byline {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 14px;
  color: var(--ink);
  opacity: 0.75;
}
.partner-card-byline strong {
  color: var(--ink);
  opacity: 1;
  font-weight: 700;
}
/* Button — solid ink rectangle on gold background. Specificity-boosted
   (a.partner-card-cta) wins against generic theme link rules. */
a.partner-card-cta,
a.partner-card-cta:link,
a.partner-card-cta:visited {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--paper);
  background: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease;
  border: 0;
  line-height: 1.2;
}
a.partner-card-cta:hover,
a.partner-card-cta:focus {
  background: #000;
  transform: translateY(-1px);
}
.partner-card-cta-arrow {
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
}
@media (max-width: 640px) {
  .partner-card { padding: 22px 22px; }
  .partner-card-headline { font-size: 22px; }
  a.partner-card-cta { padding: 11px 20px; font-size: 11px; }
}

/* ============================================================================
   Cities directory page
   ============================================================================ */
.cities-page .article-body section.cities-region {
  margin-top: 40px;
}
.cities-page .article-body section.cities-region:first-of-type {
  margin-top: 24px;
}
.cities-page .article-body .cities-region-desc {
  font-size: 16px;
  color: var(--ink-2);
  margin: -8px 0 18px;
  max-width: 60ch;
}
.cities-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin: 8px 0 0;
}
@media (max-width: 720px) {
  .cities-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .cities-grid { grid-template-columns: 1fr; }
}
.cities-card {
  display: block;
  background: var(--paper);
  padding: 20px 22px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s ease;
}
.cities-card:hover {
  background: #f1ead9;
}
.cities-card-name {
  font-family: var(--display); font-weight: 600;
  font-variation-settings: 'opsz' 18;
  font-size: 18px; line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 6px;
}
.cities-card-meta {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

/* ============================================================================
   Contact page
   ============================================================================ */
/* Contact addresses grid.
 *
 * Adapts to card count and viewport. Realistic counts are 1-3 (filtered
 * from the three default blocks via customizer; falls back to 1 if all
 * are hidden).
 *
 * Layout strategy:
 *   - 3 cards on wide screens: a single row of 3, even widths. ✓
 *   - 2 cards on wide screens: two cards, each taking half the row,
 *     with no empty third cell.
 *   - 1 card on wide screens: full-width banner — looks intentional
 *     instead of orphaned.
 *   - At mid widths (≤960px): drop to 2 columns; if there are exactly
 *     3 cards, the third spans the full second row.
 *   - At narrow widths (≤720px): single column stack.
 */
.contact-addresses {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin: 24px 0 0;
}
/* Single card on wide screens: span full row. */
.contact-addresses > .contact-card:only-child {
  grid-column: 1 / -1;
}
/* Two cards on wide screens: collapse to 2-column grid so no empty
 * third cell. We use a sibling-count hack via :first-child + last
 * being :nth-child(2). */
.contact-addresses:has(> .contact-card:nth-child(2):last-child) {
  grid-template-columns: 1fr 1fr;
}
/* Intermediate widths: drop to 2 columns. */
@media (max-width: 960px) {
  .contact-addresses { grid-template-columns: 1fr 1fr; }
  /* When an odd card lands in the last row in 2-column mode, span the
   * full row so we don't leave an empty cell next to it. */
  .contact-addresses > .contact-card:nth-last-child(1):nth-child(odd) {
    grid-column: 1 / -1;
  }
}
/* Mobile: single column stack. */
@media (max-width: 720px) {
  .contact-addresses { grid-template-columns: 1fr; }
  .contact-addresses > .contact-card:nth-last-child(1):nth-child(odd) {
    grid-column: auto;  /* reset — single column means no spanning needed */
  }
}
.contact-card {
  background: var(--paper);
  padding: 24px 26px;
}
.contact-card-eyebrow {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
  font-weight: 600;
}
.contact-card-name {
  font-family: var(--display); font-weight: 600;
  font-variation-settings: 'opsz' 18;
  font-size: 19px; color: var(--ink);
  letter-spacing: -0.01em; margin-bottom: 8px;
}
.contact-card-desc {
  font-family: var(--serif); font-size: 14px; line-height: 1.5;
  color: var(--ink-2); margin: 0 0 14px;
}
a.contact-card-email,
a.contact-card-email:link,
a.contact-card-email:visited {
  display: inline-block;
  font-family: var(--mono); font-size: 13px;
  color: var(--ink); font-weight: 600;
  text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  letter-spacing: 0.01em;
  word-break: break-all;
}
a.contact-card-email:hover {
  color: var(--gold);
}


aside.rail {
  align-self: start;  /* don't stretch to fill grid row */
}
aside.rail .sticky {
  /* Despite the class name (kept for backward compatibility), this is
     not actually sticky. We tried sticky behavior in earlier versions
     and the trade-offs weren't worth it: tall sidebars got clipped
     off-screen, internal scrollbars were ugly and easy to miss, and
     bottom-anchoring caused odd "sidebar moves with page" effects.
     A plain sidebar that scrolls normally with the article is the
     simplest and most predictable option. */
  display: flex; flex-direction: column; gap: 32px;
}
.rail-block {
  border-top: 2px solid var(--ink); padding-top: 16px;
}
.rail-block h3 {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 16px;
}
.rail-block-sub {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  margin: -10px 0 16px; letter-spacing: 0.02em;
}
.rail-list { display: grid; gap: 14px; }
.rail-source {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-3); letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 12px 0 0; padding-top: 10px;
  border-top: 1px solid var(--rule);
  text-align: right;
}
.rail-item {
  padding-bottom: 14px; border-bottom: 1px solid var(--rule);
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start;
}
.rail-item:last-child { border-bottom: none; }
.rail-item a { display: contents; }
.rail-city {
  font-family: var(--display); font-weight: 600; font-size: 15px;
  font-variation-settings: 'opsz' 14;
  color: var(--ink);
  line-height: 1.2; margin-bottom: 4px;
}
.rail-meta {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  letter-spacing: 0.05em;
}
.rail-price {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--ink); text-align: right;
  font-feature-settings: 'tnum' 1;
}
.rail-delta {
  font-family: var(--mono); font-size: 10px;
  text-align: right; margin-top: 2px;
}
.rail-delta.up,
.rail-delta.dir-up,
.rail-delta.sent-good { color: var(--pos); }
.rail-delta.down,
.rail-delta.dir-down,
.rail-delta.sent-bad  { color: var(--neg); }
.rail-delta.flat,
.rail-delta.dir-flat,
.rail-delta.sent-flat { color: var(--ink-3); }
.rail-delta.sent-warn { color: var(--gold); }
.rail-delta.dir-up::before   { content: '▲ '; }
.rail-delta.dir-down::before { content: '▼ '; }
.rail-delta.dir-flat::before { content: '– '; }

.newsletter {
  background: var(--ink); color: var(--paper);
  padding: 24px;
}
.newsletter h3 {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 24;
  font-size: 22px; line-height: 1.15;
  color: var(--paper); margin-bottom: 8px; letter-spacing: -0.01em;
}
.newsletter p {
  font-family: var(--serif); font-size: 14px; line-height: 1.5;
  color: rgba(246,241,231,0.75); margin-bottom: 16px;
}
.newsletter input[type="email"] {
  width: 100%; padding: 12px 14px;
  background: rgba(246,241,231,0.08);
  border: 1px solid rgba(246,241,231,0.2); color: var(--paper);
  font-family: var(--serif); font-size: 14px;
  margin-bottom: 8px;
}
.newsletter input::placeholder { color: rgba(246,241,231,0.4); }
.newsletter button {
  width: 100%; padding: 12px;
  background: var(--gold); color: var(--ink); border: none;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; transition: background 0.15s;
}
.newsletter button:hover { background: var(--gold-soft); }

/* ============================================================================
   Homepage / archive grids
   ============================================================================ */
.home-hero {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 64px 0;
  margin-bottom: 64px;
}
.home-hero-inner {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; align-items: center;
}
@media (max-width: 800px) { .home-hero-inner { grid-template-columns: 1fr; } }
.home-hero-card { padding: 24px; background: var(--paper-2); border-left: 4px solid var(--gold); }

.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 32px;
  flex-wrap: wrap; gap: 12px;
}
.section-head h2 {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 36;
  font-size: 28px; letter-spacing: -0.015em;
}
.section-head a {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--gold);
}
.section-head a:hover { color: var(--ink); }

.city-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px;
  margin-bottom: 64px;
}
@media (max-width: 900px) { .city-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .city-grid { grid-template-columns: 1fr; } }

.city-card {
  border-top: 1px solid var(--rule); padding-top: 16px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-top-color 0.2s;
}
.city-card:hover { border-top-color: var(--ink); }
.city-card .cat {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold);
}
.city-card h3 {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 24;
  font-size: 21px; line-height: 1.2; letter-spacing: -0.01em;
  color: var(--ink);
}
.city-card .meta {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}
.city-card .stat-pill {
  display: inline-block;
  background: var(--paper-2); padding: 6px 12px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  border-left: 2px solid var(--gold);
  font-feature-settings: 'tnum' 1;
  margin-right: 8px;
}
.city-card .stat-pill .delta-up { color: var(--pos); margin-left: 4px; }
.city-card .stat-pill .delta-down { color: var(--neg); margin-left: 4px; }

/* Region grid (homepage groupings) */
.region-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 48px;
  margin-bottom: 64px;
}
@media (max-width: 800px) { .region-grid { grid-template-columns: 1fr; } }
.region-block { border-top: 1px solid var(--ink); padding-top: 16px; }
.region-block h3 {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 24;
  font-size: 22px; margin-bottom: 16px; letter-spacing: -0.01em;
}
.region-block ul {
  list-style: none; display: grid; gap: 8px;
  font-family: var(--serif);
}
.region-block li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 16px;
  padding: 6px 0; align-items: center;
}
.region-block li a { font-weight: 600; }
.region-block li a:hover { color: var(--gold); }
.region-block li .price {
  font-family: var(--mono); font-size: 13px;
  font-feature-settings: 'tnum' 1;
}
.region-block li .delta {
  font-family: var(--mono); font-size: 11px;
}

/* ============================================================================
   Archive (city) page
   ============================================================================ */
.archive-hero {
  padding: 48px 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 48px;
}
.archive-hero .archive-eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 12px;
}
.archive-hero .archive-deck {
  font-family: var(--display); font-weight: 300;
  font-variation-settings: 'opsz' 24;
  font-size: 22px; line-height: 1.4; color: var(--ink-2);
  max-width: 50ch; margin-top: 16px;
}

.post-list { display: flex; flex-direction: column; gap: 24px; margin-bottom: 64px; }
.post-list-item {
  display: grid; grid-template-columns: 200px 1fr; gap: 24px;
  padding: 24px 0; border-top: 1px solid var(--rule);
  align-items: start;
}
@media (max-width: 600px) { .post-list-item { grid-template-columns: 1fr; gap: 12px; } }
.post-list-item .date {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
  padding-top: 4px;
}
.post-list-item h3 {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 24;
  font-size: 22px; line-height: 1.25; letter-spacing: -0.01em;
  color: var(--ink); margin-bottom: 8px;
}
.post-list-item h3 a:hover { color: var(--gold); }
.post-list-item .excerpt {
  font-family: var(--serif); font-size: 16px; line-height: 1.5; color: var(--ink-2);
}

/* Pagination */
.pagination {
  display: flex; gap: 12px; justify-content: center; margin: 48px 0;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
}
.pagination a, .pagination span {
  padding: 10px 16px; border: 1px solid var(--rule-strong);
  color: var(--ink);
}
.pagination a:hover { background: var(--ink); color: var(--paper); }
.pagination .current { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ============================================================================
   Related row (single post bottom)
   ============================================================================ */
.related-row {
  border-top: 1px solid var(--ink);
  padding: 48px 0 64px;
  max-width: 1280px; margin: 0 auto;
}
.related-row > h3 {
  font-family: var(--display); font-weight: 500;
  font-variation-settings: 'opsz' 36;
  font-size: 28px; margin-bottom: 32px; padding: 0 24px;
  letter-spacing: -0.015em;
}
.related-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px;
  padding: 0 24px;
}
@media (max-width: 800px) { .related-grid { grid-template-columns: 1fr; } }

/* ============================================================================
   Footer
   ============================================================================ */
footer.site {
  background: var(--ink); color: var(--paper);
  padding: 56px 24px 24px;
  margin-top: 64px;
}
@media (max-width: 520px) {
  footer.site { padding: 40px 18px 20px; }
}
.footer-inner { max-width: 1280px; margin: 0 auto; }
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 48px;
  padding-bottom: 40px; border-bottom: 1px solid rgba(246,241,231,0.15);
}
/* Tablet — drop to 2x2 grid */
@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
}
/* Phone — stack everything single column. The 2x2 grid above gets too
   cramped under ~520px because long headings ("COVERAGE", "Sacramento
   Region") and brand description text fight for space. */
@media (max-width: 520px) {
  .footer-grid { grid-template-columns: 1fr; gap: 28px; padding-bottom: 28px; }
}
.footer-col {
  /* Without min-width:0, grid columns refuse to shrink below their
     content's intrinsic size — that's what was clipping the right side
     of long city names. */
  min-width: 0;
}
.footer-col h4,
.footer-col a {
  /* Allow long single words ("Sacramento", "Newsletter") to wrap or
     break if a column is genuinely narrower than the word. Prefer
     normal wrapping; fall back to break-word only when needed. */
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.footer-brand .brand-text .name { color: var(--paper); }
.footer-brand p {
  margin-top: 16px; font-family: var(--serif); font-size: 14px; line-height: 1.6;
  color: rgba(246,241,231,0.65); max-width: 36ch;
}
.footer-col h4 {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold-soft); margin-bottom: 14px;
}
.footer-col ul { list-style: none; display: grid; gap: 8px; }
.footer-col a {
  font-family: var(--serif); font-size: 14px; color: rgba(246,241,231,0.75);
}
.footer-col a:hover { color: var(--paper); }
.footer-bottom {
  padding-top: 24px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 16px;
  font-family: var(--mono); font-size: 11px; color: rgba(246,241,231,0.5);
  letter-spacing: 0.05em;
}
.footer-sources {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase;
}
.footer-sources span { color: var(--gold-soft); }

/* ============================================================================
   WordPress core / Gutenberg compatibility
   ============================================================================ */
.alignleft { float: left; margin: 0 1.5em 1em 0; max-width: 50%; }
.alignright { float: right; margin: 0 0 1em 1.5em; max-width: 50%; }
.aligncenter { display: block; margin: 1em auto; }
.alignwide { max-width: 100%; }
.alignfull { width: 100%; max-width: none; }
.wp-caption,
.wp-caption-text { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.sticky-post,
.bypostauthor { /* required by WP theme review */ }

/* Comments — minimal */
.comments-area {
  margin-top: 48px; padding-top: 32px;
  border-top: 1px solid var(--rule);
  font-family: var(--serif);
}
