/* ==========================================================================
   THE GUILD — Design system (v2, modernized)
   Layered like a kit: tokens -> base -> nav -> buttons -> hero -> filter bar
   -> cards -> gallery -> sticky CTA -> forms -> footer -> helpers.
   ========================================================================== */

/* Load the Fraunces variable font for the Drevi wordmark + all headings. */
@import url('https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces/index.css');

/* --- 1. Design tokens — Drevi palette (forest green + cream) ------------ */
/* The "--gold" tokens now carry the forest green accent. Class names like
   .btn--gold stay for stability; treat "gold" as "brand accent." */
:root {
  --ink:        #14181A;   /* near-black with the faintest cool cast */
  --ink-soft:   #44494A;
  --muted:      #828780;
  --gold:       #2D5240;   /* forest green — the brand accent */
  --gold-deep:  #1E3A2C;
  --gold-soft:  #E5EDE7;
  --cream:      #FBF8EF;   /* light off-white, just a hint of cream */
  --cream-card: #FFFFFF;
  --line:       #E8E2D0;
  --line-soft:  #F2EDD9;
  --dark:       #141A16;   /* very deep cool forest */
  --dark-2:     #1B231D;
  --dark-text:  #ECE6D6;

  --radius:     12px;
  --radius-lg:  18px;
  --radius-xl:  24px;
  --maxw:       1180px;

  --shadow-sm:  0 1px 2px rgba(20, 24, 26, 0.04);
  --shadow:     0 4px 16px rgba(20, 24, 26, 0.06);
  --shadow-lg:  0 14px 38px rgba(20, 24, 26, 0.12);

  --serif: 'Fraunces Variable', Georgia, 'Times New Roman', serif;
  --sans:  -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* --- 2. Base + reset ----------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 {
  font-family: var(--serif); font-weight: 500;
  line-height: 1.1; letter-spacing: -0.01em; color: var(--ink);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-optical-sizing: auto;
}
h1 { font-size: clamp(2.4rem, 5.5vw, 4rem); }
h2 { font-size: clamp(1.8rem, 3.2vw, 2.4rem); }
h3 { font-size: 1.25rem; }
a  { color: var(--ink); text-decoration: none; }
img { max-width: 100%; display: block; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }
.section   { padding: 88px 0; }
.section--tight { padding: 56px 0; }
.text-gold { color: var(--gold); }
.muted { color: var(--muted); }
.center { text-align: center; }
.eyebrow {
  display: inline-block;
  font-family: var(--sans); font-size: 0.74rem; font-weight: 600;
  letter-spacing: 3px; text-transform: uppercase; color: var(--gold);
}

/* --- 3. Top navigation --------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250, 247, 240, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.nav__brand { display: flex; align-items: baseline; gap: 10px; }
.nav__brand .wordmark {
  font-family: var(--serif); font-size: 1.75rem; letter-spacing: 0;
  font-variation-settings: 'wght' 700, 'opsz' 36, 'SOFT' 100, 'WONK' 1;
}
.nav__brand .tag { font-size: 0.6rem; letter-spacing: 2.4px; color: var(--gold); text-transform: uppercase; }
.nav__links { display: flex; align-items: center; gap: 26px; }
/* :not(.btn) lets buttons inside the nav (like "Join Drevi") keep their own styling. */
.nav__links a:not(.btn) { font-size: 0.95rem; color: var(--ink-soft); }
.nav__links a:not(.btn):hover { color: var(--ink); }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gold); color: #fff;
  font-size: 0.68rem; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
  margin-left: 4px; vertical-align: middle;
  min-width: 18px; min-height: 18px;
}

