/* Buy Des Moines — clean, trustworthy local real-estate guide */
:root {
  --bg: #f7f9fc;
  --ink: #15233b;
  --ink-soft: #5a6b85;
  --blue: #1d4ed8;
  --blue-deep: #1e40af;
  --green: #15803d;
  --card: #ffffff;
  --line: #e3e9f2;
  --shadow: 0 1px 2px rgba(21,35,59,.04), 0 8px 24px rgba(21,35,59,.07);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --radius: 12px;
  --maxw: 1020px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg); line-height: 1.65; font-size: 17px; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
a { color: var(--blue-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { font-family: var(--serif); line-height: 1.18; letter-spacing: -0.01em; font-weight: 600; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); margin: 0 0 .3em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 1.6em 0 .5em; }
h3 { font-size: 1.2rem; margin: 1.2em 0 .3em; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(1rem, 4vw, 1.8rem); }
.narrow { max-width: 760px; }

.site-header { position: sticky; top: 0; z-index: 20; background: rgba(247,249,252,.9); backdrop-filter: saturate(160%) blur(8px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--serif); font-weight: 600; font-size: 1.25rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .mark { width: 32px; height: 32px; border-radius: 8px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 1rem; }
.nav { display: flex; gap: 1.2rem; font-size: .93rem; font-weight: 600; flex-wrap: wrap; }
.nav a { color: var(--ink-soft); }

.hero { padding: clamp(2.4rem, 6vw, 4rem) 0 1rem; }
.hero .wrap { text-align: center; }
.hero p.lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 640px; margin: .5em auto 0; }

/* Market snapshot strip */
.market { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 1rem; margin: 1.6rem 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.stat .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.stat .v { font-family: var(--serif); font-size: 1.9rem; font-weight: 600; color: var(--blue-deep); }
.stat .chg { font-size: .82rem; font-weight: 600; }
.stat .chg.up { color: var(--green); } .stat .chg.down { color: #b91c1c; }
.market-note { font-size: .82rem; color: var(--ink-soft); }

/* Area cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px,1fr)); gap: 1.2rem; margin: 1.4rem 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); display: block; transition: transform .14s ease, box-shadow .14s ease, border-color .14s; }
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(21,35,59,.13); border-color: var(--blue); text-decoration: none; }
.card h3 { margin: 0 0 .3rem; color: var(--ink); }
.card p { margin: 0; color: var(--ink-soft); font-size: .94rem; }

/* Area page */
.crumb { font-size: .85rem; color: var(--ink-soft); padding-top: 1.3rem; }
.crumb a { color: var(--ink-soft); }
.area-hero { padding: 1rem 0 .4rem; }
.lede { color: var(--ink-soft); font-size: 1.12rem; }
.highlights { list-style: none; padding: 0; margin: 1rem 0; }
.highlights li { padding: .5rem 0 .5rem 1.8rem; position: relative; border-bottom: 1px solid var(--line); }
.highlights li::before { content: "📍"; position: absolute; left: 0; }
.factbox { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; box-shadow: var(--shadow); margin: 1.2rem 0; }
.factbox h3 { margin-top: 0; }

/* Buy vs rent tool */
.tool { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); margin: 1.2rem 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 1rem; }
.fields label { display: flex; flex-direction: column; font-size: .84rem; font-weight: 600; color: var(--ink-soft); gap: .3rem; }
.fields input { font-family: var(--sans); font-size: 1.05rem; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; }
.bvr-out { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 1rem; margin-top: 1.4rem; }
.bvr-cell { background: #eef4ff; border: 1px solid #dbe6ff; border-radius: 10px; padding: .9rem; text-align: center; }
.bvr-cell span { display: block; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.bvr-cell strong { font-family: var(--serif); font-size: 1.4rem; color: var(--blue-deep); }
.bvr-verdict { margin-top: 1.2rem; text-align: center; font-weight: 600; font-size: 1.1rem; padding: .8rem; border-radius: 10px; }
.bvr-verdict.buy { background: #ecfdf3; color: var(--green); } .bvr-verdict.rent { background: #fef3f2; color: #b91c1c; } .bvr-verdict.even { background: #f1f5f9; color: var(--ink-soft); }
.assumptions { font-size: .82rem; color: var(--ink-soft); margin-top: .8rem; }

.prose { padding: 1rem 0 2rem; }
.disclaimer { font-size: .82rem; color: var(--ink-soft); border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 1rem; }
.ad-slot { margin: 2rem auto; max-width: 760px; min-height: 90px; display: grid; place-items: center; background: repeating-linear-gradient(135deg,#eef2f7,#eef2f7 12px,#e6ecf4 12px,#e6ecf4 24px); border: 1px dashed #ccd7e6; border-radius: 10px; color: #9badc4; font-size: .8rem; }

.site-footer { margin-top: 3.5rem; background: var(--ink); color: #c8d3e4; }
.site-footer .wrap { padding: 2.4rem 0 2rem; display: flex; flex-wrap: wrap; gap: 2rem; justify-content: space-between; }
.site-footer a { color: #93b4ff; }
.site-footer .brand { color: #fff; }
.site-footer h4 { font-family: var(--sans); text-transform: uppercase; letter-spacing: .07em; font-size: .72rem; color: #8fa1bd; margin: 0 0 .5rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; line-height: 1.9; font-size: .92rem; }
.copyright { width: 100%; border-top: 1px solid rgba(255,255,255,.12); padding-top: 1rem; font-size: .82rem; color: #7888a3; }
@media (max-width: 600px) { .nav { gap: .8rem; font-size: .85rem; } }

/* ---- Head-to-head comparison table ---- */
/* Wrapper scrolls on its own so a wide table never makes the page scroll sideways. */
.tablewrap { overflow-x: auto; margin: 1.2rem 0; -webkit-overflow-scrolling: touch; }
table.compare {
  width: 100%; min-width: 420px; border-collapse: collapse;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
table.compare th, table.compare td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); }
table.compare thead th {
  font-family: var(--serif); font-size: 1.02rem; font-weight: 600;
  background: #eef3fa; color: var(--ink); white-space: nowrap;
}
table.compare thead th:first-child { font-family: var(--sans); font-size: .82rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
table.compare tbody th { font-weight: 500; color: var(--ink-soft); font-size: .95rem; }
table.compare td { font-variant-numeric: tabular-nums; font-weight: 600; }
table.compare tr:last-child th, table.compare tr:last-child td { border-bottom: 0; }
table.compare tbody tr:nth-child(even) { background: #fafcff; }
/* The cheaper of the two, where "cheaper" is unambiguous. Color is a secondary cue —
   the ✓ carries the meaning for anyone who can't distinguish the green. */
table.compare td.better { color: var(--green); }
table.compare td.better::after { content: " ✓"; font-size: .85em; }

/* ---- Interactive comparator (/compare/) ---- */
/* Series colors are fixed to the SLOT, not to rank: area A is always --s1, area B
   always --s2, so changing one selection never repaints the other. Validated for
   CVD separation against the white card surface (worst adjacent pair ΔE 29.9). */
.cmp {
  --s1: #1d4ed8;   /* area A */
  --s2: #c2410c;   /* area B */
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(1rem, 3vw, 1.6rem); margin: 1.4rem 0;
}
.cmp-pickers { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.cmp-pick { flex: 1 1 200px; min-width: 0; }
.cmp-pick label {
  display: flex; align-items: center; gap: .45rem;
  font-size: .82rem; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem;
}
.cmp select {
  width: 100%; padding: .6rem .7rem; font: inherit; font-size: 1rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}
.cmp select:focus-visible, .cmp button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.cmp-swap {
  flex: 0 0 auto; width: 42px; height: 42px; margin-bottom: 1px;
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  font-size: 1.15rem; color: var(--ink-soft); cursor: pointer;
  transition: transform .25s ease, color .2s ease, border-color .2s ease;
}
.cmp-swap:hover { color: var(--blue); border-color: var(--blue); transform: rotate(180deg); }
.cmp-actions { display: flex; gap: .5rem; margin-top: .8rem; flex-wrap: wrap; }
.cmp-actions button {
  font: inherit; font-size: .88rem; padding: .4rem .8rem; cursor: pointer;
  background: #f2f6fc; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px; transition: background .15s ease, color .15s ease;
}
.cmp-actions button:hover { background: #e6eefb; color: var(--blue-deep); }
.cmp-actions button[aria-pressed="true"] { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Legend — identity is never color-alone; each dot sits beside its area name. */
.cmp-head { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.4rem 0 .4rem; }
.cmp-side { display: flex; gap: .6rem; align-items: flex-start; min-width: 0; }
.cmp-side > div { min-width: 0; }
.cmp-side a { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.cmp-sub { font-size: .84rem; color: var(--ink-soft); line-height: 1.45; margin-top: .15rem; }
.cmp-dot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; margin-top: .45rem; }
.cmp-dot.s1 { background: var(--s1); }
.cmp-dot.s2 { background: var(--sc-out); }

.cmp-metrics { margin-top: 1.2rem; }
.cmp-metric { padding: .8rem 0; border-top: 1px solid var(--line); }
.cmp-metric-label {
  font-size: .82rem; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: .5rem;
}
/* 2px surface gap between the two adjacent bars — a gap, not a stroke. */
.cmp-bar-row { display: flex; align-items: center; gap: .7rem; margin-bottom: 2px; }
.cmp-track { flex: 1 1 auto; min-width: 0; height: 14px; background: #eef2f8; border-radius: 0 4px 4px 0; }
/* Square at the baseline, 4px rounded at the data end. */
.cmp-bar { height: 100%; border-radius: 0 4px 4px 0; transition: width .55s cubic-bezier(.22,.75,.3,1); }
.cmp-bar.s1 { background: var(--s1); }
.cmp-bar.s2 { background: var(--sc-out); }
/* Values are text tokens, never the series color — the bar carries identity. */
.cmp-val { flex: 0 0 auto; min-width: 8.5rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .95rem; color: var(--ink); }
.cmp-flag { font-weight: 500; font-size: .8rem; color: var(--green); white-space: nowrap; }

.cmp-yoy { font-weight: 600; font-variant-numeric: tabular-nums; }
.cmp-yoy.up { color: var(--green); }
.cmp-yoy.down { color: #b4342b; }
.cmp-yoy.flat { color: var(--ink-soft); font-weight: 500; }
.cmp-empty { color: var(--ink-soft); padding: 1.6rem 0; text-align: center; }
.cmp-more { margin-top: 1rem; font-weight: 600; }

@media (max-width: 620px) {
  .cmp-head { grid-template-columns: 1fr; gap: .7rem; }
  .cmp-val { min-width: 6.5rem; font-size: .88rem; }
  .cmp-swap { transform: rotate(90deg); }
  .cmp-swap:hover { transform: rotate(270deg); }
}
/* Honor a reduced-motion preference — the bars still resize, just without the sweep. */
@media (prefers-reduced-motion: reduce) {
  .cmp-bar { transition: none; }
  .cmp-swap { transition: color .2s ease, border-color .2s ease; }
  .cmp-swap:hover, .cmp-swap { transform: none; }
}

/* ---- Sharing ---- */
.sharerow { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: 1.2rem 0; }
.sharebtn {
  font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1.1rem; border-radius: 999px;
  background: var(--blue); color: #fff; border: 1px solid var(--blue);
  transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
}
.sharebtn:hover { background: var(--blue-deep); box-shadow: var(--shadow); }
.sharebtn:active { transform: translateY(1px); }
.sharebtn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sharehint { font-size: .86rem; color: var(--ink-soft); flex: 1 1 240px; min-width: 0; }

.bd-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: .7rem 1.15rem; border-radius: 999px;
  font-weight: 600; font-size: .9rem; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 60; max-width: 90vw; text-align: center;
}
.bd-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.bd-share-overlay {
  position: fixed; inset: 0; background: rgba(21,35,59,.55);
  display: grid; place-items: center; z-index: 50; padding: 1rem;
}
.bd-share-card {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 12px 40px rgba(21,35,59,.22);
  padding: 1.5rem; width: min(400px, 94vw); text-align: center;
}
.bd-share-card h3 { margin: 0 0 .9rem; font-size: 1.25rem; }
.bd-share-close {
  position: absolute; top: .4rem; right: .65rem; background: none; border: none;
  font-size: 1.7rem; line-height: 1; cursor: pointer; color: var(--ink-soft);
}
.bd-share-close:hover { color: var(--ink); }
/* Preview of exactly what will be sent — no surprises about what gets posted. */
.bd-share-preview {
  font-family: var(--sans); font-size: .85rem; line-height: 1.5; text-align: left;
  white-space: pre-wrap; word-break: break-word; color: var(--ink-soft);
  background: #f4f7fc; border: 1px solid var(--line); border-radius: 10px;
  padding: .7rem .8rem; margin: 0 0 1rem; max-height: 190px; overflow-y: auto;
}
.bd-share-preview:empty { display: none; }
.bd-share-links { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .7rem; }
.bd-share-link {
  padding: .55rem .6rem; border: 1px solid var(--line); border-radius: 9px;
  font-weight: 600; font-size: .92rem; color: var(--ink); background: #fff;
}
.bd-share-link:hover { border-color: var(--blue); color: var(--blue-deep); text-decoration: none; }
.bd-share-copy { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.bd-btn {
  font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
  padding: .55rem .6rem; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink);
}
.bd-btn:hover { border-color: var(--blue); color: var(--blue-deep); }
.bd-btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.bd-btn.primary:hover { background: var(--blue-deep); color: #fff; }
@media (prefers-reduced-motion: reduce) { .sharebtn, .bd-toast { transition: none; } }

/* ---- School choice (Iowa open enrollment) ---------------------------------------------
   One card per district, because a suburb can span two and they can disagree. The net
   figure leads; in/out are supporting detail.

   The bar is the two flows as shares of ALL transfers, not the net. Sizing it by net would
   make Southeast Polk (+2 on 6,794 residents) a one-pixel sliver that reads as missing data,
   where a near 50/50 split correctly reads as balanced.

   Direction never depends on colour alone: the sign, the wording and the chip each carry it. */
.sc-stack {
  display: flex; flex-direction: column; gap: .85rem; margin: 1rem 0 .9rem;
  /* Declared here, not borrowed from .cmp — --s1/--s2 are scoped to that component, so
     var(--s2) resolved to nothing here and the "out" segment rendered invisible. Same hex
     as the compare page's series-2 so the palette stays consistent. */
  --sc-out: #c2410c;
  --sc-in: var(--green);
  --sc-rail: #eef1f6;
}
.sc {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.25rem; display: flex; flex-direction: column; gap: .85rem;
  font-variant-numeric: tabular-nums; box-shadow: var(--shadow);
}
.sc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.sc-dist { font-weight: 600; font-size: 1.02rem; line-height: 1.3; }
.sc-res { font-size: .82rem; color: var(--ink-soft); opacity: .85; white-space: nowrap; }
.sc-net { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; }
.sc-fig { font-size: 2.1rem; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.sc-label { font-size: .95rem; color: var(--ink-soft); }
.sc .sc-chip {
  display: inline-flex; align-items: center; font-size: .78rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: 999px; white-space: nowrap;
}
.sc.gain .sc-fig { color: var(--sc-in); }
.sc.gain .sc-chip { background: #e8f3ec; color: var(--green); }
.sc.loss .sc-fig { color: var(--sc-out); }
.sc.loss .sc-chip { background: #fbeee7; color: var(--sc-out); }
.sc.flat .sc-fig { color: var(--ink-soft); }
.sc.flat .sc-chip { background: #eef1f6; color: var(--ink-soft); }

.sc-track { display: flex; height: 9px; border-radius: 999px; overflow: hidden; background: var(--sc-rail); }
.sc-seg-in { background: var(--sc-in); }
.sc-seg-out { background: var(--sc-out); }
.sc-keys { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; color: var(--ink-soft); }
.sc-key { display: inline-flex; align-items: center; gap: .4rem; }
.sc-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.sc-dot-in { background: var(--sc-in); }
.sc-dot-out { background: var(--sc-out); }
.sc-keys b { color: var(--ink); font-weight: 600; }

.sc-split { font-size: .93rem; color: var(--ink-soft); background: #eef1f6;
  border-radius: 10px; padding: .7rem .9rem; }

@media (max-width: 520px) {
  .sc-fig { font-size: 1.75rem; }
  .sc-res { white-space: normal; }
}
