/*
 * CCRE Platform Design System
 * Shared tokens, typography, primitives.
 * Include BEFORE page-specific CSS.
 */

:root {
  /* Palette — warm off-white + brand navy + single accent */
  --ink: #00102E;
  --ink-2: #1a2748;
  --ink-3: #2c3a5e;
  --body: #00102E;        /* unified with --ink so body text + headings read identical deep navy */
  --muted: #6b6b66;
  --muted-2: #8a8a82;
  --line: #e8e6df;        /* warm hairline */
  --line-2: #f1efe8;      /* warm soft line */
  --bg: #fafaf7;          /* warm cream — replaces pure white */
  --bg-soft: #f5f3ea;
  --bg-soft-2: #eae6db;

  /* --accent — editorial navy (was Tailwind blue #0A5BCC). Active tabs,
     links, focus rings, eyebrows now read in brand color. */
  --accent: #00102E;
  --accent-dark: #0e1e3a;
  --accent-soft: #e8e6df;

  /* Editorial-luxury accent — for "saved" / "best deal" / love markers, charts */
  --accent-terra: #c45a3a;
  --accent-terra-deep: #9c4429;
  --accent-terra-soft: #f7e6df;
  --accent-moss: #5b6b3a;

  --green: #0E7F3E;
  --green-soft: #E3F5EA;
  --amber: #B45309;
  --amber-soft: #FEF3C7;
  --red: #B91C1C;
  --red-soft: #FEE2E2;
  --purple: #6D28D9;
  --purple-soft: #EDE7FD;
  --teal: #0F766E;

  /* Type scale */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Fraunces", ui-serif, Georgia, serif;
  --t-xs: 11px;
  --t-sm: 13px;
  --t-base: 14px;
  --t-md: 15px;
  --t-lg: 17px;
  --t-xl: 20px;
  --t-2xl: 26px;
  --t-3xl: 34px;
  --t-4xl: 44px;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Shadow */
  --sh-1: 0 1px 2px rgba(11, 15, 20, 0.04), 0 1px 3px rgba(11, 15, 20, 0.06);
  --sh-2: 0 4px 10px rgba(11, 15, 20, 0.06), 0 2px 4px rgba(11, 15, 20, 0.04);
  --sh-3: 0 12px 32px rgba(11, 15, 20, 0.09), 0 4px 12px rgba(11, 15, 20, 0.06);
  --sh-4: 0 24px 56px rgba(11, 15, 20, 0.12), 0 10px 24px rgba(11, 15, 20, 0.08);

  /* Transitions */
  --xfast: 100ms cubic-bezier(.2,.8,.2,1);
  --fast: 180ms cubic-bezier(.2,.8,.2,1);
  --med: 260ms cubic-bezier(.2,.8,.2,1);
}

/* Import Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Fraunces:wght@500;600;700&display=swap');

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--body);
  background: var(--bg);
  font-size: var(--t-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Editorial-luxury default: H1/H2/H3 set in Fraunces serif at lighter weight.
   H4 stays Inter sans for tight section labels and table headers. */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.018em;
  line-height: 1.15;
  margin: 0;
}
h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.2;
  margin: 0;
}
h1 { font-size: var(--t-4xl); letter-spacing: -0.022em; }
h2 { font-size: var(--t-3xl); letter-spacing: -0.018em; }
h3 { font-size: var(--t-xl); }
h4 { font-size: var(--t-md); }

p { margin: 0; color: var(--body); }
a { color: var(--accent); text-decoration: none; transition: color var(--xfast); }
a:hover { color: var(--accent-dark); }

/* Button system */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--body);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--fast);
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--bg-soft); border-color: var(--muted-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); color: var(--bg); }

.btn-accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: white; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--body);
}
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); }

.btn-sm { padding: 6px 12px; font-size: var(--t-xs); }
.btn-lg { padding: 14px 22px; font-size: var(--t-md); }

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 500;
  color: var(--body);
  cursor: pointer;
  transition: all var(--fast);
  line-height: 1;
  user-select: none;
}
.chip:hover { border-color: var(--ink-3); background: var(--bg-soft); }
.chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  box-shadow: var(--sh-1);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* Form controls */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.field label {
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
select,
textarea {
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--body);
  transition: border-color var(--xfast), box-shadow var(--xfast);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--muted-2); }

/* Surfaces */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: box-shadow var(--fast), transform var(--fast), border-color var(--fast);
}
.card-hover:hover {
  box-shadow: var(--sh-2);
  transform: translateY(-2px);
  border-color: var(--line-2);
}

/* Pills (status) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
}
.pill-active { background: var(--green-soft); color: var(--green); }
.pill-pending { background: var(--amber-soft); color: var(--amber); }
.pill-sold { background: var(--bg-soft-2); color: var(--muted); }
.pill-offmarket { background: var(--ink); color: var(--bg); }
.pill-listed { background: var(--accent-soft); color: var(--accent-dark); }
.pill-neutral { background: var(--bg-soft-2); color: var(--ink-3); }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-purple { background: var(--purple-soft); color: var(--purple); }
.pill-accent { background: var(--accent-soft); color: var(--accent-dark); }

/* ════════════════════════════════════════════════════════════════════════ */
/* Status chip — shared color tokens for listing-status chips on cards,    */
/* list rows, marker hovers, MyHomes and the property-modal hero.          */
/* The container class (.lcard-status-chip / .hero-status-chip) defines    */
/* size + padding; these classes set color only.                           */
/* ════════════════════════════════════════════════════════════════════════ */
.lcard-status-chip,
.hero-status-chip {
  /* Shared primitives so the chip works without search.css loaded. */
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.lcard-status-chip { font-size: 9px; padding: 3px 12px 4px; line-height: 1.3; }
.hero-status-chip { font-size: 10px; padding: 4px 14px 5px; letter-spacing: 0.08em; line-height: 1.3; margin-bottom: 8px; }

.lcard-status-chip.lcard-status-active,
.hero-status-chip.lcard-status-active {
  border-color: var(--ink);
  color: var(--ink);
}
.lcard-status-chip.lcard-status-pending,
.hero-status-chip.lcard-status-pending {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-soft);
}
.lcard-status-chip.lcard-status-sold,
.hero-status-chip.lcard-status-sold {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-soft);
}
.lcard-status-chip.lcard-status-ended,
.hero-status-chip.lcard-status-ended {
  border-color: var(--purple);
  color: var(--purple);
  background: var(--purple-soft);
}

