/* ==========================================================================
   County Dispatch — Phase 1 design system
   Hand-written, no build step. Custom properties drive the whole theme.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */
:root {
  /* Civic / trustworthy palette */
  --c-primary: #0f5c5b;        /* deep blue-green */
  --c-primary-dark: #0a4140;
  --c-primary-light: #e3f0ef;
  --c-accent: #e2683c;         /* warm CTA */
  --c-accent-dark: #c4521f;
  --c-featured: #b8860b;       /* badge gold */

  --c-ink: #1b2426;            /* near-black text */
  --c-muted: #5b6b6d;          /* secondary text */
  --c-line: #dce3e3;           /* borders */
  --c-bg: #f6f8f8;             /* page background */
  --c-surface: #ffffff;        /* cards */

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 36, 38, .06), 0 4px 16px rgba(16, 36, 38, .07);
  --shadow-hover: 0 2px 6px rgba(16, 36, 38, .10), 0 10px 28px rgba(16, 36, 38, .12);

  --container: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Reset / base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--c-ink);
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-4); }
h1 { font-size: 2.1rem; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 var(--space-4); }

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* --- Layout --------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

main.container { flex: 1 0 auto; padding-block: var(--space-7); }

/* --- Site header ---------------------------------------------------------- */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-3);
}
.wordmark {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--c-ink);
}
.wordmark:hover { text-decoration: none; }
.wordmark span { color: var(--c-primary); }

.site-nav { display: flex; align-items: center; gap: var(--space-5); }
.site-nav a { color: var(--c-muted); font-weight: 600; font-size: 0.95rem; }
.site-nav a:hover { color: var(--c-primary); text-decoration: none; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--c-ink);
}

/* --- Site footer ---------------------------------------------------------- */
.site-footer {
  flex-shrink: 0;
  background: var(--c-primary-dark);
  color: #cfe0df;
  margin-top: var(--space-8);
}
.site-footer__inner {
  padding-block: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 0.9rem;
}
.site-footer strong { color: #fff; }
.site-footer__counties {
  padding-block: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
  font-size: 0.9rem;
}
.site-footer__counties-label { color: #fff; font-weight: 600; }
.site-footer__counties a { color: #cfe0df; }
.site-footer__counties a:hover { color: #fff; }

/* --- Hero ----------------------------------------------------------------- */
.hero {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: var(--space-7) var(--space-6);
  margin-bottom: var(--space-7);
}
.hero h1 { color: #fff; margin-bottom: var(--space-3); }
.hero p { color: #d6e7e6; font-size: 1.1rem; max-width: 60ch; margin-bottom: 0; }

/* Lighter head for inner pages */
.page-head { margin-bottom: var(--space-6); }
.page-head .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c-primary);
  margin-bottom: var(--space-2);
}
.page-head p { color: var(--c-muted); max-width: 65ch; }

/* --- Card grid ------------------------------------------------------------ */
.card-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-5);
}

.card {
  display: block;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  color: inherit;
}
a.card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--c-primary);
}
.card h3 { margin-bottom: var(--space-2); color: var(--c-ink); }
.card p { margin-bottom: 0; color: var(--c-muted); font-size: 0.95rem; }
.card__cta { display: inline-block; margin-top: var(--space-3); color: var(--c-primary); font-weight: 600; font-size: 0.9rem; }

/* --- Provider cards ------------------------------------------------------- */
.provider-list { display: grid; gap: var(--space-4); margin-bottom: var(--space-7); }
.provider {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow);
}
.provider--featured { border-color: var(--c-featured); box-shadow: 0 0 0 1px var(--c-featured), var(--shadow); }
.provider__head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }
.provider__head h3 { margin: 0; }
.provider__meta { margin: var(--space-2) 0 0; color: var(--c-muted); font-size: 0.95rem; }
.provider__meta a { font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px var(--space-2);
  border-radius: 999px;
}
.badge--featured { background: #fbf3da; color: var(--c-featured); border: 1px solid #ecd9a3; }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-align: center;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn--primary { background: var(--c-accent); color: #fff; }
.btn--primary:hover { background: var(--c-accent-dark); text-decoration: none; color: #fff; }
.btn--secondary { background: transparent; color: var(--c-primary); border-color: var(--c-line); }
.btn--secondary:hover { border-color: var(--c-primary); text-decoration: none; }

/* --- Section heading + columns ------------------------------------------- */
.section-title { margin-bottom: var(--space-5); }

.split {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: var(--space-6);
  align-items: start;
}

/* --- Lead form (revenue engine) ------------------------------------------ */
.lead-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-top: 4px solid var(--c-accent);
  border-radius: var(--radius);
  padding: var(--space-6);
  box-shadow: var(--shadow);
  position: sticky;
  top: 84px;
}
.lead-card h2 { margin-bottom: var(--space-2); }
.lead-card .lead-card__sub { color: var(--c-muted); font-size: 0.95rem; margin-bottom: var(--space-5); }

/* Style the {{ form.as_p }} output */
.lead-form p { margin: 0 0 var(--space-4); }
.lead-form label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: var(--space-1); }
.lead-form input,
.lead-form select,
.lead-form textarea {
  width: 100%;
  font: inherit;
  color: var(--c-ink);
  padding: var(--space-3);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.lead-form input:focus,
.lead-form select:focus,
.lead-form textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light);
}
.lead-form textarea { resize: vertical; min-height: 96px; }
.lead-form .helptext { display: block; font-size: 0.8rem; color: var(--c-muted); margin-top: var(--space-1); }
.lead-form ul.errorlist {
  list-style: none;
  margin: 0 0 var(--space-2);
  padding: 0;
  color: var(--c-accent-dark);
  font-size: 0.85rem;
  font-weight: 600;
}
.lead-form .btn { width: 100%; margin-top: var(--space-2); }