/* When the nav sits over the dark hero, it can be transparent. */
.nav--over { background: transparent; border-bottom: none; backdrop-filter: none; }
.nav--over .nav__brand .wordmark,
.nav--over .nav__links a:not(.btn) { color: var(--dark-text); }
.nav--over .nav__links a:not(.btn):hover { color: #fff; }

/* --- 4. Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: 0.96rem; font-weight: 600;
  padding: 13px 22px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; transition: all 0.18s ease;
  white-space: nowrap; line-height: 1;
}
.btn--primary { background: var(--ink); color: var(--cream); }
.btn--primary:hover { background: #000; transform: translateY(-1px); }
.btn--gold { background: var(--gold); color: #fff; }
.btn--gold:hover { background: var(--gold-deep); transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--ghost-light { background: transparent; color: var(--dark-text); border-color: rgba(236, 230, 214, 0.4); }
.btn--ghost-light:hover { border-color: var(--dark-text); color: #fff; }
.btn--lg { padding: 16px 28px; font-size: 1.04rem; }
.btn--block { width: 100%; }

/* --- 5. Hero (modern, Zillow-style) -------------------------------------- */
.hero {
  position: relative;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(45, 82, 64, 0.30), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(45, 82, 64, 0.18), transparent 65%),
    linear-gradient(180deg, #181F1A 0%, #11160F 100%);
  color: var(--dark-text);
  padding: 28px 0 110px;
  margin-bottom: 0;
  overflow: hidden;
}
.hero__inner { max-width: 880px; margin: 0 auto; text-align: center; padding-top: 56px; }
.hero__eyebrow {
  display: inline-block;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 3px; text-transform: uppercase;
  color: var(--gold); margin-bottom: 18px;
}
.hero h1 { color: #fff; font-size: clamp(2.6rem, 6vw, 4.6rem); margin-bottom: 18px; }
.hero h1 .accent { color: var(--gold); font-style: italic; }
.hero p.lead { color: #C9C4B5; font-size: 1.15rem; max-width: 600px; margin: 0 auto 38px; }

.hero-search {
  display: flex; align-items: center; gap: 0;
  background: #fff; border-radius: 999px; padding: 6px;
  max-width: 680px; margin: 0 auto;
  box-shadow: var(--shadow-lg);
}
.hero-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: var(--sans); font-size: 1.02rem; color: var(--ink);
  padding: 12px 18px; min-width: 0;
}
.hero-search input::placeholder { color: var(--muted); }
.hero-search .hs-divider { width: 1px; background: var(--line); align-self: stretch; margin: 6px 0; flex-shrink: 0; }
.hero-search .city-autocomplete { flex: 1; min-width: 0; display: flex; }
.hero-search .city-autocomplete input { width: 100%; }
.hero-search .btn { border-radius: 999px; padding: 12px 22px; flex-shrink: 0; }

@media (max-width: 560px) {
  .hero-search { flex-direction: column; align-items: stretch; border-radius: 18px; padding: 6px; }
  .hero-search input { padding: 12px 16px; font-size: 1rem; }
  .hero-search .hs-divider { width: auto; height: 1px; margin: 0 12px; }
  .hero-search .btn { width: 100%; border-radius: 12px; margin-top: 4px; }
}
.hero__below {
  text-align: center; margin-top: 22px; font-size: 0.94rem; color: #C9C4B5;
}
.hero__below a { color: var(--gold); font-weight: 600; }

/* --- 6. Filter bar (browse page) ----------------------------------------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--cream-card); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px;
  box-shadow: var(--shadow-sm);
}
.filter-bar .field { margin: 0; flex: 1 1 180px; min-width: 0; }
.filter-bar .field label { display: none; }
.filter-bar .input, .filter-bar .select {
  border: none; background: transparent; padding: 10px 16px; border-radius: 999px;
  font-size: 0.96rem; box-shadow: none;
}
.filter-bar .input:focus, .filter-bar .select:focus { box-shadow: 0 0 0 2px rgba(45, 82, 64, 0.18); background: var(--gold-soft); }
.filter-bar .field + .field { border-left: 1px solid var(--line); padding-left: 4px; }

/* --- 7. Cards (modern, image-led) ---------------------------------------- */
.grid { display: grid; gap: 24px; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 980px) { .grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 660px) { .grid--3, .grid--2 { grid-template-columns: 1fr; } }

.card {
  background: var(--cream-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: block;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #EFE9DA 0%, #E6DEC8 100%);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); overflow: hidden;
}
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.card:hover .card__media img { transform: scale(1.04); }

/* A price/deal tag overlaid on the photo, bottom-left (Zillow-style). */
.card__price {
  position: absolute; bottom: 12px; left: 12px;
  background: var(--ink); color: #fff;
  padding: 7px 14px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 600; letter-spacing: 0.2px;
}
.card__price--gold { background: var(--gold); }

.card__status {
  position: absolute; top: 12px; left: 12px;
  background: rgba(255, 255, 255, 0.95); color: var(--ink);
  padding: 5px 11px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600;
}

.card__body { padding: 18px 20px 22px; }
.card__title { font-family: var(--serif); font-size: 1.3rem; line-height: 1.2; }
.card__row { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.92rem; margin-top: 6px; }

/* Pills (specialties, amenities). */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8rem; padding: 5px 11px; border-radius: 999px;
  background: var(--line-soft); color: var(--ink-soft);
}
.pill--gold { background: var(--gold-soft); color: var(--gold-deep); font-weight: 600; }
.pill--open { background: rgba(99, 153, 34, 0.14); color: #3B6D11; font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- 8. Listing detail: gallery + sticky CTA ----------------------------- */
.gallery {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.gallery > div {
  position: relative;
  background: linear-gradient(135deg, #EFE9DA 0%, #E6DEC8 100%);
  overflow: hidden;
}
.gallery > div img { width: 100%; height: 100%; object-fit: cover; }
.gallery > div:first-child { grid-row: 1 / 3; }
@media (max-width: 720px) {
  .gallery { grid-template-columns: 1fr; grid-template-rows: auto; aspect-ratio: 4/3; }
  .gallery > div:not(:first-child) { display: none; }
}

.detail-layout {
  display: grid; grid-template-columns: 1.7fr 1fr; gap: 56px;
  margin-top: 40px;
}
@media (max-width: 880px) { .detail-layout { grid-template-columns: 1fr; gap: 28px; } }

.sticky-cta {
  position: sticky; top: 96px;
  background: var(--cream-card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 26px;
  box-shadow: var(--shadow);
}
.sticky-cta .price { font-family: var(--serif); font-size: 2rem; }
.sticky-cta .price small { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); font-weight: 400; }

/* --- 9. Forms ------------------------------------------------------------ */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; }
.input, .textarea, .select {
  width: 100%; font-family: var(--sans); font-size: 1rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 14px; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(45, 82, 64, 0.18);
}
.textarea { min-height: 120px; resize: vertical; }

.auth-card {
  max-width: 460px; margin: 64px auto; background: var(--cream-card);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 44px 38px;
  box-shadow: var(--shadow);
}

.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 22px; }
.segmented button {
  flex: 1; padding: 13px; background: #fff; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 0.95rem; font-weight: 600; color: var(--muted);
  transition: all 0.15s ease;
}
.segmented button.active { background: var(--ink); color: var(--cream); }

/* --- 10. Featured strip on home (horizontal scroller on mobile) ---------- */
.featured-head { display: flex; align-items: end; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.featured-head h2 { margin-bottom: 4px; }

/* --- 11. CTA banner ------------------------------------------------------ */
.cta-banner {
  background: var(--dark);
  color: var(--dark-text);
  border-radius: var(--radius-xl);
  padding: 56px 48px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 28px; flex-wrap: wrap;
  background-image:
    radial-gradient(600px 300px at 90% 0%, rgba(45, 82, 64, 0.32), transparent 60%);
}
.cta-banner h2 { color: #fff; max-width: 540px; }
.cta-banner p { color: #C9C4B5; max-width: 520px; margin-top: 8px; }

/* --- 12. Footer + helpers ------------------------------------------------ */
.footer { background: var(--dark); color: var(--dark-text); padding: 56px 0; margin-top: 0; }
.footer a { color: #B8B3A8; font-size: 0.95rem; }
.footer a:hover { color: #fff; }
.footer .footer__brand .wordmark {
  color: #fff; font-family: var(--serif); font-size: 1.5rem; letter-spacing: 0;
  font-variation-settings: 'wght' 700, 'opsz' 36, 'SOFT' 100, 'WONK' 1;
}

.notice { padding: 12px 16px; border-radius: 10px; font-size: 0.94rem; margin-bottom: 18px; }
.notice--error { background: rgba(226, 75, 74, 0.12); color: #A32D2D; }
.notice--ok    { background: rgba(99, 153, 34, 0.14); color: #3B6D11; }
.hidden { display: none !important; }

/* --- 13. Results map (Leaflet) ------------------------------------------ */
.results-map {
  height: 340px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  overflow: hidden;
  background: #E8E2D0;            /* shows during tile load so it's not blank */
  margin: 22px 0;
}
.results-map .leaflet-container {
  font-family: var(--sans);
  background: #E8E2D0;
}
.results-map .leaflet-popup-content { margin: 12px 14px; line-height: 1.5; }
.results-map .leaflet-popup-content a { color: var(--gold); font-weight: 600; }
@media (max-width: 760px) {
  .results-map { height: 260px; }
}

/* --- 14. City autocomplete dropdown ------------------------------------- */
.city-autocomplete { position: relative; flex: 1; min-width: 0; }
.city-suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  list-style: none; padding: 4px 0; margin: 0;
  max-height: 260px; overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: var(--shadow-lg);
}
.city-suggestions.open { display: block; }
.city-suggestions li {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.94rem;
  color: var(--ink);
  font-family: var(--sans);
}
.city-suggestions li:hover,
.city-suggestions li.highlighted {
  background: var(--gold-soft);
  color: var(--gold-deep);
}

/* --- 14. Mobile — hamburger nav + responsive spacing -------------------- */

/* The hamburger button is injected by js/auth.js — hidden on desktop. */
.nav__burger {
  display: none;
  background: transparent; border: 0; padding: 8px 10px;
  cursor: pointer; color: var(--ink);
  font-size: 1.5rem; line-height: 1;
}
.nav--over .nav__burger { color: var(--dark-text); }

@media (max-width: 760px) {
  .nav__inner { height: 62px; }
  .nav__brand .wordmark { font-size: 1.25rem; letter-spacing: 4px; }
  .nav__brand .tag { font-size: 0.55rem; letter-spacing: 1.8px; }

  /* Show burger, collapse the link row into a dropdown panel. */
  .nav__burger { display: inline-flex; align-items: center; justify-content: center; }
  .nav__links {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--cream); border-bottom: 1px solid var(--line);
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 6px 0; display: none;
    max-height: calc(100vh - 62px); overflow-y: auto;
  }
  .nav--over .nav__links {
    background: #1B1914; border-bottom-color: rgba(255,255,255,0.08);
  }
  .nav__links.open { display: flex; }
  .nav__links a:not(.btn) {
    padding: 14px 24px; color: var(--ink);
    border-bottom: 1px solid var(--line-soft);
  }
  .nav--over .nav__links a:not(.btn) {
    color: var(--dark-text); border-bottom-color: rgba(255,255,255,0.06);
  }
  .nav__links a:not(.btn):last-child { border-bottom: none; }
  .nav__links .btn { margin: 10px 20px; text-align: center; }

  /* Filter bars look weird as squashed pills on small screens — stack them. */
  .filter-bar {
    flex-direction: column; align-items: stretch;
    border-radius: var(--radius-lg); padding: 10px 12px;
  }
  .filter-bar .field {
    flex: 1 1 auto;
    border-bottom: 1px solid var(--line-soft);
    padding-bottom: 6px;
  }
  .filter-bar .field + .field {
    border-left: none; padding-left: 0; margin-top: 6px;
  }
  .filter-bar .field:last-child { border-bottom: none; padding-bottom: 0; }
  .filter-bar .input, .filter-bar .select { padding: 12px 14px; font-size: 1rem; }

  /* Tighter section + hero rhythm */
  .section { padding: 48px 0; }
  .section--tight { padding: 36px 0; }
  .container { padding: 0 20px; }
  .hero { padding: 24px 0 72px; }
  .hero__inner { padding-top: 28px; }
  .hero h1 { letter-spacing: -0.02em; }
  .hero p.lead { font-size: 1.02rem; margin-bottom: 26px; }
  .hero-search { padding: 6px; }
  .hero-search input { padding: 10px 16px; font-size: 0.96rem; min-width: 0; }
  .hero-search .btn { padding: 12px 18px; font-size: 0.9rem; }

  /* CTA banner: stack the headline and the button on mobile. */
  .cta-banner { padding: 36px 24px; flex-direction: column; align-items: flex-start; }
  .cta-banner .btn { width: 100%; }

  /* Featured strip headline stops fighting with the "See all" button. */
  .featured-head { flex-direction: column; align-items: flex-start; gap: 14px; }

  /* Listing detail: a touch less padding on small screens. */
  .detail-layout { gap: 24px; }
  .sticky-cta { padding: 22px; }
  .sticky-cta .price { font-size: 1.7rem; }
}