/* Utility */
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.scrollable { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.scrollable::-webkit-scrollbar { width: 8px; height: 8px; }
.scrollable::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.scrollable::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* App shell */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  text-decoration: none;
  color: var(--ink);
}
.topbar-logo {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--ink), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.02em;
}
.topbar-wordmark {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.topbar-wordmark small {
  display: block;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}
.topbar-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}
.topbar-nav a {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  color: var(--body);
  font-size: var(--t-sm);
  font-weight: 500;
  transition: all var(--fast);
}
.topbar-nav a:hover { background: var(--bg-soft); color: var(--ink); }
.topbar-nav a.active {
  color: var(--ink);
  background: var(--bg-soft);
  font-weight: 600;
}

/* Section headers */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--s-4);
  gap: var(--s-4);
}
.section-head h2 { font-size: var(--t-xl); }
.section-head p { color: var(--muted); font-size: var(--t-sm); }
.eyebrow {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 6px;
}

/* Empty / loading */
.empty, .loading-block {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}
.empty h4 {
  font-size: var(--t-md);
  color: var(--ink);
  margin-bottom: var(--s-2);
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  margin: 0 auto var(--s-3);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════════════════ */
/* RESPONSIVE LAYER (added 2026-06-16 — Mobile Phase 0).                     */
/* Purely ADDITIVE. No token above this line was changed. These define the   */
/* canonical breakpoint + tap-target + safe-area contract shared by every    */
/* page. See docs/RESPONSIVE.md for the parity-system rules.                 */
/*                                                                            */
/* Breakpoint contract (Seekly, vanilla) — VALIDATED 2026-06-16:             */
/*   phone   ≤ 599px                                                         */
/*   tablet  600–1023px                                                      */
/*   desktop ≥ 1024px     ← PRIMARY SWITCH is 1024px (was 900)               */
/* Why 1024, not 900: real-estate leaders (Zillow/Redfin/Compass) switch to  */
/* the side-by-side map+list two-pane at ~1024px and use the map + bottom-    */
/* sheet layout below that. 600/768 are internal sub-breakpoints only. See    */
/* ruleset_validation_2026_06_16.md item #4.                                 */
/* The JS `isMobile()` helper (mobile.js) mirrors --bp-desktop-min and        */
/* toggles body.is-mobile / body.is-tablet. CSS may key off EITHER the body   */
/* class or a raw @media query; both must agree on these numbers.            */
/*                                                                            */
/* HOVER GATING: any :hover affordance that should NOT fire on touch must be */
/* wrapped in `@media (hover: hover)`. Touch devices report (hover: none) /  */
/* (pointer: coarse) and would otherwise get sticky/stuck hover states. New  */
/* hover rules in page CSS should follow this convention.                    */
/* ════════════════════════════════════════════════════════════════════════ */
:root {
  /* Breakpoint custom properties — single source of truth for the numbers.
     Custom props can't be used inside a bare @media query test, so page CSS
     still writes the literal px in @media (…), but these document the
     contract and can be read from JS via getComputedStyle if ever needed. */
  --bp-phone-max: 599px;     /* ≤ this = phone */
  --bp-tablet-min: 600px;    /* tablet band start */
  --bp-tablet-max: 1023px;   /* tablet band end */
  --bp-desktop-min: 1024px;  /* ≥ this = desktop (PRIMARY SWITCH) */

  /* Touch / tap-target tokens. Build default = 48px (satisfies Apple HIG
     44pt + Material 3 48dp). WCAG 2.2 SC 2.5.8 AA hard floor is 24x24 CSS px —
     never go below that. 48px is the design target for any control that must
     be comfortably tappable on a phone. Desktop controls keep their existing
     sizes; these tokens are opt-in for mobile-gated rules. */
  --tap-min: 48px;           /* minimum touch target edge (build default) */
  --tap-min-sm: 40px;        /* dense secondary controls (still finger-safe; > 24px AA floor) */

  /* Viewport-height units (validated 2026-06-16): use --svh for FIXED full-
     height sections (sheet detents, heroes) so they don't jump when the mobile
     toolbar shows/hides; use dvh directly for elements that must track the live
     viewport. svh has no env() fallback need — it resolves everywhere modern. */
  --svh: 1svh;               /* 1% of the small viewport height (toolbar-shown) */

  /* Mobile spacing — slightly tighter gutters than desktop --s-* on phones. */
  --m-gutter: 16px;          /* page edge padding on phone */
  --m-gap: 12px;             /* default stack gap on phone */

  /* Safe-area insets (notch / home-indicator). Resolve to 0 on devices that
     don't expose them, so they're safe to add unconditionally. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