/* --- Notice / empty state ------------------------------------------------- */
.notice {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: var(--space-6);
  box-shadow: var(--shadow);
}
.notice--center { text-align: center; max-width: 560px; margin-inline: auto; }
.notice--muted { background: transparent; box-shadow: none; border-style: dashed; color: var(--c-muted); }

.stack > * + * { margin-top: var(--space-4); }
.text-muted { color: var(--c-muted); }

/* --- Search --------------------------------------------------------------- */
.search-form { display: flex; gap: var(--space-3); margin-bottom: var(--space-6); }
.search-form input[type="text"],
.search-form input:not([type]) {
  flex: 1;
  font: inherit;
  padding: var(--space-3);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
}
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.pagination { margin-top: var(--space-5); display: flex; gap: var(--space-4); }

/* --- Nav CTA (Sign up) ---------------------------------------------------- */
.site-nav__cta {
  background: var(--c-accent);
  color: #fff !important;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
}
.site-nav__cta:hover { background: var(--c-accent-dark); text-decoration: none; }

/* --- Account pages (django-allauth) --------------------------------------- */
/* allauth renders plain semantic HTML (h1 + form.as_p + a submit button).
   We center it in a card and reuse the lead-form field styling. */
.page-account main.container { max-width: 460px; }
.page-account h1 { font-size: 1.6rem; margin-bottom: var(--space-2); }
.page-account form {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-top: 4px solid var(--c-accent);
  border-radius: var(--radius);
  padding: var(--space-6);
  box-shadow: var(--shadow);
  margin-top: var(--space-5);
}
.page-account form p { margin: 0 0 var(--space-4); }
.page-account label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: var(--space-1); }
.page-account input {
  width: 100%;
  font: inherit;
  color: var(--c-ink);
  padding: var(--space-3);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
  background: #fff;
}
/* Checkboxes (e.g. "Remember me") shouldn't stretch full width. */
.page-account input[type="checkbox"],
.page-account input[type="radio"] { width: auto; margin-right: var(--space-2); }
.page-account input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light);
}
.page-account .helptext,
.page-account form span { display: block; font-size: 0.8rem; color: var(--c-muted); margin-top: var(--space-1); }
.page-account ul.errorlist {
  list-style: none;
  margin: 0 0 var(--space-2);
  padding: 0;
  color: var(--c-accent-dark);
  font-size: 0.85rem;
  font-weight: 600;
}
.page-account button[type="submit"] {
  display: inline-block;
  width: 100%;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--c-accent);
  color: #fff;
  transition: background .12s ease;
}
.page-account button[type="submit"]:hover { background: var(--c-accent-dark); }

/* --- Marketplace ---------------------------------------------------------- */
.listing-card { padding: 0; overflow: hidden; }
.listing-card .listing-card__media,
.listing-card__price,
.listing-card h3,
.listing-card__meta { margin-inline: var(--space-4); }
.listing-card__media {
  margin: 0 0 var(--space-3);
  aspect-ratio: 4 / 3;
  background: var(--c-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}
.listing-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.listing-card__noimg { color: var(--c-muted); font-size: 0.85rem; }
.listing-card__price { font-weight: 700; color: var(--c-ink); margin-bottom: var(--space-1); }
.listing-card h3 {
  font-size: 1.05rem;
  margin-bottom: var(--space-1);
  /* Clamp long titles so cards in the grid stay a uniform height. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.listing-card__meta { color: var(--c-muted); font-size: 0.9rem; margin-bottom: var(--space-4); }

.listing-detail__price { font-size: 1.5rem; font-weight: 700; color: var(--c-ink); margin: 0; }
/* Multi-column so image-heavy listings tile instead of stacking one tall column.
   Single-image listings get one wide cell from auto-fill -- still looks right. */
.listing-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.listing-gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--c-line);
  display: block;
}
.listing-detail__body { color: var(--c-ink); }
.listing-facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); }
.listing-facts dt { color: var(--c-muted); font-size: 0.9rem; }
.listing-facts dd { margin: 0; font-weight: 600; }

/* Full-width form card (post/edit a listing) -- not the sticky sidebar variant. */
.lead-card--wide { position: static; top: auto; max-width: 640px; }
.listing-owner-actions { margin-top: var(--space-5); }

/* Detail-page sidebar stacks several cards (Details + contact/owner actions);
   drop the single-card sticky so they don't collide at the same top offset. */
.aside-stack { display: grid; gap: var(--space-5); align-content: start; }
.aside-stack .lead-card { position: static; top: auto; }
.aside-stack .listing-owner-actions { margin-top: 0; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  h1 { font-size: 1.7rem; }

  .nav-toggle { display: inline-block; }
  .site-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-line);
    padding: var(--space-3) var(--space-5);
  }
  .site-header__inner { position: relative; }
  .site-nav.is-open { display: flex; }
  .site-nav a { padding-block: var(--space-2); width: 100%; }

  .split { grid-template-columns: 1fr; }
  .lead-card { position: static; }
  main.container { padding-block: var(--space-6); }
  .hero { padding: var(--space-6) var(--space-5); }
}
